What happens when lsqcurvefit uses the trust region reflective algorithm?

Dear All,
I have been using lsqcurvefit to fit two curves simultaneously. The function for the fit has 3 variables to be determined.
According to lsqcurvefit help, this problem cannot be solved using the trust-region-reflective algorithm and Levenberg-Marquardt should be used instead.
However, Levenberg-Marquardt is unbounded and produces results that do not have a physical meaning in the context of my research. When I try to apply lower/upper boundaries, the warning message appears:
>> Warning: Levenberg-Marquardt and Gauss-Newton algorithms do not handle bound constraints; using trust-region-reflective algorithm instead.
But I know from the help that the trust-region-reflective algorithm cannot be used to solve my problem. Why don't I receive a warning about that?
What is lsqcurvefit doing in this case?
The plots come out nicely, but I'd like to understand better what goes on.
Below I am attaching an example of the problem described:
Function try_lsqcurvefit
%curve 1
x_1=linspace(1,2,10);
y_1=[54 85 142 249 458 890 1816 3899 8800 20875];
%curve 2
x_2=linspace(1,1.5,10);
y_2=[40 63 104 180 331 639 1302 2790 6291 14917];
%lsqcurvefit
options=optimset('Algorithm','levenberg-marquardt');
[x,resnorm] = lsqcurvefit(@myfun,[1 1 1],[x_1' x_2'],[y_1' y_2'],[0 0 0],[5 10 4],options);
%plots
figure
plot(x_1,y_1,'b',x_2,y_2,'r')
results=myfun(x,[x_1' x_2'])
hold on
plot(x_1,results(:,1),'*b',x_2,results(:,1),'*r')
end
function F=myfun(x,xdata)
F=[((x(1)*(xdata(:,1).^2))+(x(2)*exp(x(3)*(xdata(:,1).^2))))...
((x(1)*(xdata(:,2).^2))+(x(2)*exp(x(3)*(xdata(:,2).^2))))];
end

1 Comment

But I know from the help that the trust-region-reflective algorithm cannot be used to solve my problem.
Explain how you interpret the help documentation to mean that.

Sign in to comment.

Answers (1)

I met the same situation. I checked the documents of Matlab, which says the algorithm selection in the "option" is only a preference. In other words, Matlab will choose either ML or true region method based on the input automatically. So if matlab gives the warning, it has chose the true region method to solve your problem. Finally, I found that if the lower bound and upper bound vector are all assigned to void(i.e. lb=[],ub=[]), then Matlab will use the LM method without giving the warning.
Hope this can help you

Categories

Asked:

on 17 Jan 2013

Answered:

Bob
on 30 Mar 2014

Community Treasure Hunt

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

Start Hunting!