From 7c6d098812602fd307cb02f2e16bc515f60998ac Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Mon, 18 Oct 2021 18:53:24 +0200 Subject: [PATCH] increase computational performance --- aman/config/AirportSequencing.py | 5 +---- aman/sys/RecedingHorizonControl.py | 19 ++++++++++--------- aman/sys/RecedingHorizonWindow.py | 8 ++++---- aman/sys/Worker.py | 2 +- aman/sys/aco/Colony.py | 2 +- aman/types/Inbound.py | 1 + 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/aman/config/AirportSequencing.py b/aman/config/AirportSequencing.py index 7275574..0f1510f 100644 --- a/aman/config/AirportSequencing.py +++ b/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 diff --git a/aman/sys/RecedingHorizonControl.py b/aman/sys/RecedingHorizonControl.py index 2b406ef..7219623 100644 --- a/aman/sys/RecedingHorizonControl.py +++ b/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) diff --git a/aman/sys/RecedingHorizonWindow.py b/aman/sys/RecedingHorizonWindow.py index 93f6741..4cee965 100644 --- a/aman/sys/RecedingHorizonWindow.py +++ b/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 \ No newline at end of file diff --git a/aman/sys/Worker.py b/aman/sys/Worker.py index 947ff38..757a4d4 100644 --- a/aman/sys/Worker.py +++ b/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())) diff --git a/aman/sys/aco/Colony.py b/aman/sys/aco/Colony.py index 4a64052..dbc3f71 100644 --- a/aman/sys/aco/Colony.py +++ b/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 diff --git a/aman/types/Inbound.py b/aman/types/Inbound.py index 7b3aafe..6528526 100644 --- a/aman/types/Inbound.py +++ b/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