Optimizing a function from a given set?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mohamed Larabi
el 17 de Jun. de 2018
Comentada: Walter Roberson
el 17 de Jun. de 2018
Is there a way to find the optimal value of a minimized function from a given set of solutions?
Here is an example of what I would like to do:
For x in {0,0.5,1}, solve: x = arg max f(x).
I think I would need a variation of "fminbnd", as this one uses a given interval of solutions, while I need a given set of solutions.
Any suggestion would be very much appreciated. Thank you
0 comentarios
Respuesta aceptada
Walter Roberson
el 17 de Jun. de 2018
For an explicit list of arguement values, x:
[bestfval, bestidx] = max(arrayfun(@f, x))
bestx = x(bestidx);
If the function is fully vectorized then
[bestfval, bestidx] = max(f(x(:)));
bestx = x(bestidx);
2 comentarios
Walter Roberson
el 17 de Jun. de 2018
If the task is to find the y that maximizes x*f(y) for each given x, then the answer is going to be the same as the y that maximizes f(y) without considering the x because multiplication by positive x is a linear operator. If some of the x could be negative and some positive then you could have a more interesting situation.
Más respuestas (1)
Mohamed Larabi
el 17 de Jun. de 2018
1 comentario
Walter Roberson
el 17 de Jun. de 2018
If f(y) is given, then the x that maximizes x*f(y) is:
if f(y) > 0
bestx = max(x);
elseif f(y) < 0
bestx = min(x);
else
all finite non-nan entries in x give the same result
end
Ver también
Categorías
Más información sobre Optimization 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!