Choi-tttop 2024-03-24 03:25 采纳率: 0%
浏览 56

SUMO做仿真,怎么在仿真车流中控制不同类型车辆的比例?

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

img

img

  • 写回答

3条回答 默认 最新

  • 码农阿豪@新空间 新星创作者: 前端开发技术领域 2024-03-24 03:25
    关注
    让阿豪来帮你解答,本回答参考chatgpt3.5编写提供,如果还有疑问可以评论或留言
    问题描述: 在sumo上创建了两个vehicle type,然后在一条路上设置了flow,如何控制比例? 回答: 在sumo中,可以通过在flow中设置vtype来控制不同车型的流量,同时设置不同车型的比例可以使用duarouter和trips文件来实现。 具体步骤如下:
    1. 在.sumocfg文件中添加如下代码:
    <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
    
    1. 在trips文件中添加如下代码:
    <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>
    
    1. duarouter命令行中添加vTypeDistribution的命令示例:
    duarouter -n net.net.xml -r routes.rou.xml --vTypeDistribution.myvTypeDist=myvTypeDist
    
    1. trips文件中添加trip的代码示例:
    <?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>
    
    1. flow文件中设置车辆类型比例的代码示例:
    <flow id="1" begin="0" end="100000" vType="type1,type2" probability="0.4,0.6" from="edge1" to="edge2" />
    
    评论

报告相同问题?

问题事件

  • 创建了问题 3月24日