From 06974b807c2100796683c5b767305ade4a9bac43 Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Wed, 24 Nov 2021 12:05:03 +0100 Subject: [PATCH] fix bugs in TTL and TTG calculations --- aman/sys/aco/Node.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/aman/sys/aco/Node.py b/aman/sys/aco/Node.py index cf56a57..4342807 100644 --- a/aman/sys/aco/Node.py +++ b/aman/sys/aco/Node.py @@ -176,12 +176,23 @@ class Node: if None != star: flightTime, trackmiles, arrivalRoute = self.arrivalEstimation(identifier.Runway, star, weatherModel) - avgSpeed = trackmiles / (float(flightTime.seconds) / 3600.0) - # the closer we get to the IAF the less time delta can be achieved by short cuts, delay vectors or speeds - ratio = min(2.0, max(0.0, self.PredictedDistanceToIAF / (trackmiles - self.PredictedDistanceToIAF))) - possibleTimeDelta = (trackmiles / (avgSpeed * 0.9)) * 60 - ttg = timedelta(minutes = (possibleTimeDelta - flightTime.total_seconds() / 60) * ratio) - ttl = timedelta(minutes = (possibleTimeDelta - flightTime.total_seconds() / 60)) + # calculate average speed gain + avgSpeed = trackmiles / (flightTime.total_seconds() / 3600.0) + avgSpeedIncrease = avgSpeed * 1.10 + avgSpeedDecrease = avgSpeed * 0.80 + decreasedSpeedFlighttime = (trackmiles / avgSpeedDecrease) * 3600.0 # given in seconds + + # calculate shortcut gain and add 15 miles for final and base turn + currentPosition = Waypoint(latitude = self.PredictedCoordinate[0], longitude = self.PredictedCoordinate[1]) + shortcutDistance = currentPosition.haversine(identifier.Runway.Start) + 15.0 + shortcutFlighttime = (shortcutDistance / avgSpeedIncrease) * 3600.0 + if shortcutFlighttime > flightTime.total_seconds(): + shortcutFlighttime = flightTime.total_seconds() + + # the best TTG is the shortest path with the fastest speed + ttg = timedelta(seconds = flightTime.total_seconds() - shortcutFlighttime) + # the best TTL is the longest path with the slowest speed + ttl = timedelta(seconds = decreasedSpeedFlighttime - flightTime.total_seconds()) ita = self.Inbound.ReportTime + flightTime earliest = ita - ttg latest = ita + ttl