why is the fminsearch output depending upon the initial guess?
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponses (5)
John D'Errico
le 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.
0 commentaires
Mike
le 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.
0 commentaires
Nikolay
le 1 Mai 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 commentaires
Daniel Shub
le 1 Mai 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.
Sargondjani
le 1 Mai 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)
0 commentaires
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!