diff --git a/Car.py b/Car.py
index 42853cf..edab79d 100644
--- a/Car.py
+++ b/Car.py
@@ -1,6 +1,6 @@
import sumolib
from math import dist, ceil, sqrt, log, cos, sin, atan2
-from random import randint
+from random import randint, uniform
from PySide6.QtGui import QPainter
from PySide6.QtCore import QPointF, Signal, QObject
@@ -57,7 +57,7 @@ class Car():
self.gamma = 5
self.delta = 0
- self.T = 1.3
+ self.T = uniform(0.9,1.6)
self.size = 3
self.vroom = 0
diff --git a/CarController.py b/CarController.py
index 6feb147..74c2b9e 100644
--- a/CarController.py
+++ b/CarController.py
@@ -131,7 +131,11 @@ class CarController:
else:
self.cars.append(Car(vehicle.id,route,vehicle.depart,self.map,self,None))
elif vehicle.name == "flow":
- self.flows.append(Flow(vehicle.id, route, vehicle.begin, vehicle.vehsPerHour, self.map, self))
+ randomFlow = 0
+ if(vehicle.hasChild("param")):
+ params = vehicle.getChild("param")[0]
+ randomFlow = params.getAttributeSecure("value")
+ self.flows.append(Flow(vehicle.id, route, vehicle.begin, vehicle.vehsPerHour, randomFlow,self.map, self))
def prepareRoute(self):
for car in self.cars:
diff --git a/Flow.py b/Flow.py
index c669664..fa2051a 100644
--- a/Flow.py
+++ b/Flow.py
@@ -1,13 +1,16 @@
from Car import Car
import copy
+from random import randint
class Flow:
- def __init__(self,ID,route,start,vph,parentMap,parentController):
+ def __init__(self,ID,route,start,vph,randomVal,parentMap,parentController):
self.route = route
self.id = ID
self.startTime = start
self.vph = float(vph)
+ self.randomVal = int(randomVal)
+ self.adjVPH = self.vph + randint(0,self.randomVal)
self.carModel = Car("model",self.route,start,parentMap,parentController,None)
self.carsSpawned = 0
@@ -16,10 +19,11 @@ class Flow:
def shouldSpawn(self, t):
f = self.carsSpawned / (t/3600)
- return f < self.vph
+ return f < self.adjVPH
def spawnCar(self):
newCar = copy.copy(self.carModel)
newCar.id = self.id + str(self.carsSpawned)
self.carsSpawned += 1
+ self.adjVPH = self.vph + randint(0,self.randomVal)
return newCar
diff --git a/test11_rand.rou.xml b/test11_rand.rou.xml
new file mode 100644
index 0000000..5bab10b
--- /dev/null
+++ b/test11_rand.rou.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test16.rou.xml b/test16.rou.xml
new file mode 100644
index 0000000..8fdb722
--- /dev/null
+++ b/test16.rou.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+