Kaynağa Gözat

increase computational performance

Sven Czarnian 3 yıl önce
ebeveyn
işleme
7c6d098812

+ 1 - 4
aman/config/AirportSequencing.py

@@ -81,9 +81,6 @@ class AirportSequencing:
             return []
 
         # search the dependency pair
-        dependencies = []
-        for dependency in self.RunwayDependencies:
-            if index == dependency[0] and not self.ActiveArrivalRunways[dependency[1]] in dependencies:
-                dependencies.append(self.ActiveArrivalRunways[dependency[1]])
+        dependencies = [self.ActiveArrivalRunways[self.RunwayDependencies[i][1]] for i in range(0, len(self.RunwayDependencies)) if index == self.RunwayDependencies[i][0]]
 
         return dependencies

+ 10 - 9
aman/sys/RecedingHorizonControl.py

@@ -21,23 +21,24 @@ class RecedingHorizonControl:
 
     def update(self, inbound : Inbound):
         # check if we need to update
-        if inbound.Report.aircraft.callsign in self.AssignedWindow:
-            index = self.AssignedWindow[inbound.Report.aircraft.callsign][0]
-            self.AssignedWindow[inbound.Report.aircraft.callsign][1] = 0
+        if inbound.Callsign in self.AssignedWindow:
+            index = self.AssignedWindow[inbound.Callsign][0]
+            self.AssignedWindow[inbound.Callsign][1] = 0
 
             # check if we assume the scheduling as fixed
             if index < self.FreezedIndex:
                 return
 
-            plannedInbound = self.Windows[index].inbound(inbound.Report.aircraft.callsign)
+            plannedInbound = self.Windows[index].inbound(inbound.Callsign)
             plannedInbound.CurrentPosition = inbound.CurrentPosition
             plannedInbound.ArrivalCandidates = inbound.ArrivalCandidates
+            plannedInbound.WTC = inbound.WTC
 
             # check if we need to update the inbound
             if plannedInbound.PlannedArrivalTime < inbound.EarliestArrivalTime:
                 if inbound.EarliestArrivalTime < self.Windows[index].StartTime or inbound.EarliestArrivalTime >= self.Windows[index].EndTime:
-                    self.Windows[index].remove(inbound.Report.aircraft.callsign)
-                    self.AssignedWindow.pop(inbound.Report.aircraft.callsign)
+                    self.Windows[index].remove(inbound.Callsign)
+                    self.AssignedWindow.pop(inbound.Callsign)
                     self.update(inbound)
                 else:
                     plannedInbound.PlannedStar = inbound.PlannedStar
@@ -53,7 +54,7 @@ class RecedingHorizonControl:
                 # find the correct window
                 if window.StartTime <= inbound.EarliestArrivalTime and window.EndTime > inbound.EarliestArrivalTime:
                     if i > self.FreezedIndex:
-                        self.AssignedWindow[inbound.Report.aircraft.callsign] = [ i, 0 ]
+                        self.AssignedWindow[inbound.Callsign] = [ i, 0 ]
                         inbound.PlannedArrivalTime = inbound.EarliestArrivalTime
                         window.insert(inbound)
                     inserted = True
@@ -70,7 +71,7 @@ class RecedingHorizonControl:
                 while True:
                     self.Windows.append(RecedingHorizonWindow(lastWindowTime, lastWindowTime + timestep))
                     if self.Windows[-1].EndTime > inbound.EarliestArrivalTime:
-                        self.AssignedWindow[inbound.Report.aircraft.callsign] = [ len(self.Windows) - 1, 0 ]
+                        self.AssignedWindow[inbound.Callsign] = [ len(self.Windows) - 1, 0 ]
                         self.Windows[-1].insert(inbound)
                         inbound.PlannedArrivalTime = max(self.Windows[-1].StartTime, inbound.EarliestArrivalTime)
                         self.Windows[-1].Inbounds.sort(key = lambda x: x.PlannedArrivalTime)
