You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Python: Problem.addConstraint accepts the same Constraint twice #2326
In the Python API, Problem.addConstraint accepts the same Constraint object twice. The second call overwrites constr.index and appends the constraint to Problem.constrs again, so the problem has two rows for one Constraint, and both rows map to the second index.
fromcuopt.linear_programming.problemimportProblemp=Problem("dup")
x=p.addVariable(lb=0, ub=1, name="x")
c=x<=1p.addConstraint(c)
p.addConstraint(c) # accepted; c.index becomes 1 and p.constrs holds c twice
Expected: ValueError, with p.constrs and c.index left unchanged.
Same bug as the Java one in #2224 (fixed in #2226). The check belongs in Problem.addConstraint, because the native solver only receives a CSR matrix.
Activity