comparison trafficintelligence/traffic_engineering.py @ 1259:3bfdb2ffd29d

modif for plotting nserved
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 09 Apr 2024 15:21:55 -0400
parents 770306fef827
children f10e84505443
comparison
equal deleted inserted replaced
1257:e59a0a475a0a 1259:3bfdb2ffd29d
88 88
89 def queueingDuration(self): 89 def queueingDuration(self):
90 return self.reductionDuration*(1-self.beta)/(1-self.demandCapacityRatio) 90 return self.reductionDuration*(1-self.beta)/(1-self.demandCapacityRatio)
91 91
92 def nArrived(self, t): 92 def nArrived(self, t):
93 if self.demand is None: 93 '''since the beginning of the capacity reduction'''
94 if self.demand is None or t<0:
94 print('Missing demand field') 95 print('Missing demand field')
95 return None 96 return None
96 return self.demand*t 97 return self.demand*t
97 98
98 def nServed(self, t): 99 def nServed(self, t):
99 if self.capacity is None: 100 '''since the beginning of the capacity reduction'''
101 if self.capacity is None or t<0:
100 print('Missing capacity field') 102 print('Missing capacity field')
101 return None 103 return None
102 if 0<=t<=self.reductionDuration: 104 if 0<=t<=self.reductionDuration:
103 return self.beta*self.capacity*t 105 return self.beta*self.capacity*t
104 elif self.reductionDuration < t <= self.queueingDuration(): 106 elif self.reductionDuration < t:
105 return self.beta*self.capacity*self.reductionDuration+self.capacity*(t-self.reductionDuration) 107 qDuration = self.queueingDuration()
108 if t <= qDuration:
109 return self.beta*self.capacity*self.reductionDuration+self.capacity*(t-self.reductionDuration)
110 else:
111 return self.beta*self.capacity*self.reductionDuration+self.capacity*(qDuration-self.reductionDuration)+self.demand*(t-qDuration)
106 112
107 def nQueued(self, t): 113 def nQueued(self, t):
108 return self.nArrived(t)-self.nServed(t) 114 return self.nArrived(t)-self.nServed(t)
109 115
110 def maxNQueued(self): 116 def maxNQueued(self):