def execute_aco(self): for i in range(self.rounds): solutions = [] for j in range(self.k): # set to the initial state current_city = ORIGIN_CITY # operations of ant j solution = Solution() while current_city != DESTINATION_CITY: if self.best_solution is not None and solution.cost > self.best_solution.cost: break city = self.next_city(j, current_city) solution.add_city(city) current_city = city.destination.cId solutions.append(solution) # update best solution self.update_best_solution(solutions) # update pheromones trails self.update_pheromones(solutions) print self.best_solution