Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Upcoming Version

**Bug fixes**

* SCIP now applies solver options before reading the problem file, so ``model.solve("scip", **{"display/verblevel": 0})`` also suppresses the initial model-loading output.
* ``Variable.get_solver_attribute`` for Gurobi now maps values by position for the direct API. It parsed labels from the solver's variable names, which returned the values of the wrong variables when names were off and a variable was masked. (`#978 <https://github.com/PyPSA/linopy/issues/978>`__)
* ``densify_terms`` no longer raises on expressions without coordinate dimensions (``expr.sum(drop_zeros=True)`` over all dimensions) and now works on ``QuadraticExpression``, where it previously indexed the ``_factor`` axis as the term axis.
* ``sum()`` over a dimension no longer raises when another dimension of the expression has size 0; it returns an expression without terms over the kept coordinates, as summing over the empty dimension itself already did. (https://github.com/PyPSA/linopy/issues/906)
Expand Down
3 changes: 2 additions & 1 deletion linopy/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2547,7 +2547,6 @@ def _run_file(
sense = read_sense_from_problem_file(problem_fn)

m = scip.Model()
m.readProblem(path_to_string(problem_fn))

if self.solver_options is not None:
emphasis = self.solver_options.pop("setEmphasis", None)
Expand All @@ -2564,6 +2563,8 @@ def _run_file(

m.setParams(self.solver_options)

m.readProblem(path_to_string(problem_fn))

if log_fn is not None:
m.setLogfile(path_to_string(log_fn))

Expand Down
13 changes: 13 additions & 0 deletions test/test_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

from pathlib import Path
from typing import Any
from unittest.mock import MagicMock

import numpy as np
Expand Down Expand Up @@ -120,6 +121,18 @@ def test_from_name_applies_solver_options(simple_model: Model) -> None:
assert time_limit == 123


@pytest.mark.skipif(
"scip" not in set(solvers.licensed_solvers), reason="SCIP is not installed"
)
def test_scip_quiet_model_solve(
simple_model: Model, capfd: pytest.CaptureFixture[str]
) -> None:
solver_options: dict[str, Any] = {"display/verblevel": 0}
status, condition = simple_model.solve("scip", **solver_options)
assert (status, condition) == ("ok", "optimal")
assert capfd.readouterr() == ("", "")


@pytest.mark.skipif(
"highs" not in set(solvers.licensed_solvers), reason="HiGHS is not installed"
)
Expand Down
Loading