迭代输出
迭代显示的类型
迭代显示为您提供了有关求解器在运行过程中的进度的信息。
迭代显示有两种类型:
全局求解器显示
局部求解器显示
两种类型都会出现在命令行中,取决于全局和局部选项。
通过将 Display
字段中的 problem.options
选项设置为 'iter'
或 'iter-detailed'
与 optimoptions
来获得局部求解器迭代显示。有关详细信息,请参阅迭代输出。
通过将 GlobalSearch
或 MultiStart
对象中的 Display
属性设置为 'iter'
来获得全局求解器迭代显示。
全局求解器将局部求解器的默认 Display
选项设置为 'off'
,除非问题结构体具有此选项的值。全局求解器不会覆盖您对局部选项所做的任何设置。
注意
将局部求解器 Display
选项设置为 'off'
以外的任何值都可以产生大量输出。Display
创建的默认 optimoptions(@
选项是 solver
)'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 1275 -1.032 -0.2155 1 Stage 1 Local 300 1377 -1.032 248.7 -0.2137 Stage 2 Search 400 1477 -1.032 278 1.134 Stage 2 Search 446 1561 -1.032 1.6 2.073 -0.2155 1 Stage 2 Local 500 1615 -1.032 9.055 0.3214 Stage 2 Search 600 1715 -1.032 -0.7299 -0.7686 Stage 2 Search 700 1815 -1.032 0.3191 -0.7431 Stage 2 Search 800 1915 -1.032 296.4 0.4577 Stage 2 Search 900 2015 -1.032 10.68 0.5116 Stage 2 Search 1000 2115 -1.032 -0.9207 -0.9254 Stage 2 Search GlobalSearch stopped because it analyzed all the trial points. All 3 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 -1.980435e-02 0.000e+00 1.996e+00 1 9 -6.970985e-02 0.000e+00 3.140e+00 2.533e-01 2 13 -8.662720e-02 0.000e+00 2.775e+00 1.229e-01 3 18 -1.176972e-01 0.000e+00 1.629e+00 1.811e-01 4 21 -2.132377e-01 0.000e+00 2.097e-01 8.636e-02 5 24 -2.153982e-01 0.000e+00 7.701e-02 1.504e-02 6 27 -2.154521e-01 0.000e+00 1.547e-02 1.734e-03 7 30 -2.154637e-01 0.000e+00 1.222e-03 1.039e-03 8 33 -2.154638e-01 0.000e+00 1.543e-04 8.413e-05 9 36 -2.154638e-01 0.000e+00 1.543e-06 6.610e-06 10 39 -2.154638e-01 0.000e+00 1.686e-07 7.751e-08 Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the selected value of the function tolerance, and constraints were satisfied to within the selected value of the constraint tolerance. First-order Norm of Iter F-count f(x) Feasibility optimality step 0 3 -1.980435e-02 0.000e+00 1.996e+00 ... MANY ITERATIONS DELETED ... 8 33 -1.031628e+00 0.000e+00 8.742e-07 2.287e-07 Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the selected value of the function tolerance, and constraints were satisfied to within the selected value of the constraint tolerance. <stopping criteria details> GlobalSearch stopped because it analyzed all the trial points. All 4 local solver runs converged with a positive local solver exit flag.
设置 GlobalSearch
迭代显示以及 fmincon
迭代显示会导致两种显示混合在一起。
有关并行环境中迭代显示的示例,请参阅 并行 MultiStart。