Sunteți pe pagina 1din 79

Ant Colony Optimization

Requirements : .

Presented by:

Hamid Eghbalpour
Operating Manager of Asia Peyman.Co

Hamid.Eghbalpour@Gmail.com
H.Eghbalpour.1987@IEEE.org

kourosh.eghbalpour

+98 21 897 882 08


https://sbu-ir.academia.edu/HEghbalpour

Shahid Beheshti University of Tehran

Swarm Intelligence
Lecture 01

Ant Colony Optimization

Food

Nest

NEST

FOOD

Nest

10

Food

Interrupt The Flow


Nest

Food

Obstacle

11

The Path Thickens!


Nest

Food

Obstacle

12

The New Shortest Path


Nest

Food

Obstacle

13

Adapting to Environment Changes

Food

Nest

Obstacle
14

Adapting to Environment Changes

Food

Nest

Obstacle
15

History of Ant Algorithms


Goss et al. 1989,
Deneuborg et al. 1990,
experiments with
Argentine ants
Dorigo et al. 1991,
applications to shortest
path problems
Now: established method
for various optimization
problems
16

Natural Ant System


Initially, ants explore randomly
Leave behind pheromone when they travel back
to colony from food
Pheromone evaporates over time
Ants follow strong pheromone left behind by
other ants
Short routes to food have more pheromone (less
distance = less evaporation)
17

Deneubourgs Simple Experiment

18

Probabilistic Transition Function

ij (t ) ij

k
pij t ij (t ) ij
kallowedk

0
pijk t

if j allowedk
otherwise

is the probability that ant k will choose the link that goes from i to j

at time t

ij (t )

is the amount of pheromone currently on the path that goes directly from i to j

at time t

We let ij (t ) denote the intensity of trail on link(i,j) at time t.


19

ij (t ) ij

k
pij t ij (t ) ij
kallowedk

if j allowedk
otherwise

ij

is the heuristic value of this link in the classic TSP application, this is
chosen to be 1/distance(i,j) -- I.e. the shorter the distance, the higher the heuristic
value.

, are parameters that we can call the heuristic strength


Where our ant is at i and j is a point as yet unvisited on its tour, and the summation
is over all of ks unvisited points

20

Three factors drive the probabilistic model:


1) Visibility, denoted ij, equals the quantity 1/dij

2) Trail, denoted ij(t)


3) Evaporation
These three factors play an essential role in the central
probabilistic transition function of the Ant System.
In return, the weight of either factor in the transition
function is controlled by the variables and ,
respectively. Significant study has been undertaken by
researchers to derive optimal : combinations.
21

A high value for means that trail is very important


and therefore ants tend to choose edges chosen by
other ants in the past. On the other hand, low values
of make the algorithm very similar to a stochastic
multigreedy algorithm.

22

Trail intensity is updated following the completion of each


algorithm cycle, at which time every ant will have
completed a tour. Each ant subsequently deposits trail of
quantity Q/Lk on every edge (i,j) visited in its individual
tour. Notice how this method would favor shorter tour
segments. The sum of all newly deposited trail is denoted
by ij. Following trail deposition by all ants, the trail
value is updated using

ij (t n) ij (t ) ij
Where m is the rate of trail decay per time interval and
ij = . ij
N
k 1

ij (t 1) (1 ) ij (t )

23

k 1

k
ij

After each ant tour the trail intensity on each edge is updated using the following

formula

Pheromone increase at the end of tour

ij (t n) ij (t ) ij
Fixed

ij : For all links ij is fixed

i , j

select path
otherwise

ij is proportional to link which ant passes, the ant who passes


the short links, produce more pheromone
i , j
24

Q
if (i, j ) tour described by tabuk
Lk
0
otherwise

Pheromone left on each path

Short tour High pheromone


Long Tour Low Pheromone

Example 1
Here we have 10 cities as follow :
1
2
3
4
5
6
7
8
9
10

X
974.55
81.189
428
81.56
852.81
883.9
226.25
478.86
638.63
406.19

Y
90.95
701.4
783.79
685.07
699.51
330.77
673.3
820.88
884.22
782.67

The pheromone trail must not build unbounded.


Therefore, we need evaporation
Evaporation
Remove links of poor paths

26

ij (t n) (1 ) ij (t )

Cities distribution

Distance between cities

1
2
3
4
5
6
7
8
9
10

