このページは機械翻訳を使用して翻訳されました。最新版の英語を参照するには、ここをクリックします。
ソルバーを実行する
実行を呼び出して最適化する
ソルバーの実行方法は、GlobalSearch と MultiStart でほぼ同じです。構文の唯一の違いは、MultiStart が開始点を記述する追加の入力を取ることです。
例えば、sixmin関数のいくつかの極小値を見つけたいとします。
6分 = 4 x2 – 2.1 x4 + x6/3 + xy – 4 y2 + 4 y4.

この関数は、6 つのこぶを持つラクダの背関数 [3] とも呼ばれます。すべての局所最小値は –3 ≤ x,y ≤ 3 領域内にあります。
GlobalSearchでの実行例
GlobalSearch を使用して sixmin 関数のいくつかの局所最小値を見つけるには、次のように入力します。
% % Set the random stream to get exactly the same output % rng(14,'twister') gs = GlobalSearch; opts = optimoptions(@fmincon,'Algorithm','interior-point'); sixmin = @(x)(4*x(1)^2 - 2.1*x(1)^4 + x(1)^6/3 ... + x(1)*x(2) - 4*x(2)^2 + 4*x(2)^4); problem = createOptimProblem('fmincon','x0',[-1,2],... 'objective',sixmin,'lb',[-3,-3],'ub',[3,3],... 'options',opts); [xming,fming,flagg,outptg,manyminsg] = run(gs,problem);
実行の出力(ランダムシードに応じて変化します):
xming,fming,flagg,outptg,manyminsg
xming =
0.0898 -0.7127
fming =
-1.0316
flagg =
1
outptg =
struct with fields:
funcCount: 2115
localSolverTotal: 3
localSolverSuccess: 3
localSolverIncomplete: 0
localSolverNoSolution: 0
message: 'GlobalSearch stopped because it analyzed all the trial po...'
manyminsg =
1x2 GlobalOptimSolution array with properties:
X
Fval
Exitflag
Output
X0MultiStart での実行例
fmincon と MultiStart を 50 回実行して sixmin 関数のいくつかの局所最小値を見つけるには、次のように入力します。
% % Set the random stream to get exactly the same output % rng(14,'twister') ms = MultiStart; opts = optimoptions(@fmincon,'Algorithm','interior-point'); sixmin = @(x)(4*x(1)^2 - 2.1*x(1)^4 + x(1)^6/3 ... + x(1)*x(2) - 4*x(2)^2 + 4*x(2)^4); problem = createOptimProblem('fmincon','x0',[-1,2],... 'objective',sixmin,'lb',[-3,-3],'ub',[3,3],... 'options',opts); [xminm,fminm,flagm,outptm,manyminsm] = run(ms,problem,50);
実行の出力(ランダムシードに応じて変化します):
xminm,fminm,flagm,outptm,manyminsm
xminm =
0.0898 -0.7127
fminm =
-1.0316
flagm =
1
outptm =
struct with fields:
funcCount: 2034
localSolverTotal: 50
localSolverSuccess: 50
localSolverIncomplete: 0
localSolverNoSolution: 0
message: 'MultiStart completed the runs from all start points.…'
manyminsm =
1x6 GlobalOptimSolution array with properties:
X
Fval
Exitflag
Output
X0この場合、MultiStart は 6 つの局所最小値すべてを特定しましたが、GlobalSearch は 2 つを特定しました。MultiStart ソリューションの画像については、引き込み領域を視覚化する を参照してください。
