coin-or / coin-or/python-mip

Constraint creation is not symmetric for combination variable and tensor

Open
#371 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Linear Programming
Stars
600
Forks
108
PR merge metrics
No merged PRs in 30d

Description

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

**To Reproduce**
```pytohn
>>> 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 "", line 1, in
File "lib\site-packages\mip\entities.py", line 632, in __ge__
raise TypeError("type {} not supported".format(type(other)))
TypeError: type 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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.