Skip to content

Commit 91f8e09

Browse files
committed
solvers: silence version output of highs
1 parent f9e3a5e commit 91f8e09

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

linopy/solvers.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ def solve_problem_from_file(
460460

461461
# Use HiGHS to parse the problem file and find the set of variable names, needed to parse solution
462462
h = highspy.Highs()
463+
h.silent()
463464
h.readModel(path_to_string(problem_fn))
464465
variables = {v.name for v in h.getVariables()}
465466

@@ -804,6 +805,14 @@ def solve_problem_from_file(
804805

805806
problem_fn_ = path_to_string(problem_fn)
806807
h = highspy.Highs()
808+
809+
if log_fn is not None:
810+
self.solver_options["log_file"] = path_to_string(log_fn)
811+
logger.info(f"Log file at {self.solver_options['log_file']}")
812+
813+
for k, v in self.solver_options.items():
814+
h.setOptionValue(k, v)
815+
807816
h.readModel(problem_fn_)
808817

809818
return self._solve(
@@ -877,13 +886,6 @@ def _solve(
877886
highspy.HighsModelStatus.kUnknown: TerminationCondition.unknown,
878887
}
879888

880-
if log_fn is not None:
881-
self.solver_options["log_file"] = path_to_string(log_fn)
882-
logger.info(f"Log file at {self.solver_options['log_file']}")
883-
884-
for k, v in self.solver_options.items():
885-
h.setOptionValue(k, v)
886-
887889
if warmstart_fn is not None and warmstart_fn.suffix == ".sol":
888890
h.readSolution(path_to_string(warmstart_fn), 0)
889891
elif warmstart_fn:

0 commit comments

Comments
 (0)