# fmincon with nonlcon does not converge to optimum value

7 views (last 30 days)
YoungChan Kim on 27 Sep 2017
Commented: YoungChan Kim on 28 Sep 2017
function [c ceq] = test_simple(x)
c=[];
ceq=x(1)*x(2);
end
clear;
clc;
fun = @(x) -x(1)^2-x(2)^2
lb = [0;0.2;];
ub = [0.5;0.8];
A = [];
b = [];
Aeq = [];
beq = [];
x0 = [0;0.1];
nonlcon=@test_simple;
options = optimset('MaxFunEvals',Inf,'MaxIter',5000,...
'Algorithm','interior-point','Display','iter');
[x1, fval1] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,optimset)
optimum value is 0 0.8 but, matlab execution value is
x1 =
0.0000
0.7153
how do i fix it?
Torsten on 27 Sep 2017
You don't have to pass "optimset" to "fmincon", but "options":
[x1, fval1] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)
Best wishes
Torsten.

Alan Weiss on 27 Sep 2017
The 'interior-point' algorithm cannot allow for points that are right on a boundary, yet your nonlinear constraint attempts to force the points to the boundary. I suggest that you do one of the following:
• Change the lower bound on x(1) to a negative number such as lb = [-0.1;0.2]
• Use the 'sqp' algorithm
• In any case, use a feasible initial point, such as [1e-8;0.3]
Also, after fmincon finishes, try running it again from the final point if the answer isn't reliable (exit flag not equal to 1).
Alan Weiss
MATLAB mathematical toolbox documentation
YoungChan Kim on 28 Sep 2017
Thank you very much ^^ this answer has helped me a lot

Walter Roberson on 27 Sep 2017
fmincon is not a global optimizer. You need one of the tools from the Global Optimization Toolbox, such as ga or particleswarm or bounded simulated annealing or patternsearch. (Note: none of those can promise to find the global minima either -- but fmincon doesn't even try.)