How to implement a nonlinear constraint?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Mohamad Moussa
el 9 de Feb. de 2018
Editada: Mohamad Moussa
el 9 de Feb. de 2018
hello i would appreciate some help to implement a nonlinear inequality in my fmincon program. I am trying to maximize Sharpe ratio under two constraints. First that the sum of the weights equal one and the second one is that (((w-w0).^2).^1/2) -0.005 >= 0 (tracking error constraint where w0 is set to be the benchmark weights vector). I am getting errors when trying to programme the tracking error constraint. Thank you!
for i=1:T-M
objective = @(w) -(zbarA3(:,i)'*w - rf)/(sqrt(w'*covmatA3{1,i}*w));
w0 = Wi_AQ2;
Aeq = ones(1,n);
beq = 1;
W_Q3(:,i) = fmincon(objective,w0,[],[],Aeq,beq,[],[],nonling);
end
%where nonling is
function [c,ceq]=nonling(w)
c= sqrt((w(1) - Wi_AQ2)^2) -0.005;
ceq=w*0;
end
6 comentarios
Mohamad Moussa
el 9 de Feb. de 2018
Editada: Mohamad Moussa
el 9 de Feb. de 2018
Respuesta aceptada
Matt J
el 9 de Feb. de 2018
Editada: Matt J
el 9 de Feb. de 2018
for i=1:T-M
objective = @(w) -(zbarA3(:,i)'*w - rf)/(sqrt(w'*covmatA3{1,i}*w));
w0 = Wi_AQ2;
Aeq = ones(1,n);
beq = 1;
W_Q3(:,i) = fmincon(objective,w0,[],[],Aeq,beq,[],[], @(w) nonling(w,w0) );
end
function [c,ceq]=nonling(w,w0)
c= .005^2-norm(w - w0)^2 ;
ceq=[];
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Linear Programming and Mixed-Integer Linear Programming en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!