JeschkeLab / DeerLab-Matlab

Data analysis and method development toolbox for dipolar EPR spectroscopy
MIT License
4 stars 2 forks source link

multi-starting lmlsqnonlin heavily drops performance #78

Closed luisfabib closed 4 years ago

luisfabib commented 4 years ago

As mentioned in Issue #74 the new toolbox-free algorithm lmlsqnonlin appears to heavily drop in performance when the MultiStart option of fitparamodel is used.

The origin of this is still unclear, but it may be related to very strict convergence criteria in lmlsqnonlin in cases where the start values are not optimal.

luisfabib commented 4 years ago

This issue was solved in #97

Here is an example which shows that the computation times are similar for the toolbox-free and toolbox solvers:

clear,clc,clf

t = linspace(0,5,600);
r = linspace(2,6,400);
P = dd_gauss2(r,[4 0.5 0.4 4.5 0.2]);

K = dipolarkernel(t,r);
V = K*P + whitegaussnoise(t,0.01);

% Standard non-linear optimization
%--------------------------------------
info = dd_gauss2;
par0 = info.Start;
lower = info.Lower;
upper = info.Upper;
tic
[parfit,Pfit] = fitparamodel(V,@dd_gauss2,r,K,par0,lower,upper,'multistart',100,'Solver','lsqnonlin');
toc
Vfit = K*Pfit;

tic
[parfit,Pfit2] = fitparamodel(V,@dd_gauss2,r,K,par0,lower,upper,'multistart',100,'Solver','lmlsqnonlin');
toc
Vfit2 = K*Pfit2;

%Plots
subplot(211)
plot(t,V,'k.',t,Vfit,'r',t,Vfit2,'b--')
axis tight,grid on

subplot(212)
plot(r,P,'k',r,Pfit,'r',r,Pfit2,'b--')
axis tight,grid on
Elapsed time is 5.977400 seconds.
Elapsed time is 5.244371 seconds.