Skip to content

Fixes potentially outdated value of getVal #993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
raise Exception('SCIP: unspecified error!')
elif rc == SCIP_NOMEMORY:
raise MemoryError('SCIP: insufficient memory error!')
elif rc == SCIP_READERROR:

Check failure on line 304 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / test-coverage (3.11)

SCIP: unspecified error!
raise IOError('SCIP: read error!')
elif rc == SCIP_WRITEERROR:
raise IOError('SCIP: write error!')
Expand Down Expand Up @@ -1000,8 +1000,8 @@
"""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
Expand All @@ -1025,7 +1025,7 @@
"""
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
Expand Down Expand Up @@ -9628,6 +9628,9 @@
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):
Expand Down