복수 시작점 솔버를 사용하여 비선형 함수 최소화하기, 문제 기반
점 [–1,2]
에서 시작하여 범위 에서 peaks
함수의 국소 최솟값을 구합니다.
x = optimvar("x",LowerBound=-5,UpperBound=5); y = optimvar("y",LowerBound=-5,UpperBound=5); x0.x = -1; x0.y = 2; prob = optimproblem(Objective=peaks(x,y)); opts = optimoptions("fmincon",Display="none"); [sol,fval] = solve(prob,x0,Options=opts)
sol = struct with fields:
x: -3.3867
y: 3.6341
fval = 1.1224e-07
GlobalSearch
솔버를 사용하여 더 나은 해를 구해 봅니다. 이 솔버는 fmincon
을 여러 번 실행하므로 더 나은 해를 얻을 수 있습니다.
ms = GlobalSearch; [sol2,fval2] = solve(prob,x0,ms)
Solving problem using GlobalSearch. GlobalSearch stopped because it analyzed all the trial points. All 15 local solver runs converged with a positive local solver exit flag.
sol2 = struct with fields:
x: 0.2283
y: -1.6255
fval2 = -6.5511
GlobalSearch
는 더 나은(더 낮은) 목적 함수 값을 갖는 해를 구합니다. 종료 메시지가 로컬 솔버 fmincon
이 15번 실행된다는 것을 보여줍니다. 반환된 해는 약 –6.5511인 목적 함수 값을 가지며, 이 값은 첫 번째 해에서의 값인 1.1224e–07보다 낮습니다.
참고 항목
GlobalSearch
| MultiStart
| run
| solve