Main Content

surrogateopt에 대한 시작점 및 값 지정하기, 문제 기반

일부 솔버의 경우, 목적 함수 값과 제약 조건 함수 값(있는 경우)을 x0 인수의 solve에 전달할 수 있습니다. 이 경우 솔버에서 시간을 절약할 수 있습니다. OptimizationValues 객체로 구성된 벡터를 전달합니다. 이 벡터는 optimvalues 함수를 사용하여 만듭니다.

목적 함수 값을 사용할 수 있는 솔버는 다음과 같습니다.

  • ga

  • gamultiobj

  • paretosearch

  • surrogateopt

비선형 제약 조건 함수 값을 사용할 수 있는 솔버는 다음과 같습니다.

  • paretosearch

  • surrogateopt

예를 들어, surrogateopt를 사용해서 초기점 그리드의 값에서 시작하여 peaks 함수를 최소화합니다. x 변수에 -10부터 10까지의 그리드를 만들고, y 변수에 간격이 1/2이고 –5/2부터 5/2까지인 그리드를 만듭니다. 초기점에서 목적 함수 값을 계산합니다.

x = optimvar("x",LowerBound=-10,UpperBound=10);
y = optimvar("y",LowerBound=-5/2,UpperBound=5/2);
prob = optimproblem("Objective",peaks(x,y));
xval = -10:10;
yval = (-5:5)/2;
[x0x,x0y] = meshgrid(xval,yval);
peaksvals = peaks(x0x,x0y);

optimvalues를 사용하여 x0 인수에 값을 전달합니다. 그러면 solve가 값을 계산할 필요가 없기 때문에 solve의 시간이 절약됩니다. 값을 행 벡터로 전달합니다.

x0 = optimvalues(prob,'x',x0x(:)','y',x0y(:)',...
    "Objective",peaksvals(:)');

surrogateopt를 초기값과 함께 사용하여 문제를 풉니다.

[sol,fval,eflag,output] = solve(prob,x0,Solver="surrogateopt")
Solving problem using surrogateopt.

surrogateopt stopped because it exceeded the function evaluation limit set by 
'options.MaxFunctionEvaluations'.
sol = struct with fields:
    x: 0.2279
    y: -1.6258

fval = -6.5511
eflag = 
    SolverLimitExceeded

output = struct with fields:
        elapsedtime: 40.3154
          funccount: 200
    constrviolation: 0
               ineq: [1x1 struct]
           rngstate: [1x1 struct]
            message: 'surrogateopt stopped because it exceeded the function evaluation limit set by ...'
             solver: 'surrogateopt'

참고 항목

| |

관련 항목