Skip to content

Commit

Permalink
rename test solver variables (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoffrin authored Mar 6, 2022
1 parent 29cc7c7 commit e4b1235
Show file tree
Hide file tree
Showing 21 changed files with 519 additions and 519 deletions.
12 changes: 6 additions & 6 deletions test/data-basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@test length(data["switch"]) == 0
@test length(data["storage"]) == 0

result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)
@test isapprox(result["objective"], 1036.52; atol=1e0)
end

Expand All @@ -31,7 +31,7 @@
@test length(data["switch"]) == 0
@test length(data["storage"]) == 0

result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)
@test isapprox(result["objective"], 16551.7; atol=1e0)
end

Expand All @@ -43,15 +43,15 @@ end
@testset "basic bus injection" begin
data = make_basic_network(PowerModels.parse_file("../test/data/matpower/case14.m"))

result = run_opf(data, DCPPowerModel, ipopt_solver)
result = run_opf(data, DCPPowerModel, nlp_solver)
update_data!(data, result["solution"])

bi = calc_basic_bus_injection(data)

@test isapprox(real(sum(bi)), 0.0; atol=1e-6)


result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)
update_data!(data, result["solution"])

bi = calc_basic_bus_injection(data)
Expand Down Expand Up @@ -95,7 +95,7 @@ end
@test isapprox(SM_1, SM_2; atol=1e-6)


result = run_opf(data, DCPPowerModel, ipopt_solver)
result = run_opf(data, DCPPowerModel, nlp_solver)
update_data!(data, result["solution"])

va = angle.(calc_basic_bus_voltage(data))
Expand Down Expand Up @@ -155,7 +155,7 @@ end
@test isapprox(sum(P), 0.9894736; atol=1e-6)


result = run_opf(data, DCPPowerModel, ipopt_solver)
result = run_opf(data, DCPPowerModel, nlp_solver)
update_data!(data, result["solution"])

bi = real(calc_basic_bus_injection(data))
Expand Down
50 changes: 25 additions & 25 deletions test/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ TESTLOG = Memento.getlogger(PowerModels)
end

@testset "5-bus solution summary from dict" begin
result = run_ac_opf("../test/data/matpower/case5.m", ipopt_solver)
result = run_ac_opf("../test/data/matpower/case5.m", nlp_solver)
output = sprint(PowerModels.summary, result["solution"])

line_count = count(c -> c == '\n', output)
Expand Down Expand Up @@ -128,7 +128,7 @@ end


@testset "3-bus case solution" begin
result = run_ac_opf("../test/data/matpower/case3.m", ipopt_solver)
result = run_ac_opf("../test/data/matpower/case3.m", nlp_solver)
result_base = deepcopy(result)

PowerModels.make_mixed_units!(result["solution"])
Expand All @@ -137,7 +137,7 @@ end
@test InfrastructureModels.compare_dict(result, result_base)
end
@testset "5-bus case solution" begin
result = run_ac_opf("../test/data/matpower/case5_asym.m", ipopt_solver)
result = run_ac_opf("../test/data/matpower/case5_asym.m", nlp_solver)
result_base = deepcopy(result)

PowerModels.make_mixed_units!(result["solution"])
Expand All @@ -146,7 +146,7 @@ end
@test InfrastructureModels.compare_dict(result, result_base)
end
@testset "24-bus case solution" begin
result = run_ac_opf("../test/data/matpower/case24.m", ipopt_solver)
result = run_ac_opf("../test/data/matpower/case24.m", nlp_solver)
result_base = deepcopy(result)

PowerModels.make_mixed_units!(result["solution"])
Expand All @@ -157,7 +157,7 @@ end


@testset "5-bus case solution with duals" begin
result = run_dc_opf("../test/data/matpower/case5.m", ipopt_solver, setting = Dict("output" => Dict("branch_flows" => true, "duals" => true)))
result = run_dc_opf("../test/data/matpower/case5.m", nlp_solver, setting = Dict("output" => Dict("branch_flows" => true, "duals" => true)))
result_base = deepcopy(result)

PowerModels.make_mixed_units!(result["solution"])
Expand Down Expand Up @@ -437,7 +437,7 @@ end
@testset "output values" begin
data = PowerModels.parse_file("../test/data/matpower/case7_tplgy.m")
PowerModels.simplify_network!(data)
result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 1778; atol = 1e0)
Expand Down Expand Up @@ -594,7 +594,7 @@ end
data = PowerModels.parse_file("../test/data/matpower/case5.m")
data["branch"]["4"]["br_status"] = 0
data["buspairs"] = PowerModels.calc_buspair_parameters(data["bus"], data["branch"], 1:1, false)
result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 16642; atol = 1e0)
Expand All @@ -608,7 +608,7 @@ end
@testset "5-bus ac polar flow" begin
data = PowerModels.parse_file("../test/data/matpower/case5.m")
data["branch"]["4"]["br_status"] = 0
result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)
PowerModels.update_data!(data, result["solution"])

ac_flows = PowerModels.calc_branch_flow_ac(data)
Expand All @@ -626,7 +626,7 @@ end
@testset "5-bus ac rect flow" begin
data = PowerModels.parse_file("../test/data/matpower/case5.m")
data["branch"]["4"]["br_status"] = 0
result = run_opf(data, ACRPowerModel, ipopt_solver, solution_processors=[sol_data_model!])
result = run_opf(data, ACRPowerModel, nlp_solver, solution_processors=[sol_data_model!])
PowerModels.update_data!(data, result["solution"])

ac_flows = PowerModels.calc_branch_flow_ac(data)
Expand All @@ -644,7 +644,7 @@ end
@testset "5-bus dc flow" begin
data = PowerModels.parse_file("../test/data/matpower/case5.m")
data["branch"]["4"]["br_status"] = 0
result = run_opf(data, DCPPowerModel, ipopt_solver)
result = run_opf(data, DCPPowerModel, nlp_solver)
PowerModels.update_data!(data, result["solution"])

dc_flows = PowerModels.calc_branch_flow_dc(data)
Expand All @@ -666,7 +666,7 @@ end

@testset "5-bus polynomial gen cost" begin
data = PowerModels.parse_file("../test/data/matpower/case5.m")
result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)
PowerModels.update_data!(data, result["solution"])

gen_cost = PowerModels.calc_gen_cost(data)
Expand All @@ -681,7 +681,7 @@ end
@test isa(gen["ncost"], Int)
end

result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)
PowerModels.update_data!(data, result["solution"])

gen_cost = PowerModels.calc_gen_cost(data)
Expand All @@ -700,7 +700,7 @@ end

@testset "5-bus polynomial gen and dcline cost" begin
data = PowerModels.parse_file("../test/data/matpower/case5_dc.m")
result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)
PowerModels.update_data!(data, result["solution"])

gen_cost = PowerModels.calc_gen_cost(data)
Expand All @@ -713,7 +713,7 @@ end
data["gen"]["1"]["gen_status"] = 0
data["dcline"]["1"]["br_status"] = 0

result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)
PowerModels.update_data!(data, result["solution"])

gen_cost = PowerModels.calc_gen_cost(data)
Expand All @@ -729,7 +729,7 @@ end
@testset "5-bus ac polar balance" begin
data = PowerModels.parse_file("../test/data/matpower/case5_dc.m")
data["branch"]["4"]["br_status"] = 0
result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)
PowerModels.update_data!(data, result["solution"])

balance = PowerModels.calc_power_balance(data)
Expand All @@ -743,7 +743,7 @@ end
@testset "5-bus dc balance" begin
data = PowerModels.parse_file("../test/data/matpower/case5_dc.m")
data["branch"]["4"]["br_status"] = 0
result = run_opf(data, DCPPowerModel, ipopt_solver)
result = run_opf(data, DCPPowerModel, nlp_solver)
PowerModels.update_data!(data, result["solution"])

balance = PowerModels.calc_power_balance(data)
Expand All @@ -758,7 +758,7 @@ end
@testset "5-bus ac polar balance with storage" begin
data = PowerModels.parse_file("../test/data/matpower/case5_strg.m")
data["branch"]["4"]["br_status"] = 0
result = PowerModels._solve_opf_strg(data, ACPPowerModel, ipopt_solver)
result = PowerModels._solve_opf_strg(data, ACPPowerModel, nlp_solver)
PowerModels.update_data!(data, result["solution"])

balance = PowerModels.calc_power_balance(data)
Expand All @@ -772,7 +772,7 @@ end
@testset "5-bus dc balance with storage" begin
data = PowerModels.parse_file("../test/data/matpower/case5_strg.m")
data["branch"]["4"]["br_status"] = 0
result = PowerModels._solve_opf_strg(data, DCPPowerModel, ipopt_solver)
result = PowerModels._solve_opf_strg(data, DCPPowerModel, nlp_solver)
PowerModels.update_data!(data, result["solution"])

balance = PowerModels.calc_power_balance(data)
Expand All @@ -787,7 +787,7 @@ end
@testset "5-bus balance from flow ac" begin
data = PowerModels.parse_file("../test/data/matpower/case5_dc.m")
data["branch"]["4"]["br_status"] = 0
result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)
PowerModels.update_data!(data, result["solution"])

flows = PowerModels.calc_branch_flow_ac(data)
Expand All @@ -804,7 +804,7 @@ end
@testset "5-bus balance from flow dc" begin
data = PowerModels.parse_file("../test/data/matpower/case5_dc.m")
data["branch"]["4"]["br_status"] = 0
result = run_opf(data, DCPPowerModel, ipopt_solver)
result = run_opf(data, DCPPowerModel, nlp_solver)
PowerModels.update_data!(data, result["solution"])

flows = PowerModels.calc_branch_flow_dc(data)
Expand All @@ -825,22 +825,22 @@ end
@testset "test renumber bus ids" begin
@testset "5-bus with dcline" begin
data = PowerModels.parse_file("../test/data/matpower/case5_dc.m")
result_1 = run_opf(data, ACPPowerModel, ipopt_solver)
result_1 = run_opf(data, ACPPowerModel, nlp_solver)

