Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
885865a
Refactor _VarArray initialization and type checks
Zeroto521 Jul 31, 2025
9451cc6
Refactor _VarArray to support MatrixVariable input
Zeroto521 Jul 31, 2025
7ee3a6f
Add test for indicator constraint with matrix binary var
Zeroto521 Jul 31, 2025
2cde7a6
Update CHANGELOG.md
Zeroto521 Jul 31, 2025
50bb995
Declare ptr variable in create_ptr function
Zeroto521 Jul 31, 2025
d72f951
Refactor create_ptr to remove redundant size argument
Zeroto521 Jul 31, 2025
110679f
Refactor _VarArray initialization logic
Zeroto521 Jul 31, 2025
f181cf4
Update CHANGELOG
Zeroto521 Jul 31, 2025
0346c52
Update test for addConsIndicator with activeone flag
Zeroto521 Jul 31, 2025
68f2e44
ENH: flatten list
Zeroto521 Aug 1, 2025
5580e12
BUG: use `np.ravel` avoid to run out of vars range
Zeroto521 Aug 1, 2025
8fc900c
Merge branch 'master' into fix/1043
Joao-Dionisio Aug 2, 2025
d52eb54
test binvar with (1, 1, 1) matrix
Zeroto521 Aug 3, 2025
8424c6d
test binvar with (2, 3) matrix
Zeroto521 Aug 3, 2025
710a836
test binvar with (2, 1) list of lists
Zeroto521 Aug 3, 2025
3b64e79
correct index
Zeroto521 Aug 3, 2025
2be1117
Add TypeError test for addConsIndicator with binvar
Zeroto521 Aug 4, 2025
7277e55
Merge branch 'master' into fix/1043
Joao-Dionisio Aug 16, 2025
09e3a0f
Only requiring a 1D array
Zeroto521 Aug 18, 2025
c749183
TST: raise an error while get not 1D array
Zeroto521 Aug 18, 2025
cba76c2
MAINT: Update error message
Zeroto521 Aug 18, 2025
44de7b7
TST: update error type
Zeroto521 Aug 18, 2025
1fd24a9
Update CHANGELOG.md
Zeroto521 Aug 18, 2025
1a3d2e1
Fix _VarArray initialization for empty input
Zeroto521 Aug 18, 2025
e17f68b
Remove _VarArray changing from changelog
Zeroto521 Aug 18, 2025
d280764
TST: update the comparing method
Zeroto521 Aug 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test binvar with (2, 3) matrix
  • Loading branch information
Zeroto521 committed Aug 3, 2025
commit 8424c6d6015984433c7fb28cd76ae1b222052af7
17 changes: 12 additions & 5 deletions tests/test_cons.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,23 @@ def test_cons_indicator_with_matrix_binvar():
# test matrix variable binvar #1043
m = Model()

x = m.addVar(vtype="B")
# test binvar with (1, 1, 1) shape of matrix variable
binvar = m.addMatrixVar(((1, 1, 1)), vtype="B")
m.addConsIndicator(x >= 1, binvar, activeone=True)
m.addConsIndicator(x <= 0, binvar, activeone=False)
x = m.addVar(vtype="B")
binvar1 = m.addMatrixVar(((1, 1, 1)), vtype="B")
m.addConsIndicator(x >= 1, binvar1, activeone=True)
m.addConsIndicator(x <= 0, binvar1, activeone=False)

# test binvar with (2, 3) shape of matrix variable
y = m.addVar(vtype="B")
binvar2 = m.addMatrixVar(((2, 3)), vtype="B")
m.addConsIndicator(y >= 1, binvar2, activeone=True)
m.addConsIndicator(y <= 0, binvar2, activeone=False)

m.setObjective(binvar.sum(), "maximize")
m.setObjective(binvar1.sum() + binvar2.sum(), "maximize")
m.optimize()

assert m.getVal(x) == 1
assert m.getVal(y) == 1

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