Skip to content

Commit

Permalink
fix: let linopy handle solver name
Browse files Browse the repository at this point in the history
  • Loading branch information
ollie-bell committed Nov 13, 2024
1 parent 6510759 commit b7fbaf0
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ model.solve()

By default, the model will be solved using the first available solver in the list of available
solvers. To specify a solver, pass the name of the solver as a string to the solve() method for
the argument `solver` (e.g. `model.solve(solver="highs")`).
the argument `solver` (e.g. `model.solve(solver_name="highs")`).

### Viewing the model solution

Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration/test_linopy_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_linopy_model():

model = Model.from_otoole_csv(sample_path)

model.solve(solver="highs")
model.solve(solver_name="highs")

ref_results_df = pd.read_csv(Path(results_path) / "TotalDiscountedCost.csv")

Expand Down
6 changes: 3 additions & 3 deletions tests/test_solve/test_growth_rates.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_growth_rate_floor():
technologies=technologies,
)

model.solve(solver="highs")
model.solve(solver_name="highs")

assert model.solution.NewCapacity.sel(YEAR=2022, TECHNOLOGY="generator") == 0.0606
assert model.solution.NewCapacity.sel(YEAR=2020, TECHNOLOGY="unmet-demand") == 99.0
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_growth_rate_ceil():
technologies=technologies,
)

model.solve(solver="highs")
model.solve(solver_name="highs")

assert model.solution.NewCapacity.sel(YEAR=2021, TECHNOLOGY="generator") == 15.0
assert model.solution.NewCapacity.sel(YEAR=2024, TECHNOLOGY="generator") == 20.0
Expand Down Expand Up @@ -201,7 +201,7 @@ def test_growth_rate_min():
technologies=technologies,
)

model.solve(solver="highs")
model.solve(solver_name="highs")

assert model.solution.NewCapacity.sel(YEAR=2021, TECHNOLOGY="bad-generator") == 1.0
assert model.solution.NewCapacity.sel(YEAR=2022, TECHNOLOGY="bad-generator") == 1.1
2 changes: 1 addition & 1 deletion tests/test_solve/test_min_capacity_factors.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_min_capacity_factors():
technologies=technologies,
)

model.solve(solver="highs")
model.solve(solver_name="highs")

assert (
model.solution["TotalTechnologyAnnualActivity"].sel(YEAR=2025, TECHNOLOGY="unmet-demand")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_solve/test_salvage.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_salvage_value_straight_line():
technologies=technologies,
)

model.solve(solver="highs")
model.solve(solver_name="highs")

assert np.round(model.solution.DiscountedSalvageValue.sum().values) == 1203.0

Expand Down Expand Up @@ -68,6 +68,6 @@ def test_salvage_value_sinking_fund():
technologies=technologies,
)

model.solve(solver="highs")
model.solve(solver_name="highs")

assert np.round(model.solution.DiscountedSalvageValue.sum().values) == 1349.0
6 changes: 3 additions & 3 deletions tests/test_solve/test_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_model_solve_from_otoole_csv():
path = "examples/otoole_compat/input_csv/otoole-simple-hydro"

model = Model.from_otoole_csv(path)
model.solve(solver="highs")
model.solve(solver_name="highs")

assert model._m.termination_condition == "optimal"
assert np.round(model._m.objective.value) == 5591653.0
Expand Down Expand Up @@ -182,7 +182,7 @@ def test_simple_storage():
storage=storage,
technologies=technologies,
)
model.solve(solver="highs")
model.solve(solver_name="highs")

assert model.solution.NewStorageCapacity.values[0][0][0] == 12.5
assert model.solution.NetCharge[0][1][0][0] == 75 # bat-storage 2020 Day charge
Expand Down Expand Up @@ -239,7 +239,7 @@ def test_simple_trade():
],
)

model.solve(solver="highs")
model.solve(solver_name="highs")

assert model.solution["NetTrade"].values[0][2][0] == 30
assert np.round(model._m.objective.value) == 30387.0
Expand Down
2 changes: 1 addition & 1 deletion tz/osemosys/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class Model(RunSpec):
By default, the model will be solved using the first available solver in the list of available
solvers. To specify a solver, pass the name of the solver as a string to the solve() method for
the argument `solver` (e.g. `model.solve(solver="highs")`).
the argument `solver` (e.g. `model.solve(solver_name="highs")`).
### Viewing the model solution
Expand Down

0 comments on commit b7fbaf0

Please sign in to comment.