Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
### Added
- Added enableDebugSol, disableDebugSol, and check for WITH_DEBUG_SOLUTION flag
- More support for AND-Constraints
- Added support for knapsack constraints
- Added isPositive(), isNegative(), isFeasLE(), isFeasLT(), isFeasGE(), isFeasGT(), isHugeValue(), and tests
Expand Down
5 changes: 3 additions & 2 deletions docs/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ 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"
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).
Expand Down
2 changes: 2 additions & 0 deletions src/pyscipopt/scip.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,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,
Expand Down
31 changes: 28 additions & 3 deletions src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ else:
_SCIP_BOUNDTYPE_TO_STRING = {SCIP_BOUNDTYPE_UPPER: '<=',
SCIP_BOUNDTYPE_LOWER: '>='}

cdef extern from "scip/config.h":
"""
#ifndef WITH_DEBUG_SOLUTION
#define WITH_DEBUG_SOLUTION 0
#endif
"""
bint WITH_DEBUG_SOLUTION

cdef bint with_debug_solution = 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -7495,6 +7502,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 with_debug_solution:
raise RuntimeError("SCIP was not built with the WITH_DEBUG_SOLUTION flag. Please rebuild SCIP with this flag enabled.")
SCIPenableDebugSol(self._scip)

def disableDebugSol(self):
"""
Disables the debug solution mechanism.
"""
if not with_debug_solution:
raise RuntimeError("SCIP was not built with the WITH_DEBUG_SOLUTION flag. Please rebuild SCIP with this flag enabled.")
SCIPdisableDebugSol(self._scip)

def getConss(self, transformed=True):
"""
Retrieve all constraints.
Expand Down