Skip to content

Conversation

Zeroto521
Copy link
Contributor

@Zeroto521 Zeroto521 commented Aug 20, 2025

To fix a (size > 1) matrix inputting, see #1044 (comment)

from pyscipopt import Model

model = Model()
vars = model.addMatrixVar(3, vtype="B")
model.addConsKnapsack(vars, [1, 2, 3], 5)
model.setObjective(vars.sum(), "maximize")
model.optimize()
# Traceback (most recent call last):
#   line 5, in <module>
#     model.addConsKnapsack(vars, [1, 2, 3], 5)
#   File "src/pyscipopt/scip.pxi", line 6463, in pyscipopt. scip.Model.addConsKnapsack
#   File "src/pyscipopt/scip.pxi", line 2512, in pyscipopt.scip._VarArray.__cinit__
# ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

@Zeroto521 Zeroto521 changed the title BUG: small pathch to _VarArray while inputing is (size >1) matrix BUG: small pathch to _VarArray while inputting is a (size >1) matrix Aug 20, 2025
@DominikKamp DominikKamp changed the title BUG: small pathch to _VarArray while inputting is a (size >1) matrix BUG: small patch to _VarArray while inputting a matrix with length > 1 Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants