フィルターのクリア

Why does FMINCON finds a solution even when constraints are not satisfied?

2 ビュー (過去 30 日間)
Martha
Martha 2016 年 9 月 1 日
回答済み: John D'Errico 2016 年 9 月 1 日
Hi,
I'm using FMINCON solver as I need to set up Nonlinear 'OR' constraints (similar to this:http://uk.mathworks.com/help/optim/ug/or-instead-of-and-constraints.html). I'm basically searching whether some fixed points can be accommodated in feasible areas, and for that I'm using the nonlinear constraints. In theory if a feasible solution is found, the inequality constraint c is negative. However, I'm getting positive results in the vector c, and exitflags of 1, and FMINCON finds a solution and retrieve a value, however, it is wrong and I'm using that for further steps. Here is the constraint function and the lines where I call the solver:
function [c,ceq] = ConstraintsOR3n2 (x,e,t)
ex=e-e(1);ex(1)=e(1);u=1:2:length(t);
for i = u
Fx1(i)=minDist3(x+ex(1),t(i),t(i+1))
Fx2(i)=minDist3(x,t(i),t(i+1))
Fx3(i)=minDist3(x-ex(2),t(i),t(i+1))
end
Fx1=Fx1(u); Fx2=Fx2(u); Fx3=Fx3(u); %Fx4=Fx4(u);
c(1)=min(Fx1);c(2)=min(Fx2);c(3)=min(Fx3);
options=optimset('Algorithm','interior-point','Display','iter', 'FunValCheck','on');
[x, fval, exitflag]= fmincon(@(x) ObjFunction3n2(x,t,e), x0, [], [], [], [], [], [], @(x)ConstraintsOR3n2(x,e,t), options)
I appreciate very much if someone can give me clue of why is this happening, as I don't understand where is the error, I've checked plenty of times and for some runs where the exitflag is 1, the actual solution does not met the constraints.
Thanks a lot
Martha

採用された回答

John D'Errico
John D'Errico 2016 年 9 月 1 日
You might want to read about what the constraint tolerance means for fmincon. Constraints can be violated by a small amount in general.
Welcome to the wonderful, wacky world of floating point arithmetic.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by