Azzera filtri
Azzera filtri

Problems with lsqnonlin - initial parameters not changing

12 visualizzazioni (ultimi 30 giorni)
E
E il 24 Apr 2023
Risposto: Taiha il 22 Set 2023
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 Commenti
chicken vector
chicken vector il 24 Apr 2023
The initialGuess is not supposed to change.
The converged results are stored in P.
E
E il 24 Apr 2023
hello, I meant that P is not changing. it is keeping the values that i introduced in InitGuess.

Accedi per commentare.

Risposte (2)

Alan Weiss
Alan Weiss il 24 Apr 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

Taiha
Taiha il 22 Set 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.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by