BASE Algorithm
BASE Algorithm
2-// this is the phase in wich ants bulid their tours the tour of ant k is stored in tour k
For i=1 to n
If i<n
Then
For k=1 to m
Choose the next city sk according to (2) and (1)
Jk(sk) = Jk(rk) – sk
Tourk(i) = (rk , sk)
End_for
Else
For k=1 to m
// in this cycle all ants go back to thr initial city rk1
Sk=rk1
Tourk(i) = (rk , sk)
End_for
End_if
// in this step local updating occurs and pheromone is update using
For k =1 to m
τ (rk , sk) =(1-p) τ (rk, sk) + p τₒ
rs = sk //new city for ant k
End_for
End_for
3-// in this phase global update accurs and pheromone is update
For k=1 to m
Compute lk // lk the length of tour of tour done by ant k
End_for
Compute l best
//update edges belonging to lbest
For each edge(r,s)
τ (rk,sk)= (1- α) τ (rk,sk)+ α * 1/ (lbest)
End_for
4- if (End_condition = true)
Then print shortest of lk
Else goto 2
(2)