1
0.0
1082.0
882.5
1072.6
620.6
256.4
948.2
882.3
861.5
895.3

2
1082.0
0.0
356.5
16.3
771.6
884.1
147.8
415.2
586.7
335.0

3
882.5
356.5
0.0
360.2
433.1
642.7
230.0
62.9
233.3
21.8

4
1072.6
16.3
360.2
0.0
771.4
877.1
145.2
419.9
591.6
339.0

5
620.6
771.6
433.1
771.4
0.0
370.0
627.1
393.2
282.8
454.3

6
256.4
884.1
642.7
877.1
370.0
0.0
741.5
635.8
605.4
657.6

7
948.2
147.8
230.0
145.2
627.1
741.5
0.0
292.6
463.2
210.6

8
882.3
415.2
62.9
419.9
393.2
635.8
292.6
0.0
171.9
82.1

9
861.5
586.7
233.3
591.6
282.8
605.4
463.2
171.9
0.0
253.7

10
895.3
335.0
21.8
339.0
454.3
657.6
210.6
82.1
253.7
0.0

Distribute ants on cities randomly

City's
Number
Number
of ant (s)

10

Initiating pheromone table:


ij 0

M
& 0 nn
C

Ants
Number

Length of
a random
tour

Pheromone distributions table


1

10

0.000

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.000

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.000

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.000

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.000

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.000

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.000

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.000

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.000

0.001

10

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.001

0.000

Making taboo-list table and initiate


it depending on current Ants Position
Ants
Index

1
2
3
4
5
6
7
8
9
10

1
2
2
0
0
0
0
0
0
0
0

2
0
0
0
0
0
0
0
0
0
0

3
0
0
2
2
0
0
0
0
0
0

4
0
0
0
0
2
0
0
0
0
0

5
0
0
0
0
0
2
0
0
0
0

6
0
0
0
0
0
0
2
0
0
0

7
0
0
0
0
0
0
0
2
0
0

8
0
0
0
0
0
0
0
0
0
0

9
0
0
0
0
0
0
0
0
2
0

10
0
0
0
0
0
0
0
0
0
2

Making Ant-city tour table


Ant-city is a matrix that shows tour ( in row)which a
ant passes and columns are cities that ant visits
them:
Ants
Index

1
2
3
4
5
6
7
8
9
10

1
1
3
3
4
5
6
7
9
10

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

First city and last city are the same.

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

1
1
3
3
4
5
6
7
9
10

Making Ant-path length table


In this matrix we have total distance that any
ant passed until now!
Ant_Num
Total
Path_len

10

In the first step all of the path-length are zero.

For first ant in first city we determine available


cities-cities that we can go-from taboo-list.
Suppose the next ant is in the city 1
Available
Cities

In next step we compute probability of


Available cities to go by this formula:

10

When ant k is in city i and has so far constructed the partial solution sp, the
probability of going to city j is given by

ij (t ) ij

(
t
)

pij t
il
il
Cil N ( s p )

ij (t )

ij
N (s p )

if Cij N ( s p )
otherwise

Pheromone amount
between city I & j

1/(distance between city I & j)

is the set of feasible components, that is, edges


(i, l) where l is a city not yet visited by the ant k.

For the first ant we have:


Available
Cities

Available Cities
Distance from
current city(1)

Available Cities
1/Distance from
current city(1)

1082 882 1072 620

10

10

256

948

882

861

895

10

9.2E-04

1.1E-03

9.3E-04

1.6E-03

3.9E-03

1.1E-03

1.1E-03

1.2E-03

1.1E-03

Pheromone between city 1 and available


cities

Available Cities 2
3
4
5
6
7
8
9
10
(pheromone
amount)^1 1.E-03 1.E-03 1.E-03 1.E-03 1.E-03 1.E-03 1.E-03 1.E-03 1.E-03

Available Cities
(1/Distance from
current city(1))^4

2
3
4
5
6
7
8
9
10
9.2E- 1.1E- 9.3E- 1.6E- 3.9E- 1.1E- 1.1E- 1.2E- 1.1E04
03
04
03
03
03
03
03
03

10

1.1E-15 2.4E-15 1.1E-15 9.9E-15 3.4E-13 1.8E-15 2.4E-15 2.7E-15 2.3E-15

And finally based on eq.1 we have:

City's Number

Probability

0%

1%

0%

6*

