Skip to content

Commit

Permalink
Update Tests to use HiGHS instead of Cbc (#68)
Browse files Browse the repository at this point in the history
* update tests to use highs instead of cbc
* rename solvers in tests to reflect problem class not solver names
* update rrr tests for ci compat
  • Loading branch information
ccoffrin authored Jan 3, 2024
1 parent a5fbc67 commit 432b694
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 129 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "PowerModelsRestoration"
uuid = "23adbb12-a187-11e9-26a2-eb4d4e6e68fb"
authors = ["David M Fobes <dfobes@lanl.gov>", "Noah Rhodes"]
authors = ["David M Fobes", "Noah Rhodes", "Carleton Coffrin"]
version = "0.8.0"

[deps]
Expand All @@ -17,7 +17,7 @@ PowerModels = "~0.20"
julia = "1.6"

[extras]
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
Juniper = "2ddba703-00a4-53a7-87a5-e8b9971dde84"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -26,4 +26,4 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Ipopt", "Cbc", "Juniper", "SCS", "Random", "StableRNGs"]
test = ["Test", "Ipopt", "HiGHS", "Juniper", "SCS", "Random", "StableRNGs"]
66 changes: 33 additions & 33 deletions test/mld.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@testset "test ac ml" begin
@testset "3-bus case" begin
result = run_mld(case3_mld, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld(case3_mld, PowerModels.ACPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -13,7 +13,7 @@
@test all_voltages_on(result)
end
@testset "3-bus shunt case" begin
result = run_mld(case3_mld_s, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld(case3_mld_s, PowerModels.ACPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -25,7 +25,7 @@
#TODO add test where branch "2" is turned on
end
@testset "3-bus uc case" begin
result = run_mld(case3_mld_uc, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld(case3_mld_uc, PowerModels.ACPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -39,7 +39,7 @@
#=
# removed for cross platform readability, fails on Windows with Julia v1.6.3
@testset "3-bus line charge case" begin
result = run_mld(case3_mld_lc, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld(case3_mld_lc, PowerModels.ACPPowerModel, nlp_solver)
#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -54,7 +54,7 @@
end
=#
@testset "5-bus pti" begin
result = run_mld(case5_pti, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld(case5_pti, PowerModels.ACPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -72,7 +72,7 @@
data = PowerModels.parse_file("../test/data/case5.raw")
add_load_weights!(data)

result = run_mld(data, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld(data, PowerModels.ACPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -91,7 +91,7 @@
@test loads["2"]["status"] >= loads["4"]["status"]
end
@testset "24-bus rts case" begin
result = run_mld(case24, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld(case24, PowerModels.ACPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -103,15 +103,15 @@
end
end

case3_mld_ub = run_mld(case3_mld, PowerModels.ACPPowerModel, ipopt_solver)["objective"]
case3_mld_s_ub = run_mld(case3_mld_s, PowerModels.ACPPowerModel, ipopt_solver)["objective"]
case3_mld_uc_ub = run_mld(case3_mld_uc, PowerModels.ACPPowerModel, ipopt_solver)["objective"]
case24_ub = run_mld(case24, PowerModels.ACPPowerModel, ipopt_solver)["objective"]
case3_mld_ub = run_mld(case3_mld, PowerModels.ACPPowerModel, nlp_solver)["objective"]
case3_mld_s_ub = run_mld(case3_mld_s, PowerModels.ACPPowerModel, nlp_solver)["objective"]
case3_mld_uc_ub = run_mld(case3_mld_uc, PowerModels.ACPPowerModel, nlp_solver)["objective"]
case24_ub = run_mld(case24, PowerModels.ACPPowerModel, nlp_solver)["objective"]


@testset "test dc ml" begin
@testset "3-bus case" begin
result = run_mld(case3_mld, PowerModels.DCPPowerModel, ipopt_solver)
result = run_mld(case3_mld, PowerModels.DCPPowerModel, nlp_solver)

#println(result)
#println(result["objective"])
Expand All @@ -122,7 +122,7 @@ case24_ub = run_mld(case24, PowerModels.ACPPowerModel, ipopt_solver)["objective"
@test all_gens_on(result)
end
@testset "3-bus shunt case" begin
result = run_mld(case3_mld_s, PowerModels.DCPPowerModel, ipopt_solver)
result = run_mld(case3_mld_s, PowerModels.DCPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -133,7 +133,7 @@ case24_ub = run_mld(case24, PowerModels.ACPPowerModel, ipopt_solver)["objective"
#TODO add test where branch "2" is turned on
end
@testset "3-bus uc case" begin
result = run_mld(case3_mld_uc, PowerModels.DCPPowerModel, ipopt_solver)
result = run_mld(case3_mld_uc, PowerModels.DCPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -144,7 +144,7 @@ case24_ub = run_mld(case24, PowerModels.ACPPowerModel, ipopt_solver)["objective"
@test isapprox(gen_status(result, "2"), 1.000000; atol = 1e-4)
end
@testset "3-bus line charge case" begin
result = run_mld(case3_mld_lc, PowerModels.DCPPowerModel, ipopt_solver)
result = run_mld(case3_mld_lc, PowerModels.DCPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -154,7 +154,7 @@ case24_ub = run_mld(case24, PowerModels.ACPPowerModel, ipopt_solver)["objective"
@test all_gens_on(result)
end
@testset "5-bus pti" begin
result = run_mld(case5_pti, PowerModels.DCPPowerModel, ipopt_solver)
result = run_mld(case5_pti, PowerModels.DCPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -172,7 +172,7 @@ case24_ub = run_mld(case24, PowerModels.ACPPowerModel, ipopt_solver)["objective"
data = PowerModels.parse_file("../test/data/case5.raw")
add_load_weights!(data)

result = run_mld(data, PowerModels.DCPPowerModel, ipopt_solver)
result = run_mld(data, PowerModels.DCPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -191,7 +191,7 @@ case24_ub = run_mld(case24, PowerModels.ACPPowerModel, ipopt_solver)["objective"
@test loads["2"]["status"] >= loads["4"]["status"]
end
@testset "24-bus rts case" begin
result = run_mld(case24, PowerModels.DCPPowerModel, ipopt_solver)
result = run_mld(case24, PowerModels.DCPPowerModel, nlp_solver)

#println(result)
#println(result["objective"])
Expand All @@ -206,7 +206,7 @@ end

@testset "test soc ml" begin
@testset "3-bus case" begin
result = run_mld(case3_mld, PowerModels.SOCWRPowerModel, ipopt_solver)
result = run_mld(case3_mld, PowerModels.SOCWRPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -218,7 +218,7 @@ end
@test result["objective"]/case3_mld_ub >= 1.0 - opt_gap_tol
end
@testset "3-bus shunt case" begin
result = run_mld(case3_mld_s, PowerModels.SOCWRPowerModel, ipopt_solver)
result = run_mld(case3_mld_s, PowerModels.SOCWRPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -231,7 +231,7 @@ end
@test result["objective"]/case3_mld_s_ub >= 1.0 - opt_gap_tol
end
@testset "3-bus case uc" begin
result = run_mld(case3_mld_uc, PowerModels.SOCWRPowerModel, ipopt_solver)
result = run_mld(case3_mld_uc, PowerModels.SOCWRPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -244,7 +244,7 @@ end
@test result["objective"]/case3_mld_uc_ub >= 1.0 - opt_gap_tol
end
@testset "3-bus line charge case" begin
result = run_mld(case3_mld_lc, PowerModels.SOCWRPowerModel, ipopt_solver)
result = run_mld(case3_mld_lc, PowerModels.SOCWRPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -258,7 +258,7 @@ end
@test isapprox(bus_status(result, "3"), 0.560770; atol = 1e-2)
end
@testset "24-bus rts case" begin
result = run_mld(case24, PowerModels.SOCWRPowerModel, ipopt_solver)
result = run_mld(case24, PowerModels.SOCWRPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -275,7 +275,7 @@ end
#=
@testset "test qc ml" begin
@testset "3-bus case" begin
result = run_mld(case3_mld, QCWRPowerModel, ipopt_solver)
result = run_mld(case3_mld, QCWRPowerModel, nlp_solver)
println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -287,7 +287,7 @@ end
@test result["objective"]/case3_mld_ub >= 1.0 - opt_gap_tol
end
@testset "3-bus shunt case" begin
result = run_mld(case3_mld_s, QCWRPowerModel, ipopt_solver)
result = run_mld(case3_mld_s, QCWRPowerModel, nlp_solver)
println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -300,7 +300,7 @@ end
@test result["objective"]/case3_mld_s_ub >= 1.0 - opt_gap_tol
end
@testset "3-bus uc case" begin
result = run_mld(case3_mld_uc, QCWRPowerModel, ipopt_solver)
result = run_mld(case3_mld_uc, QCWRPowerModel, nlp_solver)
println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -313,7 +313,7 @@ end
@test result["objective"]/case3_mld_uc_ub >= 1.0 - opt_gap_tol
end
@testset "3-bus line charge case" begin
result = run_mld(case3_mld_lc, QCWRPowerModel, ipopt_solver)
result = run_mld(case3_mld_lc, QCWRPowerModel, nlp_solver)
println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -327,7 +327,7 @@ end
#@test isapprox(bus_status(result, "3"), 0.9343086026987113; atol = 1e-2)
end
@testset "24-bus rts case" begin
result = run_mld(case24, QCWRPowerModel, ipopt_solver)
result = run_mld(case24, QCWRPowerModel, nlp_solver)
println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -343,7 +343,7 @@ end

@testset "test sdp ml" begin
@testset "3-bus case" begin
result = run_mld(case3_mld, PowerModels.SDPWRMPowerModel, scs_solver)
result = run_mld(case3_mld, PowerModels.SDPWRMPowerModel, sdp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.OPTIMAL
Expand All @@ -355,7 +355,7 @@ end
@test result["objective"]/case3_mld_ub >= 1.0 - opt_gap_tol
end
@testset "3-bus shunt case" begin
result = run_mld(case3_mld_s, PowerModels.SDPWRMPowerModel, scs_solver)
result = run_mld(case3_mld_s, PowerModels.SDPWRMPowerModel, sdp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.OPTIMAL
Expand All @@ -369,7 +369,7 @@ end
end
# # convergence issue encounterd when updated to SCS v0.6.3
# @testset "3-bus uc case" begin
# result = run_mld(case3_mld_uc, PowerModels.SDPWRMPowerModel, scs_solver)
# result = run_mld(case3_mld_uc, PowerModels.SDPWRMPowerModel, sdp_solver)

# #println(result["objective"])
# @test result["termination_status"] == PowerModels.OPTIMAL
Expand All @@ -384,7 +384,7 @@ end
# @test result["objective"]/case3_mld_uc_ub >= 1.0 - opt_gap_tol
# end
@testset "3-bus line charge case" begin
result = run_mld(case3_mld_lc, PowerModels.SDPWRMPowerModel, scs_solver)
result = run_mld(case3_mld_lc, PowerModels.SDPWRMPowerModel, sdp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.OPTIMAL
Expand All @@ -399,7 +399,7 @@ end
end
# TODO replace this with smaller case, way too slow for unit testing
#@testset "24-bus rts case" begin
# result = run_mld(case24, PowerModels.SDPWRMPowerModel, scs_solver)
# result = run_mld(case24, PowerModels.SDPWRMPowerModel, sdp_solver)
# PowerModels.make_mixed_units(result["solution"])

# @test result["termination_status"] == PowerModels.OPTIMAL
Expand Down
2 changes: 1 addition & 1 deletion test/mld_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

data = PowerModels.parse_file("../test/data/case5_mld_ft.m")
PowerModels.simplify_network!(data)
result = run_mld(data, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld(data, PowerModels.ACPPowerModel, nlp_solver)
solution = result["solution"]

active_buses = Set(["2", "4", "5"])
Expand Down
4 changes: 2 additions & 2 deletions test/mld_output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@testset "test ml output" begin
@testset "active and reactive" begin
result = run_mld(case3_mld_s, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld(case3_mld_s, PowerModels.ACPPowerModel, nlp_solver)

@test result["termination_status"] == PowerModels.LOCALLY_SOLVED

Expand Down Expand Up @@ -54,7 +54,7 @@
end

@testset "active only" begin
result = run_mld(case3_mld_s, PowerModels.DCPPowerModel, ipopt_solver)
result = run_mld(case3_mld_s, PowerModels.DCPPowerModel, nlp_solver)

@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
atol=1e-8
Expand Down
10 changes: 5 additions & 5 deletions test/mld_smpl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@testset "test ac ml smpl" begin
@testset "3-bus case" begin
result = run_mld_smpl(case3_mld, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld_smpl(case3_mld, PowerModels.ACPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -11,7 +11,7 @@
@test isapprox(active_power_served(result), 1.0343968580341767; atol = 1e-1)
end
@testset "3-bus shunt case" begin
result = run_mld_smpl(case3_mld_s, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld_smpl(case3_mld_s, PowerModels.ACPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -20,7 +20,7 @@
@test isapprox(active_power_served(result), 0.7951651020410877; atol = 1e-1)
end
@testset "3-bus uc case" begin
result = run_mld_smpl(case3_mld_uc, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld_smpl(case3_mld_uc, PowerModels.ACPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -29,7 +29,7 @@
@test isapprox(active_power_served(result), 1.1343738262510479; atol = 1e-1)
end
@testset "3-bus line charge case" begin
result = run_mld_smpl(case3_mld_lc, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld_smpl(case3_mld_lc, PowerModels.ACPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand All @@ -38,7 +38,7 @@
@test isapprox(active_power_served(result), 0.008694603282259982; atol = 1e-1)
end
@testset "24-bus rts case" begin
result = run_mld_smpl(case24, PowerModels.ACPPowerModel, ipopt_solver)
result = run_mld_smpl(case24, PowerModels.ACPPowerModel, nlp_solver)

#println(result["objective"])
@test result["termination_status"] == PowerModels.LOCALLY_SOLVED
Expand Down
Loading

0 comments on commit 432b694

Please sign in to comment.