-
Notifications
You must be signed in to change notification settings - Fork 271
Closed
Description
Describe the bug
_VarArray
will raise an error when vars
is a MatrixVar
.
To Reproduce
from pyscipopt import Model
model = Model()
x = model.addVar()
binvar = model.addMatrixVar(1, vtype="B")
model.addConsIndicator(x >= 1, binvar)
# ---------------------------------------------------------------------------
# TypeError Traceback (most recent call last)
# Cell In[3], line 1
# ----> 1 model.addConsIndicator(x >= 1, binvar)
#
# File src/pyscipopt/scip.pxi:6834, in pyscipopt.scip.Model.addConsIndicator()
#
# File src/pyscipopt/scip.pxi:2457, in pyscipopt.scip._VarArray.__cinit__()
#
# TypeError: Expected Variable or list of Variable, got <class 'pyscipopt.scip.MatrixVariable'>.
PySCIPOpt/src/pyscipopt/scip.pxi
Lines 2465 to 2476 in f0d47a4
cdef class _VarArray: | |
cdef SCIP_VAR** ptr | |
cdef int size | |
def __cinit__(self, object vars): | |
if isinstance(vars, Variable): | |
self.size = 1 | |
self.ptr = <SCIP_VAR**> malloc(sizeof(SCIP_VAR*)) | |
self.ptr[0] = (<Variable>vars).scip_var | |
else: | |
if not isinstance(vars, (list, tuple)): | |
raise TypeError("Expected Variable or list of Variable, got %s." % type(vars)) |
Expected behavior
The result of MatrixVar
should be like list
and tuple
.
Screenshots

System
- OS: Windows 11
- Version: 24H2 (26100.4061)
- SCIP version: 9.2.3
- How did you install pyscipopt?: build from b4a70f5, base on 5.5.0
Metadata
Metadata
Assignees
Labels
No labels