主要内容

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

可视化吸引力盆地

哪些起点通向哪个盆地?对于最速下降求解器,附近的点通常通向同一个盆地;请参阅 吸引盆。然而,对于 Optimization Toolbox™ 求解器来说,盆地更加复杂。

绘制示例 使用 MultiStart 的运行的示例 中的 MultiStart 起点,并用其结束的盆地进行颜色编码。

% rng(14,'twister')
% Uncomment the previous line to get the same output
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);

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

图窗中用彩色 * 符号表示盆的中心。与 * 符号相同颜色的起点汇聚到 * 符号的中心。

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

洋红色和红色盆地很浅,如下面的等高线图所示。

 用于生成图窗的代码

另请参阅

主题