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)
|
||||
|
||||
Reference in New Issue
Block a user