Optimization: principles and algorithms, by Michel Bierlaire
insertCity.m
Go to the documentation of this file.
1 %> \file
2 %> Inserts a city in a tour for the TSP
3 %>
4 %> @note Called by \ref bestInsert
5 %> @note Called by \ref tspInsertion
6 %>
7 %> @author Michel Bierlaire
8 %> @date Tue Apr 14 12:51:09 2015
9 %> @ingroup Algorithms
10 %> @ingroup chap27
11 %>
12 %> Inserts city i after city a in the tour
13 %> @param next for each node, provides the next node in the tour
14 %> @param a index of the city after which i must be included
15 %> @param i index of the city to be inseerted
16 %> @return permutation of the cities
17 function next = insertCity(next,a,i)
18  if (next(i) != 0)
19  error("Node %d is already in the tour",i) ;
20  endif
21  next(i) = next(a) ;
22  next(a) = i ;
23 endfunction
24 
25 
26 
function insertCity(in next, in a, in i)
function bestInsert(in next, in dist, in i)
Inserts city i in the best place.
function tspInsertion(in dist, in initialTour)
Compute an halmitonian path using the insertion heuristic.
Copyright 2015-2016 Michel Bierlaire