Non negativity constraint in fmincon
Show older comments
Hello everyone..
I have a question concerning fmincon. I am trying to optimize a portfolio but i cannot have short sales, so i want to add a non-negativity constraint in fmincon. I tried to do it using lb=0 but for some reasons, and i do not find which it does not accept my constraint and still gives me as output some negative numbers...
Here are the part of the code where i put this and that does not work:
AnnualReturn=((ones(1,10)+ExpectedReturnUD).^12)-ones(1,10);
Cov=CovUD;
W0=zeros(10,1);
lb=zeros(10,1);
ub=ones(10,1);
Aeq=[ones(1,10);AnnualReturn];
beq=[1;0.12]
WEP=fmincon(@(W) SigmaFct(W,Cov),W0,[],[],Aeq,beq,lb,ub);
or
for i=1:100
[W(i,:)]=fmincon(@(W) SigmaFct(W,Cov),W0,[],[],[ExpectedReturnSample;ones(1,10)],[rbar2(1,i),1],zeros(10,1),ones(10,1));
end
If anyone has an answer for me, that would really help me!!! thanks a lot!
Answers (1)
Alan Weiss
on 24 Sep 2012
0 votes
You did not pass an options structure, so you are using the fmincon active-set algorithm. This algorithm does not strictly satisfy bound constraints; see Iterations can Violate Constraints.
I suggest you use the interior-point or sqp algorithms, each of which strictly satisfies bound constraints.
Alan Weiss
MATLAB mathematical toolbox documentation
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!