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

Can't obtain dual variable #158

Closed
Thuener opened this issue Aug 26, 2016 · 6 comments
Closed

Can't obtain dual variable #158

Thuener opened this issue Aug 26, 2016 · 6 comments

Comments

@Thuener
Copy link

Thuener commented Aug 26, 2016

The example code in http://convexjl.readthedocs.io/en/latest/advanced.html to get the dual variable doesn't work( tested with gurobi and cplex):

using Convex

x = Variable()
constraint = x >= 0
p = minimize(x, constraint)
solve!(p)

# Get the dual value for the constraint
p.constraints[1].dual
# or
constraint.dual
@mlubin
Copy link
Member

mlubin commented Aug 26, 2016

Duals are not currently available through Gurobi or Cplex. Use SCS, ECOS, or Mosek.

@Thuener
Copy link
Author

Thuener commented Aug 26, 2016

OK. I will create a function because I have to use one of these solvers. Seems easy using MathProgBase.getconstrduals(p.model.lpqpmodel). I could add this to the Convex.jl but I'm not familiar with the code.

@mlubin
Copy link
Member

mlubin commented Aug 26, 2016

Convex.jl accesses duals through getdual in the conic interface. Gurobi and CPLEX are not natively conic solvers, so it will take some work to extract the proper duals. The code that does the translation between conic form and Gurobi/CPLEX is here.

If you're just solving LPs, you can access duals for Gurobi and CPLEX through JuMP.

@odow
Copy link
Member

odow commented Feb 23, 2022

Closing as out-dated. This isn't relevant anymore.

@odow odow closed this as completed Feb 23, 2022
@degleris1
Copy link

Closing as out-dated. This isn't relevant anymore.

@odow Could you elaborate? I've been having the same issue and I'm wondering if it's been resolved.

@odow
Copy link
Member

odow commented Mar 9, 2022

The issue is from 2016, when Convex.jl used to use MathProgBase. It now uses MathOptInterface to access duals, so the distinction of being unable to get duals for a LP from Gurobi of CPLEX isn't relevant anymore.

If you have a reproducible example of your issue, please post it on the community forum https://discourse.julialang.org/c/domain/opt/13 and we can discuss. If it's a bug, we can open a new issue.

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

No branches or pull requests

4 participants