jump-dev / JuMP.jl

Modeling language for Mathematical Optimization (linear, mixed-integer, conic, semidefinite, nonlinear)
http://jump.dev/JuMP.jl/
Other
2.21k stars 393 forks source link

Something wrong with QCP example? #47

Closed IainNZ closed 10 years ago

IainNZ commented 10 years ago

@joehuchette

idunning@IAINLAPTOP:~/.../JuMP/examples$ julia qcp.jl 
Max 1.0 x
Subject to: 
1.0 x + 1.0 y + 1.0 z == 1.0
1.0 x*x + 1.0 y*y - 1.0 z*z <= 0
1.0 x*x - 1.0 y*z <= 0
-Inf <= x <= Inf
-Inf <= y <= Inf
-Inf <= z <= Inf
Optimize a model with 1 rows, 4 columns and 4 nonzeros
Model has 2 quadratic constraints
Presolve removed 0 rows and 1 columns
Presolve time: 0.00s
ERROR: GurobiError(10020,"Q matrix is not positive semi-definite (PSD)")
 in optimize at /home/idunning/.julia/Gurobi/src/grb_solve.jl:7
 in optimize at /home/idunning/.julia/Gurobi/src/GurobiSolverInterface.jl:104
 in solveLP at /home/idunning/.julia/JuMP/src/solvers.jl:152
 in solve at /home/idunning/.julia/JuMP/src/solvers.jl:12
 in include at boot.jl:238
 in include_from_node1 at loading.jl:96
 in process_options at client.jl:275
 in _start at client.jl:351
at /home/idunning/.julia/JuMP/examples/qcp.jl:39
joehuchette commented 10 years ago

Gurobi needs nonnegativity to play nicely with the SOC and rotated SOC constraints. It was put in, but I suspect it got lost in the git mess I got myself into yesterday.

An interesting thing to look into later on is if this is strictly necessary; the Python example for this same problem doesn't require explicit nonnegativity.

chriscoey commented 9 years ago

Hi guys, I'm kind of new to this, but I think this is an issue.

I can run the example (and my own SOCP) in Python without the nonnegativity constraints with no PSD error, but I can't run it (or my model) in either JuMP or JuliaOpt code (it gives the same PSD error unless I impose nonnegativity). I'm using Gurobi in both cases.

IainNZ commented 9 years ago

We call Gurobi through the C interface - the Python interface probably does some magic we don't before it too calls the C interface.

mlubin commented 9 years ago

The gurobi python documentation states that nonnegativity is required for SOC constraints: http://www.gurobi.com/documentation/6.0/reference-manual/py_model_addqconstr#pythonmethod:Model.addQConstr. JuMP's behavior is correct here.

chriscoey commented 9 years ago

Thanks. You're right - gurobipy must be making the variables nonnegative automatically.