Skip to content

BUG: small patch to _VarArray while inputting a matrix with length > 1 #1060

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants