Skip to content

Commit a23d168

Browse files
committed
Fix: Don't use self._set_column when adding variables.
This lead to index error in example cuttingstock_cg.py, because _set_column uses the mip.Var object which is not yet added to the mip.Model. Instead, manually set the coefficients.
1 parent 8918708 commit a23d168

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mip/highs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,11 @@ def add_var(
299299
)
300300

301301
if column:
302-
self._set_column(col, column)
302+
# Can't use _set_column here, because the variable is not added to
303+
# the mip.Model yet.
304+
# self._set_column(col, column)
305+
for cons, coef in zip(column.constrs, column.coeffs):
306+
self._change_coef(cons.idx, col, coef)
303307

304308
# store name & type
305309
self._var_name.append(name)

0 commit comments

Comments
 (0)