Comparar fminimax
y fminunc
Un problema minimax minimiza el máximo de un conjunto de funciones objetivo. ¿Por qué no minimizar esta función de máximo, que es una función escalar? La respuesta es que el máximo no es suave, y los solvers de Optimization Toolbox™, como fminunc
, requieren suavidad.
Por ejemplo, defina fun(x)
como tres funciones objetivo lineales en dos variables, y fun2
como el máximo de estos tres objetivos.
a = [1;1]; b = [-1;1]; c = [0;-1]; a0 = 2; b0 = -3; c0 = 4; fun = @(x)[x*a+a0,x*b+b0,x*c+c0]; fun2 = @(x)max(fun(x),[],2);
Represente el máximo de estos tres objetivos.
[X,Y] = meshgrid(linspace(-5,5)); Z = fun2([X(:),Y(:)]); Z = reshape(Z,size(X)); surf(X,Y,Z,'LineStyle','none') view(-118,28)
fminimax
encuentra el punto minimax con facilidad.
x0 = [0,0]; [xm,fvalm,maxfval] = fminimax(fun,x0)
Local minimum possible. Constraints satisfied. fminimax stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance.
xm = 1×2
-2.5000 2.2500
fvalm = 1×3
1.7500 1.7500 1.7500
maxfval = 1.7500
Sin embargo, fminunc
se detiene en un punto que está lejos del punto minimax.
[xu,fvalu] = fminunc(fun2,x0)
Local minimum possible. fminunc stopped because it cannot decrease the objective function along the current search direction.
xu = 1×2
0 1.0000
fvalu = 3.0000
fminimax
encuentra una solución mejor (más pequeña).
fprintf("fminimax finds a point with objective %g,\nwhile fminunc finds a point with objective %g.",maxfval,fvalu)
fminimax finds a point with objective 1.75, while fminunc finds a point with objective 3.