Main Content

fxpopt

システムのデータ型の最適化

説明

result = fxpopt(model, sud, options) は、モデル model 内の sud で指定されたモデルまたはサブシステムのデータ型を fxpOptimizationOptions オブジェクト options で指定された追加オプションを使用して最適化します。

すべて折りたたむ

この例では、指定した許容誤差に基づいてシステムで使用されるデータ型を最適化する方法を示します。

最初に、データ型を最適化するシステムを開きます。

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]
             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.

OptimizationResult オブジェクト resultexplore メソッドでシミュレーション データ インスペクターを起動して設計を調べ、opt オブジェクトで指定された数値許容誤差の範囲内で総ビット数が最小になっていることを確認します。

 explore(result);

OptimizationResult オブジェクトの revert メソッドを使用してモデルを元の状態に戻すことができます。

 revert(result);

入力引数

すべて折りたたむ

最適化するシステムが含まれているモデルの名前。

データ型: char

データ型を最適化するモデルまたはサブシステム。システムへのパスを含む文字ベクトルとして指定します。

データ型: char

データ型最適化プロセスで使用する追加オプションを指定する fxpOptimizationOptions オブジェクト。

出力引数

すべて折りたたむ

最適化の結果。OptimizationResult オブジェクトとして返されます。オブジェクトの explore メソッドを使用すると、シミュレーション データ インスペクターを開いて最適化されたシステムの動作を確認できます。最適化で見つかった他の解を調べることもできます。これには、fxpOptimizationOptions オブジェクト options で指定された制約を満たすものと満たさないものの両方が含まれます。

バージョン履歴

R2018a で導入