How to use lsqnonlin together with MultiStart?

3 次查看(过去 30 天)
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.

采纳的回答

Alan Weiss
Alan Weiss 2014-12-8
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
  2 个评论
Manuel Fuelling
Manuel Fuelling 2018-6-6
I used your code like this:
lb=[-15,10,-4,-20,0,5,-20,-5,-5,-20,0,-10,-20,-20,-20,-20]; %lower Bound
ub=[-5,18,4,-5,8,10,-5,0,2,-5,8,0,20,20,20,20]; %upper Bound
x0 = [-10,14,0,-13,5,8,-13,-2,0,-13,5,-8,1,2,3,4]; %Startwerte
f_schnittgeraden=...
@(x)f_root2d_schnittgeraden(x,stzpkt,w,Kantenlaenge,Winkel);
problem = createOptimProblem...
('lsqnonlin','x0',x0,'lb',lb,'ub',ub,'f_schnittgeraden',@(x)f_root2d_schnittgeraden);
ms = MultiStart;
[x,fval,eflag,output,manymins] = run(ms,problem,50);
i get the following error message: Error using createOptimProblem (line 107) No field f_schnittgeraden exists for PROBLEM structure. Type "help createOptimProblem" for a list of valid fields for each solver.
Error in s2_Schliff_Bild_to_P_Matlab (line 45) problem = createOptimProblem...
Alan Weiss
Alan Weiss 2018-6-6
You probably mean that to be your objective function. The correct field name is 'objective'. In other words, replace 'f_schnittgeraden' with 'objective'.
Alan Weiss
MATLAB mathematical toolbox documentation

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Problem-Based Optimization Setup 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by