Main Content

optimset

Create or modify optimization options structure

Description

例子

options= optimset(名称、值)退货options使用一个或多个名称-值对参数设置指定参数。

optimset(不带输入或输出参数)显示参数及其有效值的完整列表。

options= optimset(不带输入参数)创建选项结构optionswhere all parameters are set to[].

例子

options= optimset(擎天柱)createsoptionswith all parameter names and default values relevant to the optimization function擎天柱.

例子

options= optimset(oldopts,名称、值)creates a copy ofoldopts并使用一个或多个名称-值对参数修改指定的参数。

例子

options= optimset(oldopts,newopts)combines an existing options structureoldoptswith a new options structurenewopts. 中的任何参数newopts非空的值覆盖相应的parameters inoldopts.

Examples

全部折叠

Set options forfminsearchto use a plot function and a stricter stopping condition than the default.

options = optimset('绘图Fcns','optimplotfval','通行费',1e-7);

从点(–1,2)开始最小化Rosenbrock函数,并使用选项监视最小化过程。Rosenbrock函数在点(1,1)处的最小值为0。

乐趣=@(x)100*((x(2)-x(1)^2)^2)+(1-x(1))^2;% Rosenbrock's function十0 = [-1,2]; [x,fval] = fminsearch(fun,x0,options)

十=1×21.0000 1.0000
fval=4.7305e-16

Create a structure containing the default options for thefzero解算器。

options = optimset('零');

View the default value of the托尔克斯option forfzero.

tol = options.TolX
公差=2.2204e-16

Set options to use a function tolerance of1e-6.

oldopts = optimset('TolFun',1e-6);

在中修改选项oldoptsto use the'optimplotfval'plot function and a托尔克斯的价值1e-6.

options=optimset(旧选项,'绘图Fcns','optimplotfval','通行费',1e-6);

查看您设置的三个选项。

显示(选项.TolFun);
1.0000e-06
显示(选项.PlotFcns);
optimplotfval
显示(选项.TolX);
1.0000e-06

Overwrite the corresponding parts of one options structure with a different options structure by usingoptimset.

oldopts = optimset('Display',“iter”,'通行费',1e-6);newopts=optimset('绘图Fcns','optimplotfval','Display','off');options=optimset(oldopts,newopts);

Botholdoptsandnewoptsset the value of theDisplayoption. Check thatnewopts覆盖oldopts对于this option.

选项。显示
ans = 'off'

检查其他两个选项的值。

选项.TolX
ans=1.0000e-06
options.PlotFcns
ans = 'optimplotfval'

输入参数

全部折叠

优化solver, specified as a name or function handle. The returned options structure has nonempty entries for the specified solver only.

Example:options=optimset('fzero')

Example:options=optimset(@fminsearch)

Data Types:char|string|功能手柄

以前的优化选项,指定为结构。输出options与相同oldopts,指定参数除外。

Example:options=optimset(旧选项,'通行费',1e-6)

Data Types:结构

新的优化选项,指定为结构。输出options与相同newopts,还包括的非空参数oldopts都是空的newopts.

Example:options=optimset(oldopts,newopts)

Data Types:结构

名称-值对参数

指定可选的逗号分隔对名称、值arguments.Name是参数名称和价值是对应的值。Name必须出现在引号内。可以按以下任意顺序指定多个名称和值对参数:Name1 Value1,...,NameN,ValueN.

Example:options = optimset('TolX',1e-6,'PlotFcns',@optimplotfval)

显示级别,指定为由“display”和以下值之一组成的逗号分隔对:

  • '通知'-仅当函数不收敛时才显示输出。

  • 'final'-只显示最终输出。

  • 'off'or'无'-显示无输出。

  • “iter”-每次迭代时显示输出(不适用于lsqnonneg公司).

Display可用于所有优化解算器。

Example:options = optimset('Display','iter')

Data Types:char|string

用于检查函数值是否有效的标志,指定为由'欢乐支票'and the value'off'or'打开'.When the value is'打开',solvers display an error when the objective function returns a value that is complex or.

FunValCheckis available forfminbnd,fminsearch,和fzero.

Example:options=optimset('FunValCheck','on')

Data Types:char|string

最大函数求值数,specified as the comma-separated pair consisting of'最大乐趣'and a positive integer.

MaxFunEvalsis available forfminbndandfminsearch.

Example:options=optimset('MaxFunEvals',2e3)

Data Types:single|double

最大迭代次数,指定为逗号分隔对,由'MaxIter'and a positive integer.

MaxIteris available forfminbndandfminsearch.

Example:options = optimset('MaxIter',2e3)

Data Types:single|double

输出函数,指定为逗号分隔对,由'OutputFcn'and a function name or function handle. Specify multiple output functions as a cell array of function handles. An output function runs after each iteration, enabling you to monitor the solution process or stop the iterations. For more information, see优化Solver Output Functions.

OutputFcnis available forfminbnd,fminsearch,和fzero.

Example:options=optimset('OutputFcn'{@出口1,@出口2})

Data Types:char|string|细胞|功能手柄

绘图函数,specified as the comma-separated pair consisting of'绘图Fcns'and a function name or function handle. Specify multiple plot functions as a cell array of function handles. A plot function runs after each iteration, enabling you to monitor the solution process or stop the iterations. For more information, see优化求解图功能.

内置绘图功能如下:

  • @optimplotx公司打印当前点。

  • @optimplotfvalplots the function value.

  • @optimplotfunccountplots the function count (not available forfzero).

这个绘图Fcnsoption is available forfminbnd,fminsearch,和fzero.

Example:options=optimset('PlotFcns','optimplotfval')

Data Types:char|string|细胞|功能手柄

Termination tolerance on the function value, specified as the comma-separated pair consisting of'TolFun'and a nonnegative scalar. Iterations end when the current function value differs from the previous value by less thanTolFun,relative to the initial function value. SeeTolerances and Stopping Criteria.

TolFunis available forfminsearch只是。

Example:options = optimset('TolFun',2e-6)

Data Types:single|double

Termination tolerance on,the current point, specified as the comma-separated pair consisting of'通行费'and a nonnegative scalar. Iterations end when the current point differs from the previous point by less than托尔克斯,相对于.SeeTolerances and Stopping Criteria.

托尔克斯is available for all solvers.

Example:options = optimset('TolFun',2e-6)

Data Types:single|double

Output Arguments

全部折叠

优化选项,作为结构返回。未设置的参数值为[],这使解算器使用这些参数的默认值。

局限性

  • optimset设置四个选项®优化解算器:fminbnd,fminsearch,fzero,和lsqnonneg公司.To set options for Optimization Toolbox™ or全局优化工具箱解算器,建议的函数是优化选项(Optimization Toolbox).

  • optimset无法为某些优化工具箱解算器设置选项,例如intlinprog. 使用优化选项(Optimization Toolbox)相反。

  • optimsetcannot set most options for全局优化工具箱解算器。使用优化选项(Optimization Toolbox)相反。

Extended Capabilities

R2006a之前引入