Skip to content

Instantly share code, notes, and snippets.

@karanveerm
Created November 16, 2014 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karanveerm/23300969c7ffd52f7da5 to your computer and use it in GitHub Desktop.
Save karanveerm/23300969c7ffd52f7da5 to your computer and use it in GitHub Desktop.
QCQP problem using Convex.jl
## QCQP problem in a convex sub-domain
a = 77.5625
F = [ 351.0 26255.2 -6647.07 1282.81
26255.2 2.23819e6 -780203.0 80689.2
-6647.07 -780203.0 1.25858e6 151221.0
1282.81 80689.2 151221.0 979604.0]
V = [375.77,11564.5,18360.6,3891.82]
# unconstrained min
xunc = [5.0,-0.05,0.01,0.0]
# constrained min
xtrue = [5.0,-0.0516607,0.00584747,0.000464669]
using Convex, Gurobi
x = Variable(4)
constr = [sqrt(a) * norm(x[3:4]) <= -x[2]]
pr = minimize(sum_squares(F * x - V), constr)
solve!(pr, GurobiSolver())
# pr_unc = minimize(sum_squares(F * x - V))
# solve!(pr_unc, GurobiSolver())
xopt = vec(x.value)
norm(F * xopt - V)
norm(F * xtrue - V)
# xopt is much smaller
a * xopt[3]^2 + a*xopt[4]^2 <= xopt[2]^2
# True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment