Lissi
unread,Jul 9, 2013, 2:39:25 AM7/9/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to yal...@googlegroups.com
I' m trying to implement a robust version of the markowitz model, but I have problems and various errors. I think my code is too simple. I tried to rewrite various times, but honestly I don't know what to change anymore.
I hope somebody could take a look at it and give me a hint. Perhaps I'm understanding the way yalmip works wrong,
% Test data
mu_t = [0.05; 0.11; 0.16; 0.25];
Sigma_t = [ 0.025 0.00055 0.0056 0.00125;
0.00055 0.0121 -0.00352 0.011;
0.0056 -0.00352 0.0256 0.012;
0.00125 0.011 0.012 0.0625];
% Calculation of mu for the box contraint
mu_l = mu_t - 0.05*mu_t;
mu_u = mu_t + 0.05*mu_t;
% Calculation of Sigma for the box constraint
Sigma_l = Sigma_t - 0.05*Sigma_t;
Sigma_u = Sigma_t + 0.05*Sigma_t;
n = length(mu_t);
w = sdpvar(n,1);
mu = sdpvar(n,1);
sdpvar t1 t2 t3 t4
Sigma = [t1, Sigma_t(1,2), Sigma_t(1,3), Sigma_t(1,4);
Sigma_t(2,1), t2, Sigma_t(2,3), Sigma_t(2,4);
Sigma_t(3,1), Sigma_t(3,2), t3, Sigma_t(3,4);
Sigma_t(4,1), Sigma_t(4,2), Sigma_t(4,3), t4];
lambda = 0.5;
% constraints on the portfolio
W = [sum(w) == 1, w >= 0];
% Uncertainty set over the return vector - Box Constraint
M = [mu_l <= mu <= mu_u, uncertain(mu)];
% Uncertainty set over the covariance matrix - box constraint
S = [Sigma_l(1,1)<= t1 <= Sigma_u(1,1),
Sigma_l(2,2)<= t2 <= Sigma_u(2,2),
Sigma_l(3,3)<= t3 <= Sigma_u(3,3),
Sigma_l(4,4)<= t4 <= Sigma_u(4,4),
uncertain(t1), uncertain(t2), uncertain(t3), uncertain(t4)];
% objective function
objective = lambda*w'*Sigma*w - mu'*w;
solvesdp(W + S + M, objective)
solution = double(w)
Thanks!
Lissi