Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix constraint primal calculation in gurobi interface #120

Merged

Conversation

cdiener
Copy link
Member

@cdiener cdiener commented Jul 27, 2017

Now gives the correct primals for the constraint expression:

In [1]: import optlang

In [2]: gurobi = optlang.gurobi_interface

In [3]: mod = gurobi.Model()
Academic license - for non-commercial use only

In [4]: x = gurobi.Variable(lb=3, ub=3, name="x")

In [5]: const = gurobi.Constraint(x, lb=3)

In [6]: mod.add([x, const])

In [7]: mod.optimize()
Out[7]: 'optimal'

In [8]: x.primal
Out[8]: 3.0

In [9]: const.primal
Out[9]: 3.0

Fixes #115.

@codecov-io
Copy link

codecov-io commented Jul 27, 2017

Codecov Report

Merging #120 into master will decrease coverage by 20.89%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #120      +/-   ##
==========================================
- Coverage   89.43%   68.53%   -20.9%     
==========================================
  Files           8        8              
  Lines        2460     2460              
  Branches      542      542              
==========================================
- Hits         2200     1686     -514     
- Misses        171      696     +525     
+ Partials       89       78      -11
Impacted Files Coverage Δ
optlang/cplex_interface.py 2.13% <0%> (-89.51%) ⬇️
optlang/exceptions.py 88.88% <0%> (-11.12%) ⬇️
optlang/expression_parsing.py 76.82% <0%> (-7.32%) ⬇️
optlang/interface.py 90.11% <0%> (-0.58%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28656a4...667cd56. Read the comment docs.

@KristianJensen KristianJensen changed the base branch from master to bug-fixes August 9, 2017 08:54
@ghost ghost assigned KristianJensen Aug 9, 2017
@KristianJensen
Copy link
Contributor

This works great for <, > and = constraints, but not for range constraints (which gurobi does not support natively). I'll adapt your solution a bit to also cover that.

@KristianJensen KristianJensen merged commit 91d93f1 into opencobra:bug-fixes Aug 9, 2017
@ghost ghost removed the ready label Aug 9, 2017
@cdiener
Copy link
Member Author

cdiener commented Jan 31, 2018

Hi is that planned to move to master? I was just hit by the same bug again.

@KristianJensen
Copy link
Contributor

Strange. It was merged in #129

@cdiener
Copy link
Member Author

cdiener commented Feb 1, 2018

Okay just saw that I only have that problem if when using the barrier methods in gurobi. Maybe some different interpretation of slack variables or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants