迭代输出
迭代显示的类型
迭代显示为您提供了有关求解器在运行过程中的进度的信息。
迭代显示有两种类型:
全局求解器显示
局部求解器显示
两种类型都会出现在命令行中,取决于全局和局部选项。
要获得局部求解器迭代显示,请使用 optimoptions 将 problem.options 字段中的 Display 选项设置为 "iter" 或 "iter-detailed"。有关详细信息,请参阅迭代输出。
通过将 GlobalSearch 或 MultiStart 对象中的 Display 属性设置为 "iter" 来获得全局求解器迭代显示。
全局求解器将局部求解器的默认 Display 选项设置为 "off",除非问题结构体具有此选项的值。全局求解器不会覆盖您对局部选项所做的任何设置。
注意
将局部求解器 Display 选项设置为 "off" 以外的任何值都可以产生大量输出。optimoptions(@ 创建的默认 solver)Display 选项是 "final"。
检查迭代显示的类型
使用 GlobalSearch 和 GlobalSearch 迭代显示运行 运行求解器 中描述的示例:
% Set the random stream to get exactly the same output % rng(14,"twister") gs = GlobalSearch(Display="iter"); 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); [xming,fming,flagg,outptg,manyminsg] = run(gs,problem);
Num Pts Best Current Threshold Local Local
Analyzed F-count f(x) Penalty Penalty f(x) exitflag Procedure
0 34 -1.032 -1.032 1 Initial Point
200 1240 -1.032 0 1 Stage 1 Local
300 1342 -1.032 15.67 -0.2963 Stage 2 Search
400 1442 -1.032 102.6 1.022 Stage 2 Search
500 1542 -1.032 4.02 0.2542 Stage 2 Search
506 1582 -1.032 0.08424 0.2542 -1.032 1 Stage 2 Local
512 1623 -1.032 -0.2141 0.08424 -0.2155 1 Stage 2 Local
600 1711 -1.032 97.04 -0.7218 Stage 2 Search
700 1811 -1.032 114.7 -0.4829 Stage 2 Search
800 1911 -1.032 287.4 0.3737 Stage 2 Search
900 2011 -1.032 2.339 0.8699 Stage 2 Search
905 2060 -1.032 0.5993 0.8699 -0.2155 1 Stage 2 Local
1000 2155 -1.032 25.61 -1.03 Stage 2 Search
GlobalSearch stopped because it analyzed all the trial points.
All 5 local solver runs converged with a positive local solver exit flag.运行相同示例,但不进行 GlobalSearch 迭代显示,但进行 fmincon 迭代显示:
gs.Display = "final"; problem.options.Display = "iter"; [xming,fming,flagg,outptg,manyminsg] = run(gs,problem);
First-order Norm of
Iter F-count f(x) Feasibility optimality step
0 3 4.823333e+01 0.000e+00 1.088e+02
1 7 2.020476e+00 0.000e+00 2.176e+00 2.488e+00
2 10 6.525252e-01 0.000e+00 1.937e+00 1.886e+00
3 13 -8.776121e-01 0.000e+00 9.076e-01 8.539e-01
4 16 -9.121907e-01 0.000e+00 9.076e-01 1.655e-01
5 19 -1.009367e+00 0.000e+00 7.326e-01 8.558e-02
6 22 -1.030423e+00 0.000e+00 2.172e-01 6.670e-02
7 25 -1.031578e+00 0.000e+00 4.278e-02 1.444e-02
8 28 -1.031628e+00 0.000e+00 8.777e-03 2.306e-03
9 31 -1.031628e+00 0.000e+00 8.845e-05 2.750e-04
10 34 -1.031628e+00 0.000e+00 8.744e-07 1.352e-06
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the value of the optimality tolerance,
and constraints are satisfied to within the value of the constraint tolerance.
First-order Norm of
Iter F-count f(x) Feasibility optimality step
0 3 -4.399715e-01 0.000e+00 1.980e+00
1 9 -9.929469e-01 0.000e+00 1.230e+00 3.442e-01
2 15 -1.028480e+00 0.000e+00 3.291e-01 9.982e-02
3 18 -1.031263e+00 0.000e+00 6.726e-02 3.436e-02
4 21 -1.031627e+00 0.000e+00 8.806e-03 7.753e-03
5 24 -1.031628e+00 0.000e+00 1.433e-04 3.723e-04
6 27 -1.031628e+00 0.000e+00 2.492e-06 2.254e-05
7 30 -1.031628e+00 0.000e+00 8.744e-07 3.155e-07
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the value of the optimality tolerance,
and constraints are satisfied to within the value of the constraint tolerance.
First-order Norm of
Iter F-count f(x) Feasibility optimality step
0 3 -1.906111e-01 0.000e+00 8.356e-01
1 14 -2.146803e-01 0.000e+00 1.300e-01 5.455e-02
2 20 -2.151309e-01 0.000e+00 1.060e-01 6.160e-03
3 23 -2.150434e-01 0.000e+00 9.182e-02 1.143e-02
4 26 -2.154599e-01 0.000e+00 1.558e-02 5.912e-03
5 29 -2.154638e-01 0.000e+00 2.230e-04 6.503e-04
6 32 -2.154638e-01 0.000e+00 1.543e-04 1.133e-05
7 35 -2.154638e-01 0.000e+00 1.543e-06 6.249e-06
8 38 -2.154638e-01 0.000e+00 2.600e-08 5.015e-08
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the value of the optimality tolerance,
and constraints are satisfied to within the value of the constraint tolerance.
GlobalSearch stopped because it analyzed all the trial points.
All 3 local solver runs converged with a positive local solver exit flag.设置 GlobalSearch 迭代显示以及 fmincon 迭代显示会导致两种显示混合在一起。
有关并行环境中迭代显示的示例,请参阅并行 MultiStart。