我是 Python 和 DEAP 的初学者,我试图从以下位置了解 TSP 的评估函数: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]]
的[individual[-1]][individual[0]]
差异?
Onfor gene1, gene2 in zip(individual[0:-1], individual[1:])
哪个意味着价值观0:1
和1:
个人?