You are on page 1of 12

Solving TSP using

Hopfield Model &


Simulated Annealing
EEL781 Neural Networks
Instructor: Dr. Jayadeva
Teaching Assistant: Udit Kumar

Amanpreet Kaur 2014EET2441


Neeta Abiraami.T.N
2014EET2935

Introduction
The Traveling Salesman Problem (TSP) is a
classical combinatorial optimization problem.
Hopfield networkis a special kind of recurrent
neural networksthat can be used as associative
memory.
Simulated annealing (SA)is a
genericprobablisticmetaheuristicfor theglobal
optimizationproblem of locating a good
approximation to theglobal optimum of a
givenfunctionin a largesearch space.

Hopfield Energy Function


The dynamics of Hopfield networks can be described by
a system of differential equations and the activation
function is a hyperbolic tangent.
Here v is the vector of neuron activities
I is the vector of neuron biases
W is the connection matrix
Then the energy function E of the Hopfield network is

E= -(1/2) vTWv (ib)Tv


Hopfield has shown that the network will converge to
local minima of energy function if W is symmetric

Mapping the TSP onto a Hopfield


net
The output of all neurons represents the current
tour.
The weights wij of the Hopfield net are chosen such
that a Hopfield energy function can be defined with
the properties that it measures the length of a tour
The lowest energy state corresponds to the optimal
tour.
The steady state should correspond to the optimal
tour.

Mapping the TSP onto a Hopfield


net
Hopfield and Tank proposed the following energy
function:

E = A/2 (X i j i VXiVXj)
+ B/2 (i X Y

VXiVYi)

+C/2 (Xi VXi-N)2


+D/2 (X Y X i dXYVXi (VYi+1 +
VYi-1))

Obtaining weight matrix


We can Rewrite E in the form of :

E= -(1/2) vTWv (ib)Tv


Where v, ib are in terms of parameters A, B, C, D.
Thus TSP can be described as a quadratic 0-1
programming problem with linear constraints as:

xvxi=1
ivxi=1
Where n is the No. of cities.

Simulated Annealing
The SA algorithm allows the search to sometimes
accept worst solutions with a probability (p)
thatwould decrease with the temperature of the
system(t).

Implementation
MATLAB is the software used, as it provides the
possibility of developing a quadratic optimiser and
also a GUI in an easy way.
Hop Field Network
We have developed the matlab code for this.
The TSP bench mark problem is input as .txt file
with city index. and X-Y cordinates.
The W matrix is then found .
Number of iterations for optimisation and other
parameters are set.
The constraints for input vectors are also found.
Quadprog is used for finding v.

Implementation
Simulated Annealing
If the problem consists of n cities ci, i = 1, .., n,
any tour can be represented as a permutation of
numbers 1 to n. d(ci,cj) = d(cj,ci) is the distance
between ci and cj.
Given a permutation of the n cities, vi and vi+1
are adjacent cities in the permutation. The
permutation has to be found that minimizes:

xd(vi vi+1) + d(vn v1)


The size of the solution space is (n-1)!/2

Results

16 city problem

22 city problem
30
25
20
15
10
5
0
-5
-10
33

34

35

36

37

38

39

40

41

42

Results & Conclusions


TSP file
ulysses16
ulysses22

Hop field
model
107.0079
179.7079

Simulated
Annealing

ACO

157.368

73.9876 *

181.6275728

56.2237 *

att48

Converging
60087.29
41374.88+
time very
large
While using HNN , larger cities required more iterations for good
solution. So the
optimisation result for att48 was not obtained due to time
constraints.
The optimisation is not exact obviously.
As the number of iterations were increased some what better solution
was obtained.
*Cited from : Kumbharana, N. S., and Gopal M. Pandey. "A Comparative Study of ACO, GA and SA for Solving
Larger
cities
required moreJournal
iterations
for
good solution.
Travelling
Salesman
Problem."International
of Societal
Applications
of Computer Science2, no. 2
(2013): 224-228.
Alhanjouri, Mohammed, and Belal Alfarra. "Ant Colony versus Genetic Algorithm based on Travelling Salesman
Problem."International Journal of Computer Technology and Applications2, no. 3 (2011).
+

Future Work
Different energy functions can be chosen for
better results.
Ant colony optimization (ACO) belongs to the
group of metaheuristic methods and can be used
as a global search algorithm for better
optimisation along with the local search algorithm
used here.

You might also like