Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

1385

.pdf
Скачиваний:
0
Добавлен:
16.06.2024
Размер:
1.68 Mб
Скачать

Окончание прил. 7

<connections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.sf.net/xsd/connections_fi le.xsd">

<connection from="15" to="-1" fromLane="0" toLane="0"/> <connection from="15" to="-7" fromLane="0" toLane="0"/> <connection from="15" to="2" fromLane="1" toLane="1"/>

<connection from="6" to="1" fromLane="0" toLane="0"/> <connection from="6" to="-14" fromLane="0" toLane="0"/> <connection from="6" to="-22" fromLane="1" toLane="1"/>

<connection from="14" to="-22" fromLane="0" toLane="0"/> <connection from="14" to="-6" fromLane="0" toLane="0"/> <connection from="14" to="1" fromLane="1" toLane="1"/>

<connection from="7" to="2" fromLane="0" toLane="0"/> <connection from="7" to="-15" fromLane="0" toLane="0"/> <connection from="7" to="-1" fromLane="1" toLane="1"/>

<connection from="8" to="3" fromLane="0" toLane="0"/> <connection from="8" to="-16" fromLane="0" toLane="0"/> <connection from="8" to="-2" fromLane="1" toLane="1"/>

<connection from="16" to="-2" fromLane="0" toLane="0"/> <connection from="16" to="-8" fromLane="0" toLane="0"/> <connection from="16" to="3" fromLane="1" toLane="1"/>

<connection from="9" to="4" fromLane="0" toLane="0"/> <connection from="9" to="-17" fromLane="0" toLane="0"/> <connection from="9" to="-3" fromLane="1" toLane="1"/>

<connection from="17" to="-3" fromLane="0" toLane="0"/> <connection from="17" to="-9" fromLane="0" toLane="0"/> <connection from="17" to="4" fromLane="1" toLane="1"/>

</connections>

131

Приложение 8

Файлы описания транспортного спроса в сети

<?xml version="1.0" encoding="utf-8"?> <flowdefs>

<flow id="1" from="22" begin="0" end="7200" number="5000"/>

<flow id="2" from="-4" begin="0" end="7200" number="2000"/>

<flow id="3" from="6" begin="0" end="7200" number="1150"/>

<flow id="4" from="7" begin="0" end="7200" number="1100"/>

<flow id="5" from="8" begin="0" end="7200" number="950"/> <flow id="6" from="9" begin="0" end="7200"

number="1200"/>

<flow id="7" from="14" begin="0" end="7200" number="1150"/>

<flow id="8" from="15" begin="0" end="7200" number="1000"/>

<flow id="9" from="16" begin="0" end="7200" number="1250"/>

<flow id="10" from="17" begin="0" end="7200" number="1200"/>

</flowdefs>

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

<turns xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.sf.net/xsd/turns_file.xsd ">

<interval begin="0" end="7200"> <fromEdge id="6">

<toEdge id="-14" probability=".55"/> <toEdge id="1" probability=".35"/> <toEdge id="-22" probability=".10"/>

</fromEdge> <fromEdge id="7">

<toEdge id="-15" probability=".55"/> <toEdge id="2" probability=".35"/> <toEdge id="-1" probability=".10"/>

</fromEdge> <fromEdge id="8">

<toEdge id="-16" probability=".55"/> <toEdge id="3" probability=".35"/> <toEdge id="-2" probability=".10"/>

</fromEdge> <fromEdge id="9">

<toEdge id="-17" probability=".55"/> <toEdge id="4" probability=".35"/> <toEdge id="-3" probability=".10"/>

</fromEdge> <fromEdge id="14">

<toEdge id="-6" probability=".55"/> <toEdge id="-22" probability=".35"/> <toEdge id="1" probability=".10"/>

</fromEdge>

132

Окончание прил. 8

<fromEdge id="15">

<toEdge id="-7" probability=".55"/> <toEdge id="-1" probability=".35"/> <toEdge id="2" probability=".10"/>

</fromEdge> <fromEdge id="16">

<toEdge id="-8" probability=".55"/> <toEdge id="-2" probability=".35"/> <toEdge id="3" probability=".10"/>

</fromEdge> <fromEdge id="17">

<toEdge id="-9" probability=".55"/> <toEdge id="-3" probability=".35"/> <toEdge id="4" probability=".10"/>

</fromEdge>

<fromEdge id="22.300">

<toEdge id="1" probability=".85"/> <toEdge id="-6" probability=".10"/> <toEdge id="-14" probability=".05"/>

</fromEdge>

<fromEdge id="1.300">

<toEdge id="2" probability=".85"/> <toEdge id="-7" probability=".10"/> <toEdge id="-15" probability=".05"/>

</fromEdge>

<fromEdge id="2.300">

<toEdge id="3" probability=".85"/> <toEdge id="-8" probability=".10"/> <toEdge id="-16" probability=".05"/>

</fromEdge>

<fromEdge id="3.200">

<toEdge id="4" probability=".85"/> <toEdge id="-9" probability=".10"/> <toEdge id="-17" probability=".05"/>

</fromEdge>

<fromEdge id="-4.300">

<toEdge id="-3" probability=".85"/> <toEdge id="-17" probability=".10"/> <toEdge id="-9" probability=".05"/>

</fromEdge>

<fromEdge id="-3.200">

<toEdge id="-2" probability=".85"/> <toEdge id="-16" probability=".10"/> <toEdge id="-8" probability=".05"/>

</fromEdge>

<fromEdge id="-2.300">

<toEdge id="-1" probability=".85"/> <toEdge id="-15" probability=".10"/> <toEdge id="-7" probability=".05"/>

</fromEdge>

<fromEdge id="-1.300">

<toEdge id="-22" probability=".85"/> <toEdge id="-14" probability=".10"/> <toEdge id="-6" probability=".05"/>

</fromEdge>

</interval>

</turns>

133

Приложение 9

Режимы работы светофорных объектов модели SUMO при использовании алгоритма поиска разрыва в потоке

<tlLogic id="1" type="actuated" programID="0" offset="0"> <param key="max-gap" value="3.1"/>

<param key="passing-time" value="1.9"/> <param key="detector-gap" value="2.0"/> <phase duration="7" minDur="7" maxDur="51"

state="rrrGGGrrrrGGGr"/>

<phase duration="3" state="rrryyyrrrryyyr"/> <phase duration="7" minDur="7" maxDur="20"

state="rrrrrrGrrrrrrG"/>

<phase duration="3" state="rrrrrryrrrrrry"/> <phase duration="7" minDur="7" maxDur="51"

state="GGrrrrrGGrrrrr"/>

<phase duration="3" state="yyrrrrryyrrrrr"/> <phase duration="7" minDur="7" maxDur="20"

state="rrGrrrrrrGrrrr"/>

<phase duration="3" state="rryrrrrrryrrrr"/> </tlLogic>

<tlLogic id="2" type="actuated" programID="0" offset="0"> <param key="max-gap" value="3.1"/>

<param key="passing-time" value="1.9"/> <param key="detector-gap" value="2.0"/> <phase duration="7" minDur="7" maxDur="51"

state="rrrGGGrrrrGGGr"/>

<phase duration="3" state="rrryyyrrrryyyr"/> <phase duration="7" minDur="7" maxDur="20"

state="rrrrrrGrrrrrrG"/>

<phase duration="3" state="rrrrrryrrrrrry"/> <phase duration="7" minDur="7" maxDur="51"

state="GGrrrrrGGrrrrr"/>

<phase duration="3" state="yyrrrrryyrrrrr"/> <phase duration="7" minDur="7" maxDur="20"

state="rrGrrrrrrGrrrr"/>

<phase duration="3" state="rryrrrrrryrrrr"/> </tlLogic>

<tlLogic id="3" type="actuated" programID="0" offset="0"> <param key="max-gap" value="3.1"/>

<param key="passing-time" value="1.9"/> <param key="detector-gap" value="2.0"/> <phase duration="7" minDur="7" maxDur="51"

state="rrrGGGrrrrGGGr"/>

<phase duration="3" state="rrryyyrrrryyyr"/> <phase duration="7" minDur="7" maxDur="20"

state="rrrrrrGrrrrrrG"/>

<phase duration="3" state="rrrrrryrrrrrry"/> <phase duration="7" minDur="7" maxDur="51"

state="GGrrrrrGGrrrrr"/>

<phase duration="3" state="yyrrrrryyrrrrr"/> <phase duration="7" minDur="7" maxDur="20"

state="rrGrrrrrrGrrrr"/>

134

Окончание прил. 9

<phase duration="3" state="rryrrrrrryrrrr"/> </tlLogic>

<tlLogic id="4" type="actuated" programID="0" offset="0"> <param key="max-gap" value="3.1"/>

<param key="passing-time" value="1.9"/> <param key="detector-gap" value="2.0"/> <phase duration="7" minDur="7" maxDur="51"

state="rrrGGGrrrrGGGr"/>

<phase duration="3" state="rrryyyrrrryyyr"/> <phase duration="7" minDur="7" maxDur="20"

state="rrrrrrGrrrrrrG"/>

<phase duration="3" state="rrrrrryrrrrrry"/> <phase duration="7" minDur="7" maxDur="51"

state="GGrrrrrGGrrrrr"/>

<phase duration="3" state="yyrrrrryyrrrrr"/> <phase duration="7" minDur="7" maxDur="20"

state="rrGrrrrrrGrrrr"/>

<phase duration="3" state="rryrrrrrryrrrr"/> <phase duration="25" state="rrrrrrrrrrrrrr"/>

</tlLogic>

135

Приложение 10

Программа расчета режимов работы светофорных объектов в сети методом балансировки объемов движения

# -*- coding: utf-8 -*-

from xml.dom import minidom import numpy as np

import os, sys

from openopt import GLP from openopt import NLP

sys.path.append("C:\\sumo-0.18.0\\bin\\GM")

"""

------------------------ Привязкиинастройки ---------------------------

"""

tableOfConformity={} tableOfConformity['-1.300']=u'-1' tableOfConformity['-2.300']='-2' tableOfConformity['-3.200']='-3' tableOfConformity['-4.300']='-4' tableOfConformity['1.300']='1' tableOfConformity['2.300']='2' tableOfConformity['22.300']='22' tableOfConformity['3.200']='3'

tls={}

tls['1']={'0':35,'1':7,'2':3,'3':25,'4':7,'5':3}

tls['2']={'0':30,'1':7,'2':3,'3':30,'4':7,'5':3}

tls['3']={'0':30,'1':7,'2':3,'3':30,'4':7,'5':3}

tls['4']={'0':20,'1':7,'2':3,'3':20,'4':7,'5':3,'6':20}

edgControll=['-22','1','-1','-14','-6','2','-2','-15','-7','3','-3','-16','-8','4','-17','-9'] edgFlowRestrictions=['1','-1','2','-2','3','-3','17','9']

decodeTlsData={}

decodeTlsData['1']=['0','3']

decodeTlsData['2']=['0','3']

decodeTlsData['3']=['0','3']

decodeTlsData['4']=['0','3']

x0=np.array([90,0.5,0.5,0.5,0.6])

lb=np.ones(x0.size)*0.1

ub=np.ones(x0.size)*0.9

ub[0]=120

lb[0]=60

"""

136

Продолжение прил . 1 0

--------------------- Объявлениефункций --------------------------------------

"""

def decodeSolver(x0): global tls, decodeTlsData

Tp=getTpTime(tls,decodeTlsData)

key=tls.keys()

cycleTime=x0[0]

x=x0[1:]

key.sort()

for n in range(x.size): to=[]

to1=round((cycleTime-Tp[key[n]])*x[n]) to2=round(cycleTime-Tp[key[n]]-to1)

if to1<7: to1=7

to2=cycleTime-Tp[key[n]]-to1 elif to2<7:

to2=7 to1=cycleTime-Tp[key[n]]-to2

to=[to1,to2]

for m in range(len(decodeTlsData[key[n]])): tls[key[n]][decodeTlsData[key[n]][m]]=to[m]

return tls

def parseTurn(doc): turnsFlows={}

interval=doc.getElementsByTagName('interval')

Edg=interval[0].getElementsByTagName('fromEdge') for n in Edg:

temp=n.getElementsByTagName('toEdge')

out={}

for m in temp: out[m.getAttribute('id')]=float(m.getAttribute('probability'))

