Skip to content

Commit 32a156c

Browse files
committed
Expose SCIP_BASESTAT as a Python-level class
1 parent 34dc3b8 commit 32a156c

5 files changed

Lines changed: 21 additions & 10 deletions

File tree

src/pyscipopt/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from pyscipopt.scip import LP as LP
2929
from pyscipopt.scip import IISfinder as IISfinder
3030
from pyscipopt.scip import PY_SCIP_LPPARAM as SCIP_LPPARAM
31+
from pyscipopt.scip import PY_SCIP_BASESTAT as SCIP_BASESTAT
3132
from pyscipopt.scip import readStatistics as readStatistics
3233
from pyscipopt.scip import Expr as Expr
3334
from pyscipopt.scip import MatrixExpr as MatrixExpr

src/pyscipopt/lp.pxi

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,7 @@ cdef class LP:
534534
def getBase(self):
535535
"""Returns the basis status of columns and rows.
536536
537-
Column status values: SCIP_BASESTAT_LOWER (0), SCIP_BASESTAT_BASIC (1),
538-
SCIP_BASESTAT_UPPER (2), SCIP_BASESTAT_ZERO (3).
539-
540-
Row status values: SCIP_BASESTAT_LOWER (0), SCIP_BASESTAT_BASIC (1),
541-
SCIP_BASESTAT_UPPER (2).
537+
Status values are defined in SCIP_BASESTAT: LOWER, BASIC, UPPER, ZERO.
542538
543539
Returns
544540
-------
@@ -565,11 +561,7 @@ cdef class LP:
565561
def setBase(self, cstat, rstat):
566562
"""Sets the basis status of columns and rows.
567563
568-
Column status values: SCIP_BASESTAT_LOWER (0), SCIP_BASESTAT_BASIC (1),
569-
SCIP_BASESTAT_UPPER (2), SCIP_BASESTAT_ZERO (3).
570-
571-
Row status values: SCIP_BASESTAT_LOWER (0), SCIP_BASESTAT_BASIC (1),
572-
SCIP_BASESTAT_UPPER (2).
564+
Status values are defined in SCIP_BASESTAT: LOWER, BASIC, UPPER, ZERO.
573565
574566
Parameters
575567
----------

src/pyscipopt/scip.pxi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ cdef class PY_SCIP_LPPARAM:
118118
POLISHING = SCIP_LPPAR_POLISHING
119119
REFACTOR = SCIP_LPPAR_REFACTOR
120120

121+
cdef class PY_SCIP_BASESTAT:
122+
LOWER = SCIP_BASESTAT_LOWER
123+
BASIC = SCIP_BASESTAT_BASIC
124+
UPPER = SCIP_BASESTAT_UPPER
125+
ZERO = SCIP_BASESTAT_ZERO
126+
121127
cdef class PY_SCIP_PARAMEMPHASIS:
122128
DEFAULT = SCIP_PARAMEMPHASIS_DEFAULT
123129
CPSOLVER = SCIP_PARAMEMPHASIS_CPSOLVER

src/pyscipopt/scip.pyi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,13 @@ class PY_SCIP_LOCKTYPE:
18031803
MODEL: ClassVar[int] = ...
18041804
def __init__(self) -> None: ...
18051805

1806+
class PY_SCIP_BASESTAT:
1807+
LOWER: ClassVar[int] = ...
1808+
BASIC: ClassVar[int] = ...
1809+
UPPER: ClassVar[int] = ...
1810+
ZERO: ClassVar[int] = ...
1811+
def __init__(self) -> None: ...
1812+
18061813
class PY_SCIP_LPPARAM:
18071814
BARRIERCONVTOL: ClassVar[int] = ...
18081815
CONDITIONLIMIT: ClassVar[int] = ...

tests/test_lp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from pyscipopt import LP
22
from pyscipopt import SCIP_LPPARAM
3+
from pyscipopt import SCIP_BASESTAT
34

45
def test_lp():
56
# create LP instance, minimizing by default
@@ -97,6 +98,10 @@ def test_lp():
9798
cstat, rstat = myLP.getBase()
9899
assert len(cstat) == myLP.ncols()
99100
assert len(rstat) == myLP.nrows()
101+
assert all(s in (SCIP_BASESTAT.LOWER, SCIP_BASESTAT.BASIC,
102+
SCIP_BASESTAT.UPPER, SCIP_BASESTAT.ZERO) for s in cstat)
103+
assert all(s in (SCIP_BASESTAT.LOWER, SCIP_BASESTAT.BASIC,
104+
SCIP_BASESTAT.UPPER) for s in rstat)
100105

101106
# set the same basis back and re-solve
102107
myLP.setBase(cstat, rstat)

0 commit comments

Comments
 (0)