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

2 次查看(过去 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