nlgreyestOptions
R2026bOption set for nlgreyest
Description
creates the default option
set for opt = nlgreyestOptionsnlgreyest. Use dot notation to customize the option
set, if needed.
creates
an option set with options specified by one or more opt = nlgreyestOptions(Name,Value)Name,Value pair
arguments. The options that you do not specify retain their default
value.
Examples
opt = nlgreyestOptions;
Create estimation option set for nlgreyest to view estimation progress, and to set the maximum iteration steps to 50.
opt = nlgreyestOptions;
opt.Display = 'on';
opt.SearchOptions.MaxIterations = 50;Load data.
load dcmotordata z = iddata(y,u,0.1,'Name','DC-motor');
The data is from a linear DC motor with one input (voltage), and two outputs (angular position and angular velocity). The structure of the model is specified by dcmotor_m.m file.
Create a nonlinear grey-box model.
file_name = 'dcmotor_m'; Order = [2 1 2]; Parameters = [1;0.28]; InitialStates = [0;0]; init_sys = idnlgrey(file_name,Order,Parameters,InitialStates,0, ... 'Name','DC-motor');
Estimate the model parameters using the estimation options.
sys = nlgreyest(z,init_sys,opt);
Create an option set for nlgreyest where:
Parameter covariance data is not generated.
Subspace Gauss-Newton least squares method is used for estimation.
opt = nlgreyestOptions('EstimateCovariance',false,'SearchMethod','gn');
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
Example: nlgreyestOptions('Display','on')
Options for computing Jacobians and gradients, specified as
the comma-separated pair consisting of 'GradientOptions' and
a structure with fields:
| Field Name | Description | Default |
|---|---|---|
MaxDifference | Largest allowed parameter perturbation when computing numerical derivatives. Specified
as a positive real value >
| Inf |
MinDifference | Smallest allowed parameter perturbation when computing numerical derivatives. Specified
as a positive real value
< | 0.01*sqrt(eps) |
DifferencingScheme | Method for computing numerical derivatives with respect to the components of the parameters and/or the initial state(s) to form the Jacobian. Specified as one of the following:
| 'Auto' |
Type | Method used when computing derivatives (Jacobian) of the parameters or the initial states to be estimated. Specified as one of the following:
| 'Auto' |
To specify field values in GradientOptions,
create a default nlgreyestOptions set and modify
the fields using dot notation. Any fields that you do not modify retain
their default values.
opt = nlgreyestOptions;
opt.GradientOptions.Type = 'Basic';Controls whether parameter covariance data is generated, specified as
true (1) or
false (0).
Estimation progress display setting, specified as the comma-separated
pair consisting of 'Display' and one of the following:
'off'— No progress or results information is displayed.'on'— Information on model structure and estimation results are displayed in a progress-viewer window.
Options for regularized estimation of model parameters, specified
as the comma-separated pair consisting of 'Regularization' and
a structure with fields:
| Field Name | Description | Default |
|---|---|---|
Lambda | Bias versus variance tradeoff constant, specified as a nonnegative scalar. | 0 — Indicates no regularization. |
R | Weighting matrix, specified as a vector of nonnegative scalars
or a square positive semi-definite matrix. The length must be equal
to the number of free parameters in the model, np.
Use the nparams command to determine
the number of model parameters. | 1 — Indicates a value of eye(np). |
Nominal |
The nominal value towards which the free parameters are pulled during estimation specified as one of the following:
| 'zero' |
To specify field values in Regularization,
create a default nlgreyestOptions set and modify
the fields using dot notation. Any fields that you do not modify retain
their default values.
opt = nlgreyestOptions; opt.Regularization.Lambda = 1.2; opt.Regularization.R = 0.5*eye(np);
Regularization is a technique for specifying model flexibility constraints, which reduce uncertainty in the estimated parameter values. For more information, see Regularized Estimates of Model Parameters.
Numerical search method used for iterative parameter estimation,
specified as the comma-separated pair consisting of 'SearchMethod' and
one of the following:
'auto'— If Optimization Toolbox™ is available,'lsqnonlin'is used. Otherwise, a combination of the line search algorithms,'gn','lm','gna', and'grad'methods is tried in sequence at each iteration. The first descent direction leading to a reduction in estimation cost is used.'gn'— Subspace Gauss-Newton least squares search. Singular values of the Jacobian matrix less thanGnPinvConstant*eps*max(size(J))*norm(J)are discarded when computing the search direction. J is the Jacobian matrix. The Hessian matrix is approximated by JTJ. If there is no improvement in this direction, the function tries the gradient direction.'gna'— Adaptive subspace Gauss-Newton search. Eigenvalues less thangamma*max(sv)of the Hessian are ignored, where sv are the singular values of the Hessian. The Gauss-Newton direction is computed in the remaining subspace. gamma has the initial valueInitialGnaTolerance(seeAdvancedin'SearchOptions'for more information). This value is increased by the factorLMStepeach time the search fails to find a lower value of the criterion in fewer than five bisections. This value is decreased by the factor2*LMStepeach time a search is successful without any bisections.'lm'— Levenberg-Marquardt least squares search, where the next parameter value is-pinv(H+d*I)*gradfrom the previous one. H is the Hessian, I is the identity matrix, and grad is the gradient. d is a number that is increased until a lower value of the criterion is found. Requires Optimization Toolbox software.'grad'— Steepest descent least squares search.'lsqnonlin'— Trust-region-reflective algorithm oflsqnonlin(Optimization Toolbox). Requires Optimization Toolbox software.'patternsearch'— Solver for nonlinearities without well-defined gradients. You can use thepatternsearch(Global Optimization Toolbox) solver to find the minimum of a nonlinear function that does not have a well-defined gradient. This solver requires Global Optimization Toolbox software.'fmincon'— Constrained nonlinear solvers. You can use the sequential quadratic programming (SQP) and trust-region-reflective algorithms of thefminconsolver. If you have Optimization Toolbox software, you can also use the interior-point and active-set algorithms of thefmincon(Optimization Toolbox) solver. Specify the algorithm in theSearchOptions.Algorithmoption. Thefminconalgorithms may result in improved estimation results in the following scenarios:Constrained minimization problems when there are bounds imposed on the model parameters.
Model structures where the loss function is a nonlinear or non smooth function of the parameters.
Multi-output model estimation. A determinant loss function is minimized by default for MIMO model estimation.
fminconalgorithms are able to minimize such loss functions directly. The other available search methods such as'lm'and'gn'minimize the determinant loss function by alternately estimating the noise variance and reducing the loss value for a given noise variance value. Hence, thefminconalgorithms can offer better efficiency and accuracy for multi-output model estimations.
'adam'— Adaptive moment estimation (Adam). Adam is a first-order adaptive gradient solver. It supports mini-batch operation when data is segmented into multiple frames or batches. For more information, see Adaptive Moment Estimation (Deep Learning Toolbox).'sgdm'— Stochastic gradient descent with momentum (SGDM). SGDM is a first-order momentum-based gradient solver. It supports mini-batch operation when data is segmented into multiple frames or batches. For more information, see Stochastic Gradient Descent with Momentum (Deep Learning Toolbox).'lbfgs'— Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS). L-BFGS is a quasi-Newton solver that approximates the inverse Hessian using a limited history of curvature pairs. For more information, see Limited-Memory BFGS (Deep Learning Toolbox).
Option set for the search algorithm, specified as the comma-separated
pair consisting of 'SearchOptions' and a search
option set with fields that depend on the value of
SearchMethod.
SearchOptions Structure When
SearchMethod Is Specified as
'lsqnonlin' or 'auto',
When Optimization Toolbox Is Available
| Field Name | Description | Default |
|---|---|---|
FunctionTolerance | Termination tolerance on the loss function that the software minimizes to determine the estimated parameter values, specified as a positive scalar. The value of
| 1e-5 |
StepTolerance | Termination tolerance on the estimated parameter values, specified as a positive scalar. The value of
| 1e-6 |
MaxIterations | Maximum number of iterations during
loss-function minimization, specified as a
positive integer. The iterations stop when
The
value of | 20 |
SearchOptions Structure When
SearchMethod Is Specified as
'gn', 'gna',
'lm', 'grad', or
'auto', When Optimization Toolbox Is Not Available
| Field Name | Description | Default | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Tolerance | Minimum percentage difference between the
current value of the loss function and its
expected improvement after the next iteration,
specified as a positive scalar. When the
percentage of expected improvement is less than
| 1e-5 | ||||||||||||||||||||||||||||||
MaxIterations | Maximum number of iterations during
loss-function minimization, specified as a
positive integer. The iterations stop when
Setting
Use
| 20 | ||||||||||||||||||||||||||||||
Advanced | Advanced search settings, specified as a structure with the following fields:
| |||||||||||||||||||||||||||||||
SearchOptions Structure When
SearchMethod Is Specified as
'patternsearch'
| Field Name | Description | Default |
|---|---|---|
Algorithm |
For algorithm details, see How Pattern Search Polling Works (Global Optimization Toolbox) and Nonuniform Pattern Search (NUPS) Algorithm (Global Optimization Toolbox). For examples of algorithm effects, see Explore patternsearch Algorithms (Global Optimization Toolbox) and Explore patternsearch Algorithms in Optimize Live Editor Task (Global Optimization Toolbox). | 'nups' |
FunctionTolerance | Termination tolerance on the loss function that the software minimizes to determine the estimated parameter values, specified as a positive scalar. | 1e-6 |
StepTolerance | Termination tolerance on the estimated parameter values, specified as a positive scalar. | 1e-6 |
MaxIterations | Maximum number of iterations during loss
function minimization, specified as a positive
integer. The iterations stop when
| '100*numberOfVariables', where
numberOfVariables is the number of problem
variables |
UseParallel | Option to enable or disable parallel processing for improved performance, specified as one of these values:
If you do not have a parallel pool open and automatic pool creation is enabled, MATLAB opens a pool using the default cluster profile. To use a parallel pool to run computations in MATLAB, you must have Parallel Computing Toolbox™. Before R2026b: To run in
parallel, set | "off" |
SearchOptions Structure When SearchMethod Is Specified
as 'fmincon'
| Field Name | Description | Default |
|---|---|---|
Algorithm |
For more information about the algorithms, see Constrained Nonlinear Optimization Algorithms (Optimization Toolbox) and Choosing the Algorithm (Optimization Toolbox). | 'sqp' |
FunctionTolerance | Termination tolerance on the loss function that the software minimizes to determine the estimated parameter values, specified as a positive scalar. | 1e-6 |
StepTolerance | Termination tolerance on the estimated parameter values, specified as a positive scalar. | 1e-6 |
MaxIterations | Maximum number of iterations during loss function minimization, specified as a positive
integer. The iterations stop when | 100 |
SearchOptions Structure When SearchMethod Is
Specified as 'adam'
| Field Name | Description | Default |
|---|---|---|
LearnRate | Learning rate, or the step size, used for training, specified as a positive scalar. If the learning rate is too small, then training can take a long time. If the learning rate is too large, then training can be fast but it might reach a suboptimal result, diverge, or oscillate. The learning rate is denoted by α in the Adaptive Moment Estimation (Deep Learning Toolbox) section. If you specify | 0.001 |
GradientDecayFactor | Exponential decay rate of gradient moving average for the Adam solver,
specified as a positive scalar less than If the value of | 0.9 |
SquaredGradientDecayFactor | Exponential decay rate of squared gradient moving average for the Adam
solver, specified as a positive scalar less than Larger values of
| 0.999 |
Epsilon | Small constant for numerical stability, specified as a positive scalar. To avoid
division by zero when updating network parameters, the solver adds this constant
to the denominator. Epsilon is denoted by
ϵ in the Adaptive Moment Estimation (Deep Learning Toolbox)
section. | 1e-8 |
MaxEpochs | Maximum number of parameter updates or iterations to use for training,
specified as a nonnegative integer. If you specify MaxEpochs
as 0, the software disables iterations and only runs
initialization or post-processing. | 200 |
MaxFunctionEvaluations | Maximum number of objective function evaluations, specified as a positive integer. | intmax |
LearnRateSchedule | Learning rate schedule type, specified as
| "none" |
LearnRateDropFactor | Multiplicative factor for dropping the learning rate, specified as a
positive scalar less than or equal to The software
multiplies the learning rate with the factor specified by
| 0.1 |
LearnRateDropPeriod | Number of iterations in between learning rate drops, specified as a
positive integer. You can specify this option only when you specify the
The software multiplies the
learning rate with the drop factor every time the number of iterations
specified by | 10 |
MinCostValue | Target objective value, specified as a nonnegative scalar. If the
objective value at the current iteration is less than or equal to
| 0 |
ModelSelection | Iteration used to return the model parameters, specified as
If
you specify | "best" |
Advanced | Structure used to specify advanced search options consisting of these fields: | |
To disable this option, specify
| 0 | |
Decoupling prevents regularization strength from being implicitly modulated by momentum dynamics. | 1 | |
To disable this option,
specify | 0 | |
NormEpsilon — Small constant used to avoid division
by zero and underflow when computing safe norms and normalized quantities,
especially when ClipGradNorm is enabled, specified as a
positive scalar. | 1e-12 | |
SearchOptions Structure When SearchMethod Is
Specified as 'sgdm'
| Field Name | Description | Default |
|---|---|---|
LearnRate | Learning rate, or the step size, used for training, specified as a positive scalar. If the learning rate is too small, then training can take a long time. If the learning rate is too large, then training can be fast but it might reach a suboptimal result, diverge, or oscillate. The learning rate is denoted by α in the Stochastic Gradient Descent with Momentum (Deep Learning Toolbox) section. If you specify | 0.01 |
Momentum | Momentum coefficient, specified as a positive scalar less than or equal to
If the value of | 0.95 |
MaxEpochs | Maximum number of parameter updates or iterations to use for training,
specified as a nonnegative integer. If you specify MaxEpochs
as 0, the software disables iterations and only runs
initialization or post-processing. | 200 |
MaxFunctionEvaluations | Maximum number of objective function evaluations, specified as a positive integer. | intmax |
LearnRateSchedule | Learning rate schedule type, specified as
| "none" |
LearnRateDropFactor | Multiplicative factor for dropping the learning rate, specified as a
positive scalar less than or equal to The software
multiplies the learning rate with the factor specified by
| 0.1 |
LearnRateDropPeriod | Number of iterations in between learning rate drops, specified as a
positive integer. You can specify this option only when you specify the
The software multiplies the
learning rate with the drop factor every time the number of iterations
specified by | 10 |
MinCostValue | Target objective value, specified as a nonnegative scalar. If the
objective value at the current iteration is less than or equal to
| 0 |
ModelSelection | Iteration used to return the model parameters, specified as
If
you specify | "best" |
Advanced | Structure used to specify advanced search options consisting of these fields: | |
To disable this option, specify
| 0 | |
Decoupling prevents regularization strength from being implicitly modulated by momentum dynamics. | 1 | |
To disable this option,
specify | 0 | |
NormEpsilon — Small constant used to avoid division
by zero and underflow when computing safe norms and normalized quantities,
especially when ClipGradNorm is enabled, specified as a
positive scalar. | 1e-12 | |
SearchOptions Structure When SearchMethod Is
Specified as 'lbfgs'
| Field Name | Description | Default |
|---|---|---|
MaxIterations | Maximum number of quasi-Newton iterations to use for training, specified as a nonnegative integer. Each iteration forms a search direction using the stored curvature pairs and then performs a line search. If you specify | 200 |
MaxFunctionEvaluations | Maximum number of objective function evaluations, including evaluations performed by line search, specified as a positive integer. | intmax |
HistorySize | Number of curvature pairs or state updates to store, specified as a positive integer. The L-BFGS algorithm uses a history of
gradient calculations to approximate the Hessian matrix recursively. Larger
values of | 10 |
GradientTolerance | Stopping tolerance on the relative gradient, specified as a positive scalar. The software stops training when the relative gradient
is less than or equal to
| 1e-6 |
StepTolerance | Stopping tolerance on the step size, specified as a positive scalar.
The software
stops training when the step that the algorithm takes is less than or equal
to | 1e-12 |
FunctionTolerance | Stopping tolerance on the improvement in the objective value, specified
as a positive scalar. The software stops training when the objective value
improvement is less than or equal to
| 1e-12 |
LineSearchMethod | Method to find a suitable step size, specified as one of these values:
| "strong-wolfe" |
MaxNumLineSearchIterations | Maximum number of line search trials per iteration to determine the step size, specified as a positive integer. | 40 |
InitialStepSize | Step size for the starting line search trial, specified as a positive scalar. | 1.0 |
Advanced | Structure used to specify advanced search options consisting of these fields: | |
MinStepSize — Smallest step size permitted by line
search, specified as a positive scalar. If the step size for a trial goes below
this value, the line search fails and the solver can stop or fall back depending
on the implementation. | 1e-16 | |
MaxStepSize — Largest step size permitted by line
search, specified as a positive scalar. This upper bound for the trial step size
prevents excessively large moves that can cause numerical overflow or objective
evaluation failures. | 1e+16 | |
To
disable this option, specify | 0 | |
WolfeC1 — Armijo condition (sufficient decrease)
constant for Wolfe line search, specified as a positive scalar less than
1. Smaller values of WolfeC1 make
sufficient decrease easier to satisfy. | 1e-4 | |
WolfeC2 — Curvature condition constant for Wolfe
line search, specified as positive scalar less than 1. Larger
values of WolfeC2 make the curvature condition easier to
satisfy whereas smaller values enforce a stronger curvature requirement. | 0.9 | |
ZoomMaxIterations — Maximum number of iterations
allowed in the "zoom" procedure of Wolfe line search, specified as a positive
integer. | 40 | |
BacktrackingFactor — Step size shrink factor during
backtracking used to reduce trial step sizes when conditions are not satisfied,
specified as a positive scalar less than 1. Values closer to
0 shrink the step size more aggressively while values
closer to 1 shrink the step size more conservatively. | 0.5 | |
CurvatureThreshold — Number to control whether a
new curvature pair is accepted into the limited-memory history, specified as a
positive scalar. Specifying CurvatureThreshold prevents
storing nearly singular or noisy curvature information that can destabilize the
inverse-Hessian approximation. | 1e-10 | |
To disable this option, specify
| 0 | |
UseInitialScaling — Flag to control whether the
initial inverse-Hessian is scaled each iteration using curvature information,
specified as a logical scalar. This scaling often improves practical
performance. | 1 | |
To specify field values in SearchOptions, create a
default nlgreyestOptions set and modify the fields
using dot notation. Any fields that you do not modify retain their
default values.
opt = nlgreyestOptions('SearchMethod','gna'); opt.SearchOptions.MaxIterations = 50; opt.SearchOptions.Advanced.RelImprovement = 0.5;
Weighting of prediction error in multi-output model estimations,
specified as the comma-separated pair consisting of 'OutputWeight' and
one of the following:
[]— No weighting is used. Specifying as[]is the same aseye(Ny), whereNyis the number of outputs.'noise'— Optimal weighting is automatically computed as the inverse of the estimated noise variance. This weighting minimizesdet(E'*E/N), whereEis the matrix of prediction errors andNis the number of data samples. This option is not available when using'lsqnonlin'as a'SearchMethod'.A positive semidefinite matrix,
W, of size equal to the number of outputs. This weighting minimizestrace(E'*E*W/N), whereEis the matrix of prediction errors andNis the number of data samples.
Additional advanced options, specified as the comma-separated
pair consisting of 'Advanced' and a structure with
field:
| Field Name | Description | Default |
|---|---|---|
ErrorThreshold | Threshold for when to adjust the weight of large errors from
quadratic to linear, specified as a nonnegative scalar. Errors larger
than ErrorThreshold times the estimated standard
deviation have a linear weight in the loss function. The standard
deviation is estimated robustly as the median of the absolute deviations
from the median of the prediction errors divided by 0.7. If your estimation
data contains outliers, try setting ErrorThreshold to 1.6. | 0 — Leads to a purely quadratic loss
function. |
To specify field values in Advanced, create
a default nlgreyestOptions set and modify the fields
using dot notation. Any fields that you do not modify retain their
default values.
opt = nlgreyestOptions; opt.Advanced.ErrorThreshold = 1.2;
Output Arguments
Option set for nlgreyest, returned as an nlgreyestOptions option
set.
Extended Capabilities
The nlgreyestOptions object has automatic parallel support if its
SearchMethod property is set to
"patternsearch".
To run computations in parallel, set the SearchMethod
property to "patternsearch" and the
SearchOptions.UseParallel property to
"on" or "auto".
Version History
Introduced in R2015aWhen the SearchMethod property is
"patternsearch", the
SearchOptions.UseParallel property now accepts
"off", "auto", or "on"
values instead of true or false. This change
gives you more control over when to use a parallel pool for parallel
execution.
Specifying the SearchOptions.UseParallel property as
true or false is not recommended.
You can now use the adaptive moment estimation (Adam), stochastic gradient descent with
momentum (SGDM), or limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS) solvers to
estimate models by setting the SearchMethod property to
'adam', 'sgdm', or 'lbfgs',
respectively. You can change the default search option set using the
SearchOptions property.
You can now set the SearchMethod property to
'patternsearch' to estimate a system that has a nonlinearity without a
well-defined gradient. You can change the default option set for this search algorithm using the
SearchOptions property. This method requires Global Optimization Toolbox software.
The names of some estimation and analysis options were changed in R2018a. Prior names still work.
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)