use the theoretical earliest arrival time

This commit is contained in:
Sven Czarnian
2021-10-13 21:42:45 +02:00
parent 9887aa48a4
commit 5295d1c155

View File

@@ -31,43 +31,34 @@ class RecedingHorizonControl:
plannedInbound = self.Windows[index].inbound(inbound.Report.aircraft.callsign) plannedInbound = self.Windows[index].inbound(inbound.Report.aircraft.callsign)
plannedInbound.CurrentPosition = inbound.CurrentPosition plannedInbound.CurrentPosition = inbound.CurrentPosition
plannedInbound.MaximumTimeToGain = inbound.MaximumTimeToGain
# check if not accessed by the optimizer # get the reference time and update some times in case no replacement is needed
if plannedInbound.InitialArrivalTime == plannedInbound.EstimatedArrivalTime: if plannedInbound.InitialArrivalTime == plannedInbound.EarliestArrivalTime + plannedInbound.MaximumTimeToGain:
notPlanned = True plannedInbound.InitialArrivalTime = inbound.InitialArrivalTime
update = True plannedInbound.EarliestArrivalTime = inbound.EarliestArrivalTime
# check if the ITA is greater or the ETA plannedInbound.EstimatedArrivalTime = inbound.EstimatedArrivalTime
elif plannedInbound.EstimatedArrivalTime != inbound.InitialArrivalTime: reference = inbound.EarliestArrivalTime
notPlanned = False else:
update = True plannedInbound.InitialArrivalTime = inbound.InitialArrivalTime
if plannedInbound.EarliestArrivalTime < inbound.EarliestArrivalTime:
plannedInbound.EarliestArrivalTime = inbound.EarliestArrivalTime
if plannedInbound.EstimatedArrivalTime < inbound.EstimatedArrivalTime:
plannedInbound.EstimatedArrivalTime = inbound.EstimatedArrivalTime
reference = plannedInbound.EarliestArrivalTime
# update the windows # update the windows
if True == update: if reference < self.Windows[index].StartTime or reference >= self.Windows[index].EndTime:
if inbound.InitialArrivalTime >= self.Windows[index].StartTime and inbound.InitialArrivalTime < self.Windows[index].EndTime: self.Windows[index].remove(inbound.Report.aircraft.callsign)
keepInWindow = True self.AssignedWindow.pop(inbound.Report.aircraft.callsign)
else: self.update(inbound)
keepInWindow = False
# check if planning can be updated or needs to be due to a delay
if True == notPlanned or plannedInbound.Inbound.EstimatedArrivalTime < inbound.InitialArrivalTime:
# keep it in this bucket
if True == keepInWindow:
plannedInbound.EstimatedArrivalTime = inbound.InitialArrivalTime
plannedInbound.InitialArrivalTime = inbound.InitialArrivalTime
self.Windows[index].Inbounds.sort(key = lambda x: x.EstimatedArrivalTime)
# put it in the new bucket
else:
self.Windows[index].remove(inbound.Report.aircraft.callsign)
self.AssignedWindow.pop(inbound.Report.aircraft.callsign)
self.update(inbound)
else: else:
inserted = False inserted = False
for i in range(0, len(self.Windows)): for i in range(0, len(self.Windows)):
window = self.Windows[i] window = self.Windows[i]
# find the correct window # find the correct window
if window.StartTime <= inbound.EstimatedArrivalTime and window.EndTime > inbound.EstimatedArrivalTime: if window.StartTime <= inbound.EarliestArrivalTime and window.EndTime > inbound.EarliestArrivalTime:
if i > self.FreezedIndex: if i > self.FreezedIndex:
self.AssignedWindow[inbound.Report.aircraft.callsign] = [ i, 0 ] self.AssignedWindow[inbound.Report.aircraft.callsign] = [ i, 0 ]
window.insert(inbound) window.insert(inbound)
@@ -84,10 +75,10 @@ class RecedingHorizonControl:
while True: while True:
self.Windows.append(RecedingHorizonWindow(lastWindowTime, lastWindowTime + timestep)) self.Windows.append(RecedingHorizonWindow(lastWindowTime, lastWindowTime + timestep))
if self.Windows[-1].EndTime > inbound.EstimatedArrivalTime: if self.Windows[-1].EndTime > inbound.EarliestArrivalTime:
self.AssignedWindow[inbound.Report.aircraft.callsign] = [ len(self.Windows) - 1, 0 ] self.AssignedWindow[inbound.Report.aircraft.callsign] = [ len(self.Windows) - 1, 0 ]
self.Windows[-1].insert(inbound) self.Windows[-1].insert(inbound)
self.Windows[-1].Inbounds.sort(key = lambda x: x.EstimatedArrivalTime) self.Windows[-1].Inbounds.sort(key = lambda x: x.EarliestArrivalTime)
break break
lastWindowTime = self.Windows[-1].EndTime lastWindowTime = self.Windows[-1].EndTime