Is the method remove working properly?

0 views
Skip to first unread message

Ricardo Camargo

unread,
Jun 11, 2024, 10:48:17 PMJun 11
to Python-MIP
Hi guys,

Is the method remove(objects) of the Model class working properly?
I can't get it to remove a variable or a list of them.

For instance, in the following example:

from mip import Model, MAXIMIZE, CBC, INTEGER, OptimizationStatus
model = Model(sense=MAXIMIZE, solver_name=CBC)
x = model.add_var(name='x', var_type=INTEGER, lb=0, ub=10)
y = model.add_var(name='y', var_type=INTEGER, lb=0, ub=10)
model += x + y <= 10
model.objective = x + y
status = model.optimize(max_seconds=2)
status == OptimizationStatus.OPTIMAL
model.remove([x]) # model.remove(x)

I've tried to remove variable x using two different approaches:
model.remove([x]) and model.remove(x)

Both approaches lead to the following error message:

v.idx = -1
AttributeError: can't set attribute 'idx'


What am I doing wrong?




Thanks




Ricardo



Reply all
Reply to author
Forward
0 new messages