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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)