このページは機械翻訳を使用して翻訳されました。最新版の英語を参照するには、ここをクリックします。
問題ベースのMultiStartの開始点を指定する
問題ベースのアプローチで MultiStart を使用して問題を解決する場合、次のいずれかまたは両方の手法を使用して開始点を指定できます。
optimvalues関数を使用してOptimizationValuesオブジェクトのベクトルを作成します。このベクトルをx0引数としてsolveに渡します。solveを呼び出すときに、MinNumStartPoints名前値引数を設定します。MinNumStartPointsがx0のポイント数を超える場合、solveは問題の範囲内でランダムに追加のポイントを作成します。
初期点のベクトル
この例では、-10 から 10 までの整数値で構成される変数 x と、–5/2 から 5/2 までの半整数値で構成される変数 y のグリッドとして初期点 ベクトルを作成します。optimvalues 関数には問題が必要なので、目的関数が peaks(x,y) である最適化問題を作成します。
optimvalues のポイントは、ポイント数の次元 (インデックス) が最後になるように指定する必要があります。例えば、スカラーtの値をn点で複数指定するには、次のように指定します。
(これは 1 行 n 列で、n が最後のインデックスです。)
長さ2のベクトル変数wに複数の値を与えるには、次のように指定します。
(これは 2 行 n 列で、n が最後のインデックスです。)
この規則は行ベクトルにも当てはまります。つまり、複数の行ベクトルを、それぞれが列ベクトルであるかのように指定します。
2行3列の行列Aの複数の値を与えるには、次のように指定します。
(これは 2 x 3 x n で、n が最後のインデックスです。)
この例では、スカラー t の例と同様に、スカラー変数 x と y の複数の値を行ベクトルとして指定するようにしてください。
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); % Convert x0x and x0y to row vectors for optimvalues x0 = optimvalues(prob,x=x0x(:)',y=x0y(:)');
x0 内のすべての点から始めて最小化問題を解きます。
ms = MultiStart; [sol,fval,eflag,output] = solve(prob,x0,ms)
Solving problem using MultiStart. MultiStart completed the runs from all start points. All 231 local solver runs converged with a positive local solver exitflag.
sol = struct with fields:
x: 0.2283
y: -1.6255
fval = -6.5511
eflag =
LocalMinimumFoundAllConverged
output = struct with fields:
funcCount: 2230
localSolverTotal: 231
localSolverSuccess: 231
localSolverIncomplete: 0
localSolverNoSolution: 0
message: 'MultiStart completed the runs from all start points. ↵↵All 231 local solver runs converged with a positive local solver exitflag.'
local: [1×1 struct]
objectiveDerivative: "reverse-AD"
constraintDerivative: "closed-form"
globalSolver: 'MultiStart'
solver: 'fmincon'
ランダムスタートポイント
もう一度問題を解きます。今回は 25 個のランダムな初期点から MultiStart を使用します。solve の初期点を [–1,2] に設定します。
init.x = -1; init.y = 2; rng default % For reproducibility [sol2,fval2,eflag2,output2] = solve(prob,init,ms,MinNumStartPoints=25)
Solving problem using MultiStart. MultiStart completed the runs from all start points. All 25 local solver runs converged with a positive local solver exitflag.
sol2 = struct with fields:
x: 0.2283
y: -1.6255
fval2 = -6.5511
eflag2 =
LocalMinimumFoundAllConverged
output2 = struct with fields:
funcCount: 161
localSolverTotal: 25
localSolverSuccess: 25
localSolverIncomplete: 0
localSolverNoSolution: 0
message: 'MultiStart completed the runs from all start points. ↵↵All 25 local solver runs converged with a positive local solver exitflag.'
local: [1×1 struct]
objectiveDerivative: "reverse-AD"
constraintDerivative: "closed-form"
globalSolver: 'MultiStart'
solver: 'fmincon'
今回は、MultiStart は 25 個の疑似ランダム初期点から実行されます。解は以前と同じです。
参考
MultiStart | solve | optimvalues