From 64fcb8ed0135cc56bda2eee0dbee5b87fcff05f4 Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Thu, 23 Dec 2021 16:28:31 +0100 Subject: [PATCH] use deep copies for the optimization to avoid the visualization of intermediate sequences --- aman/sys/RecedingHorizonControl.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/aman/sys/RecedingHorizonControl.py b/aman/sys/RecedingHorizonControl.py index 6937cad..a651f61 100644 --- a/aman/sys/RecedingHorizonControl.py +++ b/aman/sys/RecedingHorizonControl.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import copy import time from datetime import datetime as dt @@ -101,12 +102,27 @@ class RecedingHorizonControl: def resequenceInbound(self, inbound : Inbound): index = self.AssignedWindow[inbound.Callsign][0] - if inbound.PlannedArrivalTime < self.Windows[index].StartTime or inbound.PlannedArrivalTime >= self.Windows[index].EndTime: - self.Windows[index].remove(inbound.Callsign) - self.AssignedWindow.pop(inbound.Callsign) - self.insertInWindow(inbound, True) + sequenced = self.Windows[index].inbound(inbound.Callsign) + if None == sequenced: + return + + # resynchronized the planned information + sequenced.PlannedRunway = inbound.PlannedRunway + sequenced.PlannedStar = inbound.PlannedStar + sequenced.PlannedArrivalRoute = inbound.PlannedArrivalRoute + sequenced.PlannedArrivalTime = inbound.PlannedArrivalTime + sequenced.InitialArrivalTime = inbound.InitialArrivalTime + sequenced.PlannedTrackmiles = inbound.PlannedTrackmiles + sequenced.AssignmentMode = inbound.AssignmentMode + sequenced.ExpectedRunway = inbound.ExpectedRunway + + # resort the inbound + if sequenced.PlannedArrivalTime < self.Windows[index].StartTime or sequenced.PlannedArrivalTime >= self.Windows[index].EndTime: + self.Windows[index].remove(sequenced.Callsign) + self.AssignedWindow.pop(sequenced.Callsign) + self.insertInWindow(sequenced, True) else: - inbound.FixedSequence = index < self.FreezedIndex + sequenced.FixedSequence = index < self.FreezedIndex self.Windows[index].Inbounds.sort(key = lambda x: x.PlannedArrivalTime if None != x.PlannedArrivalTime else x.EnrouteArrivalTime) def latestFixedInbounds(self, configuration : Airport, sequenceConfiguration : AirportSequencing): @@ -168,7 +184,7 @@ class RecedingHorizonControl: # check the overlapping windows for i in range(self.FreezedIndex + 1, len(self.Windows)): for inbound in self.Windows[i].Inbounds: - inbounds.append(inbound) + inbounds.append(copy.deepcopy(inbound)) if 20 <= len(inbounds): break