Skip to content

Commit 51f474e

Browse files
committed
perf: only write solution file if requested or needed
1 parent 46f846e commit 51f474e

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

linopy/model.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,17 @@ def solve(
11901190
if problem_fn is None:
11911191
problem_fn = self.get_problem_file(io_api=io_api)
11921192
if solution_fn is None:
1193-
solution_fn = self.get_solution_file()
1193+
if (
1194+
solver_name
1195+
in ["xpress", "gurobi", "highs", "mosek", "scip", "copt", "mindopt"]
1196+
and not keep_files
1197+
):
1198+
# these (solver, keep_files=False) combos do not need a solution file
1199+
solution_fn = None
1200+
else:
1201+
solution_fn = self.get_solution_file(
1202+
solver_name=solver_name, keep_files=keep_files
1203+
)
11941204

11951205
if sanitize_zeros:
11961206
self.constraints.sanitize_zeros()

0 commit comments

Comments
 (0)