activitygen 根据网络中的人口描述生成需求。为此,它使用了一个简单的基于活动的交通模型。它支持工作、学校和休闲这三种活动,以及步行、自行车、汽车和公交车这四种交通方式。汽车的起点或终点可能位于地图之外。
典型命令行#
activitygen --net-file <NET> --stat-file <STATISTICS> --output-file <TRIPS> --random
<NET> 是 SUMO 网络文件形式的地图,<STATISTICS> 包含人口描述(如下所述),<TRIPS> 是生成的 SUMO 路线文件(即需求)。
您可以使用以下示例首次尝试 activitygen。
示例#

虽然 activitygen 主要是为大型网络生成交通需求而开发的,但此示例展示了右侧图像中的小型网络。下载文件 <SUMO_HOME>/tests/activitygen/activitygen-example.net.xml 和 <SUMO_HOME>/tests/activitygen/activitygen-example.stat.xml 以遵循此示例。
要运行此示例,请使用以下命令:
activitygen --net-file activitygen-example.net.xml \
--stat-file activitygen-example.stat.xml \
--output-file activitygen-example.trips.rou.xml \
--random
duarouter --net-file activitygen-example.net.xml \
--route-files activitygen-example.trips.rou.xml \
--output-file activitygen-example.rou.xml \
--ignore-errors
sumo --net-file activitygen-example.net.xml \
--route-files activitygen-example.rou.xml
第一条命令根据节点和边的描述生成网络文件。第二条命令根据统计文件中的人口描述生成路线文件(需求)。生成的路线文件不包含完整的路线信息,而是仅包含起始边和结束边(以及可选的途经点,即所谓的行程)。这允许您选择所需的路由器来连接出发地和目的地边。
当您如上所示运行 duarouter 时,所有车辆将在假设网络中只有自己的情况下选择最快的路线。这可能导致不现实的拥堵,应通过交通分配方法进行补救。
最后,您可以使用 SUMO 主可执行文件运行交通仿真。您也可以将行程文件直接提供给 SUMO,但这会显著减慢仿真速度,因为现在所有路由都是基于当前网络状态即时完成的。这种方法的优点是路线选择更好,因为车辆在路由时会考虑出发时的网络状态(参见 Demand/Automatic_Routing)。
sumo --net-file activitygen-example.net.xml \
--route-files activitygen-example.trips.rou.xml
统计文件#
通用信息#
首先,我们需要关于城市的一般信息。
<city>
<general
inhabitants="1000"
households="500"
childrenAgeLimit="18"
retirementAgeLimit="65"
carRate="0.58"
unemploymentRate="0.05"
footDistanceLimit="350"
incomingTraffic="200"
outgoingTraffic="50"
/>
</city>
所有这些属性的含义如下表所述:
| 属性名称 (Attribute Name) | 值类型 (Value Type) | 描述 (Description) |
|---|---|---|
| inhabitants | 整数 (Integer) | 居民总数 |
| households | 整数 (Integer) | 家庭总数(必须在城市成年人数量的 0.5 到 1 倍之间) |
| childrenAgeLimit | 整数 (Integer) | 低于此年龄的人为儿童。这是成年的第一年 |
| retirementAgeLimit | 整数 (Integer) | 低于此年龄的人可以有孩子在家并工作 |
| carRate | 浮点数[0;1] (Float[0;1]) | 成年人拥有汽车的概率 |
| unemploymentRate | 浮点数[0;1] (Float[0;1]) | 处于工作年龄的成年人失业的概率 |
| footDistanceLimit | 浮点数 (Float) | 一个人愿意步行而不是使用其他交通工具的最大距离。 |
| incomingTraffic | 整数 (Integer) | 每天进入城市工作的人数 |
| outgoingTraffic | 整数[0,inhabitants] (Integer[0,inhabitants]) | 在城市外工作的居民数量 |
参数#
这些条目与通用信息元素的不同之处在于它们描述的内容。它们更多地取决于城市的特殊背景或状态(事件、人口行为等)。它们也可用于优化:之后可以观察平均速度;可以更改所有值以满足交通验证标准。
<city>
<general ... />
<parameters
carPreference="0.50"
meanTimePerKmInCity="360"
freeTimeActivityRate="0.15"
uniformRandomTraffic="0.20"
departureVariation="120"
/>
</city>
所有这些属性的含义如下表所述:
| 属性名称 (Attribute Name) | 值类型 (Value Type) | 描述 (Description) |
|---|---|---|
| carPreference | 浮点数[0;1] (Float[0;1]) | 成年人在两者都可用时,更喜欢乘坐自己的汽车而不是公共交通工具的概率;默认值: 0。 |
| meanTimePerKmInCity | 整数(秒) (Integer(sec)) | 估计在地图上行驶一公里(鸟瞰)所需的时间;默认值: 360s。 |
| freeTimeActivityRate | 浮点数[0;1] (Float[0;1]) | 给定家庭在给定日期使用汽车进行休闲活动的概率;默认值: 0.15。 |
| uniformRandomTraffic | 浮点数[0;0.999] (Float[0;0.999]) | 整个交通需求中随机交通需求的比例;默认值: 0。 |
| departureVariation | 浮点数(秒) (Float(sec)) | 为出发时间的轻微变化引入的正态分布的方差(人类相对于计划的自然变化);默认值: 0。 |
人口年龄分组#
为了将人口连贯地分配到家庭和城市中,我们需要该人口的精确年龄分布。
<city>
<general ... />
<parameters ... />
<population>
<bracket beginAge="0" endAge="4" peopleNbr="1745" />
...
<bracket beginAge="66" endAge="90" peopleNbr="978" />
</population>
</city>
以下是所有分组属性的描述。
| 属性名称 (Attribute Name) | 值类型 (Value Type) | 描述 (Description) |
|---|---|---|
| beginAge | 整数 (Integer) | 区间的起始年龄(包含)。如果这不是第一个分组,则此年龄大于或等于前一个分组的结束年龄 |
| endAge | 整数 (Integer) | 区间的结束年龄(不包含)。此年龄大于当前分组的起始年龄 |
| peopleNbr | 整数 (Integer) | 该分组年龄区间内的人数([beginAge,endAge))。这是一个相对值,将根据城市居民总数进行归一化 |
工作时间#
我们需要指定城市所有工作岗位的开放和关闭时间。
<city>
<general ... />
<parameters ... />
<population> <bracket ... /> ... </population>
<workHours>
<opening hour="30600" proportion="0.30" />
...
<closing hour="43200" proportion="0.20" />
...
</workHours>
</city>
以下是 opening 和 closing 元素的所有属性的描述:
| 属性名称 (Attribute Name) | 值类型 (Value Type) | 描述 (Description) |
|---|---|---|
| hour | 整数(秒) (Integer(sec)) | 可能的工作开始或结束时间。 |
| proportion | 浮点数 (Float) | 将此时间作为开始(或结束)时间的工作岗位的比例。这是一个相对值:出现概率是通过将所有 opening(或 closing)比例值归一化为一来计算的。 |
人口和工作岗位分布#
现在,我们必须指定城市中每条街道的人口和工作密度。(我所说的街道是指边,这更精确)
<city>
<general ... />
<parameters ... />
<population> <bracket ... /> ... </population>
<workHours> <opening ... /> ... <closing ... /> ... </workHours>
<streets>
<street edge="abc123" population="2.5" workPosition="10.0" />
...
</streets>
</city>
以下是相应的属性描述:
| 属性名称 (Attribute Name) | 值类型 (Value Type) | 描述 (Description) |
|---|---|---|
| edge | 字符串 (String) | 边的 ID |
| population | 浮点数 (Float) | 每米街道的人数。相对值(根据居民总数归一化) |
| workPosition | 浮点数 (Float) | 每米街道的工作岗位数。相对值(根据城市总工作需求归一化) |
城市入口#
为了生成进出城交通,我们需要指定城市的入口。每个入口将生成相同数量的进出城车辆(总数除以入口数量)。
<city>
<general ... />
<parameters ... />
<population> <bracket ... /> ... </population>
<workHours> <opening ... /> ... <closing ... /> ... </workHours>
<streets> <street ... /> ... </streets>
<cityGates>
<entrance edge="abc123" pos="243.67" incoming="1.5" outgoing="2.2"/>
<entrance edge="abc234" pos="0.00" incoming="1.0" outgoing="0.5"/>
...
</cityGates>
</city>
相应的属性描述:
| 属性名称 (Attribute Name) | 值类型 (Value Type) | 描述 (Description) |
|---|---|---|
| edge | 字符串 (String) | 边的 ID |
| pos | 浮点数 (米) (Float (m)) | 街道(边)中的确切位置,以米为单位,从给定边的起点开始(最大值为边的长度) |
| incoming | 浮点数 (Float) | 通过此入口进入的车辆比例(相对于其他入口的 incoming 值) |
| outgoing | 浮点数 (Float) | 通过此入口离开城市的车辆比例(相对于其他入口的 outgoing 值) |
学校#
孩子们不去工作,而是去上学。学校的特殊之处在于它们位置精确,并且每天接收大量学生。
<city>
<general ... />
<parameters ... />
<population> <bracket ... /> ... </population>
<workHours> <opening ... /> ... <closing ... /> ... </workHours>
<streets> <street ... /> ... </streets>
<cityGates> <entrance ... /> ... </cityGates>
<schools>
<school edge="123abc" pos="23.0" beginAge="12" endAge="18" capacity="400" opening="32400" closing="64800" />
...
</schools>
</city>
相应的属性描述:
| 属性名称 (Attribute Name) | 值类型 (Value Type) | 描述 (Description) |
|---|---|---|
| edge | 字符串 (String) | 边的 ID |
| pos | 浮点数 (米) (Float (m)) | 街道(边)中的确切位置,以米为单位,从给定边的起点开始(最大值为边的长度) |
| beginAge | 整数 (Integer) | 学校最年轻学生的年龄(下限,包含在接受范围内) |
| endAge | 整数 (Integer) | 不再被学校接受的儿童年龄(上限,不包含在接受范围内) |
| capacity | 整数 (Integer) | 接受的最大学生数 |
| opening | 整数 (秒) (Integer (sec)) | 上课开始时间(学校时间) |
| closing | 整数 (秒) (Integer (sec)) | 上课结束时间(回家时间) |
公交线路#
人们拥有可供使用的公共巴士系统。这个公共交通系统由站点、具有相应站点的(双向)不同公交线路以及时刻表来描述。
<city>
<general ... />
<parameters ... />
<population> <bracket ... /> ... </population>
<workHours> <opening ... /> ... <closing ... /> ... </workHours>
<streets> <street ... /> ... </streets>
<cityGates> <entrance ... /> ... </cityGates>
<schools> <school ... /> ... </schools>
<busStations>
<busStation id="1" edge="abc123" pos="456" />
<busStation id="2" edge="123cba" pos="324" />
...
</busStations>
<busLines>
<busLine id="601" maxTripDuration="3000">
<stations>
<station refId="1" />
...
</stations>
<revStations>
<station refId="2" />
...
</revStations>
<frequencies>
<frequency begin="10000" end="25000" rate="1500" />
...
</frequencies>
</busLine>
</busLines>
</city>
所有元素的相应属性描述:
| 属性名称 (Attribute Name) | 值类型 (Value Type) | 描述 (Description) |
|---|---|---|
| id | 字符串 (String) | 公交线路的 ID |
| maxTripDuration | 整数 (秒) (Integer (sec)) | 公交车完成端到端行程所需的最长时间。 |
| refId | 整数 (Integer) | 对所选站点 ID 的引用(引用 busStation 对象的 ID) |
| begin | 整数 (秒) (Integer (sec)) | 新频率开始的时间 |
| end | 整数 (秒) (Integer (sec)) | 频率的结束时间 |
| rate | 整数 (秒) (Integer (sec)) | 两辆公交车之间的时间,这是数学频率的倒数。此公交车速率在上述 begin 和 end 值之间执行 |
最终示例#
这是一个完整的统计文件示例:
<city>
<general inhabitants="1000" households="500" childrenAgeLimit="19" retirementAgeLimit="66" carRate="0.58" unemploymentRate="0.05"
footDistanceLimit="250" incomingTraffic="200" outgoingTraffic="50" />
<parameters carPreference="0.50" meanTimePerKmInCity="6" freeTimeActivityRate="0.15" uniformRandomTraffic="0.20" departureVariation="300" />
<population>
<bracket beginAge="0" endAge="30" peopleNbr="30" />
<bracket beginAge="30" endAge="60" peopleNbr="40" />
<bracket beginAge="60" endAge="90" peopleNbr="30" />
</population>
<workHours>
<opening hour="30600" proportion="0.30" />
<opening hour="32400" proportion="0.70" />
<closing hour="43200" proportion="0.20" />
<closing hour="63000" proportion="0.20" />
<closing hour="64800" proportion="0.60" />
</workHours>
<streets>
<street edge="e01t11" population="10" workPosition="100" />
<street edge="e11t12" population="10" workPosition="100" />
<street edge="e12t13" population="10" workPosition="100" />
<street edge="e13t14" population="10" workPosition="100" />
<street edge="e11t21" population="10" workPosition="100" />
<street edge="e12t22" population="10" workPosition="100" />
<street edge="e13t23" population="10" workPosition="100" />
<street edge="e14t24" population="10" workPosition="100" />
<street edge="e21t22" population="10" workPosition="100" />
<street edge="e22t23" population="10" workPosition="100" />
<street edge="e23t24" population="10" workPosition="100" />
<street edge="e21t31" population="10" workPosition="100" />
<street edge="e22t32" population="100" workPosition="10" />
<street edge="e23t33" population="100" workPosition="10" />
<street edge="e24t34" population="100" workPosition="10" />
<street edge="e31t32" population="100" workPosition="10" />
<street edge="e32t33" population="100" workPosition="10" />
<street edge="e33t34" population="100" workPosition="10" />
<street edge="e31t41" population="100" workPosition="10" />
<street edge="e32t42" population="100" workPosition="10" />
<street edge="e33t43" population="100" workPosition="10" />
<street edge="e34t44" population="100" workPosition="10" />
<street edge="e41t42" population="100" workPosition="10" />
<street edge="e42t43" population="100" workPosition="10" />
<street edge="e43t44" population="100" workPosition="10" />
<street edge="e44t51" population="100" workPosition="10" />
</streets>
<cityGates>
<entrance edge="e01t11" pos="1" incoming="0.5" outgoing="0.5" />
<entrance edge="e44t51" pos="280" incoming="0.5" outgoing="0.5" />
</cityGates>
<schools>
<school edge="e11t12" pos="20" beginAge="0" endAge="6" capacity="200" opening="32400" closing="64800" />
<school edge="e33t34" pos="100" beginAge="3" endAge="12" capacity="150" opening="30600" closing="64800" />
<school edge="e41t42" pos="50" beginAge="10" endAge="20" capacity="300" opening="32400" closing="61200" />
</schools>
<busStations>
<busStation id="1" edge="e11t12" pos="10" />
<busStation id="2" edge="e12t13" pos="10" />
<busStation id="3" edge="e13t14" pos="10" />
<busStation id="4" edge="e14t24" pos="10" />
<busStation id="5" edge="e24t23" pos="10" />
<busStation id="6" edge="e23t33" pos="10" />
<busStation id="7" edge="e33t32" pos="10" />
<busStation id="8" edge="e32t31" pos="10" />
<busStation id="9" edge="e31t21" pos="10" />
<busStation id="10" edge="e21t11" pos="10" />
<busStation id="101" edge="e12t11" pos="10" />
<busStation id="102" edge="e13t12" pos="10" />
<busStation id="103" edge="e14t13" pos="10" />
<busStation id="104" edge="e24t14" pos="10" />
<busStation id="105" edge="e23t24" pos="10" />
<busStation id="106" edge="e33t23" pos="10" />
<busStation id="107" edge="e32t33" pos="10" />
<busStation id="108" edge="e31t32" pos="10" />
<busStation id="109" edge="e21t31" pos="10" />
<busStation id="110" edge="e11t21" pos="10" />
<busStation id="11" edge="e12t22" pos="10" />
<busStation id="12" edge="e22t32" pos="10" />
<busStation id="13" edge="e32t42" pos="10" />
<busStation id="14" edge="e42t41" pos="10" />
<busStation id="15" edge="e41t31" pos="10" />
<busStation id="111" edge="e22t12" pos="10" />
<busStation id="112" edge="e32t22" pos="10" />
<busStation id="113" edge="e42t32" pos="10" />
<busStation id="114" edge="e41t42" pos="10" />
<busStation id="115" edge="e31t41" pos="10" />
</busStations>
<busLines>
<busLine id="101" maxTripDuration="10">
<stations>
<station refId="1" />
<station refId="3" />
<station refId="4" />
<station refId="5" />
<station refId="6" />
<station refId="7" />
<station refId="8" />
<station refId="9" />
</stations>
<revStations>
<station refId="109" />
<station refId="108" />
<station refId="107" />
<station refId="106" />
<station refId="105" />
<station refId="104" />
<station refId="103" />
<station refId="102" />
</revStations>
<frequencies>
<frequency begin="21600" end="36000" rate="300" />
<frequency begin="36000" end="57600" rate="1800" />
<frequency begin="57600" end="68400" rate="300" />
<frequency begin="68400" end="86399" rate="1800" />
</frequencies>
</busLine>
<busLine id="102" maxTripDuration="7">
<stations>
<station refId="15" />
<station refId="9" />
<station refId="10" />
<station refId="1" />
<station refId="11" />
<station refId="12" />
<station refId="13" />
<station refId="14" />
</stations>
<revStations>
<station refId="114" />
<station refId="113" />
<station refId="112" />
<station refId="111" />
<station refId="101" />
<station refId="110" />
<station refId="109" />
<station refId="115" />
</revStations>
<frequencies>
<frequency begin="28800" end="32400" rate="600" />
<frequency begin="57600" end="64800" rate="600" />
</frequencies>
</busLine>
</busLines>
</city>
活动#
ActivityGen 考虑了两组活动,这些活动被认为是最具交通相关性的:工作和学校以及休闲时间。每组内的活动遵循相同的统计规则。
工作和学校活动#
此活动聚合包含以下活动:
- 成年人(未退休)去工作,以及
- 儿童去上学。
这意味着从家到工作的行程以及司机的返程行程。
休闲活动#
此活动聚合包含以下活动:
- 白天外出(针对退休或失业人员)
- 晚上外出(针对所有完成工作活动且不太晚的人员)
- 深夜或夜间外出(针对没有孩子的未退休成年人)
此活动旨在涵盖所有汽车用途,用于:
- 外出见朋友
- 做运动
- 探访家人
- 参加派对
为此,活动位置是随机的。
Activitygen 未涵盖的交通#
- 从城外到城外的过境交通
- 商务交通(送货服务、物流等)
- 旅游交通
- 特殊活动交通
在某种程度上,这可以通过添加 uniformRandomTraffic 来缓解。
交通方式#
人口根据统计数据分布在街道的家庭中。人们很可能根据其位置、不同交通方式的可用性以及目的地使用不同的交通方式。Activitygen 中使用三种方式:
- 步行或自行车
- 公交车
- 汽车
它们都有自己的可能性和可用性特征:
步行或自行车#
步行仅适用于非常短的距离。但在这种情况下,人们非常可能步行。自行车并没有真正被使用(公交车和汽车是首选),它被认为用于三种方式(步行、公交车和汽车)都不可用的情况。
公交车#
公交站点位于城市中,对应于输入中给出的真实公交线路网络(城市的统计数据)。距离公交站点足够近且目的地距离另一个公交站点足够近的人有资格使用公共交通工具。
汽车#
拥有一个或多个汽车的家庭成员可以驾驶(儿童除外)或由另一个也需要汽车的成年人陪同(护送)。儿童只能被陪同(例如去学校)。一些家庭没有汽车,在这种情况下,他们必须住在离公交站点足够近的地方。如果目的地远离任何公交站点,他们可以步行或骑自行车。但这种情况不会产生任何机动车辆交通。
生成的车辆#
- carInX:Y 是通勤交通
- randUniX 是随机交通(X 是运行索引)
- blXbY 是公交线路 X 的公交车编号 Y
- hXcY 是来自家庭 X 的汽车编号 Y
- hXcY:Z 是同一辆汽车的重复使用(例如在模拟多天时),其中 Z 是所有汽车的运行索引
限制#
SUMO 有一个用于个体多式联运行程的详细模型。自 0.26.0 起,也支持使用公共交通和个体交通方式的多式联运路由。然而,activitygen 并未利用这些功能。在 activitygen 中
- 公交车根据公交时刻表生成。使用公交车的人不会出现在仿真中。
- 根据位置和公交站点之间的一些距离标准,生成的汽车行程较少,因为假定人们乘坐公交车。不考虑公共交通出行时间。
- Activitigen 假设网络完全连通,如果输入网络不完全连通,可能会创建无效行程。一个可能的解决方案是使用命令
duarouter -n your.net.xml -r old.rou.xml --ignore-errors --write-trips -o filtered.rou.xml过滤掉无效行程,但这也会大幅减少交通量并需要在其他地方进行补偿。
模型文档#
ActivityGen 是作为评估 VANET 中信任场景的工具而开发的。这项工作是项目 Fidens: Cooperative Systems 之间的信任 的一部分,该项目以车辆网络中的可信概率知识处理为特色。有关模型内部的更多文档,请参阅 <SUMO_HOME>/src/activitygen 中的源代码,或询问原始作者。
