Slow convergence of lsqnonlin

조회 수: 11 (최근 30일)
Pascal Schulthess
Pascal Schulthess 2013년 3월 26일
Hi everyone,
I have a convergence problem with lsqnonlin and I hope that someone can help me speed it up.
Ok, so what do I have:
  • 18 different data sets with 8 data points each with each data point having a standard deviation
  • 18 different and really nasty objective functions that I build with the help of a for loop
  • 28 overall free parameters from which all have a lower bound and only one has an upper bound.
What I'm doing now:
  1. Generate initial conditions from log normal distribution
  2. Pass them to lsqnonlin and let lsqnonlin do its magic
  3. Save goodness of fit (not really chi^2 because I don't use weighted fitting)
  4. Repeat a lot of times and then choose the parameter set according to "chi^2" value
After diagnosing one of those many iteration, I see that it really takes long time for lsqnonlin to converge to a solution. And with long time I mean about 35 seconds for one iteration which is just not tolerable if you wanna do this 10000 times.
I hope I made myself clear and that anyone could hint me on ways to speed up the convergence. Of course I'll try to provide anything necessary for you to help me.
Thanks a lot in advance.
Pascal
  댓글 수: 2
Sean de Wolski
Sean de Wolski 2013년 3월 26일
  1. How do you call lsqnonlin()
  2. What options are you using?
  3. Have you tried profiling your code?
Matt J
Matt J 2013년 3월 26일
편집: Matt J 2013년 3월 26일
By "one of those many iteration", you mean a single pass through steps 1-4 in your post?
In any case, the speed of convergence depends on the function being minimized. We need to see your objective and constraints to say anything about that.

댓글을 달려면 로그인하십시오.

채택된 답변

Pascal Schulthess
Pascal Schulthess 2013년 4월 4일
Alright, I figured out how to speed up the calculation of the objective function immensely. By breaking it down into matrices and vectors I was able to come from 60 sec to 2.8 sec per 10000 objective function calls.

추가 답변 (1개)

Pascal Schulthess
Pascal Schulthess 2013년 3월 26일
@Sean:
[pars, chi2] = lsqnonlin(@objFcn, iniConds, lb, ub, opts, xdata, ydata);
with
iniConds = lognrnd(mu, sigma, 1, nPar);
lb = zeros(size(iniConds));
ub = ones(size(iniConds))*Inf;
ub(23) = 1;
opts = optimset('MaxFunEvals', 10000, 'Display', 'off');
I haven't profiled my code yet, but I'm currently at it.
@Matt: Exactly. But "one of those iterations" I mean passing through points 1 to 3.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by