Problems with lsqnonlin - initial parameters not changing
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
chicken vector
el 24 de Abr. de 2023
The initialGuess is not supposed to change.
The converged results are stored in P.
Respuestas (2)
Alan Weiss
el 24 de Abr. de 2023
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 comentarios
Taiha
el 22 de Sept. de 2023
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 comentarios
Ver también
Categorías
Más información sobre Surrogate Optimization en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!