In a simultaneous fit (lsqcurvefit) with shared parameters how to supply the gradients for more than one objective functions
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello everyone I realy need your help!!!
I am not able to supply the gradients analytically while curve fitting both real and imaginary data (lsqcurvefit). To be more specific I have several real and imaginary data sets with 5 shared parameters but with different objective functions, for example (Xdata1,Ydata1,objfun1),(Xdata2,Ydata2,objfun2),(Xdata3,Ydata3,objfun3) etc. I have created columns for the Xdata and Ydata and an array of anonymous objective functions for the various datasets. Finally i call the optimzation with multistart in parallel after I have created the problem. Now when the gradients are approximated by Finite Differences everything works very well but when I use the array of anonymous objective functions (more than 2) I am not able to supply the gradients analytically. The supplied gradients work only for a single objective function.
Is any workaround for this? Thanks in advance.
PS I tried a simpler example where fun3 is the objective function, m is a 4 parameter vector .
- fun= @(m,xdata)[fun3(m,xdata(1:20,1));fun3(m,xdata(21:end,1))];
- options = optimoptions('lsqcurvefit','Algorithm','trust-region-reflective',... 'OptimalityTolerance',1e-6,'MaxFunctionEvaluations',5e3, 'MaxIterations',5e3,'display','off',... 'TolFun',1e-6,'TolX',1e-6,'SpecifyObjectiveGradient',true);
- problem = createOptimProblem('lsqcurvefit','x0',m0start,'objective',fun,... 'lb',lb,'ub',ub,'xdata',xdata,'ydata',ydata,'options',options);
- ms = MultiStart('StartPointsToRun','all','UseParallel',true,'Display','off');
- [mbest,errorbest,exitflag,Fcount,soln] = run(ms,problem,tpoints);
and the output error is:
Error using vertcat
Too many output arguments.
Error in
@(m,xdata)[fun3(m,xdata(1:20,1));fun3(m,xdata(21:end,1))]
Error in lsqcurvefit (line 213)
[initVals.F,initVals.J] =
feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Error in fmultistart
Error in MultiStart/run (line 268)
fmultistart(problem,startPointSets,msoptions);
Caused by:
Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.
Failure in call to the local solver with supplied problem structure.
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!