Topics: Travelling salesman problem, Optimization, Wavelength Pages: 17 (1520 words) Published: February 22, 2013
Applications in Business

Tour Scheduling

A Classical Traveling Salesman Problem (TSP) can be defined as a problem where starting from a node it is required to visit every other node only once in a way that the total distance covered is minimized.

The basic steps as applied to the TSP are presented below:

1. Solution Representation: A feasible solution is represented as a sequence of nodes, each node appearing only once and in the order it is visited. The first and the last visited nodes are fixed to 1. The starting node is not specified in the solution representation and is always understood to be node 1.

|3 |5 |2 |4 |7 |
| | | |3 | |
| |1 | | |2 |
| |5 | | | |

|2 |4 | | | |


Figure 3: Tabu Structure [1]

8. Termination criteria: The algorithm terminates if a pre-specified number of iterations is reached

MATLAB Code for Tabu Search

% Travelling Sales man problem using Tabu Search

% This assumes the distance matrix is symmetric

% Tour always starts from node 1

% **********Read distance (cost) matrix from Excel sheet "data.xls"******

d = xlsread('input_data127.xls');

d_orig = d;

start_time = cputime;

dim1 = size(d,1);

dim12 = size(d);

for i=1:dim1



% *****************Initialise all parameters**********************


tour = zeros(dim12);

cost = 0;

min_dist=[ ];

short_path=[ ];

best_nbr_cost = 0;

best_nbr = [ ];

% *******Generate Initial solution - find shortest path from each node****

% if node pair 1-2 is selected, make distance from 2 to each of earlier

%visited nodes very high to avoid a subtour

k = 1;

for i=1:dim1-1

min_dist(i) = min(d1(k,:));

short_path(i) = find((d1(k,:)==min_dist(i)),1);

cost = cost+min_dist(i);

k = short_path(i);

% prohibit all paths from current visited node to all earlier visited nodes


for visited_node = 1:length(short_path);





for i=2:dim1-1



%Last visited node is k;

%shortest path from last visited node is always 1, where the tour

%originally started from

last_indx = length(short_path)+1;



cost = cost+d(k,1);

% A tour is represented as a sequence of nodes startig from second node (as

% node 1 is always fixed to be 1

crnt_tour = short_path;

best_tour = short_path;

best_obj =cost;

crnt_tour_cost = cost;

fprintf('\nInitial solution\n');


fprintf('\nInitial tour cost = %d\t', crnt_tour_cost);

nbr_cost=[ ];

% Initialize Tabu List "tabu_tenure" giving the number of iterations for

% which a particular pair of nodes are forbidden from exchange

tabu_tenure = zeros(dim12);

max_tabu_tenure = round(sqrt(dim1));

%max_tabu_tenure = dim1;

penalty = zeros(1,(dim1-1)*(dim1-2)/2);

frequency = zeros(dim12);



for i=1:dim1



iter_snc_last_imprv = 0;

%*********Perform the iteration until one of the criteria is met***********

%1. Max number of iterations reached***************************************

%2. Iterations since last improvement in the best objective found so far

% reaches a threshold******************************************************

best_nbr = crnt_tour;

for iter=1:10000

fprintf('\n*****iteration number = %d*****\n', iter);

nbr =[];

% *******************Find all neighbours to current tour by an exchange

%******************between each pair of nodes***********************

% ****Calculate the object value (cost) for each of the neighbours******

nbr_cost = inf(dim12);

for i=1:dim1-2...
Continue Reading

Please join StudyMode to read the full document

Become a StudyMode Member

Sign Up - It's Free