plans.xmlとoutput/output_plans.xml を記載します。変換の概要を教えて下さい。
plans.xmlとoutput/output_plans.xml を記載します。変換の概要を教えて下さい。
[plans.xml]
<?xml version="1.0" ?>
<!DOCTYPE plans SYSTEM "http://www.matsim.org/files/dtd/plans_v4.dtd">
<plans xml:lang="de-CH">
<person id="1">
<plan>
<act type="h" link="1" end_time="06:00" />
<leg mode="car">
</leg>
<act type="w" link="10" dur="00:00:10" />
<leg mode="walk">
</leg>
<act type="w" link="11" dur="00:00:05" />
<leg mode="car">
<!-- ここは書かない(MATSim に任せる) -->
</leg>
<act type="h" link="11" />
</plan>
</person>
<person id="2">
<plan>
<act type="h" link="10" end_time="06:00" />
<leg mode="car">
<route> </route>
</leg>
<act type="w" link="11" dur="00:00:10" />
<leg mode="walk">
<route> </route>
</leg>
<act type="w" link="100" dur="00:00:05" />
<leg mode="car">
<!-- ここは書かない(MATSim に任せる) -->
</leg>
<act type="h" link="11" />
</plan>
</person>
</plans>
[output/output_plans.xml] # 正確には、output_plans.xml.gz を解凍して出てきます
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE population SYSTEM "http://www.matsim.org/files/dtd/population_v6.dtd">
<population>
<attributes>
<attribute name="coordinateReferenceSystem" class="java.lang.String">EPSG:6685</attribute>
</attributes>
<!-- ====================================================================== -->
<person id="1">
<attributes>
<attribute name="vehicles" class="org.matsim.vehicles.PersonVehicles">{"car":"1"}</attribute>
</attributes>
<plan score="22.160614886406638" selected="yes">
<activity type="h" link="1" end_time="06:00:00" >
</activity>
<leg mode="car" dep_time="06:00:00" trav_time="00:03:03">
<attributes>
<attribute name="routingMode" class="java.lang.String">car</attribute>
</attributes>
<route type="links" start_link="1" end_link="10" trav_time="00:03:03" distance="1911.1392376935653" vehicleRefId="1">1 2 86 242 74 72 60 58 56 52 719 554 216 214 628 626 624 622 301 174 172 424 437 10</route>
</leg>
<activity type="w" link="10" max_dur="00:00:10" >
</activity>
<leg mode="walk" dep_time="06:03:13" trav_time="00:21:34">
<attributes>
<attribute name="routingMode" class="java.lang.String">walk</attribute>
</attributes>
<route type="generic" start_link="10" end_link="11" trav_time="00:21:34" distance="1078.609916820958"></route>
</leg>
<activity type="w" link="11" max_dur="00:00:05" >
</activity>
<leg mode="car" dep_time="06:24:52" trav_time="00:00:00">
<attributes>
<attribute name="routingMode" class="java.lang.String">car</attribute>
</attributes>
<route type="links" start_link="11" end_link="11" trav_time="00:00:00" distance="0.0" vehicleRefId="1">11</route>
</leg>
<activity type="h" link="11" >
</activity>
</plan>
</person>
<!-- ====================================================================== -->
<person id="2">
<attributes>
<attribute name="vehicles" class="org.matsim.vehicles.PersonVehicles">{"car":"2"}</attribute>
</attributes>
<plan score="22.708654950989434" selected="yes">
<activity type="h" link="10" end_time="06:00:00" >
</activity>
<leg mode="car" dep_time="06:00:00" trav_time="00:01:55">
<attributes>
<attribute name="routingMode" class="java.lang.String">car</attribute>
</attributes>
<route type="links" start_link="10" end_link="11" trav_time="00:01:55" distance="1253.9418184836827" vehicleRefId="2">10 414 317 319 171 173 175 177 179 11</route>
</leg>
<activity type="w" link="11" max_dur="00:00:10" >
</activity>
<leg mode="walk" dep_time="06:02:05" trav_time="00:18:06">
<attributes>
<attribute name="routingMode" class="java.lang.String">walk</attribute>
</attributes>
<route type="generic" start_link="11" end_link="100" trav_time="00:18:06" distance="905.5888853493962"></route>
</leg>
<activity type="w" link="100" max_dur="00:00:05" >
</activity>
<leg mode="car" dep_time="06:20:16" trav_time="00:01:14">
<attributes>
<attribute name="routingMode" class="java.lang.String">car</attribute>
</attributes>
<route type="links" start_link="100" end_link="11" trav_time="00:01:14" distance="877.1207180228002" vehicleRefId="2">100 98 92 22 20 18 16 14 12 11</route>
</leg>
<activity type="h" link="11" >
</activity>
</plan>
</person>
<!-- ====================================================================== -->
</population>
変換の概要は、「入力 plans.xml の“骨格”(活動の場所・順序・滞在条件・モード)に対して、MATSim がシミュレーション実行時に“肉付け”(時刻の確定・経路・距離・所要時間・車両割当・スコア等)を付けたものが output_plans.xml」という理解になる。以下、入力→出力で何が起きたかを対応づけて説明する。
1. ルート未記載(または空)→ route が具体化される
car の場合
入力では leg mode="car" に route が無い/空だったが、出力では
<route type="links" start_link="1" end_link="10" ...>1 2 86 ... 10</route>
のように リンク列(link id の並び) が生成されている。
-
type="links":ネットワーク上のリンク列で経路を表現 -
start_link,end_link:出発リンク/到着リンク -
distance:経路長(m) -
trav_time:その経路の所要時間(時刻依存の旅行時間に基づく)
つまり、入力 plans の「car で移動する」という指定に対して、MATSim が network.xml と travel time(初期は freespeed 等)を使って最短(一般には最小一般化費用)経路を計算し、具体的なリンク列として埋めた。
walk の場合
入力で <route> </route> があっても、出力では
<route type="generic" start_link="10" end_link="11" trav_time="00:21:34" distance="1078.60"/>
のように リンク列ではなく generic になっている。
-
type="generic":歩行をリンク列で保持しない(=軌跡は残さない)扱い -
代わりに
distanceとtrav_timeのみを保持
ここが、あなたが疑っている点(「ルートも追ってないのに正確な歩行時間が出るのはおかしい」)の“答え”で、MATSim は歩行を多くの場合「ネットワーク経路」ではなく「距離と速度による簡略モデル」で扱い、その結果として 時間だけは計算できるが、通過リンク列は残さない。
2. dur / end_time の表現が変わる(意味はほぼ同じ)
入力:
<act ... dur="00:00:10"/>
出力:
<activity ... max_dur="00:00:10"> </activity>
-
durがmax_durに変換されている -
意味としては「この活動は最大でこの時間まで(計画上は固定に近い)」という扱い
一方で end_time="06:00" は出力で 06:00:00 に秒が補われているだけ。
3. dep_time(出発時刻)が埋められる
入力 plans.xml では leg に出発時刻は書いていないが、出力では
<leg mode="car" dep_time="06:00:00" trav_time="00:03:03">
のように dep_time が決まっている。
決め方は単純で、
-
直前の activity の終了時刻(end_time または開始+max_dur)
→ 次の leg の dep_time
例(person 1):
-
home が 06:00:00 に終了
→ car の dep_time=06:00:00 -
car trav_time=00:03:03
→ 次の activity 開始は 06:03:03 -
work max_dur=00:00:10
→ 次の walk dep_time は 06:03:13(開始 06:03:03 + 10秒)
このように、行動の時間整合が実際に“確定値”として展開される。
4. trav_time(移動時間)と distance(距離)が付与される
各 leg に
-
trav_time -
route の
distance
が付く。これは MATSim がその反復(iteration)における travel time を使って計算した結果。
5. 車両の割当が追加される(vehicles / vehicleRefId)
出力では person ごとに
<attribute name="vehicles" ...>{"car":"1"}</attribute>
が入り、さらに car route に
vehicleRefId="1"
が付く。
これは「この person の car leg は、この person に割り当てられた vehicle を使う」という情報が、実行後の population として整備されたということ。
6. plan score と selected が付与される
<plan score="22.16..." selected="yes">
-
score:その計画の効用(MATSim のスコアリング結果) -
selected="yes":その person の中で採用された plan
入力 plans.xml は「計画の候補」だが、出力は「評価・選択された結果」を含む。
7. 「ゼロ移動」が発生している箇所がある(person1 の最後の car)
person 1 の最後の car leg が
start_link="11" end_link="11" distance="0.0" trav_time="00:00:00"
<route ...>11</route>
になっている。
これは入力上、
-
wが link=11 -
次の
hも link=11
で 同一リンク内の移動になっているため、経路計算の結果として移動がゼロになった。
8. ルートの“書き方”の差より、「実行後は MATSim が上書きする」ことが本質
あなたの入力では、
-
route を完全に省略した leg
-
<route> </route>の空タグがある leg
が混在しているが、出力を見る限り、少なくとも今回の実行では どちらも MATSim が結果で埋めるため、実務上の差はほとんど出ていない。
結論:変換とは何か
-
入力 plans.xml:
行動の順序・場所(link)・活動の終了条件(end_time / dur)・移動モードだけを与える“骨格” -
出力 output_plans.xml:
骨格に対して MATSim が
(1) 時刻展開(dep_time / trav_time)
(2) 経路展開(car は links 列、walk は generic)
(3) 距離付与
(4) 車両割当
(5) スコアと選択結果
を付けた“結果の population”