Skip to content

Commit 7ee3a6f

Browse files
committed
Add test for indicator constraint with matrix binary var
Introduces a new test to verify that addConsIndicator works correctly when the binary variable is a matrix variable, addressing issue #1043.
1 parent 9451cc6 commit 7ee3a6f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/test_cons.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,19 @@ def test_cons_indicator():
179179
assert m.isEQ(m.getVal(x), 1)
180180
assert c1.getConshdlrName() == "indicator"
181181

182+
def test_cons_indicator_with_matrix_binvar():
183+
m = Model()
184+
185+
x = m.addVar(vtype="B")
186+
binvar = m.addMatrixVar(1, vtype="B")
187+
# binvar is a matrix variable to fix #1043
188+
m.addConsIndicator(x >= 1, binvar)
189+
190+
m.setObjective(binvar, "maximize")
191+
m.optimize()
192+
193+
assert m.getVal(x) == 1
194+
182195
@pytest.mark.xfail(
183196
reason="addConsIndicator doesn't behave as expected when binary variable is False. See Issue #717."
184197
)

0 commit comments

Comments
 (0)