# Dual: "getdual()" is not working for Conic/Quadratic constraints

How can I get dual values for Conic/Quadratic constraints?
getdual() function works fine for LPs, however it doesn’t work for QP or SOCP.
Below is a sample code.

``````using JuMP, Gurobi
m = Model(solver=GurobiSolver())
@variable(m, x[1:3] >=0)
@constraint(m, constraint1, x[1]^2 + x[2]^2 <= 10)
@constraint(m, constraint2, x[2] == 1)
@constraint(m, constraint3, x[1]-x[2]==0)
@constraint(m, constraint4, x[1]-x[3] <= -1 )
@objective(m, Min, x[1]+x[2]+x[3])
status = solve(m)
getdual(constraint1)
getdual(constraint2)
getdual(constraint3)
getdual(constraint4)
``````

Replace `@constraint(m, constraint1, x[1]^2 + x[2]^2 <= 10)` by `@constraint(m, constraint1, norm(x[1:2]) <= √10)`

For conic constraints: Solvers like Gurobi and CPLEX don’t return duals for SOCPs, at least not in a way that we have hooked up through the interface. I would recommend using ECOS or Mosek instead if you care about duals on SOCPs.

For quadratic constraints: I think JuMP 0.18 just doesn’t have this hooked up. The usual workaround would be to call, e.g., Ipopt and formulate the quadratic constraints with `@NLconstraint` instead of `@constraint`.

Thanks for the suggestion!
It does return dual variable values with nonlinear solvers after replacing the constraint using norm.
But I don’t know why. Could you explain the difference between three expressions?

``````@constraint(m, constraint1, norm(x[1:2]) <= sqrt(10))
``````
``````@constraint(m, constraint1, x[1]^2 + x[2]^2 <= 10)
``````
``````@NLconstraint(m, constraint1, sqrt(x[1]^2 + x[2]^2) <= sqrt(10))
``````

Miles,
Thank you for the information. It helped a lot!
I was able to obtain dual variable values with nonlinear solvers.

With the `norm` syntax, it is treated as a conic constraint with the second order cone and with the quadratic function is it treated as a LessThan expression with a quadratic function.
Duals are supporting for conic constraints but not for constraints with quadratic functions

Thank you for the kind response!