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

1 view (last 30 days)
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 Comments
Matt J
Matt J on 15 Jan 2017
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 on 16 Jan 2017
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.

Sign in to comment.

Answers (1)

John D'Errico
John D'Errico on 15 Jan 2017
Edited: John D'Errico on 15 Jan 2017
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 Comments
Vipultomar
Vipultomar on 15 Jan 2017
Edited: Vipultomar on 15 Jan 2017
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 on 15 Jan 2017
Edited: Matt J on 15 Jan 2017
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.

Sign in to comment.

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!