relative vs absolute first order optimality

Hi all, I have another question about first order optimality.
Consider the following code:
y = @(x) x^3+5*x+2;
y2 = @(x) x^2+5*x-4;
A = [-1; 1];
b = [5; 5];
const = @(x) [-x-5, x-5];
options.Algorithm = 'interior-point';
options.TolFun = 1e-6;
[optx, z, exitflag,output,lambda,grad,hessian] = fmincon(y,0,A,b,[],[],[],[], [],options);
[opt2x,z2,exitflag2,output2,lambda2,grad2,hessian2] = fmincon(y2,0,A,b,[],[],-100,100, [],options);
Okay, there's a cubic (not minimizable) and a quadratic (minimizable).
I know the default optimality tolerance is 1e-6 and algorithm is interior point, but just making sure.
output2.firstorderopt = 8.0111e-07 < 1e-6 :)
output.firstorderopt = 7.4865e-05 > 1e-6 :(
Now for the first case, if I click on the command window, I get this:
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the value of the optimality tolerance,
and constraints are satisfied to within the value of the constraint tolerance.
<stopping criteria details>
Optimization completed: The relative first-order optimality measure, 9.358141e-07,
is less than options.OptimalityTolerance = 1.000000e-06, and the relative maximum constraint
violation, 0.000000e+00, is less than options.ConstraintTolerance = 1.000000e-06.
So the relative first order opt is less than 1e-6, but that's after dividing absolute by the gradient, which is equal to 80 (b/c the optimal point is at the boundary).
Okay, but there's still a conundrum because for the other case, where the optimal point is between the bounds, output2.firstorderopt is equal to the relative first order optimality I get from this message. I mean, if it divided absolute by the gradient, which is very close to 0, it would be in big trouble.
How does MATLAB decide which one to use, can I predict this before/after, and is there a way to force it to just use absolute optimality all the time?

1 Comment

So I found this:
It suggests that the factor used is the first order optimality of the initial case. That doesn't seem like a very consistent termination condition to me. Wouldn't that mean your solver tries harder or not based on the quality of your initial guess? Or is this answer correct?

Sign in to comment.

Answers (0)

Products

Release

R2020b

Asked:

on 2 Nov 2020

Commented:

on 2 Nov 2020

Community Treasure Hunt

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

Start Hunting!