Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
if rc == SCIP_OKAY:
pass
elif rc == SCIP_ERROR:
raise Exception('SCIP: unspecified error!')

Check failure on line 311 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / test-coverage (3.11)

SCIP: unspecified error!
elif rc == SCIP_NOMEMORY:
raise MemoryError('SCIP: insufficient memory error!')
elif rc == SCIP_READERROR:
Expand Down Expand Up @@ -2509,8 +2509,8 @@
else:
raise TypeError(f"Expected Variable or list of Variable, got {type(vars)}.")

if vars:
self.size = len(vars)
self.size = len(vars)
if self.size:
self.ptr = <SCIP_VAR**> malloc(self.size * sizeof(SCIP_VAR*))
for i, var in enumerate(vars):
if not isinstance(var, Variable):
Expand Down
11 changes: 11 additions & 0 deletions tests/test_cons.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ def test_cons_indicator_with_matrix_binvar():

assert m.isEQ(m.getVal(x), 1)

def test_cons_knapsack_with_matrix_vars():
# test matrix variable vars #1043
m = Model()
vars = m.addMatrixVar(3, vtype="B")
m.addConsKnapsack(vars, [1, 2, 3], 5)

m.setObjective(vars.sum(), "maximize")
m.optimize()

assert (m.getVal(vars) == [0, 1, 1]).all()

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