From 5242fe0d8700d6b9e24a3e052cfb4ffd1f70f80a Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Wed, 15 Dec 2021 09:28:59 +0100 Subject: [PATCH] use the optimization thresholds to calculate the TTG --- aman/sys/Worker.py | 7 +++---- aman/sys/aco/Colony.py | 2 +- aman/sys/aco/Configuration.py | 3 +-- aman/sys/aco/Node.py | 19 ++++++++++++++----- aman/sys/aco/RunwayManager.py | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/aman/sys/Worker.py b/aman/sys/Worker.py index c725834..7f876d0 100644 --- a/aman/sys/Worker.py +++ b/aman/sys/Worker.py @@ -87,7 +87,7 @@ class Worker(Thread): if 0 != report.distanceToIAF and '' != report.initialApproachFix: inbound = Inbound(report, self.PerformanceData) - Node(inbound, inbound.ReportTime, self.WeatherModel, self.Configuration.GngData, self.SequencingConfiguration) + Node(inbound, inbound.ReportTime, self.WeatherModel, self.Configuration, self.SequencingConfiguration) if None != inbound.InitialArrivalTime: self.RecedingHorizonControl.updateReport(inbound) else: @@ -109,11 +109,10 @@ class Worker(Thread): preceedingInbounds[runway.Runway.Name] = Node(inbound, None, None, None, None) # configure the ACO run - acoConfig = Configuration(constraints = self.SequencingConfiguration, nav = self.Configuration.GngData, + acoConfig = Configuration(constraints = self.SequencingConfiguration, config = self.Configuration, earliest = earliestArrivalTime, weather = self.WeatherModel, preceeding = None if 0 == len(preceedingInbounds) else preceedingInbounds, - ants = 5 * len(relevantInbounds), generations = 5 * len(relevantInbounds), - maxDelayMay=self.Configuration.MaxDelayMay) + ants = 5 * len(relevantInbounds), generations = 5 * len(relevantInbounds)) # perform the ACO run aco = Colony(relevantInbounds, acoConfig) diff --git a/aman/sys/aco/Colony.py b/aman/sys/aco/Colony.py index d085aa5..c957b3e 100644 --- a/aman/sys/aco/Colony.py +++ b/aman/sys/aco/Colony.py @@ -48,7 +48,7 @@ class Colony: # create the new planning instances currentTime = dt.utcfromtimestamp(int(time.time())).replace(tzinfo = pytz.UTC) for inbound in inbounds: - self.Nodes.append(Node(inbound, currentTime, self.Configuration.WeatherModel, self.Configuration.NavData, self.Configuration.RunwayConstraints)) + self.Nodes.append(Node(inbound, currentTime, self.Configuration.WeatherModel, self.Configuration.AirportConfiguration, self.Configuration.RunwayConstraints)) rwyManager = RunwayManager(self.Configuration) delay = Colony.calculateInitialCosts(rwyManager, self.Nodes, self.Configuration.EarliestArrivalTime) diff --git a/aman/sys/aco/Configuration.py b/aman/sys/aco/Configuration.py index 34ad824..6a2080e 100644 --- a/aman/sys/aco/Configuration.py +++ b/aman/sys/aco/Configuration.py @@ -9,8 +9,7 @@ class Configuration: self.PreceedingInbounds = kwargs.get('preceeding', None) self.EarliestArrivalTime = kwargs.get('earliest', None) self.WeatherModel = kwargs.get('weather', None) - self.NavData = kwargs.get('nav', None) - self.MaxDelayMay = kwargs.get('maxDelayMay', timedelta(minutes=10)) + self.AirportConfiguration = kwargs.get('config', None) # the ACO specific information self.AntCount = kwargs.get('ants', 20) diff --git a/aman/sys/aco/Node.py b/aman/sys/aco/Node.py index 41a4f1e..3fdbccf 100644 --- a/aman/sys/aco/Node.py +++ b/aman/sys/aco/Node.py @@ -5,6 +5,7 @@ import sys from datetime import datetime, timedelta +from aman.config.Airport import Airport from aman.config.AirportSequencing import AirportSequencing from aman.formats.SctEseFormat import SctEseFormat from aman.sys.WeatherModel import WeatherModel @@ -150,7 +151,7 @@ class Node: return timedelta(seconds = flightTimeSeconds), trackmiles, arrivalRoute, timedelta(seconds = flightTimeOnStarSeconds) def __init__(self, inbound : Inbound, referenceTime : datetime, weatherModel : WeatherModel, - navData : SctEseFormat, sequencingConfig : AirportSequencing): + airportConfig : Airport, sequencingConfig : AirportSequencing): self.PredictedDistanceToIAF = inbound.Report.distanceToIAF self.PredictedCoordinate = [ inbound.CurrentPosition.latitude, inbound.CurrentPosition.longitude ] self.PredictionTime = referenceTime @@ -171,7 +172,7 @@ class Node: prediction = tempWaypoint.project(course, distance) # calculate the bearing between the current position and the IAF - star = Node.findArrivalRoute(inbound.Report.initialApproachFix, sequencingConfig.ActiveArrivalRunways[0].Runway, navData) + star = Node.findArrivalRoute(inbound.Report.initialApproachFix, sequencingConfig.ActiveArrivalRunways[0].Runway, airportConfig.GngData) # calculate the distance based on the flown distance and update the predicted distance if None != star: @@ -187,7 +188,7 @@ class Node: # calculate the timings for the different arrival runways for identifier in sequencingConfig.ActiveArrivalRunways: - star = Node.findArrivalRoute(self.Inbound.Report.initialApproachFix, identifier.Runway, navData) + star = Node.findArrivalRoute(self.Inbound.Report.initialApproachFix, identifier.Runway, airportConfig.GngData) if None != star: flightTime, trackmiles, arrivalRoute, flightTimeOnStar = self.arrivalEstimation(identifier.Runway, star, weatherModel) @@ -203,8 +204,16 @@ class Node: timeUntilIAF = timedelta(seconds = 0) # the best TTL is the longest path with the slowest speed - # TODO use configurations to define the maximum time gain - ttg = timedelta(seconds = timeUntilIAF.total_seconds() * 0.2) + ttgMax = 60 + ttgRatio = 0.05 + if star.Name in airportConfig.OptimizationParameters: + ttgMax = airportConfig.OptimizationParameters[star.Name][0] + ttgRatio = airportConfig.OptimizationParameters[star.Name][1] + + ttg = timedelta(seconds = timeUntilIAF.total_seconds() * ttgRatio) + if (ttg.total_seconds() > ttgMax): + ttg = timedelta(seconds = ttgMax) + print(self.Inbound.Callsign + ': ' + str(ttg)) ttl = timedelta(seconds = decreasedSpeedFlighttime - flightTime.total_seconds()) ita = self.Inbound.ReportTime + flightTime earliest = ita - ttg diff --git a/aman/sys/aco/RunwayManager.py b/aman/sys/aco/RunwayManager.py index fbf6a35..dd280c9 100644 --- a/aman/sys/aco/RunwayManager.py +++ b/aman/sys/aco/RunwayManager.py @@ -106,12 +106,12 @@ class RunwayManager: if RunwayAssignmentType.AircraftType in runway.MayAssignments: if node.Inbound.Report.aircraft.type in runway.MayAssignments[RunwayAssignmentType.AircraftType]: eta, _ = self.calculateEarliestArrivalTime(runway.Runway.Name, node, useETA, earliestArrivalTime) - if (eta - reference) <= self.Configuration.MaxDelayMay: + if (eta - reference) <= self.Configuration.AirportConfiguration.MaxDelayMay: mayRunways.append(runway) if RunwayAssignmentType.GateAssignment in runway.MayAssignments: if node.Inbound.Report.plannedGate in runway.MayAssignments[RunwayAssignmentType.GateAssignment]: eta, _ = self.calculateEarliestArrivalTime(runway.Runway.Name, node, useETA, earliestArrivalTime) - if (eta - reference) <= self.Configuration.MaxDelayMay: + if (eta - reference) <= self.Configuration.AirportConfiguration.MaxDelayMay: mayRunways.append(runway) runway = self.selectShallShouldMayArrivalRunway(node, shallRunways, useETA, earliestArrivalTime)