Skip to content

Commit 605aea2

Browse files
committed
Raise clear error when freeReoptSolve is called without reoptimization enabled (#624)
1 parent e3b2892 commit 605aea2

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/pyscipopt/scip.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,7 @@ cdef extern from "scip/scip.h":
15501550
SCIP_RETCODE SCIPfreeReoptSolve(SCIP* scip)
15511551
SCIP_RETCODE SCIPchgReoptObjective(SCIP* scip, SCIP_OBJSENSE objsense, SCIP_VAR** vars, SCIP_Real* coefs, int nvars)
15521552
SCIP_RETCODE SCIPenableReoptimization(SCIP* scip, SCIP_Bool enable)
1553+
SCIP_Bool SCIPisReoptEnabled(SCIP* scip)
15531554

15541555
BMS_BLKMEM* SCIPblkmem(SCIP* scip)
15551556

src/pyscipopt/scip.pxi

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3973,6 +3973,17 @@ cdef class Model:
39733973
"""
39743974
PY_SCIP_CALL(SCIPenableReoptimization(self._scip, enable))
39753975

3976+
def isReoptEnabled(self):
3977+
"""
3978+
Returns whether reoptimization is enabled.
3979+
3980+
Returns
3981+
-------
3982+
bool
3983+
3984+
"""
3985+
return SCIPisReoptEnabled(self._scip)
3986+
39763987
def lpiGetIterations(self):
39773988
"""
39783989
Get the iteration count of the last solved LP.
@@ -11950,6 +11961,10 @@ cdef class Model:
1195011961
def freeReoptSolve(self):
1195111962
"""Frees all solution process data and prepares for reoptimization."""
1195211963

11964+
if not SCIPisReoptEnabled(self._scip):
11965+
raise ValueError("freeReoptSolve requires reoptimization to be enabled. "
11966+
"Call enableReoptimization() before solving.")
11967+
1195311968
if self.getStage() not in [SCIP_STAGE_INIT,
1195411969
SCIP_STAGE_PROBLEM,
1195511970
SCIP_STAGE_TRANSFORMED,

src/pyscipopt/scip.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,7 @@ class Model:
14541454
def isObjChangedProbing(self) -> Incomplete: ...
14551455
def isObjIntegral(self) -> Incomplete: ...
14561456
def isPositive(self, val: Incomplete) -> Incomplete: ...
1457+
def isReoptEnabled(self) -> bool: ...
14571458
def isZero(self, value: Incomplete) -> Incomplete: ...
14581459
def lpiGetIterations(self) -> Incomplete: ...
14591460
def markDoNotAggrVar(self, var: Incomplete) -> Incomplete: ...

0 commit comments

Comments
 (0)