jump-dev / Convex.jl

A Julia package for disciplined convex programming
https://jump.dev/Convex.jl/stable/
Other
569 stars 123 forks source link

QCQP problem setup: constraint violated or incorrect problem setup #25

Closed multidis closed 9 years ago

multidis commented 9 years ago

Quadratically constrained quadratic programming problem discussed in this julia-opt group question.

When tried with Convex.jl, results in an unconstrained minimum and no warnings about constraint violation. Recently (probably after some commits around Nov 14 via Pkg.update()) the behavior changed and all NaN are returned. Full code to reproduce in this gist.

Is something not right about the problem formulation within the Convex.jl conventions or is it a bug?

karanveerm commented 9 years ago

I just ran the code and I'm getting

julia> pr.optval
-6.9273976020178425e-9

julia> pr.status
:Optimal

julia>xecos = vec(x.value)
4-element Array{Float64,1}:
  5.00001   
 -0.0500001 
  0.00999998
  1.91399e-8

Apart from releasing Convex, we also made changes in ECOS. Can you try deleting your ECOS repo and do Pkg.add("ECOS") ? Let me know if you're still having issues!

karanveerm commented 9 years ago

Ignore my previous comment, I see that we aren't satisfying one of your constraints. Turns out your formulation wasn't DCP compliant (http://dcp.stanford.edu/).

We also had a bug because of which we weren't throwing a warning. Sorry about that (all bugs including Base.sqrt issues etc should have now been fixed).

square(a) + square(b) <= square(c) isn't DCP compliant because it is of the form: convex <= convex

I think an equivalent, DCP compliant constraint would be norm([a b]) <= c (this enforces c>= 0) or norm([a b]) <= -c (this enforces c<= 0)

For your particular question, here's a gist: https://gist.github.com/karanveerm/23300969c7ffd52f7da5 Note: I assume you're using the latest version of MathProgBase and Convex from the master branch.

It uses Gurobi as a solver. Mosek is giving the same answer. I'm not sure why ECOS and SCS aren't able to solve this though...

Let me know if this doesn't look right, or if you run into other problems!

multidis commented 9 years ago

Not able to reproduce your code so far. I removed manually all the relevant packages and re-installed/re-built the solvers, ran Pkg.update() (using Julia v0.3 in case it makes a difference). My non-DCP-compliant formulation (thanks for pointing out) still returns unconstrained results without any warnings of non-compliance. Your norm-based formulation faild with ECOS solver, but I could not force Gurobi: no matching method for a Gurobi type https://gist.github.com/multidis/23d6417d71ec56185784

karanveerm commented 9 years ago

Sorry, I think I was unclear. I meant to ask you to checkout the master versions of Convex and MathProgBase (We still need to tag and push these to metadata- planning to do so in a few days)

Pkg.checkout("Convex")
Pkg.checkout("MathProgBase")

If you restart Julia after that, I'm pretty sure things will (finally) work, although let me know if they still don't.

multidis commented 9 years ago

Of course, I should have read more carefully. Yes it works now, thanks! Closing my issue.