Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

model.remove broken for variables in mip 1.14.0 #294

Closed
cdiener opened this issue Jul 17, 2022 · 1 comment · Fixed by #296
Closed

model.remove broken for variables in mip 1.14.0 #294

cdiener opened this issue Jul 17, 2022 · 1 comment · Fixed by #296
Labels
bug Something isn't working mip Issues related to the core mip package reproducible If a bug/behaviour could be reproduced

Comments

@cdiener
Copy link

cdiener commented Jul 17, 2022

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.

@cdiener cdiener changed the title model.varibales.remove broken in mip 1.14.0 model.remove broken for variables in mip 1.14.0 Jul 18, 2022
@sebheger sebheger added mip Issues related to the core mip package bug Something isn't working reproducible If a bug/behaviour could be reproduced labels Jul 18, 2022
@cdiener
Copy link
Author

cdiener commented Aug 8, 2022

Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working mip Issues related to the core mip package reproducible If a bug/behaviour could be reproduced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants