【SUMO学习】初级 Manhattan

目录

一、Network

1. 定义生成网状格的配置文件manhattan.netgcfg

2. 用程序生成路网文件net.net.xml

二、Demand

1. 生成随机车流 flows,为后续jtrrouter生成随机路线作准备

2. 编写jtrrouter配置文件manhattan.jtrrcfg

3. 执行jtrrouter程序为上述flows生成随机路线

三、Simulation

1. 编写配置文件manhattan.sumocfg

2. 运行仿真


Manhattan Mobility Model是一种网状格的交通路网形式,如下图:

目标:用脚本生成上图所示的交通路网和车流

一、Network

1. 定义生成网状格的配置文件manhattan.netgcfg

<?xml version="1.0" encoding="UTF-8"?>

<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/netgenerateConfiguration.xsd">

    <grid_network>
        <grid value="true"/>
        <grid.number value="10"/>
    </grid_network>

    <junctions>
        <no-turnarounds value="true"/>
    </junctions>

</configuration>

内容解释:

<grid value="true"/>  生成网(方)格状路网

grid.number  生成的路数量(横向 = 纵向)

<no-turnarounds value="true"/>  路口不允许掉头

2. 用程序生成路网文件net.net.xml

切换到netgenerate.exe程序所在路径SUMO\bin,执行程序生成路网文件:

netgenerate -c D:\sumo\manhattan\manhattan.netgcfg

实际命令行如下图所示: 

二、Demand

1. 生成随机车流 flows,为后续jtrrouter生成随机路线作准备

python D:\SUMO\tools\randomTrips.py -n net.net.xml -o flows.xml --begin 0 --end 1 \
       --flows 100 --jtrrouter \
       --trip-attributes "departPos=\"random\" departSpeed=\"max\""

注:在windows命令行中,最后一个传参的双引号要按照上述代码块的形式书写

参数解释:

-n  依照的network文件

-o  输出的文件

--begin  flow开始的时间(seconds)

--end  flow结束的时间。注意这里设置begin为0,end为1,在路网中插入车辆的时间段是[begin, end-1],即在time=0的时候插入车辆,且车流没有结束的时间。

--flows 100  指的是插入100辆车。以往用flow标签是可以插入多辆车的,但在这里1个<flow>只作1辆车来考虑,主要是为了后续调用jtrrouter来生成随机路线。

--jtrrouter  默认值是False,即不设置终点(destination),让车流在网格中运行得久一些。

生成的flows.xml部分如下图:

2. 编写jtrrouter配置文件manhattan.jtrrcfg

<?xml version="1.0" encoding="UTF-8"?>

<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/jtrrouterConfiguration.xsd">

    <input>
        <net-file value="net.net.xml"/>
        <route-files value="flows.xml"/>
    </input>

    <output>
        <output-file value="routes.xml"/>
    </output>

    <processing>
        <turn-defaults value="25,50,25"/>
        <accept-all-destinations value="true"/>
        <allow-loops value="true"/>
    </processing>

</configuration>

内容解释:

<turn-defaults value="25,50,25"/>  汽车在路口转向的概率:25% 右转,50% 直行,25% 左转

<allow-loops value="true"/>  为了让jtrrouter生成的 随机路线尽可能得长

3. 执行jtrrouter程序为上述flows生成随机路线

切换到jtrrouter.exe所在路径SUMO\bin

jtrrouter -c D:\sumo\manhattan\manhattan.jtrrcfg

实际命令行如下图所示:

生成的routes.xml部分如下图:

三、Simulation

1. 编写配置文件manhattan.sumocfg

<?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.xml"/>
    </input>
</configuration>

2. 运行仿真

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值