Skip to content

Commit

Permalink
Updates for SCS v2.0 (#898)
Browse files Browse the repository at this point in the history
* allow scs v2
* update tests for scs v2.0
  • Loading branch information
ccoffrin authored Jan 1, 2024
1 parent fd9f63d commit 010b6ee
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PowerModels.jl Change Log
### v0.19.10
- Add support for ACP and DCP formulation in OPF with PST variables (#543,#875)
- Fix implementation of `calc_theta_delta_bounds` when conductor parameter is used (#870)
- Update tests for SCS v2.0

### v0.19.9
- Fix implementation of polynomial costs above quadratic
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ JuMP = "~0.22, ~0.23, 1"
Juniper = "~0.8, ~0.9"
Memento = "~1.0, ~1.1, ~1.2, ~1.3, ~1.4"
NLsolve = "4.0"
SCS = "~0.9, ~1.0"
SCS = "~0.9, ~1.0, ~2.0"
julia = "1.6"

[extras]
Expand Down
4 changes: 2 additions & 2 deletions test/opf-var.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ end
result = PowerModels._solve_opf_cl(data, SDPWRMPowerModel, sdp_solver)

@test result["termination_status"] == OPTIMAL
@test isapprox(result["objective"], 5728.62; atol = 1e0)
#@test isapprox(result["objective"], 5747.63; atol = 1e0)
#@test isapprox(result["objective"], 5728.62; atol = 1e0)
@test isapprox(result["objective"], 5747.63; atol = 1e0)
end
@testset "5-bus case" begin
data = build_current_data("../test/data/matpower/case5.m")
Expand Down
48 changes: 26 additions & 22 deletions test/opf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,8 @@ end
result = run_opf("../test/data/matpower/case3.m", SOCWRConicPowerModel, sdp_solver)

@test result["termination_status"] == OPTIMAL
@test isapprox(result["objective"], 5736.94; atol = 2e0)
#@test isapprox(result["objective"], 5747.37; atol = 2e0)
#@test isapprox(result["objective"], 5736.94; atol = 2e0)
@test isapprox(result["objective"], 5747.37; atol = 2e0)
end
@testset "5-bus transformer swap case" begin
result = run_opf("../test/data/matpower/case5.m", SOCWRConicPowerModel, sdp_solver)
Expand Down Expand Up @@ -621,31 +621,31 @@ end
result = run_opf("../test/data/matpower/case5_npg.m", SOCWRConicPowerModel, sdp_solver)

@test result["termination_status"] == OPTIMAL
@test isapprox(result["objective"], 3551.71; atol = 40)
#@test isapprox(result["objective"], 3602.11; atol = 40)
#@test isapprox(result["objective"], 3551.71; atol = 40)
@test isapprox(result["objective"], 3602.11; atol = 40)
end
@testset "5-bus with pwl costs" begin
result = run_opf("../test/data/matpower/case5_pwlc.m", SOCWRConicPowerModel, sdp_solver)

@test result["termination_status"] == OPTIMAL
@test isapprox(result["objective"], 42889; atol = 1e0)
#@test isapprox(result["objective"], 42906; atol = 1e0)
#@test isapprox(result["objective"], 42889; atol = 1e0)
@test isapprox(result["objective"], 42906; atol = 1e0)
end
@testset "6-bus case" begin
result = run_opf("../test/data/matpower/case6.m", SOCWRConicPowerModel, sdp_solver)

@test result["termination_status"] == OPTIMAL
#@test isapprox(result["objective"], 11472.2; atol = 3e0)
@test isapprox(result["objective"], 11451.5; atol = 3e0)
#@test isapprox(result["objective"], 11473.4; atol = 3e0)
#@test isapprox(result["objective"], 11451.5; atol = 3e0)
@test isapprox(result["objective"], 11473.4; atol = 3e0)
end
@testset "24-bus rts case" begin
result = run_opf("../test/data/matpower/case24.m", SOCWRConicPowerModel, sdp_solver)

@test result["termination_status"] == OPTIMAL
#@test isapprox(result["objective"], 70693.9; atol = 1e0)
@test isapprox(result["objective"], 70670.0; atol = 1e0)
#@test isapprox(result["objective"], 70683.5; atol = 1e0)
#@test isapprox(result["objective"], 70670.0; atol = 1e0)
@test isapprox(result["objective"], 70683.5; atol = 1e0)
end
@testset "14-bus variable bounds" begin
pm = instantiate_model("../test/data/matpower/case14.m", SOCWRConicPowerModel, PowerModels.build_opf)
Expand Down Expand Up @@ -906,14 +906,16 @@ end
result = run_opf("../test/data/matpower/case3.m", SDPWRMPowerModel, sdp_solver)

@test result["termination_status"] == OPTIMAL
@test isapprox(result["objective"], 5818.00; atol = 1e1)
#@test isapprox(result["objective"], 5852.51; atol = 1e1)
#@test isapprox(result["objective"], 5818.00; atol = 1e1)
@test isapprox(result["objective"], 5852.51; atol = 1e1)

@test haskey(result["solution"],"WR")
@test haskey(result["solution"],"WI")
@test isapprox(result["solution"]["bus"]["1"]["w"], 1.179, atol = 1e-2)
#@test isapprox(result["solution"]["bus"]["1"]["w"], 1.179, atol = 1e-2)
@test isapprox(result["solution"]["bus"]["1"]["w"], 1.209, atol = 1e-2)
@test isapprox(result["solution"]["branch"]["1"]["wr"], 0.941, atol = 1e-2)
@test isapprox(result["solution"]["branch"]["1"]["wi"], 0.269, atol = 1e-2)
#@test isapprox(result["solution"]["branch"]["1"]["wi"], 0.269, atol = 1e-2)
@test isapprox(result["solution"]["branch"]["1"]["wi"], 0.284, atol = 1e-2)
end
@testset "5-bus asymmetric case" begin
result = run_opf("../test/data/matpower/case5_asym.m", SDPWRMPowerModel, sdp_solver)
Expand All @@ -938,8 +940,8 @@ end

@test result["termination_status"] == OPTIMAL
#@test isapprox(result["objective"], 6827.34; atol = 1e0)
@test isapprox(result["objective"], 6735.17; atol = 1e0)
#@test isapprox(result["objective"], 6827.71; atol = 1e0)
#@test isapprox(result["objective"], 6735.17; atol = 1e0)
@test isapprox(result["objective"], 6827.71; atol = 1e0)
end
# too slow for unit tests
# @testset "14-bus case" begin
Expand All @@ -953,8 +955,8 @@ end

@test result["termination_status"] == OPTIMAL
#@test isapprox(result["objective"], 11580.8; atol = 1e1)
@test isapprox(result["objective"], 11507.7; atol = 1e1)
#@test isapprox(result["objective"], 11580.5; atol = 1e1)
#@test isapprox(result["objective"], 11507.7; atol = 1e1)
@test isapprox(result["objective"], 11580.5; atol = 1e1)
end
@testset "14-bus variable bounds" begin
pm = instantiate_model("../test/data/matpower/case14.m", SDPWRMPowerModel, PowerModels.build_opf)
Expand All @@ -969,14 +971,16 @@ end

@test result["termination_status"] == OPTIMAL
#@test isapprox(result["objective"], 5851.23; atol = 1e1)
@test isapprox(result["objective"], 5818.00; atol = 1e1)
#@test isapprox(result["objective"], 5852.51; atol = 1e1)
#@test isapprox(result["objective"], 5818.00; atol = 1e1)
@test isapprox(result["objective"], 5852.51; atol = 1e1)

@test haskey(result["solution"]["w_group"]["1"],"WR")
@test haskey(result["solution"]["w_group"]["1"],"WI")
@test isapprox(result["solution"]["bus"]["1"]["w"], 1.179, atol = 1e-2)
#@test isapprox(result["solution"]["bus"]["1"]["w"], 1.179, atol = 1e-2)
@test isapprox(result["solution"]["bus"]["1"]["w"], 1.209, atol = 1e-2)
@test isapprox(result["solution"]["branch"]["1"]["wr"], 0.941, atol = 1e-2)
@test isapprox(result["solution"]["branch"]["1"]["wi"], 0.269, atol = 1e-2)
#@test isapprox(result["solution"]["branch"]["1"]["wi"], 0.269, atol = 1e-2)
@test isapprox(result["solution"]["branch"]["1"]["wi"], 0.284, atol = 1e-2)
end
@testset "5-bus with asymmetric line charge" begin
result = run_opf("../test/data/pti/case5_alc.raw", SparseSDPWRMPowerModel, sdp_solver)
Expand Down

0 comments on commit 010b6ee

Please sign in to comment.