Main Content

이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.

fminimaxfminunc 비교하기

최대최소화 문제는 일련의 목적 함수의 최댓값을 최소화합니다. 왜 스칼라 함수인 최댓값 함수를 최소화하지 않는 것일까요? 이는 최댓값이 매끄럽지 않고 fminunc 같은 Optimization Toolbox™ 솔버는 매끄러움이 필요하기 때문입니다.

예를 들어 fun(x)를 두 변수로 구성된 3개의 선형 목적 함수로 정의하고 fun2를 이 3개 목적 함수의 최댓값으로 정의합니다.

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

3개 목적 함수의 최댓값을 플로팅합니다.

[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.

fminimax는 최대최소화 점을 쉽게 찾습니다.

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

그러나 fminunc는 최대최소화 점에서 한참 떨어진 점에서 중지됩니다.

[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가 더 나은(더 작은) 해를 구합니다.

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.

참고 항목

관련 항목