Intelligent Systems II · TEE · read

ACO formulas: transition probability, city choice and pheromone update

Unit 3 · Ant colony optimization (ACO)

Unit 3 · Ant colony optimization for TSP · asked as a 10-mark numerical in both 2025–26 papers

From city A an ant may choose B or C. Distances are AB=2 and AC=4. Pheromones are both 1 and α=β=1. Find the next-city probabilities. [2 marks · Worked example]

Given

Current city A; allowed next cities B and C. Distances dAB=2 and dAC=4. Pheromones τAB=τAC=1, and exponents α=β=1. Visited cities are excluded.

To find

P(A→B) and P(A→C).

Formula and why it applies

\eta_{ij}=1/d_{ij}\qquad P_{ij}=\tau_{ij}\eta_{ij}/\sum_{l\in allowed}\tau_{il}\eta_{il}LaTeX: \eta_{ij}=1/d_{ij}\qquad P_{ij}=\tau_{ij}\eta_{ij}/\sum_{l\in allowed}\tau_{il}\eta_{il}

Shorter distance gives a larger reciprocal. Normalise the desirability weights to probabilities.

Solution

Step 1. Take reciprocal distances
\eta_{AB}=1/2=0.5\qquad\eta_{AC}=1/4=0.25LaTeX: \eta_{AB}=1/2=0.5\qquad\eta_{AC}=1/4=0.25
Step 2. Multiply by pheromone
w_B=1\times0.5=0.5\qquad w_C=1\times0.25=0.25LaTeX: w_B=1\times0.5=0.5\qquad w_C=1\times0.25=0.25
Step 3. Add allowed weights
0.5+0.25=0.75LaTeX: 0.5+0.25=0.75
Step 4. Divide each weight by their total
P_{AB}=0.5/0.75=2/3LaTeX: P_{AB}=0.5/0.75=2/3
P_{AC}=0.25/0.75=1/3LaTeX: P_{AC}=0.25/0.75=1/3
Final answer. B has probability 2/3; C has probability 1/3. These are probabilities, not a rule forcing the nearest city every time.

Evaporation ρ=.5 means retain 1−.5=.5 of the old pheromone. A completed tour of length 20 deposits Q/20 on each edge it used; with Q=1 this is .05. An unused edge receives no deposit from that ant. Use complete tour length, not the length of the individual edge, in this denominator.

In one line: an ant picks the next city with probability ∝ pheromone × (1/distance); after all ants finish, pheromone evaporates and each ant adds Q/(its tour length) to every edge it used.

1. Transition probability

An ant kLaTeX: k at city iLaTeX: i moves to an unvisited city jLaTeX: j with probability

P^{k}_{ij}=\frac{\tau_{ij}^{\,\alpha}\,\eta_{ij}^{\,\beta}}{\displaystyle\sum_{l\in\text{allowed}}\tau_{il}^{\,\alpha}\,\eta_{il}^{\,\beta}},\qquad \eta_{ij}=\frac1{d_{ij}}LaTeX: P^{k}_{ij}=\frac{\tau_{ij}^{\,\alpha}\,\eta_{ij}^{\,\beta}}{\displaystyle\sum_{l\in\text{allowed}}\tau_{il}^{\,\alpha}\,\eta_{il}^{\,\beta}},\qquad \eta_{ij}=\frac1{d_{ij}}

With all \tau=1LaTeX: \tau=1 and \alpha=\beta=1LaTeX: \alpha=\beta=1, the probabilities are simply proportional to 1/dLaTeX: 1/d.

2. Choosing the city with a random number (cumulative rule)

  1. List the allowed cities in alphabetical (city) order, not sorted by probability.
  2. Write their cumulative probabilities.
  3. Pick the first city whose cumulative value is ≥ the random number rLaTeX: r.
  4. When only one city is left, the ant goes there without using a random number, then returns to the start.
Exam trap. In Final 2025 Q7b, from city C the candidates are B (0.4) and D (0.6). In city order the ranges are B: 0–0.4, D: 0.4–1, so r = 0.8 selects D. If you sort by probability (D first) you would pick B and get the wrong tour. The official key uses city order.

3. Pheromone update (after all ants finish)

\tau_{ij}\leftarrow(1-\rho)\,\tau_{ij}+\sum_{k=1}^{m}\Delta\tau^{k}_{ij},\qquad \Delta\tau^{k}_{ij}=\begin{cases}Q/L_k&\text{if ant }k\text{ used edge }(i,j)\\0&\text{otherwise}\end{cases}LaTeX: \tau_{ij}\leftarrow(1-\rho)\,\tau_{ij}+\sum_{k=1}^{m}\Delta\tau^{k}_{ij},\qquad \Delta\tau^{k}_{ij}=\begin{cases}Q/L_k&\text{if ant }k\text{ used edge }(i,j)\\0&\text{otherwise}\end{cases}
When the question gives no ρ or Q (both 2025–26 papers): write “Assume ρ = 0.5 and Q = 1, as in the class example” and proceed. That is exactly what the Final 2025 key does.

4. Algorithm (Ant System)

  1. Initialise parameters: number of ants, α, β, ρ, Q, initial pheromone \tau_0LaTeX: \tau_0, maximum iterations.
  2. Place each ant on its start city.
  3. Each ant repeatedly chooses the next city with the transition probability until it has visited all cities, then returns to the start.
  4. Compute each tour length L_kLaTeX: L_k and record the best tour.
  5. Update pheromone: evaporation, then deposit Q/L_kLaTeX: Q/L_k.
  6. Repeat steps 2–5 until the iteration limit; output the best tour.
ParameterMeaningTypical value
mNumber of antsnumber of cities (or 20)
αPheromone importance1
βDistance (visibility) importance1 (often 2–5 in practice)
ρEvaporation rate0.5 in class numericals (0.05–0.5 in practice)
QDeposit constant1 (100 in one slide example)
\tau_0LaTeX: \tau_0Initial pheromone1 in exam questions
Yaad rakho: Probability = τ × (1/d), phir normalize. City order mein cumulative, pehla ≥ r. Update = ½ purana + Q/L har us edge par jo use hua (wapas wala edge bhi).