3% 93% 0%

10

1%

1%

1%

3%

93%

In next step we must select next city


from available list and depending on
probabilities in previous stage.
Normally city with more probability
has more chance to be selected!
Here in program we have city number
6 next city.

Then we update tables:


Taboo-list

Ants
Index

1
2
3
4
5
6
7
8
9
10

10

2
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0

0
2
2
0
0
0
0
0
0

0
0
0
2
0
0
0
0
0

0
0
0
0
2
0
0
0
0

0
0
0
0
0
2
0
0
0

0
0
0
0
0
0
2
0
0

0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
2
0

0
0
0
0
0
0
0
0
2

Ants
Index

ant-city table
0 0 0 0

10

10

10

6
0

7
0

Ant_Num 1
Path_len 256.3

2
0

3
0

4
0

5
0

8
0

9
0

10
0

We do this operations to other ant at other


cities to move all ants to next city.
Taboo-list
Ants
Index

1
2
3
4
5
6
7
8
9
10

10

1
1
0
0
0
0
2
0
0
0

0
0
0
0
2
0
0
0
0
0

0
0
1
1
0
0
0
0
0
2

0
0
0
0
1
0
0
2
0
0

0
0
0
0
0
1
0
0
0
0

2
2
0
0
0
0
1
0
0
0

0
0
0
0
0
0
0
1
0
0

0
0
0
0
0
0
0
0
2
0

0
0
0
0
0
2
0
0
1
0

0
0
2
2
0
0
0
0
0
1

Ant-city table
Ants
Index

1
2
3
4
5
6

7
8
9

10

1
1
3
3
4
5
6
7
9
10

6
6
10
10
2
9
1
4
8
3

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

1
1
3
3
4
5
6
7
9
10

Ant-path length table

Ant_Num

10

Path_Len 256.4 256.4 21.8 21.8 16.3 282.8 256.4 145.2 171.9 21.8

At next step we come back to first ant


and move it to next city as same as last.
Only different is that one city has
eliminated from available cities list. And
do same operation it to other ants until
a tour completed for all ants.
And update all table at any step see
here all table at the end of first tour:

Taboo-list

Ants
Index

1
2
3
4
5
6
7
8
9
10

10

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

2
1
1
1
2
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
1
1
1
1
1

1
1
1
1
1
2
1
1
1
1

1
2
2
2
1
1
2
2
1
2

1
1
1
1
1
1
1
1
2
1

Ant-city table
Ants
Index

1
2
3
4
5
6
7
8
9
10

1
1
3
3
4
5
6
7
9
10

6
6
10
10
2
9
1
4
8
3

2
8
8
8
7
1
5
2
5
8

4
3
7
1
1
6
2
6
2
1

7
10
2
4
6
7
4
3
4
5

9
2
4
2
3
2
7
10
7
2

3
4
5
6
10
4
8
8
1
4

10
5
6
5
8
3
3
1
6
7

8
7
1
7
9
10
10
5
3
6

7*

5
9
9
9
5
8
9
9
10
9

1
1
3
3
4
5
6
7
9
10

Ant-path length table

Ant_Num

10

Path_Len 3116.3 4051.5 3053.2 4653.0 3341.4 3163.6 3046.5 4041.3 3620.9 4121.4

At final step in first iteration we must


save best tour(tour with shortest
length tour).
7

Ant Number 7 is winner


Best tour in Itr.1 belongs to ant number 7

Steps
City
Number

10

11

10

Length of best tour at Itr.1 : 3046.5

After each iteration we must


update pheromone table by using
this formula:
N

ij (t 1) (1 ) ij (t )
k 1

Pheromone evaporation coefficient


= 0.5

k
ij

k
ij t L k
0

where edge (i , j ) T k t
if edge (i , j ) T k t

Constant value =1

Lk

Tours length of ant k

Tk

Tour of ant k

For ant number k=1 to 10 :

Q / Lk
Ant
_number
1/L

1
2
3
4
5
6
7
8
9
10
3.2E- 2.5E- 3.3E- 2.1E- 3.0E- 3.2E- 3.3E- 2.5E- 2.8E- 2.4E04
04
04
04
04
04
04
04
04
04

Delta-pheromone table (*e-4)


updated by ant number 1

1
2
3
4
5
6
7
8
9
10

1
0
0
0
0
3.2
3.2
0
0
0
0

2
0
0
0
3.2
0
3.2
0
0
0
0

3
0
0
0
0
0
0
0
0
3.2
3.2

4
0
3.2
0
0
0
0
3.2
0
0
0

5
3.2
0
0
0
0
0
0
3.2
0
0

6
3.2
3.2
0
0
0
0
0
0
0
0

7
0
0
0
3.2
0
0
0
0
3.2
0

8
0
0
0
0
3.2
0
0
0
0
3.2

9
0
0
3.2
0
0
0
3.2
0
0
0

10
0
0
3.2
0
0
0
0
3.2
0
0

Updating delta pheromone will be


continued by other ants and finally we
have:

Delta-pheromone table(*e-4)

1
2
3
4
5
6
7
8
9
10

1
0
0
0
0
0
6.6
5.8
7.0
3.2
0

2
0
0
0
7.6
8.5
3.2
6.4
0
0
2.5

3
0
0
0
3.2
0
8.2
0
5.8
3.2
2.4

4
2.1
20.6
0
0
0
0
2.5
0
0
0

5
11.4
0
0
8.7
0
2.1
0
6.0
3.0
0

6
14.6
4.6
0
0
3.3
0
2.4
0
0
0

7
0
3.0
0
11.7
4.6
3.2
0
3.3
0
0

8
0
0
2.4
0
3.2
2.5
3.3
0
2.8
17.3

9
5.7
0
5.4
0
5.6
5.7
10.3
3.0
0
5.7

10
0
0
25.8
0
0
0
0
0
2.8
0

Pheromone table must be evaporated


at first then add with delta pheromone:

Evaporated pheromone table(*e-4)

1
2
3
4
5
6
7
8
9
10

1
0
5
5
5
5
5
5
5
5
5

2
5
0
5
5
5
5
5
5
5
5

3
5
5
0
5
5
5
5
5
5
5

4
5
5
5
0
5
5
5
5
5
5

5
5
5
5
5
0
5
5
5
5
5

6
5
5
5
5
5
0
5
5
5
5

7
5
5
5
5
5
5
0
5
5
5

8
5
5
5
5
5
5
5
0
5
5

9
5
5
5
5
5
5
5
5
0
5

10
5
5
5
5
5
5
5
5
5
0

1
0
5
5
5
5
5
5
5
5

2
5
0
5
5
5
5
5
5
5

3
5
5
0
5
5
5
5
5
5

4
5
5
5
0
5
5
5
5
5

5
5
5
5
5
0
5
5
5
5

6
5
5
5
5
5
0
5
5
5

7
5
5
5
5
5
5
0
5
5

8
5
5
5
5
5
5
5
0
5

9
5
5
5
5
5
5
5
5
0

1
0
5
5
5
5
5
5
5
5
5

1
2
3
4
5
6
7
8
9
1
0 5 5 5 5 5 5 5 5 5 0
Evaporated pheromone table(*e-4)

1
2
3
4
5
6
7
8
9
10

1
0
0
0
0
0
6
5
7
3
0

2
0
0
0
7
8
3
6
0
0
2

3
0
0
0
3
0
8
0
5
3
2

4 5 6 7 8 9 10
2 11 14 0 0 5 0
20 0 4 3 0 0 0
0 0 0 0 2 5 25
0 8 0 11 0 0 0
0 0 3 4 3 5 0
0 2 0 3 2 5 0
2 0 2 0 3 10 0
0 6 0 3 0 3 0
0 3 0 0 2 0 2
0 0 0 0 17 5 0

Delta-pheromone table(*e-4)

pheromone table(*e-4)

1
2
3
4
5
6
7
8
9
10

1
0
7
7
7
7
14
13
14
11
7

2
7
0
7
15
16
11
14
7
7
10

3
7
7
0
11
7
16
7
13
11
10

4
10
28
7
0
7
7
10
7
7
7

5
19
7
7
16
0
10
7
13
10
7

6
22
12
7
7
11
0
10
7
7
7

7
7
10
7
19
12
11
0
11
7
7

8
7
7
10
7
11
10
11
0
10
25

9
13
7
13
7
13
13
18
10
0
13

10
7
7
33
7
7
7
7
7
10
0

For next iteration taboo-list and ant-city list set to initial


values. delta-pheromone and ant-path length table set to
be zero.
Ants
Index

1
2
3
4
5
6
7
8
9
10

