Problems with lsqnonlin - initial parameters not changing

조회 수: 11 (최근 30일)
E
E 2023년 4월 24일
답변: Taiha 2023년 9월 22일
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
chicken vector 2023년 4월 24일
The initialGuess is not supposed to change.
The converged results are stored in P.
E
E 2023년 4월 24일
hello, I meant that P is not changing. it is keeping the values that i introduced in InitGuess.

댓글을 달려면 로그인하십시오.

답변 (2개)

Alan Weiss
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

Taiha
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.

카테고리

Help CenterFile Exchange에서 Eigenvalue Problems에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by