Main Content

Comparefminimaxandfminunc

A minimax problem minimizes the maximum of a set of objective functions. Why not minimize this maximum function, which is a scalar function? The answer is that the maximum is not smooth, and Optimization Toolbox™ solvers such asfminuncrequire smoothness.

For example, definefun(x)as three linear objective functions in two variables, andfun2as the maximum of these three objectives.

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);

Plot the maximum of the three objectives.

[X,Y] = meshgrid(linspace(-5,5)); Z = fun2([X(:),Y(:)]); Z = reshape(Z,size(X)); surf(X,Y,Z,'LineStyle','none') view(-118,28)

Figure contains an axes object. The axes object contains an object of type surface.

fminimaxfinds the minimax point easily.

x0 = [0,0]; [xm,fvalm,maxfval] = fminimax(fun,x0)
局部最小值。约束满足。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×31.7500 1.7500 1.7500
maxfval = 1.7500

However,fminuncstops at a point that is far from the minimax point.

[xu,fvalu] = fminunc(fun2,x0)
局部最小值。fminunc stopped because it cannot decrease the objective function along the current search direction.
xu =1×20 1.0000
fvalu = 3.0000

fminimaxfinds a better (smaller) solution.

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.

See Also

Related Topics