1
2
2
0
0
0
0
0
0
0
0

2
0
0
0
0
0
0
0
0
0
0

3
0
0
2
2
0
0
0
0
0
0

4
0
0
0
0
2
0
0
0
0
0

5
0
0
0
0
0
2
0
0
0
0

6
0
0
0
0
0
0
2
0
0
0

7
0
0
0
0
0
0
0
2
0
0

8
0
0
0
0
0
0
0
0
0
0

9
0
0
0
0
0
0
0
0
2
0

10
0
0
0
0
0
0
0
0
0
2

Taboo list

Ants
Index

1
2
3
4
5
6
7
8
9
10

1
2
2
0
0
0
0
0
0
0
0

2
0
0
0
0
0
0
0
0
0
0

3
0
0
2
2
0
0
0
0
0
0

4
0
0
0
0
2
0
0
0
0
0

5
0
0
0
0
0
2
0
0
0
0

6
0
0
0
0
0
0
2
0
0
0

7
0
0
0
0
0
0
0
2
0
0

8
0
0
0
0
0
0
0
0
0
0

9
0
0
0
0
0
0
0
0
2
0

10
0
0
0
0
0
0
0
0
0
2

Ant-city table

Ants
Index

1
2
3
4
5
6
7
8
9
10

1
1
3
3
4
5
6
7
9
10

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

0
0
0
0
0
0
0
0
0
0

1
1
3
3
4
5
6
7
9
10

Ant-path length table

Ant_Num
Path_len

1
0

2
0

3
0

4
0

5
0

6
0

7
0

8
0

9
0

10
0

We move ants to next city as same as last


iteration and fill taboo-list ,.
Until complete a tour. At the end of tour we
update pheromone table and find best tour
and compare it to previous best tour and if
new best tour is better best tour is replace
with new best tour.

second iteration:
Ant-city table
Ants
Index

1
2
3
4
5
6
7
8
9
10

1
1
3
3
4
5
6
7
9
10

6
6
10
10
2
9
1
2
10
3

5
5
8
8
1
8
4
4
3
8

7
9
4
9
3
3
2
9
8
9

2
8
2
1
10
10
7
3
4
2

4
3
1
6
8
2
3
10
2
4

3
10
5
5
5
4
10
8
1
6

10
4
7
2
7
7
8
1
6
1

8
2
6
4
6
1
5
5
5
5

9
7
9
7
9
6
9
6
7
7

1
1
3
3
4
5
6
7
9
10

Ant-path length table

Ant_Num

6*

10

Path_Len 2915.1 2617.2 4450.1 2926.9 5043.5 2610.6 3108.4 3707.5 3573.4 3451.4

Ant Number 6 is winner


Best tour in Itr.2 belongs to ant number 6

Steps
City
Number

10

11

10

Length of best tour in Itr.2 : 2610.6


Length of new best tour is shorter than old one then we
replace it to pervious best tour.
Best tour

Steps
City
Number

10

11

10

pheromone table in Itr.2

1
2
3
4
5
6
7
8
9
10

1
0
0.001
0.000
0.000
0.000
0.001
0.001
0.001
0.001
0.000

2
0.000
0
0.000
0.002
0.001
0.001
0.001
0.000
0.001
0.001

3
0.001
0.000
0
0.001
0.000
0.001
0.001
0.001
0.001
0.001

4
0.001
0.003
0.000
0
0.000
0.000
0.000
0.001
0.000
0.001

5
0.002
0.000
0.000
0.001
0
0.002
0.000
0.001
0.001
0.000

6
0.003
0.001
0.000
0.001
0.001
0
0.001
0.000
0.000
0.000

7
0.001
0.001
0.001
0.002
0.002
0.001
0
0.001
0.001
0.001

8
0.000
0.000
0.001
0.000
0.001
0.000
0.001
0
0.001
0.003

9
0.001
0.000
0.001
0.001
0.002
0.001
0.001
0.001
0
0.001

10
0.000
0.000
0.004
0.000
0.000
0.000
0.000
0.000
0.001
0

Third iteration:
Ant-city table
Ants
Index

1
2
3
4
5
6
7
8
9
10

1
1
3
3
4
5
6
7
9
10

6
6
10
10
2
9
1
2
5
3

5
5
8
8
7
1
9
4
7
8

2
9
6
2
3
6
3
1
3
9

4
2
1
4
10
4
10
5
10
1

