Skip to content

Instantly share code, notes, and snippets.

@mlubin
Created December 17, 2015 14:35
Show Gist options
  • Save mlubin/2dfc4b2042a24cf652da to your computer and use it in GitHub Desktop.
Save mlubin/2dfc4b2042a24cf652da to your computer and use it in GitHub Desktop.
using Mosek, MathProgBase
I = [1,1,2,2,3,3,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32,32,33,33,34,34,35,36,37,38,39,40]
J = [14,10,15,11,16,12,13,18,1,21,2,24,3,19,2,22,4,25,5,20,3,23,5,26,6,17,13,17,13,14,15,16,17,18,19,20,21,22,23,24,25,26,7,10,8,11,9,12,1,2,3,4,5,6]
V = [1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,1.0,1.0,-1.0,1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0]
b = [-0.6088331477422722,-0.02852197818671054,-0.9016074145524158,0.4999165215049682,-0.025485683857737418,-0.07276320066249353,0.056565030662414396,-0.07276320066249353,-0.3319954143963322,0.3286736785015988,0.056565030662414396,0.3286736785015988,-0.43682537007384287,1.0516057442061533,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,18.999999999999996,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
var_cones = Any[(:SDP,1:6),(:NonNeg,[13,17]),(:Free,[7,8,9,10,11,12,14,15,16,18,19,20,21,22,23,24,25,26])]
con_cones = Any[(:NonNeg,[4,14]),(:NonPos,[15,16]),(:Zero,[1,2,3,5,6,7,8,9,10,11,12,13]),(:SOC,17:20),(:SOC,21:30),(:SDP,31:40)]
f = [-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,0.2269228958615089,-0.26647992165696055,-0.35104470584603914,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0]
numconstr = 40
numvar = 26
A = sparse(I,J,V,numconstr,numvar)
m = MathProgBase.ConicModel(MosekSolver(LOG=0))
MathProgBase.loadproblem!(m, f, A, b, con_cones, var_cones)
MathProgBase.optimize!(m)
@assert MathProgBase.status(m) == :Optimal
obj = MathProgBase.getobjval(m)
trueobj = -2.7231533727479005
@show trueobj
@show obj
@show abs(obj-trueobj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment