ant colonies for the traveling salesman problem

52
Ant colonies for the traveling salesman problem Eliran Natan Seminar in Bioinformatics (236818) – Spring 2013 Computer Science Department Technion - Israel Institute of Technology

Upload: nira

Post on 26-Feb-2016

85 views

Category:

Documents


1 download

DESCRIPTION

Ant colonies for the traveling salesman problem. Eliran Natan. Seminar in Bioinformatics ( 236818 ) – Spring 2013 Computer Science Department Technion - Israel Institute of Technology . Content. Pheromone trails . Ant Colony Optimization algorithms. Travelling Salesman Problem - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Ant colonies for the  traveling  salesman  problem

Ant colonies for the traveling salesman problem

Eliran NatanSeminar in Bioinformatics (236818) – Spring

2013Computer Science Department

Technion - Israel Institute of Technology

Page 2: Ant colonies for the  traveling  salesman  problem

Content

Pheromone trails

Ant Colony Optimization algorithms

Travelling Salesman Problem And its ACS solution

Page 3: Ant colonies for the  traveling  salesman  problem

Content

Pheromone trails

Ant Colony Optimization algorithms

Travelling Salesman Problem And its ACS solution

Page 4: Ant colonies for the  traveling  salesman  problem

Content

Pheromone trails

Ant Colony Optimization algorithms

Travelling Salesman Problem And its ACS solution

Page 5: Ant colonies for the  traveling  salesman  problem

Content

Pheromone trails

Ant Colony Optimization algorithms

Travelling Salesman Problem And its ACS solution

Page 6: Ant colonies for the  traveling  salesman  problem

Pheromone trails

It is well known that the primary means for ants to form and maintain the line is a pheromone trail. Ants deposit a certain amount of pheromone while walking, and each ant probabilistically prefers to follow a direction rich in pheromone.

ℙ (𝐶 )<ℙ (𝐵 )<ℙ ( 𝐴 )

ℙ (𝐴)

ℙ (𝐵)

ℙ (𝐶 )

Page 7: Ant colonies for the  traveling  salesman  problem

Pheromone trails

This elementary behavior of real ants can be used to explain how they can find the shortest path that reconnects a broken line after the sudden appearance of an unexpected obstacle has interrupted the initial path.

Shortest path around an obstacle

Let us consider the following scenario:

Ants are moving on a straight line that connects a food source to their nest .

Page 8: Ant colonies for the  traveling  salesman  problem

Pheromone trailsShortest path around an obstacle

An obstacle appears on the path.

This elementary behavior of real ants can be used to explain how they can find the shortest path that reconnects a broken line after the sudden appearance of an unexpected obstacle has interrupted the initial path.

Page 9: Ant colonies for the  traveling  salesman  problem

Pheromone trailsShortest path around an obstacle

Those ants which are just in front of the obstacle cannot continue to follow the pheromone trail and therefore they have to choose between turning right or left. In this situation we can expect half the ants to choose to turn right and the other half to turn left.

This elementary behavior of real ants can be used to explain how they can find the shortest path that reconnects a broken line after the sudden appearance of an unexpected obstacle has interrupted the initial path.

Page 10: Ant colonies for the  traveling  salesman  problem

Pheromone trailsShortest path around an obstacle

Those ants which choose, by chance, the shorterpath around the obstacle will more rapidly reconstitute the interrupted pheromone trailcompared to those which choose the longer path. Thus, the shorter path will receive a greater amount of pheromone per time unit and in turn a larger number of ants will choose the shorter path.

This elementary behavior of real ants can be used to explain how they can find the shortest path that reconnects a broken line after the sudden appearance of an unexpected obstacle has interrupted the initial path.

Page 11: Ant colonies for the  traveling  salesman  problem

Pheromone trailsShortest path around an obstacle

Shortest path is being obtained.

This elementary behavior of real ants can be used to explain how they can find the shortest path that reconnects a broken line after the sudden appearance of an unexpected obstacle has interrupted the initial path.

Page 12: Ant colonies for the  traveling  salesman  problem

Pheromone trails

Ants are able, without using any spatial Information, to identify a sudden appearance of a food source around their nest, and to find the shortest available path to it.

Shortest path from the nest to the food source

Let us describe the algorithm:

A small amount of ants travel randomly around the nest.

N

Page 13: Ant colonies for the  traveling  salesman  problem

Pheromone trailsShortest path from the nest to the food source

One of the ants find food source.

SN

Ants are able, without using any spatial Information, to identify a sudden appearance of a food source around their nest, and to find the shortest available path to it.

Page 14: Ant colonies for the  traveling  salesman  problem

Pheromone trailsShortest path from the nest to the food source

When ant finds food, it returns to the nest while laying down pheromones trail.

SN

Ants are able, without using any spatial Information, to identify a sudden appearance of a food source around their nest, and to find the shortest available path to it.

Page 15: Ant colonies for the  traveling  salesman  problem

Pheromone trailsShortest path from the nest to the food source

When other ants find a pheromone trail, they are likely not to keep travelling at random, but to instead follow the trail.

SN

Ants are able, without using any spatial Information, to identify a sudden appearance of a food source around their nest, and to find the shortest available path to it.

Page 16: Ant colonies for the  traveling  salesman  problem

Pheromone trailsShortest path from the nest to the food source

If an ant eventually find food by following a pheromone trail, it returning to the nest while reinforcing the trail with more pheromones.

SN

Ants are able, without using any spatial Information, to identify a sudden appearance of a food source around their nest, and to find the shortest available path to it.

Page 17: Ant colonies for the  traveling  salesman  problem

Pheromone trailsShortest path from the nest to the food source

Due to their stochastic behavior, some ants are not following the pheromone trails, and thus uncover more possible paths.

SN

Ants are able, without using any spatial Information, to identify a sudden appearance of a food source around their nest, and to find the shortest available path to it.

Page 18: Ant colonies for the  traveling  salesman  problem

Pheromone trailsShortest path from the nest to the food source

Over time, however, the pheromones trails starts to evaporate, thus reducing its attractive strength.

SN

Ants are able, without using any spatial Information, to identify a sudden appearance of a food source around their nest, and to find the shortest available path to it.

Page 19: Ant colonies for the  traveling  salesman  problem

Pheromone trailsShortest path from the nest to the food source

Shortest path is being obtained.

SN

Ants are able, without using any spatial Information, to identify a sudden appearance of a food source around their nest, and to find the shortest available path to it.

Page 20: Ant colonies for the  traveling  salesman  problem

Pheromone trailsShortest path from the nest to the food source

An Intuitive proof of correctness

Pheromone evaporation also has the advantage of avoiding the convergence to a locally optimal solution. If there were no evaporation at all, all paths chosen by the first ants would tend to be excessively attractive to the following ones. In that case, the exploration of the solution space would be constrained.

The more time it takes for an ant to travel down the path and back again, the more time the pheromones have to evaporate.

Thus,

A short path, by comparison, get marched over more frequently, and thus its pheromone density becomes higher on shorter paths than longer ones.

Thus, when one ant finds a short path from the colony to a food source, other ants are more likely to follow that path, and positive feedback eventually leads all the ants following a single path.

Page 21: Ant colonies for the  traveling  salesman  problem

Ant Colony Optimization (ACO) studies artificial systems that take inspiration from the behavior of real ant colonies and which are used to solve discrete optimization problems.

Ant Colony Optimization algorithms

Some applications:

Set partition problemDeciding whether a given multiset of positive integers can be partitioned into two subsets A and B such that the sum of the numbers in A equals the sum of the numbers in B.

Page 22: Ant colonies for the  traveling  salesman  problem

Ant Colony Optimization algorithms

Ant Colony Optimization (ACO) studies artificial systems that take inspiration from the behavior of real ant colonies and which are used to solve discrete optimization problems.

Some applications:

Job – Shop problemsGiven a number of jobs have to be done and every job consists of using a number of machines for a certain amount of time. Find the best planning to do all the jobs on all the different machines in the shortest period of time.

Page 23: Ant colonies for the  traveling  salesman  problem

Ant Colony Optimization algorithms

Ant Colony Optimization (ACO) studies artificial systems that take inspiration from the behavior of real ant colonies and which are used to solve discrete optimization problems.

Some applications:

Multiple knapsack problemGiven a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible.

Page 24: Ant colonies for the  traveling  salesman  problem

Ant Colony Optimization algorithms

Ant Colony Optimization (ACO) studies artificial systems that take inspiration from the behavior of real ant colonies and which are used to solve discrete optimization problems.

Some applications:

Protein foldingThe process by which a protein structure assumes its functional shape or conformation.

Page 25: Ant colonies for the  traveling  salesman  problem

Ant Colony Optimization algorithms

Ant Colony Optimization (ACO) studies artificial systems that take inspiration from the behavior of real ant colonies and which are used to solve discrete optimization problems.

Some applications:

Data miningthe computational process of discovering patterns in large data sets.

Page 26: Ant colonies for the  traveling  salesman  problem

Ant Colony Optimization algorithms

Ant Colony Optimization (ACO) studies artificial systems that take inspiration from the behavior of real ant colonies and which are used to solve discrete optimization problems.

Some applications:

Travelling salesman problemGiven a list of cities and the distances between each pair of cities, determine the shortest possible route that visits each city exactly once and returns to the origin city.

Page 27: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

Definitions

For a complete undirected weighted graphs

Undirected graph is complete if for every pear of vertexes there exist an edge

Path in is a Hamiltonian path if visits each vertex exactly once.

Problem

Given a complete undirected weighted graph , find the minimal Hamiltonian cycle in .

Complexity class

NP–Hard

Page 28: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

Algorithms for deterministic solution

For an undirected complete weighted graphs

Brute force searchCompute all possible cycles and get the minimal path.Time complexity: Exact solution

Dynamic programmingRecursive algorithms such as the Held–Karp algorithm.Time complexity: Exact solution

Greedy algorithmSuch as the nearest neighbor (NN) algorithm.Time complexity: Approximate solution

Page 29: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

The Ant Colony System (ACS) is one of the ACO algorithms, which gives a non – deterministic approximate solution to the TSP problem with a time complexity of , where is a constant.

ACS solution

Page 30: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

ACS Algorithm description

ACS solution

Given a complete undirected weighted graph :

Place ants in a randomly chosen vertexes.

Page 31: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

ACS Algorithm description

ACS solution

Given a complete undirected weighted graph :

Ant endowed with a working memory , which is used to memorize vertexes already visited. At initialization, for every , and when ant arrives to vertex , vertex is being added to .

Place ants in a randomly chosen vertexes.

Each ant preforms a Hamiltonian cycle according to the navigation function .

Page 32: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

ACS Algorithm description

ACS solution

Given a complete undirected weighted graph :

An ant in city chooses the city to move to among those which do not belong to its working memory by applying the following probabilistic formula:

- Amount of pheromone trail on edge

- A heuristic function which was chosen to be the inverse of the distance between iiiiiiiiiiiiiiivertexes and .

- A parameter which weighs the relative importance of pheromone trail and of iiiiiiiiiiiiiiicloseness.

𝑓 (𝑥 )={argmax𝑢∉𝑀 𝑘{𝜏 (𝑟 ,𝑢) ∙𝜂𝛽 (𝑟 ,𝑢 ) }𝑞<𝑞0

¿∧𝑆𝑜𝑡 h𝑒𝑟𝑤𝑖𝑠𝑒

Place ants in a randomly chosen vertexes.

Each ant preforms a Hamiltonian cycle according to the navigation function .

Page 33: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

ACS Algorithm description

ACS solution

Given a complete undirected weighted graph :

An ant in city chooses the city to move to among those which do not belong to its working memory by applying the following probabilistic formula:

- A value chosen randomly with uniform probability in .

- A parameter in .

𝑓 (𝑥 )={argmax𝑢∉𝑀 𝑘{𝜏 (𝑟 ,𝑢) ∙𝜂𝛽 (𝑟 ,𝑢 ) }𝑞<𝑞0

¿∧𝑆𝑜𝑡 h𝑒𝑟𝑤𝑖𝑠𝑒

Place ants in a randomly chosen vertexes.

Each ant preforms a Hamiltonian cycle according to the navigation function .

Page 34: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

ACS Algorithm description

ACS solution

Given a complete undirected weighted graph :

𝑓 (𝑥 )={argmax𝑢∉𝑀 𝑘{𝜏 (𝑟 ,𝑢) ∙𝜂𝛽 (𝑟 ,𝑢 ) }𝑞<𝑞0

¿∧𝑆𝑜𝑡 h𝑒𝑟𝑤𝑖𝑠𝑒

ℙ𝑘 (𝑟 , 𝑠)={ 𝜏 (𝑟 ,𝑠 ) ∙𝜂𝛽 (𝑟 ,𝑠 )

∑𝑢∉𝑀 𝑘

𝜏 (𝑟 ,𝑢) ∙𝜂𝛽 (𝑟 ,𝑢 )𝑠∉𝑀𝑘

¿∧0𝑜𝑡 h𝑒𝑟𝑤𝑖𝑠𝑒

An ant in city chooses the city to move to among those which do not belong to its working memory by applying the following probabilistic formula:

- A random variable selected according to the following probability distribution, which IIIIIfavors edges which are shorter and have a higher level of pheromone trail:

Place ants in a randomly chosen vertexes.

Each ant preforms a Hamiltonian cycle according to the navigation function .

Page 35: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

ACS Algorithm description

ACS solution

Given a complete undirected weighted graph :

Every time an edge is chosen by an ant, its amount of pheromone is changed according to the following formula:

𝜏 (𝑟 ,𝑠 )⟵ (1−𝛼 ) ∙𝜏 (𝑟 ,𝑠 )+𝛼 ∙𝜏0 - Parameters Local updating is intended to avoid a very strong edge being chosen by all the ants. Local trail updating is also motivated by trail evaporation in real ants.

Place ants in a randomly chosen vertexes.

Each ant preforms a Hamiltonian cycle according to the navigation function .

While traveling, each ant applies the local update rule for each visited edge.

Page 36: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

ACS Algorithm description

ACS solution

Given a complete undirected weighted graph :

Update the weight of each edge that belongs to the shortest tour, according to the following formula:

𝜏 (𝑟 ,𝑠 )⟵ (1−𝛼 ) ∙𝜏 (𝑟 ,𝑠 )+𝛼 ∙𝐿𝑚𝑖𝑛−1

- The length of the shortest tour. Global updating is intended to reward edges belonging to shorter tours. The amount of weight deposited on each edge is inversely proportional to the length

of the tour: The shorter the tour the greater the amount of weight deposited on edges.

Place ants in a randomly chosen vertexes.

Each ant preforms a Hamiltonian cycle according to the navigation function .

While traveling, each ant applies the local update rule for each visited edge.

Once ants have completed their tours, apply the global update rule.

Page 37: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

ACS Algorithm description

ACS solution

Given a complete undirected weighted graph :

𝜏 (𝑟 ,𝑠 )⟵ (1−𝛼 ) ∙𝜏 (𝑟 ,𝑠 )+𝛼 ∙𝐿𝑚𝑖𝑛−1

- The length of the shortest tour. Global updating is intended to emulate the property of differential pheromone trail

accumulation, which in the case of real ants was due to the interplay between length of the path and continuity of time.

Update the weight of each edge that belongs to the shortest tour, according to the following formula:

Place ants in a randomly chosen vertexes.

Each ant preforms a Hamiltonian cycle according to the navigation function .

While traveling, each ant applies the local update rule for each visited edge.

Once ants have completed their tours, apply the global update rule.

Page 38: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

ACS Algorithm description

ACS solution

Given a complete undirected weighted graph :

Place ants in a randomly chosen vertexes.

Each ant preforms a Hamiltonian cycle according to the navigation function .

While traveling, each ant applies the local update rule for each visited edge.

Once ants have completed their tours, apply the global update rule.

times

Page 39: Ant colonies for the  traveling  salesman  problem

Travelling Salesman Problem

ACS Algorithm description

ACS solution

Given a complete undirected weighted graph :

Place ants in a randomly chosen vertexes.

Each ant preforms a Hamiltonian cycle according to the navigation function .

While traveling, each ant applies the local update rule for each visited edge.

Once ants have completed their tours, apply the global update rule.

times

Return shortest tour.

Page 40: Ant colonies for the  traveling  salesman  problem

Travelling Salesman ProblemFor an undirected complete weighted graphs

Algorithm – Initialization

Choose constant between 1 and to be the number of ants.

A

B

CD

E

𝑘=3

Page 41: Ant colonies for the  traveling  salesman  problem

Travelling Salesman ProblemFor an undirected complete weighted graphs

Algorithm – Initialization

Place each ant in a randomly chosen city.

𝑘=3A

B

CD

E

Page 42: Ant colonies for the  traveling  salesman  problem

A

B

CD

E

Travelling Salesman ProblemFor an undirected complete weighted graphs

Algorithm – Step 1

Each ant preforms a Hamiltonian cycle according to the navigation function , while applying the local update rule for each visited edge.

Page 43: Ant colonies for the  traveling  salesman  problem

A

B

CD

E

Travelling Salesman ProblemFor an undirected complete weighted graphs

Algorithm – Step 2

Apply the Global Update Rule.

Page 44: Ant colonies for the  traveling  salesman  problem

Travelling Salesman ProblemFor an undirected complete weighted graphs

Comparison with other algorithms

Comparison of ACS tour length on a TSP problem with 50 vertexes with the following nature-inspired algorithms:

SA – Simulated Annealing

EN – Elastic Net

SOM – Self Organizing Map

FI – Farthest Insertion Heuristic

Page 45: Ant colonies for the  traveling  salesman  problem

5.865.88 5.98

6.06 6.03

ACS SA EN SOM FI

Best

Travelling Salesman ProblemFor an undirected complete weighted graphs

Comparison with other algorithms

Test A

Page 46: Ant colonies for the  traveling  salesman  problem

Travelling Salesman ProblemFor an undirected complete weighted graphs

Comparison with other algorithms

6.05 6.01 6.03

6.25

6.28

ACS SA EN SOM FI

Test B

Best

Page 47: Ant colonies for the  traveling  salesman  problem

Travelling Salesman ProblemFor an undirected complete weighted graphs

Comparison with other algorithms

5.7 5.815.86 5.87

5.96

ACS SA EN SOM FI

Test C

Best

Page 48: Ant colonies for the  traveling  salesman  problem

Travelling Salesman ProblemFor an undirected complete weighted graphs

Comparison with other algorithms

6.17 6.336.49 6.7

6.71

ACS SA EN SOM FI

Test D

Best

Page 49: Ant colonies for the  traveling  salesman  problem

Travelling Salesman ProblemFor an undirected complete weighted graphs

Comparison with other algorithms

6.056.01

6.03 6.25 6.28

ACS SA EN SOM FI

Test E

Best

Page 50: Ant colonies for the  traveling  salesman  problem

Travelling Salesman ProblemFor an undirected complete weighted graphs

Number of ants

ACS runtime on a TSP problem with 10 vertexes for , where is the number of ants.

0.050.1 0.13

0.15 0.160.18

0.20.22

0.23

1 2 3 4 5 6 7 8 9 𝑘

𝑡𝑖𝑚𝑒 [𝑚𝑠𝑒𝑐 ]

Page 51: Ant colonies for the  traveling  salesman  problem

Travelling Salesman ProblemFor an undirected complete weighted graphs

An Intuitive proof of correctness

We can interpret the ant colony as a reinforcement learning system, in which reinforcements modify the strength (Pheromone trail) of connections between vertexes.

Each ant has two options:

Exploit the experience accumulated by the ant colony in the form of pheromone trail (pheromone trail will tend to grow on those edges which belong to short tours, making them more desirable).

Apply a biased exploration of new paths (exploration is biased towards short and high trail edges) by choosing the vertex to move to randomly, with a probability distribution that is a function of both the accumulated pheromone trail, the heuristic function, and the working

memory.

Page 52: Ant colonies for the  traveling  salesman  problem

Reference

Marco DorigoIRIDIA, Université Libre de Bruxelles, Avenue Franklin Roosevelt 50, CP 194/6, 1050Bruxelles, Belgium

Luca Maria GambardellaIDSIA, Corso Elvezia 36, 6900 Lugano, Switzerland

Marco Dorigo is a Research Associate with the FNRS. Luca Gambardella is Research Director at IDSIA.

This research has been funded by the Swiss National Science Fund, contract 21–45653.95 titled “Cooperation and learning for combinatorial optimization”.

“Ant colonies for the traveling salesman problem”Université Libre de Bruxelles, Belgium.