jump-dev / Convex.jl

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

Sequential quadratic programming does not work with quadcost #398

Closed raphaelchinchilla closed 4 years ago

raphaelchinchilla commented 4 years ago

I want to solve a sequence of constrained Quadratic Programming where the matrix H changes. In order to do this, I use the fix! and free! functions, as explained in the tutorial. The issue is that even if I declare H as Semidefinite, Convex.jl does not realize the problem is DCP compliant

Here is a minimum (not) working example:

n=5
b = randn(n) 
x = Variable(n)
H=Semidefinite(n)
Hval=randn(n,n)
Hval.=Hval'*Hval+10*diagm(ones(n)) # symmetric positive definite
fix!(H,Hval)
problem = minimize(x'b +quadform(x,H), [x >= 0])
solve!(problem, SCS.Optimizer(verbose=0))

If I try to do this, I get the error ERROR: MethodError: no method matching quadform(::Variable, ::Variable)

And if I try to write instead

problem = minimize(x'b +x'Hx, [x >= 0])

I get Warning: Expression not DCP compliant. Trying to solve non-DCP compliant problems can lead to unexpected behavior.

and the solution does not work.

ericphanson commented 4 years ago

Thanks for the report; it looks like an easy fix. Once #399 passes CI, I'll merge it and tag a release.

ericphanson commented 4 years ago

Ok, once https://github.com/JuliaRegistries/General/pull/20132 is merged you should be able to update and use it! Let me know if you run into any other issues.

ericphanson commented 5 months ago

FYI @raphaelchinchilla, we found out in #585 that my "fix" in #399 of this issue made the error go away but did not actually make this work correctly! I am sorry about that, I hope no results were compromised.

raphaelchinchilla commented 5 months ago

Oh man it has been 4 years (and those were pandemic years, so they count double). I have no idea whether results were compromised. Not even sure I remember why I needed that 🤣