主要内容

本页采用了机器翻译。点击此处可查看英文原文。

可视化吸引域

哪些起点通向哪个吸引域?对于最陡下降求解器,附近的点通常通向同一个吸引域;请参阅吸引域。然而,对于工具箱求解器而言,吸引域的情况则更为复杂。

根据示例 使用 MultiStart 的运行的示例 绘图 MultiStart 的起始点,并根据其终点所在的吸引域进行颜色编码。

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);
MultiStart completed the runs from all start points. 

All 50 local solver runs converged with a positive local solver exitflag.
possColors = 'kbgcrm';
hold on
for i = 1:size(manyminsm,2)

    % Color of this line
    cIdx = rem(i-1, length(possColors)) + 1;
    color = possColors(cIdx);

    % Plot start points
    u = manyminsm(i).X0; 
    x0ThisMin = reshape([u{:}], 2, length(u));
    plot(x0ThisMin(1, :), x0ThisMin(2, :),".", ...
        Color=color,MarkerSize=25);

    % Plot the basin with color i
    plot(manyminsm(i).X(1), manyminsm(i).X(2),"*", ...
        Color=color,MarkerSize=25);
end % Basin center marked with a *, start points with dots
hold off

Figure contains an axes object. The axes object contains 12 objects of type line. One or more of the lines displays its values using only markers

图中用彩色*符号标出了各吸引域的中心。与*符号颜色相同的起点会收敛到*符号的中心。

起点并不总是汇聚到最近的吸引域。例如,品红色点距离青色吸引域中心比距离红色吸引域中心更近。此外,许多黑色和蓝色的起点更靠近相反的吸引域中心。

洋红色和红色吸引域很浅,如下面的等高线图所示。

sixminxy = @(x,y)(4*x.^2 - 2.1*x.^4 + x.^6/3 ...
    + x.*y - 4*y.^2 + 4*y.^4);
f = @(x,y)sixminxy(x,y); % Vectorized objective fcn
fcontour(f,[-2 2 -1.1 1.1])
hold on
for i = 1:size(manyminsm,2)
    cIdx = rem(i-1, length(possColors)) + 1;
    color = possColors(cIdx);
    plot(manyminsm(i).X(1),manyminsm(i).X(2),"*",...
        Color=color,MarkerSize=25); % Plot center of basin with *
end
hold off

Figure contains an axes object. The axes object contains 7 objects of type functioncontour, line. One or more of the lines displays its values using only markers

另请参阅

主题