1

As a uni project I'm trying to implement the simulated annealing to solve the traveling salesman problem using python.

I need to find the neighbors of my initial solution and I'm not quite sure how can i easily do this in python.

For example i have a list of cities, which is the order of initial solution, lets say: [A, B, C, D, E, F].

Original array

A neighbor of the initial solution is found by randomizing i and j with j>i+1. Then I could have a new list (for i=1 j=5) [A, B, F, E, D, C].

Neighbor of initial solution

Is there an easy way to implement this in python?

0 Answers0