How to keep signs of input parameters fixed while using "levenberg-marquardt" algorithm for lsqcurvefit?

조회 수: 1 (최근 30일)
If I use upper and lower bounds for my parameters, the algorithm switches to trust region method automatically. Is there any other way to just keep the signs constant during iterations?
  댓글 수: 2
Matt J
Matt J 2017년 1월 15일
But why cling to Levenberg-Marquardt when it is not natural for the problem you are trying to solve? If you have bounds, why oppose MATLAB's efforts to choose a solver more appropriate for that?
Vipultomar
Vipultomar 2017년 1월 16일
The choice of Levenberg-Marquardt is totally based on what people have used for solving similar problems as mine (from published data) but I think they didn't make such boundary conditions. However somewhere along they have mentioned that they fixed one initial parameter or two time to time. But on the contrary I am not able to fix the parameters using these algorithms (it starts giving lb is same as ub, sort of error). So I was using lb and ub to be very close, so that corresponding parameters are almost fixed.

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

답변 (1개)

John D'Errico
John D'Errico 2017년 1월 15일
편집: John D'Errico 2017년 1월 15일
An easy solution is to change your model slightly using a transformation. For example, suppose you wanted to solve for coefficients of the model
y = a*x
but you wanted to ensure that a was ALWAYS positive, but you don't want to apply bound constraints? Instead solve for the coefficients of the model:
y = b^2*x
As you can see, b^2 will always be positive, so there is never a chance that b^2 will change sign on you. When you are done, just transform b back into a as
a = b^2
Yes, it is a hack. But it allows you to formulate a problem to work in the solver you want to use, without the employment of explicit bound constraints.
  댓글 수: 2
Vipultomar
Vipultomar 2017년 1월 15일
편집: Vipultomar 2017년 1월 15일
Thanks. Seems like a great idea. But my main function (whose output I want to be fitted with my experimental values Yexp) involves calculation of eigenvalues of matrix whose components are some exponential of Xexp (experimental xdata). e.g.
function y=funct_name(parameters,X,Y)
y=[]
for j=length(X);
L=eig([a+b*exp(X(j)*b),c*b*exp(X(j)*c)....;c+a*exp(X(j)*b)....]); %a,b,c etc are parameters
....
.... %eigenvalues arranged in descending order
ycalc=[y,L(2)]; %
Now I am not sure whether taking squares of the parameters e.g. a,b etc, would be so straightforward. Wouldn't it be much easier if it were simple function e.g. polynomial, trigonometeric etc.. Or do you think I can simply take the square roots of parameters a,bc.. etc as starting parameters and then in the matrix replace them with their squares. Would it make much difference to the solver?
Matt J
Matt J 2017년 1월 15일
편집: Matt J 2017년 1월 15일
Just be sure not to initialize the iterations with a=b=c...=0. The squaring technique makes the gradient zero there, e.g., minimizing f(b)=exp(-b) transforms to g(b)=exp(-b^2), so the iterations will not move from that point.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by