主要内容

优化系统的定点数据类型

数据类型优化旨在最小化目标函数,例如指定系统生成的代码中的总比特宽度或操作员的估计计数,同时在指定的公差内保持原始系统行为。在优化期间,软件通过模拟原始模型来建立基线。然后,它构建模型的不同的固定点版本,并运行模拟以确定使用新数据类型的行为。优化选择最小化目标函数的模型,同时也满足指定的行为约束。

包含要优化的系统的模型必须具有以下特征:

  • 模型中的所有块必须支持定点数据类型。金宝app

  • 模型中的块上指定的设计范围必须与模拟范围一致。

  • 如果模型包含MATLAB函数块,它必须使用matlab®定点转换支持的语言特性。金宝app有关更多信息,请参阅支持自动定点转换的MATLAB语言特性金宝app

  • 模型必须具有有限的仿真停止时间。

在优化过程中,软件更改了多个设置和模型配置参数。这些变化的这些目的包括抑制诊断,使使用仿真数据检查器进行记录,从而减少结果所消耗的内存,确保模型的有效性,加速优化过程,并关闭数据类型覆盖。有关更多信息,请参阅数据类型优化期间的模型配置更改。您可以在优化完成后恢复这些诊断。

优化数据类型的最佳实践

定义约束

为了确定一个新的定点实现的行为是否可接受,优化需要定义良好的行为约束。要定义约束,请使用addTolerance的方法fxpOptimizationOptions对象,或使用一个或多个模型验证块在您的模型中。有关更多信息,请参阅指定行为的约束

最小化锁定数据类型

针对定点工具的更改锁定数据类型启用您要优化的系统中的块设置,最大限度地减少了优化过程的自由查找新解决方案。金宝搏官方网站

模式管理与探索

fxpopt函数返回一个OptimizationResult对象,该对象包含一系列称为解决方案的定点实现。金宝搏官方网站如果优化过程找到满足指定行为约束的定点实现,则按成本对解决方案进行排序,以最小成本(位宽或运算符计数)作为数组的第一个元素给出最佳解决方案。金宝搏官方网站

在优化无法找到满足行为约束的定点实现的情况下,解按与基线模型的最大绝对差排序,以最小的差作为第一个元素。金宝搏官方网站

探索最好的解决方案使用探索的方法OptimizationResult对象。您还可以以同样的方式探索任何其他已找到的解决方案。金宝搏官方网站在选择要保留的解决方案之前,不要保存并关闭模型。关闭或保存模型会阻碍对不同解决方案的进一步探索。金宝搏官方网站

优化定点数据类型

这个例子展示了如何基于指定的公差优化系统使用的数据类型。

首先,打开要优化数据类型的系统。

模型=“ex_auto_gain_controller”;sud =“ex_auto_gain_controller / sud”;open_system(模型)

创建一个fxpOptimizationOptions对象定义约束和公差以满足您的设计目标。设定UseParallel财产的财产fxpOptimizationOptions反对真的并行运行优化的迭代。您还可以指定Word Lengths以允许您的设计允许的wordLength.财产。

opt = fxpoptimizationOptions(“AllowableWordLengths”24,“UseParallel”,真正的)
opt = fxpOptimizationOptions with properties: MaxIterations: 50 MaxTime: 600 Patience: 10 Verbosity: High allowablewordlength: [10 11 12 13 14 15 16 17 18 19 20 21 22 23 24]

使用addTolerance方法定义系统的原始行为与使用优化的定点数据类型的行为之间的差异的容差。

tol = 10e-2;addtolerance(opt,[模型' / output_signal '), 1“AbsTol”, tol);

使用fxpopt函数来运行优化。该软件分析了系统中系统中对象的范围,并在设计中指定的约束fxpOptimizationOptions对象将异构数据类型应用于系统,同时最小化总比特宽度。

