Borrar filtros
Borrar filtros

fminsearch - find best x0

2 visualizaciones (últimos 30 días)
N
N el 1 de Feb. de 2016
Respondida: John D'Errico el 1 de Feb. de 2016
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??

Respuesta aceptada

Walter Roberson
Walter Roberson el 1 de Feb. de 2016
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 comentarios
N
N el 1 de Feb. de 2016
Editada: N el 1 de Feb. de 2016
thank you for your answer, what do i need to do if there are multiple smallest values?
Walter Roberson
Walter Roberson el 1 de Feb. de 2016
Then pick any of them, because it does not matter.

Iniciar sesión para comentar.

Más respuestas (1)

John D'Errico
John D'Errico el 1 de Feb. de 2016
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.

Categorías

Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by