flow 定义多个车辆
上面我们每次设置都需要单独对每一辆车进行设置,如果车辆很多就会很麻烦。例如我们希望给定起点和终点,给定这条路线上车辆的数量,一次性生成多个车辆,前面的方法就不适用了。这个时候就需要使用 flow,
flow 的参数如下所示(flow 是主要设置车辆数量,可以有以下的参数,vehsPerHour、period、probability、number):
- begin, 第一个车辆的出发时间;
- end, end of departure interval (if undefined, defaults to 24 hours);
- vehsPerHour, number of vehicles per hour, equally spaced (not together with period or probability);(每小时的车辆数量)
- period, insert equally spaced vehicles at that period (not together with vehsPerHour or probability);
- probability, probability for emitting a vehicle each second (not together with vehsPerHour or period), see also Simulation/Randomness;
- number, total number of vehicles, equally spaced;(给定总的车辆)
通过 flow 中的 period 和 vehsPerHour 定义连续车辆
定义两个 flow,分别是每小时 1000 辆车,和每 5 秒会有一辆车。同时下面使用了两种不同的定义 flow 的方式(具体的如下所示):
<routes>
<!-- 定义两个车辆类型 -->
<vType id="type1" accel="0.8" decel="4.5" sigma="0.5" length="5" maxSpeed="70"/>
<vType id="type2" accel="1.2" decel="4.5" sigma="0.5" length="7" maxSpeed="120"/>
<!-- 定义 flow, 每小时 1000 辆车 -->
<flow id="flow1" color="1,1,0" begin="0" end= "7200" vehsPerHour="1000" type='type1'>
<route edges="3fi 3si 4o"/>
</flow>
<!-- 定义 flow, 每个 5 秒有车 -->
<flow id="flow2" color="0,1,1" begin="0" end="7200" period="5" type="type2" from="1si" to="2o"/>
</routes>