robust error handling to avoid later crashes
This commit is contained in:
@@ -27,6 +27,9 @@ class Ant:
|
||||
# Implements function (5)
|
||||
def heuristicInformation(self, current : int):
|
||||
_, eta, _ = self.RunwayManager.selectArrivalRunway(self.Nodes[current], self.Configuration.EarliestArrivalTime)
|
||||
if None == eta:
|
||||
return -1.0
|
||||
|
||||
inboundDelay = eta - self.Nodes[current].Inbound.InitialArrivalTime
|
||||
|
||||
# calculate the fraction with a mix of the unused runway time and the delay of single aircrafts
|
||||
@@ -54,6 +57,10 @@ class Ant:
|
||||
if False == self.InboundSelected[i]:
|
||||
weights.append(self.heuristicInformation(i) / (pheromoneScale or 1))
|
||||
|
||||
# something was wrong in the runway selection
|
||||
if -1.0 in weights:
|
||||
return None
|
||||
|
||||
total = sum(weights)
|
||||
cumdist = list(itertools.accumulate(weights)) + [total]
|
||||
candidateIndex = bisect.bisect(cumdist, random.random() * total)
|
||||
|
||||
Reference in New Issue
Block a user