Gurobi SOC Constraint


I am having issues using Gurobi Solver for my SOC formulation. Following are my constraints:

I am getting an error ERROR: LoadError: MethodError: no method matching NonlinearModel(::Gurobi.GurobiSolver)

The mathematical form of constraints is:

How can I solve this issue? I will appreciate any help.


Assuming that is a variable and not a constant, the first of those constraints is a non-convex quadratic constraint. Gurobi can’t handle general nonlinear models. See the table at


Thanks for the reply. is a constant. The problem is with the last constraint. It works with Ipopt Solver but by using @NLconstraint command.


After trying several times to use this hint (, I think that my main problem is that I don’t understand how the last constraint can be represented in terms of norm()… Is there any trick or reformulation that can help me wit this?

Thank y’all again.


What are the variables in that constraint / could you provide a minimal code example?


My variables are

Rl , Xl and Sl are constants.


The constraints are:


The constraint I am having issues with is:


The ‘rotated second-order cone constraint’ is a convex constraint of the form y*z >= ||x||^2, y>=0, z>=0. It appears that your constraint is of this form. I don’t know if Gurobi supports this, but if it does, then probably it will help Gurobi recognize it if you move the ‘a’ variable to the other side of the inequality.

If Gurobi doesn’t support it, then you can convert it to a standard second-order cone constraint by changing variables: let y=u+v and z=u-v.


[Please do not use images; instead, copy the code and “quote” it using backticks (`) or the “</>” button.]


The @constraint call should not throw the error you originally specified; the division by the a variable should fail.

using JuMP, Gurobi
m = Model(solver = GurobiSolver())
@variables m begin
@constraint(m, (fp^2 + fq^2) / a^2 <= v)

results in

/(::Int64,::JuMP.GenericQuadExpr{Float64,JuMP.Variable}) is not defined. Are you trying to build a nonlinear problem? Make sure you use @NLconstraint/@NLobjective.

 in /(::Int64, ::JuMP.GenericQuadExpr{Float64,JuMP.Variable}) at /Users/twan/code/julia/RigidBodyDynamics/v0.5/JuMP/src/operators.jl:639


using JuMP, Gurobi
m = Model(solver = GurobiSolver())
@variables m begin
@NLconstraint(m, (fp^2 + fq^2) / a^2 <= v)

does result in the error you reported originally. Please do provide a minimal example right off the bat in the future; all of the back and forth above would have been unnecessary.

The constraint is indeed convex since a and v are also constrained to be positive; this is a rotated Lorentz cone constraint, as @Stephen_Vavasis mentioned.


See also


Thank y’all for your help and suggestions. It is working now by implementing the suggestion mentioned by @Stephen_Vavasis. I appreciate your help.

I will be more specific in future and thanks again everyone.