MATLAB: Multistart or global search for lsqnlin

globalsearchMATLABmultistart

Dear All,
I am estimating a nonlinear function defined by the following:
function F = myfun(x,y,X)
F = (y - (1 + x(1)*(x(2)/0.0025662))*X(:,1) - (x(2)/x(3))*(sqrt(1-x(1)^2))*X(:,2) - x(4)*X(:,3));
end
I submit the command x = lsqnonlin(@(x) myfun(x, y, X), x0,lb);
And obtain a local minimum
x = 0.0664 0.0586 0.0086 0.8603
I now wish to use the multistart or globalsearch features of MATLAB to obtain a possible global minimum
When I define a problem as follows:
problem = createOptimProblem('lsqnonlin','objective',@myfun, 'xdata',X,'ydata',y, 'x0',x0,'lb',lb,'ub',ub);
and then submit
[x,fval] = lsqnonlin(problem)
I get the following error messages:
Not enough input arguments.
Error in myfun (line 2)
F = (y - (1 + x(1)*(x(2)/0.0025662))*X(:,1) - (x(2)/x(3))*(sqrt(1-x(1)^2))*X(:,2) - x(4)*X(:,3));
Error in lsqnonlin (line 206)
initVals.F = feval(funfcn{3},xCurrent,varargin{:});
Caused by:
Failure in initial objective function evaluation. LSQNONLIN cannot continue.
Kindly let me know how I can use multistart/global search feature of MATLAB along with lsqnonlin Using fmincon, gives a similar error
Thanks, Srinivasan

Best Answer

problem = createOptimProblem('lsqnonlin','objective',@(x) myfun(x, y, X),...
'x0',x0,'lb',lb);
ms = MultiStart;
[x,f] = run(ms,problem,20)