Skip to content

Commit 5e96a9e

Browse files
Merge branch 'master' into master
2 parents e299a40 + 9aa8c8f commit 5e96a9e

File tree

5 files changed

+40
-9
lines changed

5 files changed

+40
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
## Unreleased
44
### Added
5-
- Added recipe for getting local constraints
65
- More support for AND-Constraints
76
- Added support for knapsack constraints
87
- Added isPositive(), isNegative(), isFeasLE(), isFeasLT(), isFeasGE(), isFeasGT(), isHugeValue(), and tests
@@ -12,7 +11,9 @@
1211
- Wrapped SCIPgetNLPBranchCands
1312
- Added getConsVals() to get coefficients of any linear type constraint
1413
- Generalized getLhs() and getRhs() to additionally support any linear type constraint
15-
- Added getVarPseudocostScore and getVarPseudocost
14+
- Added recipe for getting local constraints
15+
- Added enableDebugSol() and disableDebugSol() for controlling the debug solution mechanism if DEBUGSOL=true
16+
- Added getVarPseudocostScore() and getVarPseudocost()
1617
### Fixed
1718
- Raised an error when an expression is used when a variable is required
1819
- Fixed some compile warnings

docs/build.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ Build with Debug
168168
To use debug information in PySCIPOpt you need to build it with the following command:
169169

170170
.. code-block::
171-
172-
python -m pip install --install-option="--debug" .
171+
172+
export CFLAGS="-UNDEBUG"
173+
export CXXFLAGS="-UNDEBUG"
174+
python -m pip install .
173175
174176
.. note:: Be aware that you will need the debug library of the SCIP Optimization Suite for this to work
175177
(cmake .. -DCMAKE_BUILD_TYPE=Debug).

src/pyscipopt/recipes/getLocalConss.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from pyscipopt import Model, Constraint
2+
from typing import List
23

3-
def getLocalConss(model: Model, node = None) -> list[list[Constraint]]:
4+
def getLocalConss(model: Model, node = None) -> List[List[Constraint]]:
45
"""
56
Returns local constraints.
67
@@ -30,7 +31,7 @@ def getLocalConss(model: Model, node = None) -> list[list[Constraint]]:
3031

3132
return [model.getConss(), added_conss]
3233

33-
def getNLocalConss(model: Model, node = None) -> tuple[int,int]:
34+
def getNLocalConss(model: Model, node = None) -> List[int]:
3435
"""
3536
Returns the number of local constraints of a node.
3637

src/pyscipopt/scip.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,8 @@ cdef extern from "scip/scip.h":
918918
SCIP_Real SCIPgetSolTime(SCIP* scip, SCIP_SOL* sol)
919919

920920
SCIP_RETCODE SCIPsetRelaxSolVal(SCIP* scip, SCIP_RELAX* relax, SCIP_VAR* var, SCIP_Real val)
921+
void SCIPenableDebugSol(SCIP* scip)
922+
void SCIPdisableDebugSol(SCIP* scip)
921923

922924
# Row Methods
923925
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: 28 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+
#ifdef WITH_DEBUG_SOLUTION
62+
#define PYSCIPOPT_WITH_DEBUG_SOLUTION 1
63+
#else
64+
#define PYSCIPOPT_WITH_DEBUG_SOLUTION 0
65+
#endif
66+
"""
67+
bint PYSCIPOPT_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
@@ -7790,6 +7797,24 @@ cdef class Model:
77907797
"""
77917798
PY_SCIP_CALL(SCIPsetRelaxSolVal(self._scip, NULL, var.scip_var, val))
77927799

7800+
def enableDebugSol(self):
7801+
"""
7802+
Enables the debug solution mechanism, which allows tracing back the invalidation of
7803+
a debug solution during the solution process of SCIP. It must be explicitly
7804+
enabled for the SCIP data structure.
7805+
"""
7806+
if not PYSCIPOPT_WITH_DEBUG_SOLUTION:
7807+
raise RuntimeError("SCIP must be built with `DEBUGSOL=true` to enable the debug solution mechanism.")
7808+
SCIPenableDebugSol(self._scip)
7809+
7810+
def disableDebugSol(self):
7811+
"""
7812+
Disables the debug solution mechanism.
7813+
"""
7814+
if not PYSCIPOPT_WITH_DEBUG_SOLUTION:
7815+
raise RuntimeError("SCIP must be built with `DEBUGSOL=true` to disable the debug solution mechanism.")
7816+
SCIPdisableDebugSol(self._scip)
7817+
77937818
def getConss(self, transformed=True):
77947819
"""
77957820
Retrieve all constraints.

0 commit comments

Comments
 (0)