Skip to content

Adding stage checks #1051

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
17 changes: 16 additions & 1 deletion src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
if rc == SCIP_OKAY:
pass
elif rc == SCIP_ERROR:
raise Exception('SCIP: unspecified error!')

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

View workflow job for this annotation

GitHub Actions / test-coverage (3.11)

SCIP: unspecified error!
elif rc == SCIP_NOMEMORY:
raise MemoryError('SCIP: insufficient memory error!')
elif rc == SCIP_READERROR:
Expand Down Expand Up @@ -1834,7 +1834,7 @@
int
"""
return SCIPvarGetNBranchingsCurrentRun(self.scip_var, branchdir)

class MatrixVariable(MatrixExpr):

def vtype(self):
Expand Down Expand Up @@ -4737,6 +4737,11 @@
list of Column

"""
stage_check = SCIPgetStage(self._scip) in [SCIP_STAGE_SOLVING]

if not stage_check:
raise Warning("Method cannot be called in stage ", self.getStage())

cdef SCIP_COL** cols
cdef int ncols
cdef int i
Expand Down Expand Up @@ -9738,6 +9743,11 @@

def restartSolve(self):
"""Restarts the solving process as soon as possible."""
stage_check = SCIPgetStage(self._scip) in [SCIP_STAGE_INITPRESOLVE, SCIP_STAGE_PRESOLVING, SCIP_STAGE_EXITPRESOLVE, SCIP_STAGE_SOLVING]

if not stage_check:
raise Warning("Method cannot be called in stage ", self.getStage())

PY_SCIP_CALL(SCIPrestartSolve(self._scip))

# Solution functions
Expand Down Expand Up @@ -10109,6 +10119,11 @@
whether given solution was feasible and good enough to keep

"""
stage_check = SCIPgetStage(self._scip) in [SCIP_STAGE_TRANSFORMED, SCIP_STAGE_INITPRESOLVE, SCIP_STAGE_PRESOLVING, SCIP_STAGE_EXITPRESOLVE, SCIP_STAGE_PRESOLVED, SCIP_STAGE_SOLVING]

if not stage_check:
raise Warning("Method cannot be called in stage ", self.getStage())

cdef SCIP_Bool stored
if free:
PY_SCIP_CALL(SCIPtrySolFree(self._scip, &solution.sol, printreason, completely, checkbounds, checkintegrality, checklprows, &stored))
Expand Down