7
4
2
7
8
2
8
3
8
5

9
3
4
1
9
7
5
10
2
6

8
10
7
6
1
8
4
8
4
2

3
8
5
5
5
3
2
9
1
4

10
7
9
9
6
10
7
6
6
7

1
1
3
3
4
5
6
7
9
10

Ant-path length table

Ant_Num

4*

10

Path_Len 3174.7 3217.2 3382.9 2771.5 3399.1 3273.5 3525.3 3913.0 3609.8 3365.0

Ant Number 4 is winner


Best tour in Itr.3 belong to ant number 4

Steps
City
Number

10

11

10

Length of best tour in Itr.3 : 2771.5


Length of new best tour is longer than old one then we dont
replace it to pervious best tour.
Best tour

Steps
City
Number

10

11

10

pheromone table in Itr.3

1
2
3
4
5
6
7
8
9
10

1
0
0.001
0.000
0.001
0.000
0.001
0.001
0.000
0.001
0.000

2
0.000
0
0.000
0.002
0.001
0.001
0.001
0.001
0.001
0.000

3
0.000
0.000
0
0.001
0.000
0.000
0.001
0.001
0.001
0.001

4
0.000
0.004
0.000
0
0.000
0.000
0.000
0.000
0.000
0.000

5
0.002
0.000
0.000
0.000
0
0.002
0.000
0.001
0.001
0.000

6
0.003
0.000
0.000
0.001
0.001
0
0.001
0.000
0.001
0.000

7
0.001
0.001
0.000
0.002
0.001
0.001
0
0.001
0.000
0.001

8
0.000
0.000
0.001
0.000
0.000
0.000
0.001
0
0.001
0.004

9
0.001
0.000
0.001
0.000
0.002
0.001
0.001
0.002
0
0.000

10
0.000
0.000
0.005
0.000
0.000
0.000
0.000
0.000
0.000
0

Fourth iteration:
Ant-city table
Ants
Index

1
2
3
4
5
6
7
8
9
10

1
1
3
3
4
5
6
7
9
10

6
6
10
10
2
3
1
6
8
3

3
7
8
8
7
10
2
8
3
8

10
2
9
9
3
8
4
3
10
9

8
4
5
1
10
9
7
10
2
4

4
9
6
2
8
6
8
1
4
2

2
5
2
4
5
2
3
2
7
5

7
3
4
7
6
4
10
4
1
1

5
10
7
5
1
1
5
5
5
6

9
8
1
6
9
7
9
9
6
7

1
1
3
3
4
5
6
7
9
10

Ant-path length table

Ant_Num

5*

10

Path_Len 3358.4 3455.8 3805.0 4020.6 2970.7 4862.6 3219.7 4973.1 3297.4 3465.3

Ant Number 5 is winner


Best tour in Itr.4 belongs to ant number 5

Steps
City
Number

10

11

10

Length of best tour in Itr.4 : 2970.5


Length of new best tour is longer than old one then we dont
replace it to pervious best tour.
Best tour

Steps
City
Number

10

11

10

pheromone table in Itr.4

1
2
3
4
5
6
7
8
9
10

1
0
0.000
0.000
0.001
0.000
0.001
0.001
0.000
0.001
0.000

2
0.001
0
0.000
0.002
0.000
0.001
0.001
0.000
0.000
0.001

3
0.000
0.000
0
0.000
0.001
0.000
0.001
0.001
0.000
0.001

4
0.000
0.004
0.000
0
0.000
0.000
0.000
0.001
0.000
0.000

5
0.001
0.000
0.000
0.000
0
0.001
0.001
0.001
0.001
0.000

6
0.002
0.000
0.000
0.000
0.002
0
0.001
0.000
0.001
0.000

7
0.001
0.001
0.000
0.002
0.001
0.001
0
0.000
0.000
0.001

8
0.000
0.000
0.001
0.000
0.000
0.000
0.001
0
0.001
0.003

9
0.001
0.000
0.001
0.001
0.002
0.001
0.001
0.002
0
0.000

10
0.000
0.000
0.005
0.000
0.000
0.000
0.000
0.000
0.000
0

8th iteration:
Ant-city table
Ants
Index

1
2
3
4
5
6
7
8
9
10

1
1
3
3
4
5
6
7
9
10

6
6
10
10
2
9
1
1
8
3

