fxpOptimizationOptions class
Specify options for data type optimization
Description
ThefxpOptimizationOptions
object enables you to specify options and constraints to use during the data type optimization process.
Construction
creates aopt
= fxpOptimizationOptions()fxpOptimizationOptions
object with default values.
creates anopt
= fxpOptimizationOptions(Name,Value
)fxpOptimizationOptions
object with property values specified by one or moreName,Value
pair arguments.Name
must appear inside single quotes (''
). You can specify several name-value pair arguments in any order asName1,Value1,...,NameN,ValueN
.
Properties
MaxIterations
—Maximum number of iterations to perform
50(default) |scalar integer
Maximum number of iterations to perform, specified as a scalar integer. The optimization process iterates through different solutions until it finds an ideal solution, reaches the maximum number of iterations, or reaches another stopping criteria.
Example:opt.MaxIterations = 75;
Data Types:double
MaxTime
—Maximum amount of time for the optimization to run (in seconds)
600(default) |scalar
Maximum amount of time for the optimization to run, specified in seconds as a scalar number. The optimization runs until it reaches the time specified, an ideal solution, or another stopping criteria.
Example:opt.MaxTime = 1000;
Data Types:double
Patience
—Maximum number of iterations where no new best solution is found
10(default) |scalar integer
Maximum number of iterations where no new best solution is found, specified as a scalar integer. The optimization continues as long as the algorithm continues to find new best solutions.
Example:opt.Patience = 15;
Data Types:double
已经rbosity
—Level of information displayed at the command line during the optimization
'High'
(default) |'Moderate'
|'Silent'
The level of information displayed at the command line during the optimization process, specified as either'High'
,'Moderate'
, or'Silent'
.
'Silent'
- Nothing is displayed at the command line until the optimization process is finished'Moderate'
- Information is displayed at each major step of the optimization process, including when the process is in the preprocessing, modeling, and optimization phases.'High'
- Information is displayed at the command line at each iteration of the optimization process, including whether a new best solution was found, and the cost of the solution.
Example:opt.Verbosity = 'Moderate';
Data Types:char
|string
AllowableWordLengths
—Word lengths that can be used in your optimized system under design
[2:128]
(default) |scalar integer|向量的整数
Specify the word lengths that can be used in your optimized system under design. Use this property to target the neighborhood search of the optimization process. The final result of the optimization uses word lengths in the intersection of theAllowableWordLengths
and word lengths compatible with hardware constraints specified in theHardware Implementationpane of your model.
Example:opt.AllowableWordLengths = [8:11,16,32];
Data Types:double
ObjectiveFunction
—Objective function to use during optimization search
'BitWidthSum'
(default) |“OperatorCount”
Objective function to use during optimization search, specified as one of these values:
'BitWidthSum'
— Minimize total bit width sum.“OperatorCount”
— Minimize estimated count of operators in generated C code.This option may result in a lower program memory size for C code generated from Simulink®models. The
“OperatorCount”
objective function is not suitable for FPGA or ASIC targets.Note
To use
“OperatorCount”
在优化目标函数,model must be ready for code generation. For more information about determining code generation readiness, seeCheck Model and Configuration for Code Generation(Embedded Coder).
Data Types:char
UseParallel
—Whether to run iterations in parallel
false
(default) |true
Whether to run iterations of the optimization in parallel, specified as a logical. Running the iterations in parallel requires a Parallel Computing Toolbox™ license. If you do not have a Parallel Computing Toolbox license, or if you specifyfalse
, the iterations run in serial.
Data Types:logical
AdvancedOptions
—Additional options for optimization
object
Additional advanced options for optimization.AdvancedOptions
is an object containing additional properties that can affect the optimization.
Property | Description |
---|---|
PerformNeighborhoodSearch |
|
EnforceLooseCoupling |
Some blocks have a parameter that forces inputs to share a data type, or forces the output to share the same data type as the input.
|
UseDerivedRangeAnalysis |
Depending on the model configuration, derived range analysis may take longer than simulation of the model. |
SimulationScenarios |
Define additional simulation scenarios to consider during optimization using aSimulink.SimulationInput object. For an example, seeOptimize Data Types Using Multiple Simulation Scenarios. |
SafetyMargin |
Enter a safety margin, specified as a positive scalar value indicating the percentage increase in the bounds of the collected range. The safety margin is applied to the union of all collected ranges, including simulation ranges, derived ranges, and design ranges. |
DataTypeOverride |
Override data types specified in the model when simulating during the range collection phase of optimization.
|
HandleUnsupported |
Some blocks are not supported for fixed-point conversion. For more information, seeBlocks That Do Not Support Fixed-Point Data Types.
|
PerformSlopeBiasCancellation |
|
InstrumentationContext |
[model '/Subsystem'] – Restrict instrumentation for minimum, maximum, and overflow logging for the range collection step of optimization to a subsystem. The subsystem must be under the top-level model and contain the system under design. |
Methods
addSpecification | Specify known data types in a system |
addTolerance | Specify numeric tolerance for optimized system |
showSpecifications | Show specifications for a system |
showTolerances | Show tolerances specified for a system |
Copy Semantics
Handle. To learn how handle classes affect copy operations, seeCopying Objects.
Examples
Create anfxpOptimizationOptions
Object
Create anfxpOptimizationObject
with default property values.
options = fxpOptimizationOptions();
Edit the properties after creation using dot syntax.
options.Patience = 15; options.AllowableWordLengths = [8,16,32]; options.AdvancedOptions.UseDerivedRangeAnalysis = true
options = fxpOptimizationOptions with properties: MaxIterations: 50 MaxTime: 600 Patience: 15 Verbosity: High AllowableWordLengths: [8 16 32] ObjectiveFunction: BitWidthSum UseParallel: 0 Advanced Options AdvancedOptions: [1x1 DataTypeOptimization.AdvancedFxpOptimizationOptions]
Create anfxpOptimizationOptions
Object With Non-Default Settings
Use property name-value pairs to set properties at object creation.
options = fxpOptimizationOptions('Patience',15,'AllowableWordLengths',[8,16,32])
options = fxpOptimizationOptions with properties: MaxIterations: 50 MaxTime: 600 Patience: 15 Verbosity: High AllowableWordLengths: [8 16 32] ObjectiveFunction: BitWidthSum UseParallel: 0 Advanced Options AdvancedOptions: [1x1 DataTypeOptimization.AdvancedFxpOptimizationOptions]
Specify advanced options.
options.AdvancedOptions.UseDerivedRangeAnalysis = 1
options = fxpOptimizationOptions with properties: MaxIterations: 50 MaxTime: 600 Patience: 15 Verbosity: High AllowableWordLengths: [8 16 32] ObjectiveFunction: BitWidthSum UseParallel: 0 Advanced Options AdvancedOptions: [1x1 DataTypeOptimization.AdvancedFxpOptimizationOptions]
Import anfxpOptimizationOptions
Object into Fixed-Point Tool
You can import anfxpOptimizationOptions
object into the Fixed-Point Tool to perform data type optimization in the app. By importing anfxpOptimizationOptions
object rather than specifying settings manually in the app, you can easily save and restore your settings.
Open the model.
model ='ex_controllerHarness'; open_system(model);
To specify options for the optimization, such as the allowable word length and number of iterations, use thefxpOptimizationOptions
object.
options = fxpOptimizationOptions('AllowableWordLengths', [2:32],'MaxIterations', 3e2,'Patience', 50);
Open the Fixed-Point Tool with theController
subsystem selected.
fxptdlg('ex_controllerHarness/Controller')
In the Fixed-Point Tool, selectNew > Optimized Fixed-Point Conversionto start the data type optimization workflow.
In theSetuppane, underAdvanced Options, select the optimization options object to import from the dropdown menu. ClickImport.
Expand theSettingsmenu in the toolstrip to confirm that the optimization options were applied.
已经rsion History
See Also
Classes
Functions
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
- 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)