diff --git a/src/core/solution.jl b/src/core/solution.jl index 930235733..29fa14ff7 100644 --- a/src/core/solution.jl +++ b/src/core/solution.jl @@ -238,9 +238,10 @@ end solver_status_lookup = Dict{Any, Dict{Symbol, Symbol}}( :Ipopt => Dict(:Optimal => :LocalOptimal, :Infeasible => :LocalInfeasible), + :Juniper => Dict(:Optimal => :LocalOptimal, :Infeasible => :LocalInfeasible), :ConicNonlinearBridge => Dict(:Optimal => :LocalOptimal, :Infeasible => :LocalInfeasible), # note that AmplNLWriter.AmplNLSolver is the solver type of bonmin - :AmplNLWriter => Dict(:Optimal => :LocalOptimal, :Infeasible => :LocalInfeasible) + :AmplNLWriter => Dict(:Optimal => :LocalOptimal, :Infeasible => :LocalInfeasible), ) "translates solver status codes to our status codes" diff --git a/src/form/acp.jl b/src/form/acp.jl index 8bfaf0a2e..980454e7e 100644 --- a/src/form/acp.jl +++ b/src/form/acp.jl @@ -252,7 +252,7 @@ function constraint_ohms_yt_to_ne(pm::GenericPowerModel{T}, n::Int, i, f_bus, t_ end "`angmin <= branch_z[i]*(t[f_bus] - t[t_bus]) <= angmax`" -function constraint_voltage_angle_difference_on_off(pm::GenericPowerModel{T}, n::Int, arc_from, f_bus, t_bus, angmin, angmax, vad_min, vad_max) where T <: AbstractACPForm +function constraint_voltage_angle_difference_on_off(pm::GenericPowerModel{T}, n::Int, i, f_bus, t_bus, angmin, angmax, vad_min, vad_max) where T <: AbstractACPForm va_fr = pm.var[:nw][n][:va][f_bus] va_to = pm.var[:nw][n][:va][t_bus] z = pm.var[:nw][n][:branch_z][i] diff --git a/test/REQUIRE b/test/REQUIRE index 3d1cc456e..770b1248b 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -3,4 +3,5 @@ julia 0.6 Ipopt SCS GLPKMathProgInterface +Juniper 0.2.0 Pajarito 0.4.0 diff --git a/test/ots.jl b/test/ots.jl index b57a51c14..9c9b99a04 100644 --- a/test/ots.jl +++ b/test/ots.jl @@ -2,42 +2,39 @@ # used by OTS models function check_br_status(sol) for (i,branch) in sol["branch"] - @test branch["br_status"] == 0.0 || branch["br_status"] == 1.0 + @test isapprox(branch["br_status"], 0.0, rtol=1e-6) || isapprox(branch["br_status"], 1.0, rtol=1e-6) end end -if (Pkg.installed("AmplNLWriter") != nothing && Pkg.installed("CoinOptServices") != nothing) - @testset "test ac ots" begin - #Omitting this test, until bugs can be resolved, bonmin does not report a integral solution - #@testset "3-bus case" begin - # result = run_ots("../test/data/matpower/case3.m", ACPPowerModel, BonminNLSolver(["bonmin.bb_log_level=0", "bonmin.nlp_log_level=0"])) +@testset "test ac ots" begin + @testset "3-bus case" begin + result = run_ots("../test/data/matpower/case3.m", ACPPowerModel, juniper_solver) - # check_br_status(result["solution"]) + check_br_status(result["solution"]) - # @test result["status"] == :LocalOptimal - # @test isapprox(result["objective"], 5812; atol = 1e0) - #end - @testset "5-bus case" begin - result = run_ots("../test/data/matpower/case5.m", ACPPowerModel, BonminNLSolver(["bonmin.bb_log_level=0", "bonmin.nlp_log_level=0"])) + @test result["status"] == :LocalOptimal + #@test isapprox(result["objective"], 5812; atol = 1e0) # true opt objective + @test isapprox(result["objective"], 5906.8; atol = 1e0) + end + @testset "5-bus case" begin + result = run_ots("../test/data/matpower/case5.m", ACPPowerModel, juniper_solver) - check_br_status(result["solution"]) + check_br_status(result["solution"]) - @test result["status"] == :LocalOptimal - # NOTE this objective value is out of date, and this test will not pass - @test isapprox(result["objective"], 15174; atol = 1e0) - end - #Omitting this test, returns local infeasible - #@testset "6-bus case" begin - # result = run_ots("../test/data/matpower/case6.m", ACPPowerModel, BonminNLSolver(["bonmin.bb_log_level=0", "bonmin.nlp_log_level=0"])) + @test result["status"] == :LocalOptimal + @test isapprox(result["objective"], 15174; atol = 1e0) + end + #Omitting this test, returns local infeasible + #@testset "6-bus case" begin + # result = run_ots("../test/data/matpower/case6.m", ACPPowerModel, juniper_solver) - # check_br_status(result["solution"]) + # check_br_status(result["solution"]) - # @test result["status"] == :LocalOptimal - # println(result["objective"]) - # @test isapprox(result["objective"], 15174; atol = 1e0) - #end - end + # @test result["status"] == :LocalOptimal + # println(result["objective"]) + # @test isapprox(result["objective"], 15174; atol = 1e0) + #end end diff --git a/test/runtests.jl b/test/runtests.jl index abae3747f..a73b779d8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,20 +8,18 @@ setlevel!(getlogger(PowerModels), "error") using Ipopt using Pajarito +using Juniper using GLPKMathProgInterface using SCS -# needed for Non-convex OTS tests -if (Pkg.installed("AmplNLWriter") != nothing && Pkg.installed("CoinOptServices") != nothing) - using AmplNLWriter - using CoinOptServices -end - using Base.Test # default setup for solvers ipopt_solver = IpoptSolver(tol=1e-6, print_level=0) -pajarito_solver = PajaritoSolver(mip_solver=GLPKSolverMIP(), cont_solver=ipopt_solver, log_level=0) +glpk_solver = GLPKSolverMIP() +juniper_solver = JuniperSolver(IpoptSolver(tol=1e-4, print_level=0), mip_solver=glpk_solver, log_levels=[]) +#juniper_solver = JuniperSolver(IpoptSolver(tol=1e-4, print_level=0), mip_solver=glpk_solver) +pajarito_solver = PajaritoSolver(mip_solver=glpk_solver, cont_solver=ipopt_solver, log_level=0) scs_solver = SCSSolver(max_iters=1000000, verbose=0) diff --git a/test/tnep.jl b/test/tnep.jl index 0c00e5b0a..93de3ce4c 100644 --- a/test/tnep.jl +++ b/test/tnep.jl @@ -2,11 +2,32 @@ function check_tnep_status(sol) for (idx,val) in sol["ne_branch"] - @test val["built"] == 0.0 || val["built"] == 1.0 + @test isapprox(val["built"], 0.0, rtol=1e-6) || isapprox(val["built"], 1.0, rtol=1e-6) end end +@testset "test ac tnep" begin + @testset "3-bus case" begin + result = run_tnep("../test/data/matpower/case3_tnep.m", ACPPowerModel, juniper_solver) + + check_tnep_status(result["solution"]) + + @test result["status"] == :LocalOptimal + @test isapprox(result["objective"], 2; atol = 1e-2) + end + # omitting due to numerical stability issues on Linux + #@testset "5-bus case" begin + # result = run_tnep("../test/data/matpower/case5_tnep.m", ACPPowerModel, juniper_solver) + + # check_tnep_status(result["solution"]) + + # @test result["status"] == :LocalOptimal + # @test isapprox(result["objective"], 1; atol = 1e-2) + #end +end + + @testset "test soc tnep" begin @testset "3-bus case" begin result = run_tnep("../test/data/matpower/case3_tnep.m", SOCWRPowerModel, pajarito_solver; setting = Dict("output" => Dict("branch_flows" => true))) @@ -70,22 +91,6 @@ end end -if (Pkg.installed("AmplNLWriter") != nothing && Pkg.installed("CoinOptServices") != nothing) - - @testset "test ac tnep" begin - @testset "5-bus case" begin - result = run_tnep("../test/data/matpower/case5_tnep.m", ACPPowerModel, BonminNLSolver(["bonmin.bb_log_level=0", "bonmin.nlp_log_level=0"])) - - check_tnep_status(result["solution"]) - - @test result["status"] == :LocalOptimal - @test isapprox(result["objective"], 1; atol = 1e-2) - end - end - -end - - @testset "test tnep branch flow output" begin @testset "3-bus case" begin result = run_tnep("../test/data/matpower/case3_tnep.m", SOCWRPowerModel, pajarito_solver; setting = Dict("output" => Dict("branch_flows" => true)))