coin-or / coin-or/python-mip

set_expr not working

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

Description

**Describe the bug**
The functions below are not updating the coefficients
model.objective.set_expr()
constraint.expr.set_expr()

**To Reproduce**
```
from mip import Model, maximize

m = Model()
v = m.add_var('v', ub=1)
m.objective = maximize(v)
print(m.objective.expr) # should print {mip.Var id : 1}
m.objective.set_expr({v: 2})
print(m.objective.expr) # should print {mip.Var id : 2}

c = m.add_constr(v <= 0.5, 'c')
print(c.expr) # should print + v - 0.5
c.expr.set_expr({v: 0.6})
print(c.expr) # should print + v - 0.6
m.optimize()
```

**Expected behavior**
The output of the print statements should be as shown above in comments. However, they are not updating so it prints 1,1 and 0.5, 0.5. The expected solution to the problem is 0.6, but instead it is 0.5. Here is the ouput:
![image](https://user-images.githubusercontent.com/38300604/85184152-b0baf800-b25c-11ea-85ec-ae2b366cbffd.png)

**Desktop:**
- Operating System, version: Ubuntu 18.04.4 LTS
- Python version: 3.7.3
- Python-MIP: 1.9.3

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.