Skip to content

Commit b805bf5

Browse files
committed
refactor: adds no_solution_file_solvers constant
1 parent 42369b3 commit b805bf5

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

linopy/model.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@
5959
from linopy.matrices import MatrixAccessor
6060
from linopy.objective import Objective
6161
from linopy.remote import OetcHandler, RemoteHandler
62-
from linopy.solvers import IO_APIS, available_solvers, quadratic_solvers
62+
from linopy.solvers import (
63+
IO_APIS,
64+
NO_SOLUTION_FILE_SOLVERS,
65+
available_solvers,
66+
quadratic_solvers,
67+
)
6368
from linopy.types import (
6469
ConstantLike,
6570
ConstraintLike,
@@ -1190,11 +1195,7 @@ def solve(
11901195
if problem_fn is None:
11911196
problem_fn = self.get_problem_file(io_api=io_api)
11921197
if solution_fn is None:
1193-
if (
1194-
solver_name
1195-
in ["xpress", "gurobi", "highs", "mosek", "scip", "copt", "mindopt"]
1196-
and not keep_files
1197-
):
1198+
if solver_name in NO_SOLUTION_FILE_SOLVERS and not keep_files:
11981199
# these (solver, keep_files=False) combos do not need a solution file
11991200
solution_fn = None
12001201
else:

linopy/solvers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@
5050
"mindopt",
5151
]
5252

53+
# Solvers that don't need a solution file when keep_files=False
54+
NO_SOLUTION_FILE_SOLVERS = [
55+
"xpress",
56+
"gurobi",
57+
"highs",
58+
"mosek",
59+
"scip",
60+
"copt",
61+
"mindopt",
62+
]
63+
5364
FILE_IO_APIS = ["lp", "lp-polars", "mps"]
5465
IO_APIS = FILE_IO_APIS + ["direct"]
5566

0 commit comments

Comments
 (0)