このページは機械翻訳を使用して翻訳されました。最新版の英語を参照するには、ここをクリックします。
MultiStart または GlobalSearch を使用して複数の局所解を見つける、問題ベース
問題ベースのアプローチで MultiStart または GlobalSearch 関数を使用する問題の解決では、output 構造体に、局所解に関する情報が含まれる local というフィールドが含まれます。たとえば、この例を実行すると使用できる 2 つの変数の rastriginsfcn 関数の局所解をMultiStart を使用して見つけます。
x = optimvar("x",LowerBound=-50,UpperBound=50); y = optimvar("y",LowerBound=-50,UpperBound=50); fun = rastriginsfcn([x,y]); prob = optimproblem(Objective=fun); ms = MultiStart; x0.x = -30; x0.y = 20; rng default % For reproducibility [sol,fval,exitflag,output] = solve(prob,x0,ms,MinNumStartPoints=50);
Solving problem using MultiStart. MultiStart completed the runs from all start points. All 50 local solver runs converged with a positive local solver exitflag.
disp(sol)
x: 6.8842e-10
y: 1.0077e-09
disp(fval)
0
MultiStart はいくつの局所解を見つけますか?
multisols = output.local.sol; N = numel(multisols)
N = 46
値をプロットします。
plot3(multisols.x,multisols.y,multisols.Objective,'bo')
MultiStart は 50 個の初期点から開始しますが、46 個のソリューションしか見つかりません。MultiStart はすべての実行が収束したと報告します。したがって、一部のソリューションには、そのソリューションに至る複数の初期点があります。複数の初期点をリストする x0 値を見つけます。
myx0 = output.local.x0; sx = zeros(size(myx0)); for i = 1:length(sx) sx(i) = numel(myx0{i}); end mults = find(sx >= 2)
mults = 1×4
13 17 25 36
mults(1) の 2 つの初期点から始まる fmincon が同じ解で終わるかどうかを判断します。
pts = myx0(mults(1));
r = pts{1}.x;
t01.x = r(1);
s = pts{1}.y;
t01.y = s(1);
disp(t01) x: -30
y: 20
opts = optimoptions("fmincon",Display="none"); sol1 = solve(prob,t01,Options=opts)
sol1 = struct with fields:
x: -1.9899
y: -2.9849
t02.x = r(2); t02.y = s(2); disp(t02)
x: 34.9129
y: -24.5718
sol2 = solve(prob,t02,Options=opts)
sol2 = struct with fields:
x: -1.9899
y: -2.9849
開始点 t01 と t02 は離れていますが、ソリューション sol1 と sol2 は表示精度では同一です。
参考
MultiStart | solve | GlobalSearch