Last active
August 29, 2015 14:04
-
-
Save jfsantos/e4a17788656b515a118d to your computer and use it in GitHub Desktop.
SOCP from https://github.com/ifa-ethz/ecos/blob/master/test/matlab/test_portfolio.m implemented in JuMP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using JuMP, Gurobi, MAT, Base.Test | |
# Reading problem variables from .mat file | |
vars = matread("data.mat") | |
D = vars["D"] | |
F = vars["F"] | |
c = vars["c"] | |
cvx_x = vars["true_x"] | |
m = Model(solver=GurobiSolver()) | |
@defVar(m, x[1:5]) | |
#@setObjective(m, :Min, c'*x + x'*D*x + sum((F'*x).^2)) | |
@setObjective(m, Min, sum{c[i]*x[i] + D[i,i]*x[i]*x[i], i=1:5} + dot(F[:,1],x)^2 + dot(F[:,2],x)^2) | |
@addConstraint(m, sum(x) == 1) | |
status = solve(m) | |
jump_x = getValue(x).innerArray | |
@test_approx_eq jump_x cvx_x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment