Skip to content

Commit 7410cd3

Browse files
committed
Add disableDebugSol and check
1 parent 6bea3e0 commit 7410cd3

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Unreleased
44
### Added
5-
- Added enableDebugSol
5+
- Added enableDebugSol, disableDebugSol, and check for WITH_DEBUG_SOLUTION flag
66
- More support for AND-Constraints
77
- Added support for knapsack constraints
88
- Added isPositive(), isNegative(), isFeasLE(), isFeasLT(), isFeasGE(), isFeasGT(), isHugeValue(), and tests

src/pyscipopt/scip.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@ cdef extern from "scip/scip.h":
925925

926926
SCIP_RETCODE SCIPsetRelaxSolVal(SCIP* scip, SCIP_RELAX* relax, SCIP_VAR* var, SCIP_Real val)
927927
void SCIPenableDebugSol(SCIP* scip)
928+
void SCIPdisableDebugSol(SCIP* scip)
928929

929930
# Row Methods
930931
SCIP_RETCODE SCIPcreateRow(SCIP* scip, SCIP_ROW** row, const char* name, int len, SCIP_COL** cols, SCIP_Real* vals,

src/pyscipopt/scip.pxi

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ else:
5656
_SCIP_BOUNDTYPE_TO_STRING = {SCIP_BOUNDTYPE_UPPER: '<=',
5757
SCIP_BOUNDTYPE_LOWER: '>='}
5858

59+
cdef extern from "scip/config.h":
60+
"""
61+
#ifndef WITH_DEBUG_SOLUTION
62+
#define WITH_DEBUG_SOLUTION 0
63+
#endif
64+
"""
65+
bint WITH_DEBUG_SOLUTION
66+
67+
cdef bint with_debug_solution = WITH_DEBUG_SOLUTION
68+
5969
# Mapping the SCIP_RESULT enum to a python class
6070
# This is required to return SCIP_RESULT in the python code
6171
# In __init__.py this is imported as SCIP_RESULT to keep the
@@ -141,7 +151,6 @@ cdef class PY_SCIP_STATUS:
141151
INFORUNBD = SCIP_STATUS_INFORUNBD
142152

143153
StageNames = {}
144-
145154
cdef class PY_SCIP_STAGE:
146155
INIT = SCIP_STAGE_INIT
147156
PROBLEM = SCIP_STAGE_PROBLEM
@@ -171,7 +180,6 @@ cdef class PY_SCIP_NODETYPE:
171180
SUBROOT = SCIP_NODETYPE_SUBROOT
172181
REFOCUSNODE = SCIP_NODETYPE_REFOCUSNODE
173182

174-
175183
cdef class PY_SCIP_PROPTIMING:
176184
BEFORELP = SCIP_PROPTIMING_BEFORELP
177185
DURINGLPLOOP = SCIP_PROPTIMING_DURINGLPLOOP
@@ -198,7 +206,6 @@ cdef class PY_SCIP_HEURTIMING:
198206
AFTERPROPLOOP = SCIP_HEURTIMING_AFTERPROPLOOP
199207

200208
EventNames = {}
201-
202209
cdef class PY_SCIP_EVENTTYPE:
203210
DISABLED = SCIP_EVENTTYPE_DISABLED
204211
VARADDED = SCIP_EVENTTYPE_VARADDED
@@ -7501,7 +7508,17 @@ cdef class Model:
75017508
a debug solution during the solution process of SCIP. It must be explicitly
75027509
enabled for the SCIP data structure.
75037510
"""
7511+
if not with_debug_solution:
7512+
raise RuntimeError("SCIP was not built with the WITH_DEBUG_SOLUTION flag. Please rebuild SCIP with this flag enabled.")
75047513
SCIPenableDebugSol(self._scip)
7514+
7515+
def disableDebugSol(self):
7516+
"""
7517+
Disables the debug solution mechanism.
7518+
"""
7519+
if not with_debug_solution:
7520+
raise RuntimeError("SCIP was not built with the WITH_DEBUG_SOLUTION flag. Please rebuild SCIP with this flag enabled.")
7521+
SCIPdisableDebugSol(self._scip)
75057522

75067523
def getConss(self, transformed=True):
75077524
"""

0 commit comments

Comments
 (0)