use weights to find better sequence with TTG and TTL constraints
This commit is contained in:
@@ -35,7 +35,8 @@ class Colony:
|
||||
# TODO remove this after testing and optimization
|
||||
for runway in inbound.ArrivalCandidates:
|
||||
inbound.ArrivalCandidates[runway].InitialArrivalTime = tmp
|
||||
inbound.ArrivalCandidates[runway].EarliestArrivalTime = tmp
|
||||
inbound.ArrivalCandidates[runway].EarliestArrivalTime = tmp - inbound.ArrivalCandidates[runway].MaximumTimeToGain
|
||||
inbound.ArrivalCandidates[runway].LatestArrivalTime = tmp + inbound.ArrivalCandidates[runway].MaximumTimeToLose
|
||||
tmp += timedelta(seconds = 20)
|
||||
Colony.associateInbound(rwyManager, inbound, earliestArrivalTime, False)
|
||||
overallDelay += inbound.PlannedArrivalTime - inbound.InitialArrivalTime
|
||||
@@ -83,19 +84,26 @@ class Colony:
|
||||
ant.findSolution(index)
|
||||
|
||||
# fallback to check if findSolution was successful
|
||||
if None == ant.SequenceDelay or None == ant.Sequence:
|
||||
if None == ant.SequenceDelay or None == ant.Sequence or None == ant.SequenceScore:
|
||||
sys.stderr.write('Invalid ANT run detected!')
|
||||
sys.exit(-1)
|
||||
|
||||
candidates.append([ ant.SequenceDelay, ant.Sequence ])
|
||||
candidates.append(
|
||||
[
|
||||
ant.SequenceDelay,
|
||||
ant.Sequence,
|
||||
ant.SequenceScore,
|
||||
ant.SequenceDelay.total_seconds() / ant.SequenceScore
|
||||
]
|
||||
)
|
||||
|
||||
# find the best solution in all candidates of this generation
|
||||
bestCandidate = None
|
||||
for candidate in candidates:
|
||||
if None == bestCandidate or candidate[0] < bestCandidate[0]:
|
||||
if None == bestCandidate or candidate[3] < bestCandidate[3]:
|
||||
bestCandidate = candidate
|
||||
|
||||
dTheta = 1.0 / (candidate[0].total_seconds() / 60.0)
|
||||
dTheta = 1.0 / ((candidate[0].total_seconds() / 60.0) or 1.0)
|
||||
for i in range(1, len(candidate[1])):
|
||||
update = (1.0 - self.Configuration.Epsilon) * self.PheromoneMatrix[candidate[1][i - 1], candidate[1][i]] + dTheta
|
||||
self.PheromoneMatrix[candidate[1][i - 1], candidate[1][i]] = max(update, self.Configuration.ThetaZero)
|
||||
|
||||
Reference in New Issue
Block a user