Skip to content

Commit 710a836

Browse files
committed
test binvar with (2, 1) list of lists
1 parent 8424c6d commit 710a836

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/test_cons.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,20 @@ def test_cons_indicator_with_matrix_binvar():
195195
m.addConsIndicator(y >= 1, binvar2, activeone=True)
196196
m.addConsIndicator(y <= 0, binvar2, activeone=False)
197197

198-
m.setObjective(binvar1.sum() + binvar2.sum(), "maximize")
198+
# test binvar with (2, 1) shape of list of lists
199+
z = m.addVar(vtype="B")
200+
binvar3 = [[m.addVar(vtype="B")], [m.addVar(vtype="B")]]
201+
m.addConsIndicator(z >= 1, binvar3, activeone=True)
202+
m.addConsIndicator(z <= 0, binvar3, activeone=False)
203+
204+
m.setObjective(
205+
binvar1.sum() + binvar2.sum() + binvar3[0][0] + binvar3[0][1], "maximize"
206+
)
199207
m.optimize()
200208

201209
assert m.getVal(x) == 1
202210
assert m.getVal(y) == 1
211+
assert m.getVal(z) == 1
203212

204213
@pytest.mark.xfail(
205214
reason="addConsIndicator doesn't behave as expected when binary variable is False. See Issue #717."

0 commit comments

Comments
 (0)