From 3279d11813856488f1edb91b65b44f6325f17887 Mon Sep 17 00:00:00 2001 From: qheuristics Date: Fri, 26 Dec 2025 23:21:05 +0100 Subject: [PATCH] fix: correct regex to capture negative objective values when using CBC Currently returns np.nan if objective function value solved by CBC is negative --- linopy/solvers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linopy/solvers.py b/linopy/solvers.py index 2783e7b8..75ba14ae 100644 --- a/linopy/solvers.py +++ b/linopy/solvers.py @@ -482,7 +482,7 @@ def solve_problem_from_file( variables = {v.name for v in h.getVariables()} def get_solver_solution() -> Solution: - m = re.match(r"Optimal.* - objective value (\d+\.?\d*)$", first_line) + m = re.match(r"Optimal.* - objective value (-?\d+\.?\d*)$", first_line) if m and len(m.groups()) == 1: objective = float(m.group(1)) else: