4. 基于OD矩阵的交通流生成

任务说明

本案例为单交叉口设计一套固定配时信号灯控制方案,包含相位划分、绿灯时长计算与全红时间设置,并在SUMO中完成仿真验证。交叉口为两条双向两车道道路相交,各进口道均含左转、直行、右转三条车道。要求通过仿真输出排队长度与停车次数,验证配时方案在给定交通需求下未出现车辆溢流。

1. 交叉口几何与相位设计

交叉口采用四相位控制方案(表1),相位1、2分别服务东西向直行与左转,相位3、4服务南北向直行与左转,右转车辆不受信号控制(允许常绿让行)。各相位之间设置全红时间以清空交叉口内的冲突车辆。

相位通行方向绿灯时长(s)黄灯(s)全红(s)
1东西直行3032
2东西左转1532
3南北直行3032
4南北左转1532

周期时长C = 30+3+2 + 15+3+2 + 30+3+2 + 15+3+2 = 110 s。全红时间设置在黄灯结束之后,用于清空已进入交叉口的车辆,避免与下一相位起始车流冲突。

2. 路网与信号灯配置

使用SUMO自带的netedit生成交叉口路网,或直接使用以下XML定义。路网文件cross.net.xml包含四条进口道与出口道,交叉口中心节点ID为J1。

<?xml version="1.0" encoding="UTF-8"?>
<nodes>
    <node id="W" x="0" y="500"/>
    <node id="E" x="1000" y="500"/>
    <node id="S" x="500" y="0"/>
    <node id="N" x="500" y="1000"/>
    <node id="J1" x="500" y="500" type="traffic_light"/>
</nodes>

<edges>
    <edge id="WtoJ" from="W" to="J1" numLanes="3" speed="13.89">
        <lane id="WtoJ_0" index="0" allow="w" disallow="m"/>
        <lane id="WtoJ_1" index="1" allow="w" disallow="m"/>
        <lane id="WtoJ_2" index="2" allow="w" disallow="m"/>
    </edge>
    <edge id="JtoE" from="J1" to="E" numLanes="3" speed="13.89"/>
    <edge id="StoJ" from="S" to="J1" numLanes="3" speed="13.89"/>
    <edge id="JtoN" from="J1" to="N" numLanes="3" speed="13.89"/>
    <edge id="EtoJ" from="E" to="J1" numLanes="3" speed="13.89"/>
    <edge id="JtoW" from="J1" to="W" numLanes="3" speed="13.89"/>
    <edge id="NtoJ" from="N" to="J1" numLanes="3" speed="13.89"/>
    <edge id="JtoS" from="J1" to="S" numLanes="3" speed="13.89"/>
</edges>

<connections>
    <connection from="WtoJ" to="JtoE" fromLane="0" toLane="0"/>
    <connection from="WtoJ" to="JtoE" fromLane="1" toLane="1"/>
    <connection from="WtoJ" to="JtoN" fromLane="2" toLane="0"/>
    <connection from="EtoJ" to="JtoW" fromLane="0" toLane="0"/>
    <connection from="EtoJ" to="JtoW" fromLane="1" toLane="1"/>
    <connection from="EtoJ" to="JtoS" fromLane="2" toLane="0"/>
    <connection from="StoJ" to="JtoN" fromLane="0" toLane="0"/>
    <connection from="StoJ" to="JtoN" fromLane="1" toLane="1"/>
    <connection from="StoJ" to="JtoE" fromLane="2" toLane="0"/>
    <connection from="NtoJ" to="JtoS" fromLane="0" toLane="0"/>
    <connection from="NtoJ" to="JtoS" fromLane="1" toLane="1"/>
    <connection from="NtoJ" to="JtoW" fromLane="2" toLane="0"/>
</connections>
</nodes>

信号灯配时文件cross.tll.xml定义四相位逻辑,每个相位包含绿灯、黄灯与全红状态。SUMO中全红通过在同一相位末尾添加state为r的时长实现。

<tlLogic id="J1" type="static" programID="fixed1" offset="0">
    <phase duration="30" state="GGGgrrrrGGGgrrrr"/>
    <phase duration="3"  state="yyyyrrrryyyyrrrr"/>
    <phase duration="2"  state="rrrrrrrrrrrrrrrr"/>
    <phase duration="15" state="rrrrGGGGrrrrGGGG"/>
    <phase duration="3"  state="rrrryyyyrrrryyyy"/>
    <phase duration="2"  state="rrrrrrrrrrrrrrrr"/>
    <phase duration="30" state="GGGgrrrrGGGgrrrr"/>
    <phase duration="3"  state="yyyyrrrryyyyrrrr"/>
    <phase duration="2"  state="rrrrrrrrrrrrrrrr"/>
    <phase duration="15" state="rrrrGGGGrrrrGGGG"/>
    <phase duration="3"  state="rrrryyyyrrrryyyy"/>
    <phase duration="2"  state="rrrrrrrrrrrrrrrr"/>
</tlLogic>

信号灯状态字符串中每两个字符对应一个进口方向(按SUMO内部顺序:W→E直行、W→N左转、E→W直行、E→S左转、S→N直行、S→E左转、N→S直行、N→W左转)。G表示绿灯,g表示允许直行但需让行(此处未使用),y黄灯,r红灯。全红阶段所有方向均为r。

3. 交通需求与仿真配置

生成flow.rou.xml定义各进口道流量:东西直行每小时600辆,东西左转200辆,南北直行500辆,南北左转150辆。仿真时长3600秒。

<routes>
    <flow id="f_WE" begin="0" end="3600" number="600" from="WtoJ" to="JtoE"/>
    <flow id="f_WN" begin="0" end="3600" number="200" from="WtoJ" to="JtoN"/>
    <flow id="f_EW" begin="0" end="3600" number="600" from="EtoJ" to="JtoW"/>
    <flow id="f_ES" begin="0" end="3600" number="200" from="EtoJ" to="JtoS"/>
    <flow id="f_SN" begin="0" end="3600" number="500" from="StoJ" to="JtoN"/>
    <flow id="f_SE" begin="0" end="3600" number="150" from="StoJ" to="JtoE"/>
    <flow id="f_NS" begin="0" end="3600" number="500" from="NtoJ" to="JtoS"/>
    <flow id="f_NW" begin="0" end="3600" number="150" from="NtoJ" to="JtoW"/>
</routes>

SUMO配置文件cross.sumocfg:

<configuration>
    <input>
        <net-file value="cross.net.xml"/>
        <route-files value="flow.rou.xml"/>
        <additional-files value="cross.tll.xml"/>
    </input>
    <time>
        <begin value="0"/>
        <end value="3600"/>
    </time>
    <processing>
        <time-to-teleport value="-1"/>
    </processing>
</configuration>

4. 仿真运行与验证

在命令行执行:

sumo -c cross.sumocfg --tripinfo-output tripinfo.xml --queue-output queue.xml

验证方法:仿真结束后检查queue.xml中各进口道最大排队长度是否超过车道可容纳车辆数(每条车道约可停靠8辆车,3条车道共24辆)。若某进口道排队长度持续接近或超过24辆,说明绿灯时长不足或周期设计不合理。同时检查tripinfo.xml中车辆平均停车次数,若直行车辆平均停车次数大于1次,说明车辆未能在单个绿灯周期内通过,需要调整绿信比。

判定标准:所有进口道最大排队长度≤20辆,且直行车辆平均停车次数≤1.0次,则配时方案通过验证。

5. 信号相位时序图

固定配时信号相位时序(周期110s) 0s 35s 55s 90s 110s 相位1 东西直行 相位2 左转 相位3 南北直行 相位4 左转 绿灯 黄灯 全红 周期 C = 110s

6. 结果分析说明

运行仿真后,通过queue.xml观察各进口道排队长度随时间变化。若在绿灯启亮后排队在10秒内消散,且最大排队长度未超过20辆,说明绿灯时长充足。若某方向持续存在长排队,可增加该相位绿灯时长并相应减少其他相位时长,保持周期不变或重新计算周期。全红时间2秒用于清空交叉口,在饱和流量下应观察是否有车辆在黄灯期间进入交叉口但未能在全红结束前通过,若出现此类情况需延长全红时间。