fminsearch - find best x0
2 次查看(过去 30 天)
显示 更早的评论
Hi i was wondering how to best use the function fminsearch. I determine a x0 for this function and get a result but this result changes when I change my x0 parameter. How can I best optimize my x0 suggestion? Run a loop for multiple x0's and take the mean??
0 个评论
采纳的回答
Walter Roberson
2016-2-1
With each x0 you can have the value of the objective displayed. You would take the x0 that gave you the smallest objective value.
2 个评论
更多回答(1 个)
John D'Errico
2016-2-1
If there were a simple way to find the BEST starting point, then it would be used already. As it is, that is what optimization is, finding a minimal solution from a starting point.
The problem is, there are often multiple local minimizers. So if you start from a point that gets you to one of the non-globally optimal solutions, then that is what you get. Choose better starting values next time.
Do NOT use multiple starting values, then take the average of the results!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! It is easily shown that this may lead you to garbage for results. For example, find the minimum of the function cos(x), with several start points. Try it. See what happens.
x1 = fminsearch(@cos,2)
x1 =
3.1416015625
x2 = fminsearch(@cos,-2)
x2 =
-3.1416015625
So, now take the average of these results:
x3 = (x1 + x2)/2
x3 =
0
Taking the average worked rather poorly. Instead of a minimizer, the average of two minimizers actually got us to a point that is a local MAXIMIZER.
A good plan is to simply use multiple start points, taking the best (i.e., lowest function value) solution from among them. You can also use the global optimization toolbox to help you with some of this, although even that toolbox cannot guarantee a truly global solution.
Finally, in some cases (hard to know since we don't know your problem) you can improve things by the careful application of mathematics to a problem.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!