我在sumo上创建了两个vehicle type,然后在一条路上设置了flow,怎么可以控制比例?


我在sumo上创建了两个vehicle type,然后在一条路上设置了flow,怎么可以控制比例?


关注让阿豪来帮你解答,本回答参考chatgpt3.5编写提供,如果还有疑问可以评论或留言问题描述: 在sumo上创建了两个vehicle type,然后在一条路上设置了flow,如何控制比例? 回答: 在sumo中,可以通过在flow中设置vtype来控制不同车型的流量,同时设置不同车型的比例可以使用duarouter和trips文件来实现。 具体步骤如下:
<vTypeDistribution id="myvTypeDist" type="alphabetically">
<vType weight="0.2" id="type1"/>
<vType weight="0.8" id="type2"/>
</vTypeDistribution>
上述代码中,按照字母顺序,比例为0.2的车辆类型为type1,比例为0.8的车辆类型为type2。 2. 在duarouter中使用vTypeDistribution。在duarouter的命令行中,添加如下代码:
$ duarouter -n net.net.xml -r routes.rou.xml --vTypeDistribution.myvTypeDist=myvTypeDist
<trip id="trip_id" depart="0" from="edge_id1" to="edge_id2" type="my_vtype"/>
上述代码中,“my_vtype”为上面.vTypeDistribution中定义的车辆类型id。 4. 设置flow的车辆类型比例。在flow文件中,可以设置不同车型的比例。下面是一个例子:
<flow id="1" begin="0" end="100000" vType="type1,type2" probability="0.4,0.6" from="edge1" to="edge2" />
上述代码中,flow中包含了type1和type2两种车型,且比例为0.4和0.6。 代码示例: 1. sumocfg文件中添加vTypeDistribution的代码示例:
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">
<input>
<net-file value="net.net.xml"/>
<route-files value="routes.rou.xml"/>
<additional-files value="route_type.xml"/>
</input>
<output>
<log value="log.txt"/>
<gui-settings-file value="settings.gui.xml"/>
<summary value="summary.xml"/>
<fcd-output value="fcd_output.xml"/>
<emission-output value="emission_output.xml"/>
<vehroute-output value="vehroute_output.xml"/>
</output>
<time>
<begin value="0"/>
<end value="100000"/>
<step-length value="1"/>
</time>
<processing>
<no-step-log value="true"/>
</processing>
<vTypeDistribution id="myvTypeDist" type="alphabetically">
<vType weight="0.2" id="type1"/>
<vType weight="0.8" id="type2"/>
</vTypeDistribution>
</configuration>
duarouter -n net.net.xml -r routes.rou.xml --vTypeDistribution.myvTypeDist=myvTypeDist
<?xml version="1.0" encoding="UTF-8"?>
<trips>
<trip id="trip1" depart="0" from="edge1" to="edge2" type="type1"/>
<trip id="trip2" depart="0" from="edge1" to="edge2" type="type2"/>
</trips>
<flow id="1" begin="0" end="100000" vType="type1,type2" probability="0.4,0.6" from="edge1" to="edge2" />