File tree Expand file tree Collapse file tree
ch06-swarm_intelligence-ants Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88# Load the carnival attraction distances from a CSV file
99attraction_count = 48
1010attraction_data_file = 'attractions-' + str (attraction_count ) + '.csv'
11- attraction_permutations = set (itertools .permutations (range (0 , attraction_count )))
1211attraction_distances = []
1312with open (attraction_data_file ) as file :
1413 reader = csv .reader (file , quoting = csv .QUOTE_NONNUMERIC )
2019best_distance = math .inf
2120best_permutation = None
2221# Determine the distance score for every permutation to find the best
23- for attraction_permutation in attraction_permutations :
22+ for attraction_permutation in itertools . permutations ( range ( 0 , attraction_count )) :
2423 last_attraction = attraction_permutation [0 ]
2524 total_distance = 0
2625 for attraction_index in range (1 , len (attraction_permutation )):
You can’t perform that action at this time.
0 commit comments