-
Notifications
You must be signed in to change notification settings - Fork 277
Closed
Description
Hi,
I would like to add some constraints locally using model.addConsNode().
(Set some variables to be zero. )
From coloring examples and documents, I learned it should be something like:
Class myConshdlr(Conshdlr):
def consprop(self, constraints, nusefulconss, nmarkedconss, proptiming):
for var in self.model.vars:
if condition is True:
self.model.chgVarUb(var, 0.0)
return {"result": SCIP_RESULT.DIDNOTFIND}
# fundamental callbacks
def consenfolp(self, constraints, nusefulconss, solinfeasible):
return {"result": SCIP_RESULT.FEASIBLE}
def conscheck(self, constraints, solution, checkintegrality, checklprows, printreason):
return {"result": SCIP_RESULT.FEASIBLE}
def conslock(self, constraint, nlockspos, nlocksneg):
return {"result": SCIP_RESULT.FEASIBLE}
con1 = model.createCons(myConshdlr, "my constraint", stickingatnode=True)
model.addConsNode(node, con1)
- Is using constraint handler the only way to create constraints locally and use addConsNode()?
Is there any simpler way to add constraint at node, like using constraint expression in addCons()?
Such as
for var in self.model.vars:
if condition is True:
model.addConsNode(var == 0)
- What does "stickingatnode" parameter in the model.createCons() do?
Thank you
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels