Describe the bug
Removing variables from a model is broken due to trying to write a protected property. This was caught while running the tests for the optlang package:
src/optlang/interface.py:1249: in variables
self.update()
src/optlang/interface.py:1491: in update
self._remove_variables(rm_var)
src/optlang/coinor_cbc_interface.py:687: in _remove_variables
self.problem.remove(mip_vars)
../../.local/lib/python3.10/site-packages/mip/model.py:1424: in remove
self.vars.remove(vlist)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <mip.lists.VarList object at 0x7f3610954fd0>, vars = [<mip.entities.Var object at 0x7f36109783a0>]
def remove(self: "VarList", vars: List["mip.Var"]):
iv = [1 for i in range(len(self.__vars))]
vlist = [v.idx for v in vars]
vlist.sort()
for i in vlist:
iv[i] = 0
self.__model.solver.remove_vars(vlist)
i = 0
for v in self.__vars:
if iv[v.idx] == 0:
> v.idx = -1
E AttributeError: can't set attribute 'idx'
../../.local/lib/python3.10/site-packages/mip/lists.py:72: AttributeError
To Reproduce
Try to remove variables from a model.
Expected behavior
It should remove the variable and not crash.
Desktop (please complete the following information):
Operating System, version: Debian sid
Python version: 3.10.5
Python-MIP version (we recommend you to test with the latest version): 1.14.0
Additional context
Add any other context about the problem here.
Describe the bug Removing variables from a model is broken due to trying to write a protected property. This was caught while running the tests for the optlang package:
To Reproduce
Try to remove variables from a model.
Expected behavior
It should remove the variable and not crash.
Desktop (please complete the following information):
Additional context Add any other context about the problem here.