@@ -123,7 +124,7 @@ class RecedingHorizonControl:
         while 0 != len(self.Windows) and currentUtc > self.Windows[0].EndTime:
             # cleanup the association table
             for inbound in self.Windows[0].Inbounds:
-                self.AssignedWindow.pop(inbound.Report.aircraft.callsign)
+                self.AssignedWindow.pop(inbound.Callsign)
 
             offsetCorrection += 1
             self.Windows.pop(0)

+ 4 - 4
aman/sys/RecedingHorizonWindow.py

@@ -10,24 +10,24 @@ class RecedingHorizonWindow:
 
     def isInWindow(self, inbound : Inbound):
         for report in self.Inbounds:
-            if report.Report.aircraft.callsign == inbound.Report.aircraft.callsign:
+            if report.Callsign == inbound.Callsign:
                 return True
         return False
 
     def inbound(self, callsign : str):
         for report in self.Inbounds:
-            if report.Report.aircraft.callsign == callsign:
+            if report.Callsign == callsign:
                 return report
         return None
 
     def insert(self, inbound : Inbound):
         for i in range(0, len(self.Inbounds)):
-            if self.Inbounds[i].Report.aircraft.callsign == inbound.Report.aircraft.callsign:
+            if self.Inbounds[i].Callsign == inbound.Callsign:
                 return
         self.Inbounds.append(inbound)
 
     def remove(self, callsign : str):
         for i in range(0, len(self.Inbounds)):
-            if self.Inbounds[i].Report.aircraft.callsign == callsign:
+            if self.Inbounds[i].Callsign == callsign:
                 self.Inbounds.pop(i)
                 return

+ 1 - 1
aman/sys/Worker.py

@@ -128,7 +128,7 @@ class Worker(Thread):
                 if None != aco.Result:
                     print('ACO-Sequence:')
                     for inbound in aco.Result:
-                        print('    ' + inbound.Report.aircraft.callsign + ': ' + inbound.PlannedRunway.Name + ' @ ' + str(inbound.PlannedArrivalTime) +
+                        print('    ' + inbound.Callsign + ': ' + inbound.PlannedRunway.Name + ' @ ' + str(inbound.PlannedArrivalTime) +
                               ' dt=' + str((inbound.PlannedArrivalTime - inbound.InitialArrivalTime).total_seconds()))
                     print('Delays: FCFS=' + str(aco.FcfsDelay.total_seconds()) + ', ACO=' + str(aco.ResultDelay.total_seconds()))
 

+ 1 - 1
aman/sys/aco/Colony.py

@@ -39,7 +39,7 @@ class Colony:
             tmp += timedelta(seconds = 20)
             Colony.associateInbound(rwyManager, inbound, earliestArrivalTime, False)
             overallDelay += inbound.PlannedArrivalTime - inbound.InitialArrivalTime
-            print('    ' + inbound.Report.aircraft.callsign + ': ' + inbound.PlannedRunway.Name + ' @ ' + str(inbound.PlannedArrivalTime) +
+            print('    ' + inbound.Callsign + ': ' + inbound.PlannedRunway.Name + ' @ ' + str(inbound.PlannedArrivalTime) +
                   ' dt=' + str((inbound.PlannedArrivalTime - inbound.InitialArrivalTime).total_seconds()))
 
         return overallDelay

+ 1 - 0
aman/types/Inbound.py

@@ -28,6 +28,7 @@ class Inbound:
     def __init__(self, report : AircraftReport_pb2.AircraftReport, sequencingConfig : AirportSequencing, navData : SctEseFormat,
                  performanceData : PerformanceData, weatherModel : WeatherModel):
         self.Report = report
+        self.Callsign = report.aircraft.callsign
         self.CurrentPosition = report.position
         self.ReportTime = datetime.strptime(report.reportTime + '+0000', '%Y%m%d%H%M%S%z').replace(tzinfo = pytz.UTC)
         self.InitialArrivalTime = None