changeset 314:539e2b4cfaa3

modified for 4740 tps
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 09 Apr 2013 12:38:58 -0400
parents 93d851d0d21e
children 82b9be447608
files python/traffic_engineering.py
diffstat 1 files changed, 8 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/python/traffic_engineering.py	Tue Apr 02 15:27:42 2013 -0400
+++ b/python/traffic_engineering.py	Tue Apr 09 12:38:58 2013 -0400
@@ -159,11 +159,16 @@
             self.types = types
             self.proportions = proportions
             self.equivalents = equivalents
-            self.nLanes = nLanes # unused
+            self.nLanes = nLanes
         else:
             print('Proportions do not sum to 1')
             pass
 
+    def checkProtected(self, opposedThroughMvt):
+        '''Checks if this left movement should be protected,
+        ie if one of the main two conditions on left turn is verified'''
+        return self.volume >= 200 or self.volume*opposedThroughMvt.volume/opposedThroughMvt.nLanes > 50000
+
     def getPCUVolume(self):
         '''Returns the passenger-car equivalent for the input volume'''
         v = 0
@@ -182,15 +187,6 @@
     def getTVUVolume(self):
         return self.mvtEquivalent*self.volume.getPCUVolume()    
 
-class IntersectionApproach: # should probably not be used
-    def __init__(self, leftTurnVolume, throughVolume, rightTurnVolume):
-        self.leftTurnVolume = leftTurnVolume
-        self.throughVolume = throughVolume
-        self.rightTurnVolume = rightTurnVolume
-
-    def getTVUVolume(self, leftTurnEquivalent = 1, throughEquivalent = 1, rightTurnEquivalent = 1):
-        return self.leftTurnVolume.getPCUVolume()*leftTurnEquivalent+self.throughVolume.getPCUVolume()*throughEquivalent+self.rightTurnVolume.getPCUVolume()*rightTurnEquivalent
-
 class LaneGroup:
     '''Class that represents a group of mouvements'''
 
@@ -204,11 +200,6 @@
     def getCharge(self, saturationVolume):
         return self.getTVUVolume()/(self.nLanes*saturationVolume)
 
-def checkProtectedLeftTurn(leftMvt, opposedThroughMvt):
-    '''Checks if one of the main two conditions on left turn is verified
-    The lane groups should contain left and through movement'''
-    return leftMvt.volume >= 200 or leftMvt.volume*opposedThroughMvt.volume/opposedThroughMvt.nLanes > 50000
-
 def optimalCycle(lostTime, criticalCharge):
     return (1.5*lostTime+5)/(1-criticalCharge)
 
@@ -226,9 +217,7 @@
         self.saturationVolume = saturationVolume
 
     def computeCriticalCharges(self):
-        self.criticalCharges = []
-        for phase in self.phases:
-            self.criticalCharges.append(max([lg.getCharge(self.saturationVolume) for lg in phase]))
+        self.criticalCharges = [max([lg.getCharge(self.saturationVolume) for lg in phase]) for phase in self.phases]
         self.criticalCharge = sum(self.criticalCharges)
         
     def computeOptimalCycle(self):
@@ -242,7 +231,7 @@
         return self.C
 
     def computeEffectiveGreen(self):
-        from numpy import round
+        #from numpy import round
         #self.computeCycle() # in case it was not done before
         effectiveGreenTime = self.C-self.lostTime
         self.effectiveGreens = [round(c*effectiveGreenTime/self.criticalCharge,1) for c in self.criticalCharges]