I'm trying to write a custom separator (aka, MIP cutter) to my SCIP model (in Python). To do this I need to detect which constraints are tight/binding at the given MIP node. I thought that I could do this by comparing LHS to RHS on the rows (aka, the constraints). However, one of the two always reports +/- 1e20. Why is that? How do I iterate on the binding constraints?
class Cutter(scip.Sepa):
def sepaexeclp(self):
m: scip.Model = self.model
if not m.getLPSolstat() or not m.isLPSolBasic():
return {"result": scip.PY_SCIP_RESULT.DIDNOTRUN}
cols = m.getLPColsData()
rows = m.getLPRowsData()
values = [col.getPrimsol() for col in cols]
constraints = [row for row in rows if row.getLhs() == row.getRhs()] # always empty
...
I think there is a misunderstanding. All rows in SCIP are ranged rows, i.e., they are of the form
lhs <= a^Tx (+constant) <= rhs. When a model contains inequalities with only one side (as seems to be the case for you) then the non-existant side is set to either1e20for the rhs (SCIPs infinity value) or-1e20for the lhs.I'm assuming what you really want to do is check which constraints are tight w.r.t. the current LP at that node? In that case you should use
getRowActivity