coin-or / python-mip

Python-MIP: collection of Python tools for the modeling and solution of Mixed-Integer Linear programs
Eclipse Public License 2.0
525 stars 92 forks source link

`0 - Var` returns wrong result #126

Closed vang1ong7ang closed 4 years ago

vang1ong7ang commented 4 years ago

Describe the bug

0 - Var returns wrong result

To Reproduce Steps to reproduce the behavior please include attached any files needed to reproduce the error. We can only help you if we can reproduce the error ourselves and debug.

from mip import Model

m = Model()

x = m.add_var()
print(x)
y = 0 - x
print(y)

Expected behavior A clear and concise description of what you expected to happen.

expect output should be:

var(0)
- var(0)

but actually it is:

var(0)
var(0)

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

vang1ong7ang commented 4 years ago

the problem should be here:

https://github.com/coin-or/python-mip/blob/a215205607bad484d57a6bc7cba0e3c75e64f3ed/mip/entities.py#L571-L572

tuliotoffolo commented 4 years ago

Thank you very much for pointing this out! I believe the problem is fixed now!