burst mode
This commit is contained in:
parent
72aab1eecb
commit
c61c92b3b0
@ -139,10 +139,18 @@ class CarController:
|
|||||||
self.cars.append(Car(vehicle.id,route,vehicle.depart,self.map,self,None))
|
self.cars.append(Car(vehicle.id,route,vehicle.depart,self.map,self,None))
|
||||||
elif vehicle.name == "flow":
|
elif vehicle.name == "flow":
|
||||||
randomFlow = 0
|
randomFlow = 0
|
||||||
|
burstInterval = 1
|
||||||
|
burstTime = 1
|
||||||
if(vehicle.hasChild("param")):
|
if(vehicle.hasChild("param")):
|
||||||
params = vehicle.getChild("param")[0]
|
for param in vehicle.getChild("param"):
|
||||||
randomFlow = params.getAttributeSecure("value")
|
key = param.getAttributeSecure("key")
|
||||||
self.flows.append(Flow(vehicle.id, route, vehicle.begin, vehicle.vehsPerHour, randomFlow,self.map, self))
|
if key == "random":
|
||||||
|
randomFlow = param.getAttributeSecure("value")
|
||||||
|
elif key == "burstInterval":
|
||||||
|
burstInterval = param.getAttributeSecure("value")
|
||||||
|
elif key == "burstTime":
|
||||||
|
burstTime = param.getAttributeSecure("value")
|
||||||
|
self.flows.append(Flow(vehicle.id, route, vehicle.begin, vehicle.vehsPerHour, randomFlow, burstInterval, burstTime, self.map, self))
|
||||||
|
|
||||||
def prepareRoute(self):
|
def prepareRoute(self):
|
||||||
for car in self.cars:
|
for car in self.cars:
|
||||||
|
6
Flow.py
6
Flow.py
@ -4,7 +4,7 @@ import copy
|
|||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
class Flow:
|
class Flow:
|
||||||
def __init__(self,ID,route,start,vph,randomVal,parentMap,parentController):
|
def __init__(self,ID,route,start,vph,randomVal, burstInterval, burstTime,parentMap,parentController):
|
||||||
self.route = route
|
self.route = route
|
||||||
self.id = ID
|
self.id = ID
|
||||||
self.startTime = start
|
self.startTime = start
|
||||||
@ -14,6 +14,8 @@ class Flow:
|
|||||||
self.carModel = Car("model",self.route,start,parentMap,parentController,None)
|
self.carModel = Car("model",self.route,start,parentMap,parentController,None)
|
||||||
self.carsSpawned = 0
|
self.carsSpawned = 0
|
||||||
self.priority = 0
|
self.priority = 0
|
||||||
|
self.burstInterval = float(burstInterval)
|
||||||
|
self.burstTime = float(burstTime)
|
||||||
self.cc = parentController
|
self.cc = parentController
|
||||||
|
|
||||||
def prepareRoute(self):
|
def prepareRoute(self):
|
||||||
@ -21,7 +23,7 @@ class Flow:
|
|||||||
|
|
||||||
def shouldSpawn(self, t):
|
def shouldSpawn(self, t):
|
||||||
f = self.carsSpawned / (t/3600)
|
f = self.carsSpawned / (t/3600)
|
||||||
return f < self.adjVPH
|
return f < self.adjVPH and t%self.burstInterval < self.burstTime
|
||||||
|
|
||||||
def spawnCar(self):
|
def spawnCar(self):
|
||||||
newCar = copy.copy(self.carModel)
|
newCar = copy.copy(self.carModel)
|
||||||
|
40
rdpt_polytech_burst.rou.xml
Normal file
40
rdpt_polytech_burst.rou.xml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!-- generated on 2022-05-09 15:36:56 by Eclipse SUMO netedit Version 1.12.0
|
||||||
|
-->
|
||||||
|
|
||||||
|
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
|
||||||
|
<flow id="f_0" begin="0.00" end="3600.00" vehsPerHour="1800.00">
|
||||||
|
<param key="burstInterval" value="300"/>
|
||||||
|
<param key="burstTime" value="60"/>
|
||||||
|
<route edges="E2 30807871 26745293#0 318654808 941887916 600325951#0 600325949 600325948 143886851#0 26745142 E3"/>
|
||||||
|
</flow>
|
||||||
|
<flow id="f_1" begin="0.00" end="3600.00" vehsPerHour="1800.00">
|
||||||
|
<param key="burstInterval" value="300"/>
|
||||||
|
<param key="burstTime" value="60"/>
|
||||||
|
<route edges="E2 30807871 26745293#0 318654808 941887917#0 -143879980 -E1"/>
|
||||||
|
</flow>
|
||||||
|
<flow id="f_2" begin="0.00" end="3600.00" vehsPerHour="1800.00">
|
||||||
|
<param key="burstInterval" value="300"/>
|
||||||
|
<param key="burstTime" value="60"/>
|
||||||
|
<route edges="E2 30807871 26745293#0 318654808 941887916 600325951#0 143879989#0 318654806#0 -E0"/>
|
||||||
|
</flow>
|
||||||
|
<flow id="f_3" begin="0.00" end="3600.00" vehsPerHour="1800.00">
|
||||||
|
<route edges="E0 -318654806#1 318654807#0 600325948 143886851#0 26745142 E3"/>
|
||||||
|
</flow>
|
||||||
|
<flow id="f_5" begin="0.00" end="3600.00" vehsPerHour="1800.00">
|
||||||
|
<route edges="E0 -318654806#1 318654807#0 600325948 143886851#0 301625138 -30807871 -E2"/>
|
||||||
|
</flow>
|
||||||
|
<flow id="f_6" begin="0.00" end="3600.00" vehsPerHour="1800.00">
|
||||||
|
<route edges="E0 -318654806#1 318654807#0 600325948 600325946 318654808 941887917#0 -143879980 -E1"/>
|
||||||
|
</flow>
|
||||||
|
<flow id="f_7" begin="0.00" end="3600.00" vehsPerHour="1800.00">
|
||||||
|
<route edges="E1 143879980 941887918#0 600325951#0 143879989#0 318654806#0 -E0"/>
|
||||||
|
</flow>
|
||||||
|
<flow id="f_8" begin="0.00" end="3600.00" vehsPerHour="1800.00">
|
||||||
|
<route edges="E1 143879980 941887918#0 600325951#0 600325949 600325948 143886851#0 26745142 E3"/>
|
||||||
|
</flow>
|
||||||
|
<flow id="f_9" begin="0.00" end="3600.00" vehsPerHour="1800.00">
|
||||||
|
<route edges="E1 143879980 941887918#0 600325951#0 600325949 600325948 143886851#0 301625138 -30807871 -E2"/>
|
||||||
|
</flow>
|
||||||
|
</routes>
|
Loading…
x
Reference in New Issue
Block a user