Skip to content

Commit 32ff742

Browse files
SCIP: Don't disable presolve, fix dual value retrieval
1 parent 67e13a1 commit 32ff742

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

linopy/solvers.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,12 @@ def get_solver_solution() -> Solution:
471471

472472
sol = df[variables_b][2]
473473
dual = df[~variables_b][3]
474+
475+
# import ipdb
476+
# ipdb.set_trace()
477+
# TODO the problem is that this sol file has both rows and columns in it, and uses original names
478+
# linopy requires highs for MPS files anyway, so we can use highs for MPS to tell which ones are vars
479+
474480
return Solution(sol, dual, objective)
475481

476482
solution = self.safe_get_solution(status=status, func=get_solver_solution)
@@ -1341,9 +1347,6 @@ def solve_problem_from_file(
13411347
if warmstart_fn:
13421348
logger.warning("Warmstart not implemented for SCIP")
13431349

1344-
# In order to retrieve the dual values, we need to turn off presolve
1345-
m.setPresolve(scip.SCIP_PARAMSETTING.OFF)
1346-
13471350
m.optimize()
13481351

13491352
if basis_fn:
@@ -1369,14 +1372,11 @@ def get_solver_solution() -> Solution:
13691372
["quadobjvar", "qmatrixvar"], errors="ignore", inplace=True, axis=0
13701373
)
13711374

1372-
cons = m.getConss()
1375+
cons = m.getConss(False)
13731376
if len(cons) != 0:
13741377
dual = pd.Series({c.name: m.getDualSolVal(c) for c in cons})
1375-
dual = dual[
1376-
dual.index.str.startswith("c") & ~dual.index.str.startswith("cf")
1377-
]
13781378
else:
1379-
logger.warning("Dual values of MILP couldn't be parsed")
1379+
logger.warning("Dual values not available (is this an MILP?)")
13801380
dual = pd.Series(dtype=float)
13811381

13821382
return Solution(sol, dual, objective)

0 commit comments

Comments
 (0)