comparison python/traffic_engineering.py @ 205:aeaaf5579b46

minor changes to traffic engineering
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 20 Mar 2012 22:32:38 -0400
parents c91c8fd8bf1e
children 82b4101d9a2f
comparison
equal deleted inserted replaced
204:966c2cd2bd9f 205:aeaaf5579b46
146 self.equivalents = equivalents 146 self.equivalents = equivalents
147 self.nLanes = nLanes 147 self.nLanes = nLanes
148 else: 148 else:
149 pass 149 pass
150 150
151 def getPCEVolume(self): 151 def getPCUVolume(self):
152 '''Returns the passenger-car equivalent for the input volume''' 152 '''Returns the passenger-car equivalent for the input volume'''
153 v = 0 153 v = 0
154 for p, e in zip(self.proportions, self.equivalents): 154 for p, e in zip(self.proportions, self.equivalents):
155 v += p*e 155 v += p*e
156 return v*self.volume 156 return v*self.volume
157 157
158 class IntersectionMovement: 158 class IntersectionMovement:
159 '''Represents an intersection movement 159 '''Represents an intersection movement
160 with a volume, a type (through, left or right) 160 with a volume, a type (through, left or right)
161 and an equivalent for movement type''' 161 and an equivalent for movement type'''
162 def __init__(self, volume, type, mvtEquivalent = 1): 162 def __init__(self, volume, mvtEquivalent = 1):
163 self.volume = volume 163 self.volume = volume
164 self.type = type
165 self.mvtEquivalent = mvtEquivalent 164 self.mvtEquivalent = mvtEquivalent
166 165
167 def getTVUVolume(self): 166 def getTVUVolume(self):
168 return self.mvtEquivalent*self.volume.getPCEVolume() 167 return self.mvtEquivalent*self.volume.getPCUVolume()
169 168
170 class IntersectionApproach: 169 class IntersectionApproach:
171 def __init__(self, leftTurnVolume, throughVolume, rightTurnVolume): 170 def __init__(self, leftTurnVolume, throughVolume, rightTurnVolume):
172 self.leftTurnVolume = leftTurnVolume 171 self.leftTurnVolume = leftTurnVolume
173 self.throughVolume = throughVolume 172 self.throughVolume = throughVolume
174 self.rightTurnVolume = rightTurnVolume 173 self.rightTurnVolume = rightTurnVolume
175 174
176 def getTVUVolume(self, leftTurnEquivalent = 1, throughEquivalent = 1, rightTurnEquivalent = 1): 175 def getTVUVolume(self, leftTurnEquivalent = 1, throughEquivalent = 1, rightTurnEquivalent = 1):
177 return self.leftTurnVolume.getPCEVolume()*leftTurnEquivalent+self.throughVolume.getPCEVolume()*throughEquivalent+self.rightTurnVolume.getPCEVolume()*rightTurnEquivalent 176 return self.leftTurnVolume.getPCUVolume()*leftTurnEquivalent+self.throughVolume.getPCUVolume()*throughEquivalent+self.rightTurnVolume.getPCUVolume()*rightTurnEquivalent
178 177
179 class LaneGroup: 178 class LaneGroup:
180 '''Class that represents a group of mouvements''' 179 '''Class that represents a group of mouvements'''
181 180
182 def __init__(self, movements, nLanes): 181 def __init__(self, movements, nLanes):