Skip to content

Commit bbca627

Browse files
fix: use HiGHS to parse CBC sol correctly (#442)
* fix: use HiGHS to parse CBC sol correctly * Update release notes --------- Co-authored-by: Fabian Hofmann <fab.hof@gmx.de>
1 parent 07c9d13 commit bbca627

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

doc/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Upcoming Version
66

77
**Bug Fixes**
88

9+
* Fix the parsing of solutions returned by the CBC solver when solving from a file to not
10+
assume that variables start with `x`.
911
* Fix the retrieval of solutions from the SCIP solver, and do not turn off presolve.
1012

1113
Version 0.5.2

linopy/solvers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,11 @@ def solve_problem_from_file(
453453
status = Status(SolverStatus.warning, TerminationCondition.unknown)
454454
status.legacy_status = data
455455

456+
# Use HiGHS to parse the problem file and find the set of variable names, needed to parse solution
457+
h = highspy.Highs()
458+
h.readModel(path_to_string(problem_fn))
459+
variables = {v.name for v in h.getVariables()}
460+
456461
def get_solver_solution() -> Solution:
457462
objective = float(data[len("Optimal - objective value ") :])
458463

@@ -467,7 +472,7 @@ def get_solver_solution() -> Solution:
467472
usecols=[1, 2, 3],
468473
index_col=0,
469474
)
470-
variables_b = df.index.str[0] == "x"
475+
variables_b = df.index.isin(variables)
471476

472477
sol = df[variables_b][2]
473478
dual = df[~variables_b][3]

0 commit comments

Comments
 (0)