Skip to content

Commit

Permalink
add new test
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-lara committed Jan 8, 2024
1 parent d1dd6b1 commit bf24077
Showing 1 changed file with 40 additions and 22 deletions.
62 changes: 40 additions & 22 deletions test/test_network_constructors.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# Note to devs. Use GLPK or Cbc for models with linear constraints and linear cost functions
# Use OSQP for models with quadratic cost function and linear constraints and ipopt otherwise
const networks_for_testing = networks = [
(PM.ACPPowerModel, fast_ipopt_optimizer),
(PM.ACRPowerModel, fast_ipopt_optimizer),
(PM.ACTPowerModel, fast_ipopt_optimizer),
#(PM.IVRPowerModel, fast_ipopt_optimizer), #instantiate_ivp_expr_model not implemented
(PM.DCPPowerModel, fast_ipopt_optimizer),
(PM.DCMPPowerModel, fast_ipopt_optimizer),
(PM.NFAPowerModel, fast_ipopt_optimizer),
(PM.DCPLLPowerModel, fast_ipopt_optimizer),
(PM.LPACCPowerModel, fast_ipopt_optimizer),
(PM.SOCWRPowerModel, fast_ipopt_optimizer),
(PM.SOCWRConicPowerModel, scs_solver),
(PM.QCRMPowerModel, fast_ipopt_optimizer),
(PM.QCLSPowerModel, fast_ipopt_optimizer),
#(PM.SOCBFPowerModel, fast_ipopt_optimizer), # not implemented
(PM.BFAPowerModel, fast_ipopt_optimizer),
#(PM.SOCBFConicPowerModel, fast_ipopt_optimizer), # not implemented
(PM.SDPWRMPowerModel, scs_solver),
(PM.SparseSDPWRMPowerModel, scs_solver),
(PTDFPowerModel, fast_ipopt_optimizer),
]

@testset "All PowerModels models construction" begin
networks = [
(PM.ACPPowerModel, fast_ipopt_optimizer),
(PM.ACRPowerModel, fast_ipopt_optimizer),
(PM.ACTPowerModel, fast_ipopt_optimizer),
#(PM.IVRPowerModel, fast_ipopt_optimizer), #instantiate_ivp_expr_model not implemented
(PM.DCPPowerModel, fast_ipopt_optimizer),
(PM.DCMPPowerModel, fast_ipopt_optimizer),
(PM.NFAPowerModel, fast_ipopt_optimizer),
(PM.DCPLLPowerModel, fast_ipopt_optimizer),
(PM.LPACCPowerModel, fast_ipopt_optimizer),
(PM.SOCWRPowerModel, fast_ipopt_optimizer),
(PM.SOCWRConicPowerModel, scs_solver),
(PM.QCRMPowerModel, fast_ipopt_optimizer),
(PM.QCLSPowerModel, fast_ipopt_optimizer),
#(PM.SOCBFPowerModel, fast_ipopt_optimizer), # not implemented
(PM.BFAPowerModel, fast_ipopt_optimizer),
#(PM.SOCBFConicPowerModel, fast_ipopt_optimizer), # not implemented
(PM.SDPWRMPowerModel, scs_solver),
(PM.SparseSDPWRMPowerModel, scs_solver),
(PTDFPowerModel, fast_ipopt_optimizer),
]
c_sys5 = PSB.build_system(PSITestSystems, "c_sys5")
for (network, solver) in networks
for (network, solver) in networks_for_testing
template = get_thermal_dispatch_template_network(
NetworkModel(network; PTDF_matrix = PTDF(c_sys5)),
)
Expand Down Expand Up @@ -696,3 +697,20 @@ end
)
@test all(isapprox.(sum(zone_2_gen .+ zone_2_load; dims = 2), 0.0; atol = 1e-3))
end

@testset "All PowerModels models construction with reduced radial branches" begin
# use the system with a radial branch
#c_sys5 = PSB.build_system(PSITestSystems, "c_sys5")
for (network, solver) in networks_for_testing
template = get_thermal_dispatch_template_network(
NetworkModel(network;
PTDF_matrix = PTDF(c_sys5),
reduce_radial_branches = true,
use_slacks),
)
ps_model = DecisionModel(template, c_sys5; optimizer = solver)
@test build!(ps_model; output_dir = mktempdir(; cleanup = true)) ==
PSI.BuildStatus.BUILT
@test ps_model.internal.container.pm !== nothing
end
end

0 comments on commit bf24077

Please sign in to comment.