diff --git a/CHANGELOG.md b/CHANGELOG.md index ce0a27178..91921a5da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,6 @@ ## Unreleased ### Added -- Added recipe for getting local constraints - More support for AND-Constraints - Added support for knapsack constraints - Added isPositive(), isNegative(), isFeasLE(), isFeasLT(), isFeasGE(), isFeasGT(), isHugeValue(), and tests @@ -12,6 +11,8 @@ - Wrapped SCIPgetNLPBranchCands - Added getConsVals() to get coefficients of any linear type constraint - Generalized getLhs() and getRhs() to additionally support any linear type constraint +- Added recipe for getting local constraints +- Added enableDebugSol() and disableDebugSol() for controlling the debug solution mechanism if DEBUGSOL=true ### Fixed - Raised an error when an expression is used when a variable is required - Fixed some compile warnings diff --git a/docs/build.rst b/docs/build.rst index 72b752cf4..01ddd32f0 100644 --- a/docs/build.rst +++ b/docs/build.rst @@ -168,8 +168,10 @@ Build with Debug To use debug information in PySCIPOpt you need to build it with the following command: .. code-block:: - - python -m pip install --install-option="--debug" . + + export CFLAGS="-UNDEBUG" + export CXXFLAGS="-UNDEBUG" + python -m pip install . .. note:: Be aware that you will need the debug library of the SCIP Optimization Suite for this to work (cmake .. -DCMAKE_BUILD_TYPE=Debug). diff --git a/src/pyscipopt/scip.pxd b/src/pyscipopt/scip.pxd index 7059a9f3c..6f2203b9d 100644 --- a/src/pyscipopt/scip.pxd +++ b/src/pyscipopt/scip.pxd @@ -917,6 +917,8 @@ cdef extern from "scip/scip.h": SCIP_Real SCIPgetSolTime(SCIP* scip, SCIP_SOL* sol) SCIP_RETCODE SCIPsetRelaxSolVal(SCIP* scip, SCIP_RELAX* relax, SCIP_VAR* var, SCIP_Real val) + void SCIPenableDebugSol(SCIP* scip) + void SCIPdisableDebugSol(SCIP* scip) # Row Methods SCIP_RETCODE SCIPcreateRow(SCIP* scip, SCIP_ROW** row, const char* name, int len, SCIP_COL** cols, SCIP_Real* vals, diff --git a/src/pyscipopt/scip.pxi b/src/pyscipopt/scip.pxi index 26abf8c29..18e6746e9 100644 --- a/src/pyscipopt/scip.pxi +++ b/src/pyscipopt/scip.pxi @@ -56,6 +56,16 @@ else: _SCIP_BOUNDTYPE_TO_STRING = {SCIP_BOUNDTYPE_UPPER: '<=', SCIP_BOUNDTYPE_LOWER: '>='} +cdef extern from "scip/config.h": + """ + #ifdef WITH_DEBUG_SOLUTION + #define PYSCIPOPT_WITH_DEBUG_SOLUTION 1 + #else + #define PYSCIPOPT_WITH_DEBUG_SOLUTION 0 + #endif + """ + bint PYSCIPOPT_WITH_DEBUG_SOLUTION + # Mapping the SCIP_RESULT enum to a python class # This is required to return SCIP_RESULT in the python code # In __init__.py this is imported as SCIP_RESULT to keep the @@ -141,7 +151,6 @@ cdef class PY_SCIP_STATUS: INFORUNBD = SCIP_STATUS_INFORUNBD StageNames = {} - cdef class PY_SCIP_STAGE: INIT = SCIP_STAGE_INIT PROBLEM = SCIP_STAGE_PROBLEM @@ -171,7 +180,6 @@ cdef class PY_SCIP_NODETYPE: SUBROOT = SCIP_NODETYPE_SUBROOT REFOCUSNODE = SCIP_NODETYPE_REFOCUSNODE - cdef class PY_SCIP_PROPTIMING: BEFORELP = SCIP_PROPTIMING_BEFORELP DURINGLPLOOP = SCIP_PROPTIMING_DURINGLPLOOP @@ -198,7 +206,6 @@ cdef class PY_SCIP_HEURTIMING: AFTERPROPLOOP = SCIP_HEURTIMING_AFTERPROPLOOP EventNames = {} - cdef class PY_SCIP_EVENTTYPE: DISABLED = SCIP_EVENTTYPE_DISABLED VARADDED = SCIP_EVENTTYPE_VARADDED @@ -7756,6 +7763,24 @@ cdef class Model: """ PY_SCIP_CALL(SCIPsetRelaxSolVal(self._scip, NULL, var.scip_var, val)) + def enableDebugSol(self): + """ + Enables the debug solution mechanism, which allows tracing back the invalidation of + a debug solution during the solution process of SCIP. It must be explicitly + enabled for the SCIP data structure. + """ + if not PYSCIPOPT_WITH_DEBUG_SOLUTION: + raise RuntimeError("SCIP must be built with `DEBUGSOL=true` to enable the debug solution mechanism.") + SCIPenableDebugSol(self._scip) + + def disableDebugSol(self): + """ + Disables the debug solution mechanism. + """ + if not PYSCIPOPT_WITH_DEBUG_SOLUTION: + raise RuntimeError("SCIP must be built with `DEBUGSOL=true` to disable the debug solution mechanism.") + SCIPdisableDebugSol(self._scip) + def getConss(self, transformed=True): """ Retrieve all constraints.