MATLAB: How to use lsqnonlin together with MultiStart

Global Optimization Toolboxglobal solutioninitial pointslsqnonlinMATLABmultistartportfolio optimization

Hello,
Please, I would like to see how I can use lsqnonlin together with the MultiStart solver to search over many initial points automatically and find the global solution of the portfolio optimization problem below.
I am using lsqnonlin to solve the following system for the n-order vector w and the scalar lambda. There is only a lower bound constraint at 0 for each element of w (short-selling constraint).
x0=[1/n*ones(n,1);1];
lb=[zeros(n,1);0];
[w phi]=lsqnonlin(@sub,x0,lb);
function fcns=sub(x)
w=x(1:n,1);
lambda=x(n+1,1);
fcns(1:n,1)=lambda^(-1)*covmat^(-1)*(meanbl-(vec1'*covmat^(-1)*vec1)^(-1)*(vec1'*covmat^(-1)*meanbl-lambda)*vec1)-w;
fcns(n+1,1)=w'*meanbl+phi*sqrt(w'*covmat*wb)-H;
Where the scalars H and phi, the n-order vectors meanbl and vec1, and the nxn matrix covmat are known.
I did not really understand the example at http://www.mathworks.com/help/gads/multistart-using-lsqcurvefit-or-lsqnonlin.html where the local solver used with MultiStart is lsqcurvefit instead of lsqnonlin.
Thank you very much.
Best wishes.

Best Answer

First you need to figure out bounds on all the parameters w and lambda. In general, it is not enough to say that lb = zeros(n+1,1), you also need an upper bound vector.
Once you have that, you can set up your problem for MultiStart easily. You just need to put your problem into a problem structure using the createOptimProblem function:
problem = createOptimProblem('lsqnonlin','x0',x0,'lb',lb,'ub',ub,'objective',@sub);
ms = MultiStart;
[x,fval,eflag,output,manymins] = run(ms,problem,50);
Alan Weiss
MATLAB mathematical toolbox documentation