File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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."
You can’t perform that action at this time.
0 commit comments