Оптимизация типов данных системы
В этом примере показано, как оптимизировать типы данных, используемые системой, на основе заданных допусков.
Для начала откройте систему, для которой требуется оптимизировать типы данных.
model = 'ex_auto_gain_controller'; sud = 'ex_auto_gain_controller/sud'; open_system(model)

Создание fxpOptimizationOptions для определения ограничений и допусков в соответствии с целями проектирования. Установите UseParallel имущества fxpOptimizationOptions объект в 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]
UseParallel: 1
Advanced Options
AdvancedOptions: [1×1 struct]
Используйте addTolerance метод определения допусков для различий между исходным поведением системы и поведением с использованием оптимизированных типов данных с фиксированной точкой.
tol = 10e-2; addTolerance(opt, [model '/output_signal'], 1, 'AbsTol', tol);
Используйте fxpopt для выполнения оптимизации. Программа анализирует диапазоны объектов в проектируемой системе и ограничения, указанные в fxpOptimizationOptions объект для применения разнородных типов данных к системе при минимизации общей ширины битов.
result = fxpopt(model, sud, opt);
Starting parallel pool (parpool) using the 'local' profile ... Connected to the parallel pool (number of workers: 4). + Preprocessing + Modeling the optimization problem - Constructing decision variables + Running the optimization solver Analyzing and transferring files to the workers ...done. - Evaluating new solution: cost 180, does not meet the tolerances. - Evaluating new solution: cost 198, does not meet the tolerances. - Evaluating new solution: cost 216, does not meet the tolerances. - Evaluating new solution: cost 234, does not meet the tolerances. - Evaluating new solution: cost 252, does not meet the tolerances. - Evaluating new solution: cost 270, does not meet the tolerances. - Evaluating new solution: cost 288, does not meet the tolerances. - Evaluating new solution: cost 306, meets the tolerances. - 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.

Используйте explore способ OptimizationResult объект, result, чтобы запустить Simulation Data Inspector и изучить конструкцию, содержащую наименьшее общее количество битов при сохранении числовых допусков, указанных в opt объект.
explore(result);
Можно вернуть модель в исходное состояние с помощью revert способ OptimizationResult объект.
revert(result);
model - Модель, содержащая проектируемую систему, sudИмя модели, содержащей систему, которую требуется оптимизировать.
Типы данных: char
sud - модель или подсистема, типы данных которых необходимо оптимизировать;Модель или подсистема, типы данных которых требуется оптимизировать, заданная как символьный вектор, содержащий путь к системе.
Типы данных: char
options - Дополнительные возможности оптимизацииfxpOptimizationOptions объектfxpOptimizationOptions задание дополнительных параметров для использования в процессе оптимизации типов данных.
result - Объект, содержащий оптимизированный проектOptimizationResult объектРезультат оптимизации, возвращенный как OptimizationResult объект. Используйте explore метод объекта для открытия инспектора данных моделирования и просмотра поведения оптимизированной системы. Можно также изучить другие решения, найденные во время оптимизации, которые могут соответствовать или не соответствовать ограничениям, указанным в fxpOptimizationOptions объект, options.
Имеется измененная версия этого примера. Открыть этот пример с помощью изменений?
1. Если смысл перевода понятен, то лучше оставьте как есть и не придирайтесь к словам, синонимам и тому подобному. О вкусах не спорим.
2. Не дополняйте перевод комментариями “от себя”. В исправлении не должно появляться дополнительных смыслов и комментариев, отсутствующих в оригинале. Такие правки не получится интегрировать в алгоритме автоматического перевода.
3. Сохраняйте структуру оригинального текста - например, не разбивайте одно предложение на два.
4. Не имеет смысла однотипное исправление перевода какого-то термина во всех предложениях. Исправляйте только в одном месте. Когда Вашу правку одобрят, это исправление будет алгоритмически распространено и на другие части документации.
5. По иным вопросам, например если надо исправить заблокированное для перевода слово, обратитесь к редакторам через форму технической поддержки.