turnsFlows[n.getAttribute('id')]=out return turnsFlows

def Conformity(turnsFlows,tableOfConformity): key=tableOfConformity.keys()

for n in key: temp=turnsFlows.pop(n)

turnsFlows[tableOfConformity[n]]=temp return turnsFlows

def parseFlow(doc): flows={}

flowdefs=doc.getElementsByTagName('flowdefs')

flowRead=flowdefs[0].getElementsByTagName('flow')

137

Продолжение прил . 1 0

for n in flowRead: begin=float(n.getAttribute('begin')) end=float(n.getAttribute('end')) number=float(n.getAttribute('number'))

flows[n.getAttribute('from')]=number*3600.0/(end-begin) return flows

def parseInputFlowToEdg(turn): out={}

key=turn.keys() for n in key:

key2=turn[n].keys() for m in key2:

if out.has_key(m): out[m].append(n)

else:

out[m]=[n] return out

def parseEdgControll(edgDefs): edg=edgDefs.getElementsByTagName('edg') out={}

for n in edg:

out[n.getAttribute('id')]={'capacity':float(n.getAttribute('capacity')),'tls':n.getAttribute('tls'),'fa

za':n.getAttribute('faza')} return out

def getCycleTime(tls): out={} key=tls.keys()

for n in key: faza=tls[n].keys() time=0

for m in faza: time+=tls[n][m]

out[n]=time return out

def getTpTime(tls,decodeTlsData): out={}

key=tls.keys() for n in key:

faza=tls[n].keys()

time=0

for m in faza:

if not((decodeTlsData[n][0]==m)or(decodeTlsData[n][1]==m)):

138

Продолжение прил . 1 0

time+=tls[n][m]

out[n]=time return out

def getMaxCycleTime(tls): cycleTime=getCycleTime(tls) key=cycleTime.keys() out=cycleTime[key[0]] KEY=key[0]

for n in key:

if cycleTime[n]>out: out=cycleTime[n] KEY=n

return (out,KEY)

def getEdgTlsFlow(edg,tls): CycleTime=getCycleTime(tls) out={}

key=edg.keys() for n in key:

out[n]=edg[n]['capacity']*tls[edg[n]['tls']][edg[n]['faza']]/CycleTime[edg[n]['tls']] return out

def ObjFunction(x0):

global net,edg,edgControll tls=decodeSolver(x0) net._setTlsFlow(edg,tls) net.setStateFlow()

out=0

for n in edgControll: out+=net.Flow[n]

return out

def flowRestrictions(x0):

global net,edg,edgFlowRestrictions tls=decodeSolver(x0) net._setTlsFlow(edg,tls) net.setStateFlow()

out=[]

for n in edgFlowRestrictions: out.append(net.Flow[n]-net.TlsFlow[n])

return out

139

Продолжение прил . 1 0

"""

---------------------------- Объявлениеклассов -------------------------------

"""

class flowNet():

def __init__(self,turnDef,flowDef): self.TurnFlows=turnDef self.FlowDef=flowDef

self.InputFlowToEdg=parseInputFlowToEdg(self.TurnFlows) def _setTlsFlow(self,edg,tls):

self.TlsFlow=getEdgTlsFlow(edg,tls) def clearGoList(self):

out={}

key=self.InputFlowToEdg.keys() for n in key:

temp={}

for m in self.InputFlowToEdg[n]: temp[m]='None'

out[n]={'flow':'not success','flow_from':temp} self.GoList=out

def setStatusFlowEdg(self): try:

key=self.GoList.keys()

except:

self.clearGoList()

key=self.GoList.keys() for n in key:

if self.GoList[n]['flow']=='not success': flag=0 key2=self.GoList[n]['flow_from'].keys() for m in key2:

if self.GoList[n]['flow_from'][m]=='None': flag+=1

if flag==0: sumFlow=0.0 for m in key2:

sumFlow+=self.GoList[n]['flow_from'][m] self.GoList[n]['flow']=sumFlow

def _init_flow(self): out={} key=self.FlowDef.keys() for n in key:

out[n]=self.FlowDef[n]

self.Flow=out self._FlowList=out

def _setFlow(self):

140

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]