File tree Expand file tree Collapse file tree 4 files changed +24
-1
lines changed Expand file tree Collapse file tree 4 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44### Added
5+ - Added getLinearConsIndicator
56### Fixed
67### Changed
78### Removed
Original file line number Diff line number Diff line change @@ -1828,6 +1828,7 @@ cdef extern from "scip/cons_indicator.h":
18281828 SCIP_Real val)
18291829
18301830 SCIP_VAR* SCIPgetSlackVarIndicator(SCIP_CONS* cons)
1831+ SCIP_CONS* SCIPgetLinearConsIndicator(SCIP_CONS* cons)
18311832
18321833cdef extern from " scip/misc.h" :
18331834 SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP** hashmap, BMS_BLKMEM* blkmem, int mapsize)
Original file line number Diff line number Diff line change @@ -6229,6 +6229,25 @@ cdef class Model:
62296229 PY_SCIP_CALL(SCIPreleaseCons(self ._scip, & scip_cons))
62306230
62316231 return pyCons
6232+
6233+ def getLinearConsIndicator (self , Constraint cons ):
6234+ """
6235+ Get the linear constraint corresponding to the indicator constraint.
6236+
6237+ Parameters
6238+ ----------
6239+ cons : Constraint
6240+ The indicator constraint
6241+
6242+ Returns
6243+ -------
6244+ Constraint or None
6245+ """
6246+
6247+ cdef SCIP_CONS* lincons = SCIPgetLinearConsIndicator(cons.scip_cons)
6248+ if lincons == NULL :
6249+ return None
6250+ return Constraint.create(lincons)
62326251
62336252 def getSlackVarIndicator (self , Constraint cons ):
62346253 """
@@ -6245,7 +6264,7 @@ cdef class Model:
62456264 Variable
62466265
62476266 """
6248- cdef SCIP_VAR* var = SCIPgetSlackVarIndicator(cons.scip_cons);
6267+ cdef SCIP_VAR* var = SCIPgetSlackVarIndicator(cons.scip_cons)
62496268 return Variable.create(var)
62506269
62516270 def addPyCons (self , Constraint cons ):
Original file line number Diff line number Diff line change @@ -118,6 +118,8 @@ def test_cons_indicator():
118118
119119 slack = m .getSlackVarIndicator (c1 )
120120
121+ lin_cons = m .getLinearConsIndicator (c1 )
122+
121123 m .optimize ()
122124
123125 assert m .getNConss (transformed = False ) == 5
You can’t perform that action at this time.
0 commit comments