Specify options for data type optimization
fxpOptimizationOptions object enables you to specify options
and constraints to use during the data type optimization process.
opt = fxpOptimizationOptions()
fxpOptimizationOptions object with default values.
opt = fxpOptimizationOptions(
fxpOptimizationOptions object with property values
specified by one or more
Name,Value pair arguments.
Name must appear inside single quotes (
You can specify several name-value pair arguments in any order as
MaxIterations— Maximum number of iterations to perform
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.
opt.MaxIterations = 75;
MaxTime— Maximum amount of time for the optimization to run (in seconds)
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.
opt.MaxTime = 1000;
Patience— Maximum number of iterations where no new best solution is found
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.
opt.Patience = 15;
Verbosity— Level of information displayed at the command line during the optimization
The level of information displayed at the command line during the
optimization process, specified as either
'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
'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
opt.Verbosity = 'Moderate';
AllowableWordLengths— Word lengths that can be used in your optimized system under design
[2:128](default) | scalar integer | vector of integers
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 the
word lengths compatible with hardware constraints specified in the
Hardware Implementation pane of your model.
ObjectiveFunction— Objective function to use during optimization search
Objective function to use during optimization search, specified as one of these values:
'BitWidthSum' — Minimize total bit width
'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
objective function is not suitable for FPGA or ASIC
'OperatorCount' as the objective
function during optimization, the model must be ready for
code generation. For more information about determining code
generation readiness, see Check Model and Configuration for Code Generation (Embedded Coder).
UseParallel— Whether to run iterations in parallel
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 specify
iterations run in serial.
AdvancedOptions— Additional options for optimization
Additional advanced options for optimization.
AdvancedOptions is an object containing additional
properties that can affect the optimization.
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.
Depending on the model configuration, derived range analysis may take longer than simulation of the model.
|Define additional simulation scenarios to consider
during optimization using a |
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.
Override data types specified in the model when simulating during the range collection phase of optimization.
Some blocks are not supported for fixed-point conversion. For more information, see Blocks That Do Not Support Fixed-Point Data Types.
|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|
Handle. To learn how handle classes affect copy operations, see Copying Objects.
fxpOptimizationObject 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]
fxpOptimizationOptionsObject into Fixed-Point Tool
You can import an
fxpOptimizationOptions object into the Fixed-Point Tool to perform data type optimization in the app. By importing an
fxpOptimizationOptions 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 the
options = fxpOptimizationOptions('AllowableWordLengths', [2:32], 'MaxIterations', 3e2, 'Patience', 50);
Open the Fixed-Point Tool with the
Controller subsystem selected.
In the Fixed-Point Tool, select New > Optimized Fixed-Point Conversion to start the data type optimization workflow.
In the Setup pane, under Advanced Options, select the optimization options object to import from the dropdown menu. Click Import.
Expand the Settings menu in the toolstrip to confirm that the optimization options were applied.