Skip to content

Commit be3022e

Browse files
committed
Start of support for exact scip
1 parent ae60d7e commit be3022e

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

src/pyscipopt/scip.pxd

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,18 @@ cdef extern from "scip/scip.h":
384384

385385
ctypedef struct SCIP_ROW:
386386
pass
387+
388+
ctypedef struct SCIP_ROW_EXACT:
389+
pass
387390

388391
ctypedef struct SCIP_NLROW:
389392
pass
390393

391394
ctypedef struct SCIP_COL:
392395
pass
396+
397+
ctypedef struct SCIP_COL_EXACT:
398+
pass
393399

394400
ctypedef struct SCIP_SOL:
395401
pass
@@ -1397,6 +1403,30 @@ cdef extern from "scip/scip.h":
13971403
SCIP_Bool SCIPisIntegral(SCIP* scip, SCIP_Real val)
13981404
SCIP_Real SCIPgetTreesizeEstimation(SCIP* scip)
13991405

1406+
# Exact SCIP methods
1407+
SCIP_RETCODE SCIPenableExactSolving(SCIP* scip, SCIP_Bool enable);
1408+
SCIP_Bool SCIPisExact(SCIP* scip);
1409+
SCIP_Bool SCIPallowNegSlack(SCIP* scip);
1410+
SCIP_RETCODE SCIPbranchLPExact(SCIP* scip, SCIP_RESULT* result);
1411+
SCIP_RETCODE SCIPaddRowExact(SCIP* scip, SCIP_ROWEXACT* rowexact);
1412+
1413+
# Exact LP SCIP methods
1414+
SCIP_VAR* SCIPcolExactGetVar(SCIP_COLEXACT* col);
1415+
SCIP_RATIONAL* SCIProwExactGetLhs(SCIP_ROWEXACT* row);
1416+
SCIP_RATIONAL* SCIProwExactGetRhs(SCIP_ROWEXACT* row);
1417+
SCIP_RATIONAL* SCIProwExactGetConstant(SCIP_ROWEXACT* row);
1418+
int SCIProwExactGetNNonz(SCIP_ROWEXACT* row);
1419+
SCIP_RATIONAL** SCIProwExactGetVals(SCIP_ROWEXACT* row);
1420+
SCIP_Bool SCIProwExactIsInLP(SCIP_ROWEXACT* row);
1421+
void SCIProwExactSort(SCIP_ROWEXACT* row);
1422+
SCIP_COLEXACT** SCIProwExactGetCols(SCIP_ROWEXACT* row);
1423+
void SCIProwExactLock(SCIP_ROWEXACT* row);
1424+
void SCIProwExactUnlock(SCIP_ROWEXACT* row);
1425+
SCIP_ROW* SCIProwExactGetRow(SCIP_ROWEXACT* row);
1426+
SCIP_ROW* SCIProwExactGetRowRhs(SCIP_ROWEXACT* row);
1427+
SCIP_Bool SCIProwExactHasFpRelax(SCIP_ROWEXACT* row);
1428+
SCIP_Bool SCIPlpExactDiving(SCIP_LPEXACT* lpexact);
1429+
14001430
# Statistic Methods
14011431
SCIP_RETCODE SCIPprintStatistics(SCIP* scip, FILE* outfile)
14021432
SCIP_RETCODE SCIPprintStatisticsJson(SCIP* scip, FILE* file)
@@ -2053,6 +2083,14 @@ cdef class Column:
20532083
@staticmethod
20542084
cdef create(SCIP_COL* scipcol)
20552085

2086+
cdef class Column:
2087+
cdef SCIP_COLEXACT* scip_col_exact
2088+
# can be used to store problem data
2089+
cdef public object data
2090+
2091+
@staticmethod
2092+
cdef create(SCIP_COLEXACT* scipcol_exact)
2093+
20562094
cdef class Row:
20572095
cdef SCIP_ROW* scip_row
20582096
# can be used to store problem data
@@ -2061,6 +2099,14 @@ cdef class Row:
20612099
@staticmethod
20622100
cdef create(SCIP_ROW* sciprow)
20632101

2102+
cdef class RowExact:
2103+
cdef SCIP_ROWEXACT* scip_row_exact
2104+
# can be used to store problem data
2105+
cdef public object data
2106+
2107+
@staticmethod
2108+
cdef create(SCIP_ROWEXACT* sciprow_exact)
2109+
20642110
cdef class NLRow:
20652111
cdef SCIP_NLROW* scip_nlrow
20662112
# can be used to store problem data

src/pyscipopt/scip.pxi

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11008,6 +11008,64 @@ cdef class Model:
1100811008
return SCIPgetTreesizeEstimation(self._scip)
1100911009

1101011010

11011+
# Exact SCIP methods
11012+
def enableExactSolving(self, SCIP_Bool enable):
11013+
"""
11014+
Enables or disables exact solving mode in SCIP.
11015+
11016+
Parameters
11017+
----------
11018+
enable : SCIP_Bool
11019+
Whether to enable exact solving mode (True) or disable it (False).
11020+
"""
11021+
11022+
PY_SCIP_CALL(SCIPenableExactSolving(self._scip, enable))
11023+
11024+
def isExact(self):
11025+
"""
11026+
Returns whether exact solving mode is enabled in SCIP.
11027+
11028+
Returns
11029+
-------
11030+
bool
11031+
"""
11032+
11033+
return SCIPisExact(self._scip)
11034+
11035+
def allowNegSlack(self):
11036+
"""
11037+
Returns whether negative slack is allowed in exact solving mode.
11038+
11039+
Returns
11040+
-------
11041+
bool
11042+
"""
11043+
11044+
return SCIPallowNegSlack(self._scip)
11045+
11046+
def branchLPExact(self):
11047+
"""
11048+
Performs exact LP branching.
11049+
11050+
Returns
11051+
-------
11052+
SCIP_RESULT
11053+
"""
11054+
cdef SCIP_RESULT result
11055+
PY_SCIP_CALL(SCIPbranchLPExact(self._scip, &result))
11056+
return result
11057+
11058+
def addRowExact(self, rowexact):
11059+
"""
11060+
Adds an exact row to the LP.
11061+
11062+
Parameters
11063+
----------
11064+
rowexact : RowExact
11065+
The exact row to add.
11066+
"""
11067+
PY_SCIP_CALL(SCIPaddRowExact(self._scip, rowexact.scip_row_exact))
11068+
1101111069
def getBipartiteGraphRepresentation(self, prev_col_features=None, prev_edge_features=None, prev_row_features=None,
1101211070
static_only=False, suppress_warnings=False):
1101311071
"""

0 commit comments

Comments
 (0)