Main Content

このページは機械翻訳を使用して翻訳されました。元の英語を参照するには、ここをクリックします。

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

開始点 t01t02 は離れていますが、ソリューション sol1sol2 は表示精度では同一です。

参考

| |

関連するトピック