5
5
8
8
7
8
4
6
3
8

9
8
9
9
3
3
2
5
10
9

7
3
1
1
10
10
7
8
1
4

4
10
2
6
8
6
3
3
5
2

2
2
4
2
1
4
10
10
6
5

3
4
6
4
6
2
8
2
2
6

10
7
5
7
5
1
5
4
4
1

8
9
7
5
9
7
9
9
7
7

1
1
3
3
4
5
6
7
9
10

Ant-path length table

Ant_Num

1*

10

Path_Len 2876.7 2925.5 4339.9 3499.5 2881.2 4747.8 3108.4 3458.7 3651.4 3421.4

Ant Number 1 is winner


Best tour in Itr.8 belongs to ant number 1

Steps
City
Number

10

11

10

Length of best tour in Itr.8 : 2876.7


Length of new best tour is longer than old one then we dont
replace it to pervious best tour.
Best tour

Steps
City
Number

10

11

10

pheromone table in Itr.8

1
2
3
4
5
6
7
8
9
10

1
0
0.000
0.000
0.000
0.000
0.001
0.001
0.001
0.001
0.000

2
0.001
0
0.000
0.003
0.000
0.001
0.000
0.000
0.000
0.001

3
0.000
0.000
0
0.000
0.000
0.000
0.001
0.002
0.000
0.001

4
0.000
0.003
0.000
0
0.000
0.000
0.000
0.000
0.001
0.000

5
0.001
0.000
0.000
0.000
0
0.003
0.001
0.000
0.000
0.000

6
0.003
0.000
0.000
0.001
0.001
0
0.000
0.000
0.000
0.000

7
0.001
0.002
0.000
0.002
0.001
0.000
0
0.000
0.001
0.001

8
0.001
0.000
0.001
0.000
0.001
0.000
0.000
0
0.001
0.003

9
0.000
0.000
0.000
0.001
0.002
0.001
0.001
0.002
0
0.000

10
0.000
0.000
0.005
0.000
0.000
0.000
0.000
0.000
0.000
0

th
last(10 )

iteration:

Ant-city table
Ants
Index

1
2
3
4
5
6
7
8
9
10

1
1
3
3
4
5
6
7
9
10

6
6
10
10
2
2
1
2
8
3

5
5
8
8
7
4
5
4
3
8

9
9
9
9
3
7
9
5
10
1

3
8
2
6
10
1
4
1
1
2

10
3
4
4
8
6
2
9
2
4

8
10
7
2
9
3
7
8
4
5

2
2
1
7
1
10
3
3
7
6

4
4
5
1
6
8
10
10
5
7

7
7
6
5
5
9
8
6
6
9

1
1
3
3
4
5
6
7
9
10

Ant-path length table

Ant_Num

2*

10

Path_Len 2771.5 2610.6 3605.5 3924.3 2929.2 3339.0 2885.3 4073.3 3998.0 4665.2

Ant Number 2 is winner


Best tour in Itr.10 belongs to ant number 2

Steps
City
Number

10

11

10

Length of best tour in Itr.10 :


2610.62030
Length of new best tour is the same as old one then we dont
replace it to pervious best tour.
Best tour

Steps
City
Number

10

11

10

pheromone table in last Itr

1
2
3
4
5
6
7
8
9
10

1
0
0.000
0.000
0.000
0.000
0.001
0.001
0.001
0.001
0.000

2
0.001
0
0.000
0.002
0.000
0.000
0.000
0.001
0.001
0.001

3
0.000
0.000
0
0.000
0.000
0.000
0.001
0.002
0.001
0.000

4
0.000
0.004
0.000
0
0.000
0.000
0.000
0.000
0.001
0.000

5
0.001
0.000
0.000
0.001
0
0.002
0.001
0.000
0.000
0.000

6
0.003
0.000
0.000
0.000
0.001
0
0.000
0.000
0.001
0.001

7
0.001
0.002
0.000
0.002
0.001
0.000
0
0.000
0.000
0.000

8
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0
0.001
0.004

9
0.000
0.000
0.000
0.000
0.002
0.001
0.001
0.002
0
0.000

10
0.000
0.000
0.005
0.000
0.000
0.000
0.000
0.000
0.000
0

Finally we find best-tour as:


Steps
City
Number

10

11

10

2610.62030

Questions? Discussion? Suggestions ?

79

S-ar putea să vă placă și