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!