バックナンバーはこちら。
https://www.simulationroom999.com/blog/model-based-of-minimum-2-backnumber/
はじめに
前回はMDFの物理変換ルールのrationalについて説明。
制限付き有理関数で、
\(\displaystyle f(x)=\frac{ax^2+bx+c}{dx^2+ex+f}\)
を構成を前提としてもので6個の係数を指定すればOKな仕様。
今回も引き続きtabularから説明開始。
登場人物
博識フクロウのフクさん
![指差しフクロウ](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/指差しフクロウ.png)
イラストACにて公開の「kino_k」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=iKciwKA9&area=1
エンジニア歴8年の太郎くん
![技術者太郎](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/技術者01アップ.png)
イラストACにて公開の「しのみ」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=uCKphAW2&area=1
MDF conversion仕様 tabular
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/指差しフクロウ.png)
次のMDF conversion仕様はtabular。
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/「技術者a」20アップ.png)
名前的には表形式ってことのようだけど・・・。
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/お休みフクロウ.png)
これは本当に名前のまんまだね。
いわゆるテーブル変換だ。
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/「技術者a」13アップ.png)
1だったら10。
5だったら30。
8だったら60。
に変換みたな感じ?
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/指差しフクロウ.png)
そうだね。
あとは線形補間を入れる入れないのオプションもあるけど。
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/「技術者a」13アップ.png)
線形補間?
tabularの線形補間仕様
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/指差しフクロウ.png)
MDF conversionのinterpolation仕様といって、
線形補間をする場合”with interpolation仕様“
線形補間をしない場合”without interpolation仕様“
って言ったりもするね。
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/「技術者a」13アップ.png)
で、どういう違いがあるの?
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/お休みフクロウ.png)
さっきの太郎くんの例を元にまず表形式で表現すると以下になると思う。
input value | output value |
---|---|
1 | 10 |
5 | 30 |
8 | 60 |
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/指差しフクロウ.png)
で、これらをそれぞれ”with interpolation仕様”と”without interpolation仕様”で表現すると以下になる。
![MDF conversion仕様tabular(Value to value tabular look-up)"with interpolation仕様"と"without interpolation仕様"](https://www.simulationroom999.com/blog/wp-content/uploads/2022/03/02_MDF-conversion仕様tabularValue-to-value-tabular-look-up-1024x727.png)
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/技術者03アップ.png)
“with interpolation仕様”の方は間を補間されるのか!
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/技術者02アップ.png)
“without interpolation仕様”の方も良く見ると
変換元の範囲を見てそうだね。
0~3が0。
3~6.5が30。
6.5以上は60。
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/お休みフクロウ.png)
そうそう。
同じtabularでも補間仕様を使うかどうかで表現が大きく変わってくる。
tabularの指定の仕方
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/「技術者a」13アップ.png)
で、AsamMdfでtabularの変換ルールを使うにはどうしたら良いの?
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/指差しフクロウ.png)
今回のパターンだと以下の書き方だな。
conversion=dict()
conversion['raw_0']=1
conversion['raw_1']=5
conversion['raw_2']=8
conversion['phys_0']=10
conversion['phys_1']=30
conversion['phys_2']=60
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/お休みフクロウ.png)
さらに、”with interpolation仕様”にしたい場合は以下も追加。
尚、0を入れてはいるけど、‘interpolation’というKeyがあればOKなので、
Value側は何を入れてもOK。
conversion['interpolation']=0
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/技術者01アップ.png)
あ、Keyが存在しているかどうかだけで切り替えてるのね。
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/考え中フクロウ.png)
この仕様はドキュメントとしては載ってなかったからソースコードから調べてきた感じだ。
![太郎くん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/「技術者a」20アップ.png)
まぁこの手のライブラリあるあるだねー。
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/お休みフクロウ.png)
まぁ比較的マイナーな仕様なんで知らなくてもそうそう困ることはないんだけどね。
まとめ
![フクさん](https://www.simulationroom999.com/blog/wp-content/uploads/2020/05/指差しフクロウ.png)
まとめだよ。
- MDF conversion仕様のtabularについて説明。
- 一言で言うとテーブル変換。
- tabularには線形補間に関連する仕様がある。
- with interpolation仕様。
- 指定した点の間を線形補間。
- without interpolation仕様。
- 線形補間はしないが中点を境に変換範囲を推定。
- with interpolation仕様。
バックナンバーはこちら。
コメント