Result = fxpopt(model, sud, opt);
使用“本地”配置文件...连接到并行池(工人数:4)开始并行池(Parpool)。+预处理+建模优化问题 - 构建决策变量+运行优化求解器分析和将文件传输给工人......完成。- 评估新解决方案:成本180,不符合公差。- 评估新解决方案:成本198,不符合公差。- 评估新解决方案:成本216,不符合公差。- 评估新解决方案:234,不符合公差。- 评估新解决方案:成本252,不符合公差。- 评估新解决方案:270,不符合公差。- 评估新的解决方案:成本288,不符合公差。- 评估新解决方案:花费306,满足公差。 - Evaluating new solution: cost 324, meets the tolerances. - Evaluating new solution: cost 342, meets the tolerances. - Evaluating new solution: cost 360, meets the tolerances. - Evaluating new solution: cost 378, meets the tolerances. - Evaluating new solution: cost 396, meets the tolerances. - Evaluating new solution: cost 414, meets the tolerances. - Evaluating new solution: cost 432, meets the tolerances. - Updated best found solution, cost: 306 - Evaluating new solution: cost 304, meets the tolerances. - Evaluating new solution: cost 304, meets the tolerances. - Evaluating new solution: cost 301, meets the tolerances. - Evaluating new solution: cost 305, does not meet the tolerances. - Evaluating new solution: cost 305, meets the tolerances. - Evaluating new solution: cost 301, meets the tolerances. - Evaluating new solution: cost 299, meets the tolerances. - Evaluating new solution: cost 299, meets the tolerances. - Evaluating new solution: cost 296, meets the tolerances. - Evaluating new solution: cost 299, meets the tolerances. - Evaluating new solution: cost 291, meets the tolerances. - Evaluating new solution: cost 296, does not meet the tolerances. - Evaluating new solution: cost 299, meets the tolerances. - Evaluating new solution: cost 300, meets the tolerances. - Evaluating new solution: cost 296, does not meet the tolerances. - Evaluating new solution: cost 301, meets the tolerances. - Evaluating new solution: cost 303, meets the tolerances. - Evaluating new solution: cost 299, meets the tolerances. - Evaluating new solution: cost 304, does not meet the tolerances. - Evaluating new solution: cost 300, meets the tolerances. - 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 280, meets the tolerances. - Evaluating new solution: cost 287, meets the tolerances. - Evaluating new solution: cost 288, does not meet the tolerances. - Evaluating new solution: cost 287, does not meet the tolerances. - Evaluating new solution: cost 283, meets the tolerances. - Evaluating new solution: cost 283, does not meet the tolerances. - Evaluating new solution: cost 262, does not meet the tolerances. - Evaluating new solution: cost 283, does not meet the tolerances. - Evaluating new solution: cost 282, does not meet the tolerances. - Evaluating new solution: cost 288, meets the tolerances. - Evaluating new solution: cost 289, meets the tolerances. - Evaluating new solution: cost 288, meets the tolerances. - Evaluating new solution: cost 290, meets the tolerances. - Evaluating new solution: cost 281, does not meet the tolerances. - Evaluating new solution: cost 286, does not meet the tolerances. - Evaluating new solution: cost 287, meets the tolerances. - Evaluating new solution: cost 284, meets the tolerances. - Evaluating new solution: cost 282, meets the tolerances. - Evaluating new solution: cost 285, does not meet the tolerances. - Evaluating new solution: cost 277, meets the tolerances. - Updated best found solution, cost: 280 - Updated best found solution, cost: 277 - Evaluating new solution: cost 272, meets the tolerances. - Evaluating new solution: cost 266, meets the tolerances. - Evaluating new solution: cost 269, meets the tolerances. - Evaluating new solution: cost 271, does not meet the tolerances. - Evaluating new solution: cost 274, meets the tolerances. - Evaluating new solution: cost 275, meets the tolerances. - Evaluating new solution: cost 274, does not meet the tolerances. - Evaluating new solution: cost 275, meets the tolerances. - Evaluating new solution: cost 276, does not meet the tolerances. - Evaluating new solution: cost 271, meets the tolerances. - Evaluating new solution: cost 267, meets the tolerances. - Evaluating new solution: cost 270, meets the tolerances. - Evaluating new solution: cost 272, meets the tolerances. - Evaluating new solution: cost 264, does not meet the tolerances. - Evaluating new solution: cost 265, does not meet the tolerances. - Evaluating new solution: cost 269, meets the tolerances. - Evaluating new solution: cost 270, meets the tolerances. - Evaluating new solution: cost 269, meets the tolerances. - Evaluating new solution: cost 276, meets the tolerances. - Evaluating new solution: cost 274, meets the tolerances. - Updated best found solution, cost: 272 - Updated best found solution, cost: 266 + Optimization has finished. - Neighborhood search complete. - Maximum number of iterations completed. + Fixed-point implementation that met the tolerances found. - Total cost: 266 - Maximum absolute difference: 0.087035 - Use the explore method of the result to explore the implementation.

使用探索的方法OptimizationResult目的,结果,启动仿真数据检查器并探索包含最小总位数的设计,同时保持中指定的数公差选择对象。

探索(结果);

您可以使用返回模型将模型恢复到原始状态恢复的方法OptimizationResult对象。

恢复(结果);

另请参阅

功能

班级

相关话题