why is the fminsearch output depending upon the initial guess?

10 views (last 30 days)
Hi, Im using fminsearch to calibrate a camera. The reprojection error is a smooth function which attains minimum at a certain value. Im trying to find this value numerically. If I set a starting point really close to the minimum, it finds the minimum but even if the initial guess is a little off, fminsearch stops a little way off from the minimum. How is it that the solution does not reach the true minimum?

Answers (5)

John D'Errico
John D'Errico on 25 Jan 2011
A third possibility beyond that which Mike gives - your function is very flat near the solution. fminsearch looks at it, and decides that any point in that vicinity is effectively the same, so it happily quits once the simplex is small enough.
You need to know how fminsearch exits. Is it returning a specific exitflag? There are several possible exitflags. A zero return value tells you that it exceeded the allowed iterations. A one return value tells you that it has converged as far as it is concerned, so either your problem has multiple solutions, or the objective is flat.
Look at your surface. Test it with various test points if you are unsure. Change the tolerances, TolX and TolFun, using optimset as Mike has shown you.

Mike
Mike on 25 Jan 2011
Two possibilities spring to mind. The first is that your function has many local minima and fminsearch is stopping at one of those rather than the global minimum that you really want.
Another possibility is that you have evaluated your objective function so many times that it has exceeded either the MaxFunEvals or MaxIter limits. These are normally 200*number of variables. So, if you have only one optimisation variable then fminsearch will stop at 200 iterations whether or not it has found the minimum.
Here's how you might change this
optims=optimset('fminsearch');
optims.MaxIter = 1000;
optims.MaxFunEvals = 1000;
x = fminsearch(fun,x0,options)
Assuming that your objective function is called 'fun' and your starting point is contained in x0.

Soumen Banerjee
Soumen Banerjee on 27 Jan 2011
Hi, Ive increased the MaxFunEval and MaxIter values to a point where the the search quits due to termination rather than over-running these parameters. It still finds other points to be optimum. My function has 11 variables, so checking out the surface is pretty difficult. I know Im supposed to be using fminunc for such a large number of variables but some license issues are preventing me from doing so. I have seen sections of the function along all 11 of these variables only to find absolutely no reason other minima should exist. it shows a smooth descent and a smooth ascent. The function is pasted here http://pastebin.com/GJ3U5Kux Here's how it is called-
ftp = [-1.5 -13 27]*pi/180; Pcam0 = [-0.96 -0.48 -0.28]; TH0 = [360 235 2785 2785 ftp Pcam0]; options=optimset('MaxFunEvals',10000,'MaxIter',10000,'Display','Iter'); THopt=fminsearch(@(TH)krd2(TH),TH0,options);
The point is, if you put TH0*1.05 into the starting value, it will terminate elsewhere. I dont understand what is going on here, please help..

Nikolay
Nikolay on 1 May 2012
I've increased the number of MaxFunEvals and MaxIter to 100,000 Matlab began working for a while, then the cursor appeared but matlab neither retrieved any information nor is accepting new commands. What has happened and how can I abort?
  2 Comments
Daniel Shub
Daniel Shub on 1 May 2012
I don't see how this is an answer to the question. This appears to be a new, but related, question. You should consider deleting this answer and asking it as a new question.
Nikolay
Nikolay on 1 May 2012
sorry about that, I didn't want to clutter the forum

Sign in to comment.


Sargondjani
Sargondjani on 1 May 2012
try increasing the accuracy (set TolFun, TolX at smaller values, ie. 1e-12)
scaling the problem might also help (such that the TolFun is about equal in size for all variables in the optimum)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!