update_bus_ids!(data, Dict(1 => 10, 2=>20, 3=>30, 4=>40, 5=>50))

result_2 = run_opf(data, ACPPowerModel, ipopt_solver)
result_2 = run_opf(data, ACPPowerModel, nlp_solver)

@test isapprox(result_1["objective"], result_2["objective"]; atol=1e-6)
end

@testset "5-bus with switches" begin
data = PowerModels.parse_file("../test/data/matpower/case5_sw.m")
result_1 = PowerModels._solve_opf_sw(data, DCPPowerModel, ipopt_solver)
result_1 = PowerModels._solve_opf_sw(data, DCPPowerModel, nlp_solver)

update_bus_ids!(data, Dict(1 => 10, 2=>20, 3=>30, 4=>40, 10=>100))

result_2 = PowerModels._solve_opf_sw(data, DCPPowerModel, ipopt_solver)
result_2 = PowerModels._solve_opf_sw(data, DCPPowerModel, nlp_solver)

@test isapprox(result_1["objective"], result_2["objective"]; atol=1e-6)
end
Expand All @@ -854,7 +854,7 @@ end
@test length(data["switch"]) == 0
@test length(data["bus"]) == 4

result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)

@test isapprox(result["objective"], 16641.20; atol=1e0)
end
Expand Down
16 changes: 8 additions & 8 deletions test/matpower.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@testset "test matpower parser" begin
@testset "30-bus case file" begin
result = run_opf("../test/data/matpower/case30.m", ACPPowerModel, ipopt_solver)
result = run_opf("../test/data/matpower/case30.m", ACPPowerModel, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 204.96; atol = 1e-1)
Expand All @@ -10,7 +10,7 @@
data = PowerModels.parse_file("../test/data/matpower/case30.m")
@test isa(JSON.json(data), String)

result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 204.96; atol = 1e-1)
Expand All @@ -20,7 +20,7 @@
data = PowerModels.parse_matpower("../test/data/matpower/case30.m")
@test isa(JSON.json(data), String)

result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 204.96; atol = 1e-1)
Expand All @@ -31,7 +31,7 @@
data = PowerModels.parse_matpower(f)
@test isa(JSON.json(data), String)

result = run_opf(data, ACPPowerModel, ipopt_solver)
result = run_opf(data, ACPPowerModel, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 204.96; atol = 1e-1)
Expand All @@ -57,7 +57,7 @@
end

@testset "2-bus case file with spaces" begin
result = run_pf("../test/data/matpower/case2.m", ACPPowerModel, ipopt_solver)
result = run_pf("../test/data/matpower/case2.m", ACPPowerModel, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 0.0; atol = 1e-1)
Expand All @@ -76,20 +76,20 @@ end

@testset "test matpower data coercion" begin
@testset "ACP Model" begin
result = run_opf("../test/data/matpower/case14.m", ACPPowerModel, ipopt_solver)
result = run_opf("../test/data/matpower/case14.m", ACPPowerModel, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 8081.5; atol = 1e0)
#@test result["status"] = bus_name
end
@testset "DC Model" begin
result = run_opf("../test/data/matpower/case14.m", DCPPowerModel, ipopt_solver)
result = run_opf("../test/data/matpower/case14.m", DCPPowerModel, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 7642.6; atol = 1e0)
end
@testset "QC Model" begin
result = run_opf("../test/data/matpower/case14.m", QCRMPowerModel, ipopt_solver)
result = run_opf("../test/data/matpower/case14.m", QCRMPowerModel, nlp_solver)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 8075.1; atol = 1e0)
Expand Down
6 changes: 3 additions & 3 deletions test/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@testset "run with user provided JuMP model" begin
m = JuMP.Model()
x = JuMP.@variable(m, my_var >= 0, start=0.0)
result = run_ac_opf("../test/data/matpower/case5.m", ipopt_solver, jump_model=m)
result = run_ac_opf("../test/data/matpower/case5.m", nlp_solver, jump_model=m)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 18269; atol = 1e0)
Expand Down Expand Up @@ -49,7 +49,7 @@ end

@testset "relax integrality" begin
@testset "relax OTS model" begin
result = run_ots("../test/data/matpower/case5.m", DCPPowerModel, ipopt_solver, relax_integrality=true)
result = run_ots("../test/data/matpower/case5.m", DCPPowerModel, nlp_solver, relax_integrality=true)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 14810.0; atol = 1e0)
Expand All @@ -59,7 +59,7 @@ end
end

@testset "relax TNEP model" begin
result = run_tnep("../test/data/matpower/case5_tnep.m", SOCWRPowerModel, ipopt_solver, relax_integrality=true)
result = run_tnep("../test/data/matpower/case5_tnep.m", SOCWRPowerModel, nlp_solver, relax_integrality=true)

@test result["termination_status"] == LOCALLY_SOLVED
@test isapprox(result["objective"], 0.1236; atol = 1e-2)
Expand Down
Loading

0 comments on commit e4b1235

Please sign in to comment.