fix some bugs in the runway manager during the ETA calculation

This commit is contained in:
Sven Czarnian
2021-10-16 08:06:04 +02:00
parent c835944e8d
commit c09a5ffe77
2 changed files with 48 additions and 51 deletions

View File

@@ -74,16 +74,16 @@ class AirportSequencing:
return runway return runway
return None return None
def findDependentRunway(self, identifier : str): def findDependentRunways(self, identifier : str):
# runway is unknown # runway is unknown
index = self.runwayIndex(identifier) index = self.runwayIndex(identifier)
if 0 > index: if 0 > index:
return None return []
# search the dependency pair # search the dependency pair
dependencies = []
for dependency in self.RunwayDependencies: for dependency in self.RunwayDependencies:
if index == dependency[0]: if index == dependency[0] and not self.ActiveArrivalRunways[dependency[1]] in dependencies:
return self.ActiveArrivalRunways[dependency[1]] dependencies.append(self.ActiveArrivalRunways[dependency[1]])
# no dependencies found return dependencies
return None

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
from datetime import timedelta from datetime import datetime, timedelta
from aman.sys.aco.Configuration import Configuration from aman.sys.aco.Configuration import Configuration
from aman.sys.aco.Constraints import SpacingConstraints from aman.sys.aco.Constraints import SpacingConstraints
@@ -22,57 +22,52 @@ class RunwayManager:
def validateWtc(inbound : Inbound): def validateWtc(inbound : Inbound):
wtc = inbound.Report.aircraft.wtc.upper() wtc = inbound.Report.aircraft.wtc.upper()
if 'L' == wtc or 'M' == wtc or 'H' == None or 'J' == None: if 'L' == wtc or 'M' == wtc or 'H' == wtc or 'J' == wtc:
return wtc return wtc
else: else:
return None return None
def calculateEarliestArrivalTime(self, runway : str, inbound : Inbound): def calculateEarliestArrivalTime(self, runway : str, inbound : Inbound, useITA : bool, earliestArrivalTime : datetime):
if None == self.RunwayInbounds[runway]: earliestArrivalTimes = []
return inbound.ArrivalCandidates[runway].EarliestArrivalTime
preceedingInbound = self.RunwayInbounds[runway] if None != self.RunwayInbounds[runway]:
# get the WTC based ETA
# get the WTC constrained ETA wtcPre = RunwayManager.validateWtc(self.RunwayInbounds[runway])
wtcPre = RunwayManager.validateWtc(preceedingInbound)
wtcThis = RunwayManager.validateWtc(inbound) wtcThis = RunwayManager.validateWtc(inbound)
if None == wtcPre or None == wtcThis: if None == wtcPre or None == wtcThis:
spacing = 3 spacing = 3
else: else:
spacing = self.Spacings[wtcPre][wtcThis] spacing = self.Spacings[wtcPre][wtcThis]
delay = timedelta(minutes = spacing / (inbound.PerformanceData.SpeedApproach / 60)) delay = timedelta(minutes = spacing / (inbound.PerformanceData.SpeedApproach / 60))
wtcEarliestArrivalTime = preceedingInbound.PlannedArrivalTime + delay earliestArrivalTimes.append(self.RunwayInbounds[runway].PlannedArrivalTime + delay)
# get the staggered time spacing
dependentRunway = self.Configuration.RunwayConstraints.findDependentRunway(runway)
if None != dependentRunway and None != self.RunwayInbounds[dependentRunway.Runway.Name]:
# check if the one on the same runway lands before the one on the parallel runway
if preceedingInbound.PlannedArrivalTime < self.RunwayInbounds[dependentRunway.Runway.Name].PlannedArrivalTime:
delay = timedelta(minutes = 3 / (inbound.PerformanceData.SpeedApproach / 60))
staggeredEarliestArrivalTime = self.RunwayInbounds[dependentRunway.Runway.Name].PlannedArrivalTime + delay
# landing on the same runway
else:
staggeredEarliestArrivalTime = wtcEarliestArrivalTime
# no neighbor or no dependent runway (IPA)
else:
staggeredEarliestArrivalTime = wtcEarliestArrivalTime
# get the runway time spacing # get the runway time spacing
spacing = self.Configuration.RunwayConstraints.findRunway(runway).Spacing spacing = self.Configuration.RunwayConstraints.findRunway(runway).Spacing
delay = timedelta(minutes = spacing / (inbound.PerformanceData.SpeedApproach / 60)) delay = timedelta(minutes = spacing / (inbound.PerformanceData.SpeedApproach / 60))
runwayEarliestArrivalTime = preceedingInbound.PlannedArrivalTime + delay earliestArrivalTimes.append(self.RunwayInbounds[runway].PlannedArrivalTime + delay)
# the candidate with the latest ETA is used -> ensure all safety and procedure constraints # calculate the arrival times for the dependent inbounds
candidate = max(max(wtcEarliestArrivalTime, staggeredEarliestArrivalTime), runwayEarliestArrivalTime) for dependentRunway in self.Configuration.RunwayConstraints.findDependentRunways(runway):
if None != self.RunwayInbounds[dependentRunway.Runway.Name]:
delay = timedelta(minutes = 3 / (inbound.PerformanceData.SpeedApproach / 60))
earliestArrivalTimes.append(self.RunwayInbounds[dependentRunway.Runway.Name].PlannedArrivalTime + delay)
# check if inbound comes later than the latest possible ETA # get the arrival time on the runway of the inbound
if candidate < inbound.ArrivalCandidates[runway].EarliestArrivalTime: if True == useITA:
return inbound.ArrivalCandidates[runway].EarliestArrivalTime arrivalTime = inbound.ArrivalCandidates[runway].EarliestArrivalTime
# candidate fits into earliest arrival time or is later than this
else: else:
return candidate arrivalTime = inbound.ArrivalCandidates[runway].InitialArrivalTime
def selectArrivalRunway(self, inbound : Inbound): if 0 == len(earliestArrivalTimes):
return arrivalTime, timedelta(seconds = 0)
else:
eta = max(earliestArrivalTimes)
if eta < arrivalTime:
return arrivalTime, arrivalTime - eta
else:
return eta, timedelta(seconds = 0)
def selectArrivalRunway(self, inbound : Inbound, useITA : bool, earliestArrivalTime : datetime):
availableRunways = [] availableRunways = []
for runway in self.Configuration.RunwayConstraints.ActiveArrivalRunways: for runway in self.Configuration.RunwayConstraints.ActiveArrivalRunways:
availableRunways.append(runway) availableRunways.append(runway)
@@ -85,17 +80,19 @@ class RunwayManager:
# fallback to check if we have available runways # fallback to check if we have available runways
if 0 == len(availableRunways): if 0 == len(availableRunways):
runway = self.Configuration.RunwayConstraints.ActiveArrivalRunways[0] runway = self.Configuration.RunwayConstraints.ActiveArrivalRunways[0]
return runway, self.calculateEarliestArrivalTime(runway.Runway.Name, inbound) return runway, self.calculateEarliestArrivalTime(runway.Runway.Name, inbound, useITA, earliestArrivalTime)
# start with the beginning # start with the beginning
selectedRunway = None selectedRunway = None
lostTime = None
eta = None eta = None
# get the runway with the earliest ETA # get the runway with the earliest ETA
for runway in availableRunways: for runway in availableRunways:
candidate = self.calculateEarliestArrivalTime(runway.Runway.Name, inbound) candidate, delta = self.calculateEarliestArrivalTime(runway.Runway.Name, inbound, useITA, earliestArrivalTime)
if None == eta or eta > candidate: if None == eta or eta > candidate:
selectedRunway = runway.Runway selectedRunway = runway.Runway
lostTime = delta
eta = candidate eta = candidate
return selectedRunway, eta return selectedRunway, eta, lostTime