2 %> Perform a 2-opt operation of a list of cities
7 %> @author Michel Bierlaire
8 %> @date Tue Apr 14 15:30:42 2015
12 %> Perform a 2-opt operation of a list of cities
14 %> @param c1 index of the first city
15 %> @param c2 index of the second city
16 %> @
return new list of cities
17 function newlist =
twoOpt(cities,c1,c2)
24 error(
'Cannot perform a 2-opt with the depot')
28 newlist = cities(1:c1);
29 newlist = [newlist ; flipud(cities(c1+1:c2))];
30 newlist = [newlist ; cities(c2+1:end)];
function twoOpt(in cities, in c1, in c2)
Perform a 2-opt operation of a list of cities.
function twoOptNeighborhood(in cities)
Generate the 2-opt neightborhood for the TSP.
function twoOptRandomNeighbor(in cities)
Generate one random 2-opt neighbor for the TSP.