I am a beginner in Python and DEAP and I am trying to understand the evaluatiobn function for the TSP from: https://github.com/DEAP/deap/blob/master/examples/ga/tsp.py
def evalTSP(individual):
distance = distance_map[individual[-1]][individual[0]]
for gene1, gene2 in zip(individual[0:-1], individual[1:]):
distance += distance_map[gene1][gene2]
return distance,
On distance = distance_map[individual[-1]][individual[0]]
The [individual[-1]][individual[0]]
means the difference between the previous and the current individual positions?
On for gene1, gene2 in zip(individual[0:-1], individual[1:])
Which means the values 0:1
and 1:
of individual?