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!