Skip to content

Commit

Permalink
Add support for reusing Gurobi environment in multistage models (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
NLaws authored Nov 5, 2024
1 parent 06e1a34 commit 654e49d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Fusion plant optional features for thermal plants (#743).
- Support for reusing the same Gurobi environment for multiple solves when
number of concurrent Gurobi uses is limited (#783).

### Changed
- The `charge.csv` and `storage.csv` files now include only resources with
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GenX"
uuid = "5d317b1e-30ec-4ed6-a8ce-8d2d88d7cfac"
authors = ["Bonaldo, Luca", "Chakrabarti, Sambuddha", "Cheng, Fangwei", "Ding, Yifu", "Jenkins, Jesse D.", "Luo, Qian", "Macdonald, Ruaridh", "Mallapragada, Dharik", "Manocha, Aneesha", "Mantegna, Gabe ", "Morris, Jack", "Patankar, Neha", "Pecci, Filippo", "Schwartz, Aaron", "Schwartz, Jacob", "Schivley, Greg", "Sepulveda, Nestor", "Xu, Qingyu", "Zhou, Justin"]
version = "0.4.1-dev.8"
version = "0.4.1-dev.9"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Expand Down
1 change: 1 addition & 0 deletions docs/src/User_Guide/model_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ The following tables summarize the model settings parameters and their default/p

|**Parameter** | **Description**|
| :------------ | :-----------|
|Solver | OPTIONAL name of solver. Default is "HiGHS" effectively. It is necessary to set `Solver: "Gurobi"` when [reusing the same gurobi environment for multiple solves](https://github.com/jump-dev/Gurobi.jl?tab=readme-ov-file#reusing-the-same-gurobi-environment-for-multiple-solves).
|EnableJuMPStringNames | Flag to enable/disable JuMP string names to improve the performance.|
||1 = enable JuMP string names.|
||0 = disable JuMP string names.|
Expand Down
6 changes: 4 additions & 2 deletions src/case_runners/case_runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ function run_genx_case_simple!(case::AbstractString, mysetup::Dict, optimizer::A

### Configure solver
println("Configuring Solver")
OPTIMIZER = configure_solver(settings_path, optimizer)
solver_name = lowercase(get(mysetup, "Solver", ""))
OPTIMIZER = configure_solver(settings_path, optimizer; solver_name=solver_name)

#### Running a case

Expand Down Expand Up @@ -137,7 +138,8 @@ function run_genx_case_multistage!(case::AbstractString, mysetup::Dict, optimize

### Configure solver
println("Configuring Solver")
OPTIMIZER = configure_solver(settings_path, optimizer)
solver_name = lowercase(get(mysetup, "Solver", ""))
OPTIMIZER = configure_solver(settings_path, optimizer; solver_name=solver_name)

model_dict = Dict()
inputs_dict = Dict()
Expand Down
6 changes: 4 additions & 2 deletions src/configure_solver/configure_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ Currently supported solvers include: "Gurobi", "CPLEX", "Clp", "Cbc", or "SCIP"
# Returns
- `optimizer::MathOptInterface.OptimizerWithAttributes`: the configured optimizer instance.
"""
function configure_solver(solver_settings_path::String, optimizer::Any)
solver_name = infer_solver(optimizer)
function configure_solver(solver_settings_path::String, optimizer::Any; solver_name::String="")
if isempty(solver_name)
solver_name = infer_solver(optimizer)
end
path = joinpath(solver_settings_path, solver_name * "_settings.yml")

configure_functions = Dict("highs" => configure_highs,
Expand Down

0 comments on commit 654e49d

Please sign in to comment.