From 4e211460fc3a0821f6602db59c7b81d85cfccda2 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Wed, 14 May 2025 11:58:53 +0200 Subject: [PATCH 1/2] Fixes potentially outdated value of getVal --- src/pyscipopt/scip.pxi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pyscipopt/scip.pxi b/src/pyscipopt/scip.pxi index 970e6f039..759f94a51 100644 --- a/src/pyscipopt/scip.pxi +++ b/src/pyscipopt/scip.pxi @@ -9628,6 +9628,9 @@ cdef class Model: if not stage_check or self._bestSol.sol == NULL and SCIPgetStage(self._scip) != SCIP_STAGE_SOLVING: raise Warning("Method cannot be called in stage ", self.getStage()) + # update best sol + self.getBestSol() + if isinstance(expr, MatrixExpr): result = np.empty(expr.shape, dtype=float) for idx in np.ndindex(result.shape): From 4f4817b4bad11bd95c01c2b0b548e767608c4c0f Mon Sep 17 00:00:00 2001 From: Joao-Dionisio Date: Tue, 17 Jun 2025 18:00:15 +0100 Subject: [PATCH 2/2] Fix funny error --- src/pyscipopt/scip.pxi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pyscipopt/scip.pxi b/src/pyscipopt/scip.pxi index 759f94a51..c1d123284 100644 --- a/src/pyscipopt/scip.pxi +++ b/src/pyscipopt/scip.pxi @@ -1000,8 +1000,8 @@ cdef class Solution: """Base class holding a pointer to corresponding SCIP_SOL.""" # We are raising an error here to avoid creating a solution without an associated model. See Issue #625 - def __init__(self, raise_error = False): - if not raise_error: + def __init__(self, raise_error = True): + if raise_error: raise ValueError("To create a solution you should use the createSol method of the Model class.") @staticmethod @@ -1025,7 +1025,7 @@ cdef class Solution: """ if scip == NULL: raise Warning("cannot create Solution with SCIP* == NULL") - sol = Solution(True) + sol = Solution(raise_error=False) sol.sol = scip_sol sol.scip = scip return sol