Local Minimum possible - exit flag 2 - Non linear optimisation problem with Non-linear constraints.

10 views (last 30 days)
Dear all,
This is my optimisation settings,
%% Optimisation settings
lb = [];
ub = [];
% options = optimoptions(@fmincon,'Algorithm','sqp','SpecifyConstraintGradient',true,'CheckGradients',true,'DiffMinChange',0.0000000089205,'StepTolerance',1.0000e-12,'MaxFunctionEvaluations',10000000,'plotFcns',{@optimplotx,@optimplotconstrviolation,@optimplotfval,@optimplotfirstorderopt},'Display','iter');
options = optimoptions(@fmincon,'Algorithm','sqp','DiffMinChange',0.0000000089205,'StepTolerance',1.0000e-12,'MaxFunctionEvaluations',10000000,'plotFcns',{@optimplotx,@optimplotconstrviolation,@optimplotfval,@optimplotfirstorderopt},'Display','iter');
[pos_opt,fval,exitflag,output,lambda,grad,hessian] = fmincon(@(pos_init) objective(pos_init,XX,YY),pos_init,[],[],[],[],lb,ub,@(pos_init) nonlinconst(pos_init),options);
My optimisation problem stops with the following final output,
Iter Func-count Fval Feasibility Step Length Norm of First-order
step optimality
60 1553 6.209509e-01 0.000e+00 7.000e-01 1.204e-02 1.075e-02
61 1578 6.208916e-01 0.000e+00 1.000e+00 1.116e-02 3.934e-03
62 1603 6.208123e-01 0.000e+00 1.000e+00 4.193e-02 1.638e-02
63 1632 6.207893e-01 0.000e+00 2.401e-01 4.117e-02 4.864e-02
64 1711 6.207893e-01 0.000e+00 5.791e-13 9.406e-12 4.864e-02
fmincon stopped because the size of the current step is less than
the value of the step size tolerance and constraints are
satisfied to within the value of the constraint tolerance.
Optimization stopped because the relative changes in all elements of x are
less than options.StepTolerance = 1.000000e-12, and the relative maximum constraint
violation, 0.000000e+00, is less than options.ConstraintTolerance = 1.000000e-06.
When I decrease the step tolerance to 1e-20 or even lesser, i am getting repetitive values and the Local minum is not acheived.
So I want to know, is this the best result I could get for my problem? or am I missing something?
If you need any further details to help me out with the problem, please feel free to ask in the comments, I will provide you with all the relevant information.

Answers (1)

John D'Errico
John D'Errico on 23 May 2020
Setting the tolerances to some absurdly tiny number is something I frequently see people do. It almost never seems to improve things, and as you see in this case, apparently made things worse.
The solution that fmincon arrived at appears to be a solution, in the sense that it could not make any further progress from that point. Cranking down on the tolerances as tightly as you did was the algorithmic equivalent of using a whip and insisting the code should try harder.
That it stopped where it did may be a relfection that it got into a bad spot, or perhaps there is a problem with the objective function as posed. Note that not all optimization problems are well posed, with unique solutions. A far better approach is to try starting the solver from a different point. Does it still terminate with essentially the same solution at the same point? Does it terminate with the same exit flag and the same objective function value, but at a different point?
  2 Comments
Selvaprakash Vijayaraman
Selvaprakash Vijayaraman on 23 May 2020
Thank you so much for your response.
Yes I agree with you on the tolerance settings.
When I tried to start the solver with a different initial point, it terminates with the same exit flag and the same objective function value but slightly at a different point.
What should I do to get the Local minimum point? or is this the best solution I could get for my problem?
John D'Errico
John D'Errico on 23 May 2020
It is pretty easy to pose a problem that converges to an equally valid (but different) solution based on the start point.
[xymin,fval,exitflag] = fmincon(@(xy) sin(xy(1) - xy(2)),rand(1,2))
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>
xymin =
-0.299603067336948 1.2711932517434
fval =
-1
exitflag =
1
I was hoping this would terminate with an exitflag of 2 but it gave me 1. Anyway, as long as
x-y= -pi/2 + 2*n*pi
I should find an equally valid solution, but it would be at an arbitrarily different point based on the start point. The solver cannot know that I have posed an essentially impossible problem to solve however.
I don't see your complete problem, so I do not know how many dimensions it is in. However, if this were a low dimensional thing, I would plot it. Look, for example at a contour plot in the vicinity of the solution. What behavior does the function show? In the 2-d example I show, we would see contours that would make clear the behaviour I described.
I might also look at the Hessian matrix. Although do not trust the Hessian matrix returned by fmincon as being correct. This is only an updated approximation to the matrix as fmincon iterates towards the solution. For example...
[xymin,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = fmincon(@(xy) sin(xy(1) - xy(2)),rand(1,2));
xymin
xymin =
-0.400701337952194 1.17009498139961
>> HESSIAN
HESSIAN =
1.50001529889884 -0.500005665092141
-0.500005665092141 1.49999603134215
>> [H,Herr] = hessian(@(xy) sin(xy(1) - xy(2)),xymin)
H =
0.999999999999906 -0.999999999614284
-0.999999999614284 0.999999999999799
Herr =
1.96993212428807e-12 3.53175112863009e-09
3.53175112863009e-09 2.50842857490531e-13
The function hessian is one from my derivest suite of tools, as found on the file exchange. It uses adaptive finite differences to approximate the Hessian matrix at some point.
eig(H)
ans =
3.85568243999046e-10
1.99999999961414
As you can see, the matrix appears to be quite close to singular, though not exactly so due to the use of finite differences. That would suggest to me I have an objective function with a problem. I could have used the symbolic toolbox here to get a better Hessian for this simple problem of course.
But I might question if your problem is well posed, with a unique solution.
You might also consider using tools from the global optimization toolbox, to see if it can find a better solution.

Sign in to comment.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!