Problems with lsqnonlin - initial parameters not changing
15 次查看(过去 30 天)
显示 更早的评论
Hello, I am trying to find the kinetic parameters for the production of CO and CO2 by comparing experimental data with the data generated by the model and minimzing the difference. The code itself runs, however, the initial guesses are not changing.
InitGuess=[1.4833e10/60 97000 5.9331e10/60 97000];
objf=@(P)ObjFunE(P, tspan, y0, ExpConc, Tref, n);
options=optimoptions("lsqnonlin","Algorithm","levenberg-marquardt");
lb=[0 0 0 0];
ub=[1e11 1e6 1e11 1e6];
[P,resnorm,residual,exitflag,output,lambda,jacobian]=lsqnonlin(objf,InitGuess,lb,ub,options)
ObjFunE is an ode15s solver that generates the model data and then substract it from the experimental data.
2 个评论
chicken vector
2023-4-24
The initialGuess is not supposed to change.
The converged results are stored in P.
回答(2 个)
Alan Weiss
2023-4-24
We don't see your ObjFunE code, so cannot be sure of what is going on. It seems that you are solving an ODE to create some output. I do not see where you subtract that output from experimental data. Are you summing and squaring the difference? If so, that is a mistake; you should have ObjFunE return a vector that lsqnonlin implicitly squares and sums.
It is also possible that your ODE has a bit of noise in the solution that stops lsqnonlin from converging. See Optimizing a Simulation or Ordinary Differential Equation.
And it is also possible that your issue is the scale of your response variables. Perhaps you can divide the first and third components by 1e10 and the second and fourth by 1e5, and then unscale them within your function, so that the variables you pass are all of more of less the same order of magnitude.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
0 个评论
Taiha
2023-9-22
Lsqnonlin (sometimes) does not work well when initial values are largely different, that is, if your two initial vales are a = 0.001 and b = 1000.
For safety, I always use scaling. I set all initial values as 1, and pass proper initial guesses as parameters to the fit-function to correctly calculate diference vector.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surrogate Optimization 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!