Problem using fmincon to find a constrained minimum

Hello,
I have a problem using fmincon to optimize a function. I have an iterative function. my code is:
function [dy,tanbnew,rt]=fresnel_b(h,n2,m,r,F)
i=1
while i<=ceil(m/2)
dy(i)=0;
dytemp=100;
while abs(dy(i)-dytemp)>0.01
dytemp=dy(i);
aprov=atan(r/(F-h/2));
tanbnew(i)=sin(aprov)/(n2-cos(aprov));
dy(i)=h/tanbnew(i);
end
rt(i)=r;
r=r-dy(i);
i=i+1;
end
width=sum(dy(1:end-1))+dy(end)/2;
and
function [c, ceq]=mycon2(h,n2,m,r,F)
i=1;
while i<=ceil(m/2)
dy(i)=0;
dytemp=100;
while abs(dy(i)-dytemp)>0.01
dytemp=dy(i);
aprov=atan(r/(F-h/2));
tanbnew(i)=sin(aprov)/(n2-cos(aprov));
dy(i)=h/tanbnew(i);
end
rt(i)=r;
r=r-dy(i);
i=i+1;
end
width=sum(dy(1:end-1))+dy(end)/2;
c=-dy;
ceq=width-rt(1)/2;
and
clear,close all
format long
n1=1;
n2=1.5;
d=10;
F=20;
m=21;
h=0.1;
j=1;
r=d/2;
i=1;
fun=@(h)(fresnel(h,n2,m,r,F)-d/2);
con=@(h)mycon2(h,n2,m,r,F);
[h,fval]=fmincon(fun,h,[],[],[],[],[],[],con);
When i run the code it find a minimun but it's not right! A warning message appears in the command window
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 function tolerance, and constraints are satisfied to within the default value of the constraint tolerance.
I don't completly understand thi message, as a consequence i have no idea how to deal with it! Any help would be appreciated. Thanks in advance...

2 Comments

Please write the function to be minimized and the constraint you impose in mathematical notation.
Best wishes
Torsten.
Ok. I need to warn you that I'm not the best writing in mathematical notation. Anyway in the attached figure there is the problem written as good as i could! As I anticipated is an iterative problem, I have to repeat the equations several times. (I'm remarking this because I'm not sure it was clear from my notation). In the notation there is nothing about the while loop in the middle (while abs(dy(i)-dytemp)>0.01), that is only a local optimization which I think it's not going to change the global optimization procedure.

Sign in to comment.

Answers (1)

The exit message does not indicate a problem; in fact, it indicates that fmincon arrived at a true local minimum.
Alan Weiss
MATLAB mathematical toolbox documentation

2 Comments

I understand but it is not the "minimum" I need. I know it because manually changing the h value I can easily obtain a better optimization. The message does not indicate a problem but i know for sure there is one!!!
Then you need to use better starting values. Or you need to use a tool that can do global optimization. Fmincon returns only ONE solution. If that solution is a local one (although still greater than the global solution) based on the starting values it was supplied, then it will return the solution that it finds. It cannot know there is a better solution out there.
Think of fmincon as a blind person placed on the surface of the earth, and tasked with finding the lowest spot (I hope you supplied scuba gear.) It can only look at the local neighborhood it is started in, and searches from there. If you put it in the wrong place, the solver will stop in a non-optimal spot, although locally the lowest spot in that area.

Sign in to comment.

Tags

Asked:

on 4 Dec 2015

Commented:

on 5 Dec 2015

Community Treasure Hunt

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

Start Hunting!