nonlinear constraints violated by fmincon in output with sqp and interior point algorithms
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
John Terilla
am 15 Jul. 2016
Kommentiert: GKH
am 18 Dez. 2017
I'm trying to use fmincon to solve an optimization problem with nonlinear equality constraints. If I use the objective function @(x) 0 then fmincon finds solutions that satisfy the constraints.
However, when I use the actual objective function 'phi' that I'm interested in, fmincon converges to infeasible points. I've supplied the constraints with gradients and checked that the gradients are correct.
From the documentation, I thought that 'sqp' and 'interior-point' algorithms satisfy constraints at all steps, but that doesn't seem to be the case for me. Is there a way for me to force the constraints to be satisfied ?
>> testf=@(x) 0;
>> options = optimoptions(@fmincon, 'Display', 'iter', 'Algorithm','sqp','SpecifyConstraintGradient',true);
>> [x,fval,exitflag,output] = fmincon(testf,x0,[],[],Aeq,beq,[],[],mycon,options);
Norm of First-order
Iter F-count f(x) Feasibility Steplength step optimality
0 241 0.000000e+00 3.142e+01 0.000e+00
1 482 0.000000e+00 7.660e+00 1.000e+00 3.874e+00 3.917e-01
2 723 0.000000e+00 1.719e+00 1.000e+00 1.830e+00 2.343e-01
3 964 0.000000e+00 3.148e-01 1.000e+00 7.764e-01 3.408e-02
4 1205 0.000000e+00 3.682e-02 1.000e+00 2.552e-01 3.380e-02
5 1446 0.000000e+00 3.354e-03 1.000e+00 7.941e-02 3.197e-02
6 1687 0.000000e+00 8.161e-04 1.000e+00 3.829e-02 1.804e-02
7 1928 0.000000e+00 2.286e-04 1.000e+00 2.003e-02 9.960e-03
8 2169 0.000000e+00 9.448e-05 1.000e+00 1.240e-02 9.707e-03
9 2411 0.000000e+00 8.976e-05 7.000e-01 1.003e-02 1.703e-02
10 2652 0.000000e+00 4.688e-05 1.000e+00 8.007e-03 6.804e-02
11 2893 0.000000e+00 2.772e-06 1.000e+00 1.995e-03 1.814e-02
12 3134 0.000000e+00 2.522e-09 1.000e+00 6.914e-05 3.462e-04
> In stopTestSQP
In sqpLineSearch
In fmincon (line 807)
Warning: Rank deficient, rank = 7, tol = 1.065814e-13.
13 3375 0.000000e+00 5.596e-14 1.000e+00 4.943e-07 0.000e+00
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the optimality tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.
And I can check it:
>> [c ceq]=mycon(x)
c =
[]
ceq =
1.0e-13 *
0.4197
0.4849
0.4849
0.5596
0.5163
-0.3947
-0.3947
0.4596
So I'm satisfied with the constraint. But now,
>> [xx,fval,exitflag,output] = fmincon(phi,x,[],[],Aeq,beq,[],[],mycon,options);
Norm of First-order
Iter F-count f(x) Feasibility Steplength step optimality
0 241 2.010037e+03 5.596e-14 4.875e+02
1 483 1.190043e+03 3.415e+00 1.000e+00 1.732e+00 2.438e+02
2 724 1.184067e+03 3.426e+00 1.000e+00 1.976e+00 1.649e+02
3 966 -6.682926e+02 3.907e+02 7.000e-01 2.145e+01 2.209e+03
4 1214 -8.078034e+02 3.972e+02 8.235e-02 9.463e+00 4.025e+02
...
79 23098 -1.583155e+03 3.897e+02 1.636e-14 6.390e-04 1.216e+02
80 23429 -1.583191e+03 3.897e+02 1.636e-14 6.371e-04 1.214e+02
81 23760 -1.583226e+03 3.897e+02 1.636e-14 6.331e-04 1.212e+02
82 24091 -1.583260e+03 3.897e+02 1.636e-14 6.322e-04 1.210e+02
Solver stopped prematurely.
fmincon stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 24000 (the default value).
Checking this, and I see the constraints are violated.
>> [c ceq]=mycon(xx)
c =
[]
ceq =
224.5184
106.4913
106.4913
262.0540
-33.3208
-45.3544
-45.3544
389.7484
>>
I understand that the solver exited prematurely, but I believe the problem with the constraints is illustrated. The problem exists with 'interior-point' algorithms also. With other initial data, fmincon exits with exitflag -2 and displays the following output:
Converged to an infeasible point.
fmincon stopped because the size of the current step is less than
the default value of the step size tolerance but constraints are not
satisfied to within the default value of the constraint tolerance.
Since fmincon has the capability to satisfy the constraints by ignoring the objective function, I imagine there is there a way for me to force the constraints to be satisfied when I use the objective function that I care about. My question is: is there a way for me to force the constraints to be satisfied ?
0 Kommentare
Akzeptierte Antwort
Alan Weiss
am 15 Jul. 2016
You misunderstand the documentation: the 'sqp' and 'interior-point' algorithms satisfy BOUNDS at all iterations, not nonlinear constraints.
For your problem, it is clear that the merit function that the solvers use internally is not working well. This merit function balances the two goals of lowering infeasibility and lowering the objective function. Therefore, I suggest that you artificially make your constraint function much larger, to have fmincon pay more attention to it. Multiply mycon by 1e4 or so (that is, have mycon return a value that is a large factor multiplied by the true constraint value)and see whether that helps.
Alan Weiss
MATLAB mathematical toolbox documentation
2 Kommentare
GKH
am 18 Dez. 2017
Hi Alan, does the same explanation apply to the lineae inequalities as well? In my problem, I do not have a nonlinear constraint but I do have values for A and b in the fmincon definition
(x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options))
In my simulations, the constraints defined via A and b are also violated.
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!