what is this mean: Gradient must be provided for trust-region algorithm?
4 views (last 30 days)
Show older comments
Hi,
I have matlab code, when I run it I receive this message:
Warning: Gradient must be provided for trust-region algorithm; using line-search algorithm instead. > In fminunc at 367 In false_alarm_detection_2 at 14
Local minimum found.
Optimization completed because the size of the gradient is less than the selected value of the function tolerance.
what is that mean? and how can be solved?
Thanks
1 Comment
Sean de Wolski
on 24 May 2013
It means the default algorithm isn't suitable for the way you've called fminunc. You can just ignore the warning, it picked a different algorithm instead.
Accepted Answer
Alan Weiss
on 24 May 2013
Edited: Alan Weiss
on 24 May 2013
fmincon options describes the restrictions for the trust-region-reflective algorithm. Including Derivatives describes how you include the derivative in the objective function definition.
To avoid the warning without including a derivative, set the Algorithm option to 'interior-point' or some other algorithm:
opts = optimset('Algorithm','interior-point');
x = fmincon(objfn,x0,[],[],[],[],lb,ub,[],opts);
Take a look at the documentation examples for more information on setting gradients and options: <http://www.mathworks.com/help/optim/constrained-optimization.html>
Alan Weiss
MATLAB mathematical toolbox documentation
1 Comment
More Answers (1)
Matt J
on 24 May 2013
Edited: Matt J
on 24 May 2013
FMINUNC seems like overkill for a 1D root finding problem. Why not just use FZERO?
xv = fzero(@(x) gammainc(5,x)- vall(i) ,4);
6 Comments
Matt J
on 27 May 2013
Edited: Matt J
on 27 May 2013
so, after gammainc(5,6.982) the result will be between 0.24 and 1
Yes, but your target values of gammainc are not between 0.24 and 1. Here is the stream of vall(i) that your code produces
vall =
0.0024 0.0120 0.0240 0.1200 0.2400 1.2000 2.4000 12.0000 24.0000
As you can see, they exceed 1 for i>=6. As Alan said, it is not possible for gammainc(5,x) to reach a value greater than 1.
See Also
Categories
Find more on Calculus 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!