fxpopt
优化系统的数据类型
说明
示例
此示例说明如何基于指定的容差优化系统使用的数据类型。
首先,打开您要为其优化数据类型的系统。
model = 'ex_auto_gain_controller'; sud = 'ex_auto_gain_controller/sud'; open_system(model)

创建一个 fxpOptimizationOptions 对象来定义约束和容差以满足您的设计目标。将 fxpOptimizationOptions 对象的 UseParallel 属性设置为 true 以并行运行优化迭代。您也可以通过 AllowableWordLengths 属性指定设计中允许的字长。
opt = fxpOptimizationOptions('AllowableWordLengths', 10:24, 'UseParallel', true)
opt =
fxpOptimizationOptions with properties:
MaxIterations: 50
MaxTime: 600
Patience: 10
Verbosity: High
AllowableWordLengths: [10 11 12 13 14 15 16 17 18 19 20 21 22 23 24]
ObjectiveFunction: BitWidthSum
UseParallel: 1
Advanced Options
AdvancedOptions: [1×1 DataTypeOptimization.AdvancedFxpOptimizationOptions]
使用 addTolerance 方法定义系统原始行为与使用优化的定点数据类型的行为之间差异的容差。
tol = 10e-2; addTolerance(opt, [model '/output_signal'], 1, 'AbsTol', tol);
使用 fxpopt 函数运行优化。软件分析您的在设系统中对象的范围以及在 fxpOptimizationOptions 对象中指定的约束,以将异构数据类型应用于您的系统,同时最小化总位宽。
result = fxpopt(model, sud, opt);
+ Starting data type optimization... + Checking for unsupported constructs. Starting parallel pool (parpool) using the 'Processes' profile ... 08-Aug-2024 13:41:00: Job Queued. Waiting for parallel pool job with ID 1 to start ... Connected to parallel pool with 8 workers. + Preprocessing + Modeling the optimization problem - Constructing decision variables + Running the optimization solver - Evaluating new solution: cost 180, does not meet the behavioral constraints. - Evaluating new solution: cost 198, does not meet the behavioral constraints. - Evaluating new solution: cost 216, does not meet the behavioral constraints. - Evaluating new solution: cost 234, does not meet the behavioral constraints. - Evaluating new solution: cost 252, does not meet the behavioral constraints. - Evaluating new solution: cost 270, does not meet the behavioral constraints. - Evaluating new solution: cost 288, does not meet the behavioral constraints. - Evaluating new solution: cost 306, meets the behavioral constraints. - Evaluating new solution: cost 324, meets the behavioral constraints. - Evaluating new solution: cost 342, meets the behavioral constraints. - Evaluating new solution: cost 360, meets the behavioral constraints. - Evaluating new solution: cost 378, meets the behavioral constraints. - Evaluating new solution: cost 396, meets the behavioral constraints. - Evaluating new solution: cost 414, meets the behavioral constraints. - Evaluating new solution: cost 432, meets the behavioral constraints. - Updated best found solution, cost: 306 - Evaluating new solution: cost 304, meets the behavioral constraints. - Evaluating new solution: cost 304, meets the behavioral constraints. - Evaluating new solution: cost 301, meets the behavioral constraints. - Evaluating new solution: cost 305, does not meet the behavioral constraints. - Evaluating new solution: cost 305, meets the behavioral constraints. - Evaluating new solution: cost 301, meets the behavioral constraints. - Evaluating new solution: cost 299, meets the behavioral constraints. - Evaluating new solution: cost 299, meets the behavioral constraints. - Evaluating new solution: cost 296, meets the behavioral constraints. - Evaluating new solution: cost 299, meets the behavioral constraints. - Evaluating new solution: cost 291, meets the behavioral constraints. - Evaluating new solution: cost 296, does not meet the behavioral constraints. - Evaluating new solution: cost 299, meets the behavioral constraints. - Evaluating new solution: cost 300, meets the behavioral constraints. - Evaluating new solution: cost 296, does not meet the behavioral constraints. - Evaluating new solution: cost 301, meets the behavioral constraints. - Evaluating new solution: cost 303, meets the behavioral constraints. - Evaluating new solution: cost 299, meets the behavioral constraints. - Evaluating new solution: cost 304, does not meet the behavioral constraints. - Evaluating new solution: cost 300, meets the behavioral constraints. - Evaluating new solution: cost 295, meets the behavioral constraints. - Evaluating new solution: cost 302, meets the behavioral constraints. - Evaluating new solution: cost 303, does not meet the behavioral constraints. - Evaluating new solution: cost 302, does not meet the behavioral constraints. - Evaluating new solution: cost 298, meets the behavioral constraints. - Evaluating new solution: cost 298, does not meet the behavioral constraints. - Evaluating new solution: cost 277, does not meet the behavioral constraints. - Evaluating new solution: cost 298, does not meet the behavioral constraints. - Evaluating new solution: cost 297, does not meet the behavioral constraints. - Evaluating new solution: cost 303, meets the behavioral constraints. - Evaluating new solution: cost 304, meets the behavioral constraints. - Evaluating new solution: cost 303, meets the behavioral constraints. - Evaluating new solution: cost 305, meets the behavioral constraints. - Evaluating new solution: cost 296, does not meet the behavioral constraints. - Evaluating new solution: cost 301, does not meet the behavioral constraints. - Evaluating new solution: cost 302, meets the behavioral constraints. - Evaluating new solution: cost 299, meets the behavioral constraints. - Evaluating new solution: cost 297, meets the behavioral constraints. - Evaluating new solution: cost 300, does not meet the behavioral constraints. - Evaluating new solution: cost 292, meets the behavioral constraints. - Updated best found solution, cost: 304 - Updated best found solution, cost: 301 - Updated best found solution, cost: 299 - Updated best found solution, cost: 296 - Updated best found solution, cost: 291 - Evaluating new solution: cost 286, meets the behavioral constraints. - Evaluating new solution: cost 276, meets the behavioral constraints. - Evaluating new solution: cost 283, meets the behavioral constraints. - Evaluating new solution: cost 285, does not meet the behavioral constraints. - Evaluating new solution: cost 288, meets the behavioral constraints. - Evaluating new solution: cost 289, meets the behavioral constraints. - Evaluating new solution: cost 288, does not meet the behavioral constraints. - Evaluating new solution: cost 289, meets the behavioral constraints. - Evaluating new solution: cost 290, does not meet the behavioral constraints. - Evaluating new solution: cost 285, meets the behavioral constraints. - Evaluating new solution: cost 281, meets the behavioral constraints. - Evaluating new solution: cost 284, meets the behavioral constraints. - Evaluating new solution: cost 286, meets the behavioral constraints. - Evaluating new solution: cost 278, does not meet the behavioral constraints. - Evaluating new solution: cost 279, does not meet the behavioral constraints. - Evaluating new solution: cost 283, meets the behavioral constraints. - Evaluating new solution: cost 284, meets the behavioral constraints. - Evaluating new solution: cost 283, meets the behavioral constraints. - Evaluating new solution: cost 290, meets the behavioral constraints. - Evaluating new solution: cost 288, meets the behavioral constraints. - Evaluating new solution: cost 283, meets the behavioral constraints. - Evaluating new solution: cost 289, meets the behavioral constraints. - Evaluating new solution: cost 286, meets the behavioral constraints. - Evaluating new solution: cost 288, meets the behavioral constraints. - Evaluating new solution: cost 283, meets the behavioral constraints. - Evaluating new solution: cost 284, meets the behavioral constraints. - Evaluating new solution: cost 282, meets the behavioral constraints. - Evaluating new solution: cost 284, meets the behavioral constraints. - Evaluating new solution: cost 277, does not meet the behavioral constraints. - Evaluating new solution: cost 286, meets the behavioral constraints. - Evaluating new solution: cost 278, does not meet the behavioral constraints. - Evaluating new solution: cost 277, meets the behavioral constraints. - Evaluating new solution: cost 281, meets the behavioral constraints. - Evaluating new solution: cost 290, meets the behavioral constraints. - Evaluating new solution: cost 288, meets the behavioral constraints. - Evaluating new solution: cost 288, meets the behavioral constraints. - Evaluating new solution: cost 287, does not meet the behavioral constraints. - Evaluating new solution: cost 282, meets the behavioral constraints. - Evaluating new solution: cost 286, does not meet the behavioral constraints. - Evaluating new solution: cost 277, meets the behavioral constraints. - Updated best found solution, cost: 286 - Updated best found solution, cost: 276 + Optimization has finished. - Neighborhood search complete. - Maximum number of iterations completed. + Fixed-point implementation that satisfies the behavioral constraints found. The best found solution is applied on the model. - Total cost: 276 - Maximum absolute difference: 0.077478 - Use the explore method of the result to explore the implementation.

使用 OptimizationResult 对象 result 的 explore 方法启动仿真数据检查器并探索包含最小总位数且同时保持在 opt 对象中指定的数值容差的设计。
explore(result);
您可以使用 OptimizationResult 对象的 revert 方法将模型还原回其原始状态。
revert(result);
输入参数
包含您要优化的系统的模型的名称。
数据类型: char
要优化其数据类型的模型或子系统,指定为包含系统路径的字符向量。
数据类型: char
fxpOptimizationOptions 对象,指定在数据类型优化过程中使用的其他选项。
输出参量
优化的结果,以 OptimizationResult 对象形式返回。使用对象的 explore 方法打开仿真数据检查器并查看优化系统的行为。您也可以探索在优化期间找到的其他解,这些解可能满足也可能不满足在 fxpOptimizationOptions 对象 options 中指定的约束。
版本历史记录
在 R2018a 中推出
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)