increase computational performance
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -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()))
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user