Skip to content

Commit

Permalink
Merge pull request #1179 from NREL-Sienna/jd/solver_change
Browse files Browse the repository at this point in the history
remove GLPK and CBC
  • Loading branch information
jd-lara authored Dec 4, 2024
2 parents cfc1f52 + 129f569 commit 5e3e737
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/core/settings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function Settings(
optimizer_ = MOI.OptimizerWithAttributes(optimizer)
else
error(
"The provided input for optimizer is invalid. Provide a JuMP.OptimizerWithAttributes object or a valid Optimizer constructor (e.g. GLPK.Optimizer).",
"The provided input for optimizer is invalid. Provide a JuMP.OptimizerWithAttributes object or a valid Optimizer constructor (e.g. HiGHS.Optimizer).",
)
end

Expand Down
4 changes: 2 additions & 2 deletions src/operation/emulation_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ keyword arguments to that function.
# Examples
```julia
status = run!(model; optimizer = GLPK.Optimizer, executions = 10)
status = run!(model; output_dir = ./model_output, optimizer = GLPK.Optimizer, executions = 10)
status = run!(model; optimizer = HiGHS.Optimizer, executions = 10)
status = run!(model; output_dir = ./model_output, optimizer = HiGHS.Optimizer, executions = 10)
```
"""
function run!(
Expand Down
3 changes: 0 additions & 3 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
GLPK = "60bf3e95-4087-53dc-ae20-288a0d20c6a6"
HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
HydroPowerSimulations = "fc1677e0-6ad7-4515-bf3a-bd6bf20a0b1b"
InfrastructureSystems = "2cd47ed4-ca9b-11e9-27f2-ab636a7671f1"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"
PowerNetworkMatrices = "bed98974-b02a-5e2f-9fe0-a103f5c450dd"
Expand Down
2 changes: 1 addition & 1 deletion test/test_device_thermal_generation_constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ end
UnitCommitmentProblem,
template,
sys;
optimizer = cbc_optimizer,
optimizer = HiGHS_optimizer,
initialize_model = false,
)
@test build!(UC; output_dir = mktempdir(; cleanup = true)) == PSI.ModelBuildStatus.BUILT
Expand Down
32 changes: 16 additions & 16 deletions test/test_model_decision.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@test_throws MethodError DecisionModel(template, c_sys5; bad_kwarg = 10)

model = DecisionModel(template, c_sys5; optimizer = GLPK_optimizer)
model = DecisionModel(template, c_sys5; optimizer = HiGHS_optimizer)
@test build!(model; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT

Expand All @@ -15,14 +15,14 @@
NetworkModel(CopperPlatePowerModel; use_slacks = true),
),
c_sys5_re;
optimizer = GLPK_optimizer,
optimizer = HiGHS_optimizer,
)
@test build!(model; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
model = DecisionModel(
get_thermal_dispatch_template_network(),
c_sys5;
optimizer = GLPK_optimizer,
optimizer = HiGHS_optimizer,
)
@test build!(model; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
Expand All @@ -35,7 +35,7 @@
get_thermal_dispatch_template_network(),
c_sys5,
my_model;
optimizer = GLPK_optimizer,
optimizer = HiGHS_optimizer,
)
@test build!(model; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
Expand All @@ -49,10 +49,10 @@ end
template,
ServiceModel(VariableReserve{ReserveUp}, RangeReserve, "test"),
)
UC = DecisionModel(template, c_sys5; optimizer = GLPK_optimizer)
UC = DecisionModel(template, c_sys5; optimizer = HiGHS_optimizer)
output_dir = mktempdir(; cleanup = true)
@test build!(UC; output_dir = output_dir) == PSI.ModelBuildStatus.BUILT
@test solve!(UC; optimizer = GLPK_optimizer) == PSI.RunStatus.SUCCESSFULLY_FINALIZED
@test solve!(UC; optimizer = HiGHS_optimizer) == PSI.RunStatus.SUCCESSFULLY_FINALIZED
res = OptimizationProblemResults(UC)
@test isapprox(get_objective_value(res), 340000.0; atol = 100000.0)
vars = res.variable_values
Expand Down Expand Up @@ -98,7 +98,7 @@ end
template,
ServiceModel(VariableReserve{ReserveUp}, RangeReserve, "test"),
)
model = DecisionModel(template, c_sys5; optimizer = GLPK_optimizer)
model = DecisionModel(template, c_sys5; optimizer = HiGHS_optimizer)
@test build!(model; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
container = PSI.get_optimization_container(model)
Expand Down Expand Up @@ -245,10 +245,10 @@ end
template,
ServiceModel(VariableReserve{ReserveUp}, RangeReserve, "test"),
)
UC = DecisionModel(template, c_sys5; optimizer = GLPK_optimizer)
UC = DecisionModel(template, c_sys5; optimizer = HiGHS_optimizer)
output_dir = mktempdir(; cleanup = true)
@test_throws ErrorException solve!(UC)
@test solve!(UC; optimizer = GLPK_optimizer, output_dir = output_dir) ==
@test solve!(UC; optimizer = HiGHS_optimizer, output_dir = output_dir) ==
PSI.RunStatus.SUCCESSFULLY_FINALIZED
end

Expand Down Expand Up @@ -357,7 +357,7 @@ end
c_sys5 = PSB.build_system(PSITestSystems, "c_sys5")
valid_bounds =
(coefficient = (min = 1.0, max = 1.0), rhs = (min = 0.4, max = 9.930296584))
model = DecisionModel(template, c_sys5; optimizer = GLPK_optimizer)
model = DecisionModel(template, c_sys5; optimizer = HiGHS_optimizer)
@test build!(model; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT

Expand Down Expand Up @@ -387,7 +387,7 @@ end
template = get_template_basic_uc_simulation()
c_sys5 = PSB.build_system(PSITestSystems, "c_sys5_uc")
valid_bounds = (min = 0.0, max = 6.0)
model = DecisionModel(template, c_sys5; optimizer = GLPK_optimizer)
model = DecisionModel(template, c_sys5; optimizer = HiGHS_optimizer)
@test build!(model; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT

Expand Down Expand Up @@ -494,7 +494,7 @@ end
template,
ServiceModel(VariableReserve{ReserveUp}, RangeReserve, "test"),
)
optimizer = GLPK_optimizer
optimizer = HiGHS_optimizer

# Construct and build with default behavior that builds initial conditions.
model = DecisionModel(template, sys; optimizer = optimizer)
Expand Down Expand Up @@ -575,7 +575,7 @@ end
UC = DecisionModel(
template,
c_sys5;
optimizer = GLPK_optimizer,
optimizer = HiGHS_optimizer,
detailed_optimizer_stats = true,
)
output_dir = mktempdir(; cleanup = true)
Expand All @@ -601,7 +601,7 @@ end
UC = DecisionModel(
template,
c_sys5;
optimizer = GLPK_optimizer,
optimizer = HiGHS_optimizer,
detailed_optimizer_stats = true,
)
output_dir = mktempdir(; cleanup = true)
Expand Down Expand Up @@ -645,7 +645,7 @@ end
UC = DecisionModel(
template,
c_sys5;
optimizer = GLPK_optimizer,
optimizer = HiGHS_optimizer,
detailed_optimizer_stats = true,
)
output_dir = mktempdir(; cleanup = true)
Expand All @@ -672,7 +672,7 @@ end
model = DecisionModel(
template,
c_sys5_bat;
optimizer = GLPK_optimizer,
optimizer = HiGHS_optimizer,
)
@test build!(model; output_dir = output_dir) == PSI.ModelBuildStatus.BUILT
@test solve!(model) == PSI.RunStatus.SUCCESSFULLY_FINALIZED
Expand Down
6 changes: 3 additions & 3 deletions test/test_model_emulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
force_build = true,
)

model = EmulationModel(template, c_sys5; optimizer = GLPK_optimizer)
model = EmulationModel(template, c_sys5; optimizer = HiGHS_optimizer)
@test build!(model; executions = 10, output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
@test run!(model) == PSI.RunStatus.SUCCESSFULLY_FINALIZED
Expand All @@ -20,7 +20,7 @@
force_build = true,
)
set_device_model!(template, RenewableDispatch, RenewableFullDispatch)
model = EmulationModel(template, c_sys5_uc_re; optimizer = GLPK_optimizer)
model = EmulationModel(template, c_sys5_uc_re; optimizer = HiGHS_optimizer)

@test build!(model; executions = 10, output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
Expand Down Expand Up @@ -315,7 +315,7 @@ end
# Deserialize with a different optimizer.
@test_logs (:warn, r"Original solver was .* new solver is") match_mode = :any EmulationModel(
path,
GLPK_optimizer,
HiGHS_optimizer,
)
end

Expand Down
8 changes: 4 additions & 4 deletions test/test_network_constructors.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Note to devs. Use GLPK or Cbc for models with linear constraints and linear cost functions
# Note to devs. Use HiGHS for models with linear constraints and linear cost functions
# Use OSQP for models with quadratic cost function and linear constraints and ipopt otherwise

@testset "All PowerModels models construction" begin
Expand Down Expand Up @@ -59,7 +59,7 @@ end
ps_model_re = DecisionModel(
template,
PSB.build_system(PSITestSystems, "c_sys5_re");
optimizer = GLPK_optimizer,
optimizer = HiGHS_optimizer,
)
@test build!(ps_model_re; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
Expand Down Expand Up @@ -121,7 +121,7 @@ end
)
end
# PTDF input Error testing
ps_model = DecisionModel(template, c_sys5; optimizer = GLPK_optimizer)
ps_model = DecisionModel(template, c_sys5; optimizer = HiGHS_optimizer)
@test build!(
ps_model;
console_level = Logging.AboveMaxLevel, # Ignore expected errors.
Expand Down Expand Up @@ -644,7 +644,7 @@ end
set_device_model!(template_uc, ThermalStandard, thermal_model)

##### Solve Reduced Model ####
solver = GLPK_optimizer
solver = HiGHS_optimizer
uc_model_red = DecisionModel(
template_uc,
new_sys;
Expand Down
4 changes: 2 additions & 2 deletions test/test_print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ end
template = get_thermal_dispatch_template_network()
c_sys5 = PSB.build_system(PSITestSystems, "c_sys5")

dm_model = DecisionModel(template, c_sys5; optimizer = GLPK_optimizer)
dm_model = DecisionModel(template, c_sys5; optimizer = HiGHS_optimizer)
@test build!(dm_model; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
@test solve!(dm_model; optimizer = GLPK_optimizer) ==
@test solve!(dm_model; optimizer = HiGHS_optimizer) ==
PSI.RunStatus.SUCCESSFULLY_FINALIZED
results = OptimizationProblemResults(dm_model)
variables = read_variables(results)
Expand Down
2 changes: 1 addition & 1 deletion test/test_recorder_events.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
force_build = true,
)
set_device_model!(template, RenewableDispatch, RenewableFullDispatch)
model = EmulationModel(template, c_sys5_uc_re; optimizer = GLPK_optimizer)
model = EmulationModel(template, c_sys5_uc_re; optimizer = HiGHS_optimizer)

@test build!(model; executions = 10, output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
Expand Down
2 changes: 1 addition & 1 deletion test/test_services_constructor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ end
)
c_sys5_uc = PSB.build_system(PSITestSystems, "c_sys5_uc"; add_reserves = true)

model = DecisionModel(template, c_sys5_uc; optimizer = cbc_optimizer)
model = DecisionModel(template, c_sys5_uc; optimizer = HiGHS_optimizer)
@test build!(model; output_dir = mktempdir(; cleanup = true)) ==
PSI.ModelBuildStatus.BUILT
moi_tests(model, 984, 0, 576, 216, 168, true)
Expand Down
2 changes: 1 addition & 1 deletion test/test_simulation_execute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ end
UnitCommitmentProblem,
template,
PSB.build_system(PSITestSystems, "c_market_bid_cost");
optimizer = cbc_optimizer,
optimizer = HiGHS_optimizer,
initialize_model = false,
),
],
Expand Down
4 changes: 2 additions & 2 deletions test/test_utils/mock_operation_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ function create_simulation_build_test_problems(
)
return SimulationModels(;
decision_models = [
DecisionModel(template_uc, sys_uc; name = "UC", optimizer = GLPK_optimizer),
DecisionModel(template_ed, sys_ed; name = "ED", optimizer = GLPK_optimizer),
DecisionModel(template_uc, sys_uc; name = "UC", optimizer = HiGHS_optimizer),
DecisionModel(template_ed, sys_ed; name = "ED", optimizer = HiGHS_optimizer),
],
)
end
Expand Down
4 changes: 0 additions & 4 deletions test/test_utils/solver_definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ fast_ipopt_optimizer = JuMP.optimizer_with_attributes(
"max_cpu_time" => 5.0,
)
# use default print_level = 5 # set to 0 to disable
GLPK_optimizer =
JuMP.optimizer_with_attributes(GLPK.Optimizer, "msg_lev" => GLPK.GLP_MSG_OFF)
scs_solver = JuMP.optimizer_with_attributes(
SCS.Optimizer,
"max_iters" => 100000,
Expand All @@ -27,5 +25,3 @@ HiGHS_optimizer = JuMP.optimizer_with_attributes(
"time_limit" => 100.0,
"log_to_console" => false,
)

cbc_optimizer = JuMP.optimizer_with_attributes(Cbc.Optimizer)

0 comments on commit 5e3e737

Please sign in to comment.