Skip to content

Commit 83d5a34

Browse files
committed
Correct stage requirements and allow node input
1 parent 8c2a498 commit 83d5a34

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/pyscipopt/recipes/getLocalConss.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
from pyscipopt import Model
1+
from pyscipopt import Model, Constraint
22

3-
def getLocalConss(model: Model) -> list:
3+
def getLocalConss(model: Model, node = None) -> list[Constraint]:
44
"""
55
Returns the local constraints of a node.
66
"""
7-
assert model.getStageName() == "SOLVING", "Model must be in SOLVING stage to get local constraints."
87

9-
cur_node = model.getCurrentNode()
8+
if not node:
9+
assert model.getStageName() in ["INITPRESOLVE", "PRESOLVING", "EXITPRESOLVE", "SOLVING"], "Model cannot be called in stage %s." % model.getStageName()
10+
cur_node = model.getCurrentNode()
11+
else:
12+
cur_node = node
1013

1114
local_conss = []
1215
while cur_node is not None:

0 commit comments

Comments
 (0)