In this code:
x0 = [1 1];
UB = [1 1];
LB = [0 0];
options = optimset('LargeScale', 'off', 'MaxFunEvals', 1000, 'TolFun', 1e-6, 'TolCon', 1e-6, 'disp', 'off');
n = 50;
eps_min = -1; eps_max = 0;
epsval = eps_min:(eps_max - eps_min)/(n-1):eps_max;
xopt = zeros(n,length(x0));
xopt(i,:)=fmincon('obj_eps', x0, , , , , LB, UB,...
'nonlcon_eps', options, epsval(i));
function [C,Ceq] = nonlcon_eps(x, epsval)
Ceq = ;
C(2) = -x(1) - epsval;
xopt(1,:) = [0.999999999395037, 2.08338048669441e-10]
has been obtaind by fmincon() . However, when I use it to get the constraints value, the results were:
C(1) = 2.0834e-10
C(2) = 6.0496e-10
C(1) and C(2) are > 0, the solution xopt(1,:) violated the constraints. Therefore, it should not be returned by fmincon().
I could not understand why the fmincon() returned it as a best solution?