Is this the correct optimization tool (lsqcurvefit,MultiStart)
1 view (last 30 days)
Show older comments
I have checked the Optimization tool box to see which one would be good for my optimization problem, so I thought lsqcurvefit would be good for my problem. Upon making a model with data with known parameters and trying to fit it with a model. The parameters estimated are not the same as the known parameters (or converge to the known parameters) that I first created the noisy data. What do you think is wrong with this? I'm also using MultiStart to find different initial points also.
%Creating data with noise:
tu is a (225x3) data
tdata is 225x1 =tu(:,1);
ptest=[0.2,0.1,0.25,0.05];
Tissue= odefnc_noise(ptest,tdata,tu);
%Fitting the data with noise
fun = @(p,tdatas) odefnc_test(p,tdatas,tu);
param0=[0.1 0.1 0.1 0.1];
problem = createOptimProblem('lsqcurvefit','objective',fun,...
'xdata',tdata,'ydata',Tissue,'x0',param0,'lb',[0 0 0 0],'ub',[1 1 1 1],...
'options',options);
[b,fval,exitflag,output,solutions]=run(ms,problem,2);
%Fitting Function
function Tissue= odefnc_test(p,texp,tu)
F=p(1);
fp=p(2);
fis=p(3);
PS=p(4);
init = [0 0];
[~,y]=ode45(@(t,x) myeqn(t,x,F,fp,fis,PS,tu), texp, init);
P=y(:,1);
I=y(:,2);
Tissue = (I+P);
function dx=myeqn(t,x,F,fp,fis,PS,tu)
output=interp1(tu(:,1),tu(:,2),t);
dx(1)= (F/fp)*(output-x(1))- (PS/fp)*(x(1)-x(2));
dx(2)= (PS/fis) *(x(1)-x(2));
dx=[dx(1);dx(2)];
end
end
This will converge to different value even if param0=ptest. So is it the ode function that create a problem? If 'fun' is not an ode, so it is like fun=@(b) b(1)*xdata +b(2)*xdata^2, the solution would converge according to many other problems I found online.
16 Comments
Walter Roberson
on 14 Jun 2017
I have not run with your modifications yet. With the version before them, when I changed the tolerance and step size tolerance to some that looked reasonable, nearly all of the runs end with "Change in x was less than the specified tolerance." which is exit 2; the remaining run was at a higher function value and ran out of iterations (exit 0).
I pushed up the number of starts to 20, but by random chance the final output was not better than one of the runs with only 2 multistarts -- so the starting position is important.
Answers (0)
See Also
Categories
Find more on Global or Multiple Starting Point Search in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!