python-mip icon indicating copy to clipboard operation
python-mip copied to clipboard

Constraint creation is not symmetric for combination variable and tensor

Open stranma opened this issue 2 years ago • 0 comments

Describe the bug MIP allows to create constraint like mip.LinExprTensor <= mip.Var, but not the opposite way.

To Reproduce

>>> import mip
>>> m = mip.Model()
>>> y = m.add_var_tensor((10,2), 'y')
>>> x = m.add_var('x')
>>> m += y >= x
>>> m += x >= y
Traceback (most recent call last):
  File "python\helpers\pydev\pydevconsole.py", line 364, in runcode
    coro = func()
  File "<input>", line 1, in <module>
  File "lib\site-packages\mip\entities.py", line 632, in __ge__
    raise TypeError("type {} not supported".format(type(other)))
TypeError: type <class 'mip.ndarray.LinExprTensor'> not supported

Expected behavior Both constraints mip.LinExprTensor <= mip.Var and mip.Var <= mip.LinExprTensor are supported and behave identically.

Desktop (please complete the following information):

  • Operating System, version: Windows
  • Python version: 3.10.11
  • Python-MIP version (we recommend you to test with the latest version): 1.15.0

Additional context N/A

stranma avatar Feb 19 '24 17:02 stranma