ACO Dashboard
Best Solution Found
Run the optimization to see results.
Convergence Log
| Iter | Best x | f_best | f_worst | Converged? |
|---|
All Iteration Details (Step-by-Step)
Run the optimization to see detailed iteration computations.
In real life, when ants walk from their nest (Home) to food, they leave a chemical smell on the ground called pheromone. Other ants can smell it and follow the same path. Shorter/better paths get walked more often β more pheromone β even more ants follow β eventually ALL ants use the best path. ACO copies this idea to solve math problems!
| GA | PSO | ACO | |
|---|---|---|---|
| Inspired by | Evolution | Birds flying | Ants finding food |
| Works with | Any value (continuous) | Any value (continuous) | Fixed choices only (discrete) |
| How it searches | Crossover + Mutation | Velocity toward best | Pheromone makes good paths attractive |
| Memory | No memory | Each bird remembers P_best | Pheromone IS the memory |
GA and PSO can find x = 1.12405... (any decimal). ACO can only pick from a menu like {0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0}. It's like GA/PSO are searching on Google Maps freely, but ACO is choosing from a restaurant menu.
| Term | Symbol | Simple Meaning |
|---|---|---|
| Pheromone | Ο (tau) | Smell on a path. Just a number we assign. Higher Ο = stronger smell = more attractive. At the start, ALL paths get Ο = 1.0 (equal smell, so no path is preferred). |
| Evaporation Rate | Ο (rho) | How fast the smell disappears. Ο = 0.5 means 50% of old smell evaporates each round. Like rain washing away ant trails. Formula: Ο_new = (1 β Ο) Γ Ο_old |
| Scaling Parameter | ΞΆ (zeta) | How much extra smell the best ant drops. Higher ΞΆ = more reward for the best path. Used in the deposit formula. |
| Colony Size | N | Number of ants (like number of particles in PSO or population in GA). |
| Discrete Values | xij | The menu of choices. ACO can only pick from these fixed values, not any value in between. |
| f_best | fbest | Best objective function value among all ants this round. |
| f_worst | fworst | Worst objective function value among all ants this round. |
| Pheromone Deposit | ΞΟ | Extra smell added to the best path. Formula: ΞΟ = ΞΆ Γ f_best / f_worst |
| Ξ± (alpha) | Ξ± | Exponent on pheromone in probability formula. Usually Ξ± = 1. Higher Ξ± = ants care more about pheromone. |
Minimize f(x) = xΒ² β 2x β 11 in range (0, 3)
We give ACO a menu of 7 choices: 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0
Think of it as 7 roads from Home to Food. Each ant picks ONE road:
Road 1 β x = 0.0
Road 2 β x = 0.5
Road 3 β x = 1.0
HOME β Road 4 β x = 1.5 β FOOD
Road 5 β x = 2.0
Road 6 β x = 2.5
Road 7 β x = 3.0
Each road starts with equal smell (Ο = 1.0)
Since all roads have equal smell (Ο = 1.0):
probability = smell of this road / total smell of all roads
= 1.0 / (1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0)
= 1.0 / 7.0
= 0.1429 (about 14.29% chance for each road)
We line up all 7 probabilities on a number line from 0 to 1. Each road "owns" a section:
0 0.1429 0.2857 0.4286 0.5714 0.7143 0.8571 1.0 |---1---|---2---|---3---|---4---|---5---|---6---|---7---| x=0.0 x=0.5 x=1.0 x=1.5 x=2.0 x=2.5 x=3.0
| Value | Range it "owns" |
|---|---|
| x = 0.0 | (0.0000 to 0.1429) |
| x = 0.5 | (0.1429 to 0.2857) |
| x = 1.0 | (0.2857 to 0.4286) |
| x = 1.5 | (0.4286 to 0.5714) |
| x = 2.0 | (0.5714 to 0.7143) |
| x = 2.5 | (0.7143 to 0.8571) |
| x = 3.0 | (0.8571 to 1.0000) |
Generate a random number between 0 and 1. See which range it falls in:
Ant 1: r = 0.3122 β 0.3122 is between 0.2857 and 0.4286 β That's x = 1.0 β Ant 2: r = 0.8701 β 0.8701 is between 0.8571 and 1.0 β That's x = 3.0 β Ant 3: r = 0.4729 β 0.4729 is between 0.4286 and 0.5714 β That's x = 1.5 β Ant 4: r = 0.6190 β 0.6190 is between 0.5714 and 0.7143 β That's x = 2.0 β
Now evaluate f(x) for each ant:
Ant 1: x=1.0 β f(1.0) = 1β2β11 = -12.0 β BEST (smallest) Ant 2: x=3.0 β f(3.0) = 9β6β11 = -8.0 β WORST (largest) Ant 3: x=1.5 β f(1.5) = 2.25β3β11 = -11.75 Ant 4: x=2.0 β f(2.0) = 4β4β11 = -11.0
Two things happen after each round:
β EVAPORATE: Old smell fades on NON-best roads
Ο_new = (1 β Ο) Γ Ο_old = (1 β 0.5) Γ 1.0 = 0.5
β‘ DEPOSIT: Best ant drops EXTRA smell on its road
ΞΟ = ΞΆ Γ f_best / f_worst = 2 Γ (β12)/(β8) = 3.0
Ο_best = 1.0 + 3.0 = 4.0 (no evaporation on best path!)
After Iteration 1:
Road x=0.0: Ο = 0.5 (weak smell β evaporated) Road x=0.5: Ο = 0.5 (weak smell β evaporated) Road x=1.0: Ο = 4.0 β STRONG SMELL! πππ Road x=1.5: Ο = 0.5 (weak smell β evaporated) Road x=2.0: Ο = 0.5 (weak smell β evaporated) Road x=2.5: Ο = 0.5 (weak smell β evaporated) Road x=3.0: Ο = 0.5 (weak smell β evaporated)
Now in Iteration 2, the probability of x=1.0 becomes 4.0/7.0 = 57% while others are only 7% each. Most ants will now pick x=1.0!
If pheromone never evaporated, a path chosen by luck in iteration 1 would keep attracting ants forever, even if it's not the best. Evaporation allows bad early choices to be forgotten over time.
In iteration 2, if Ant 1 AND Ant 4 both pick x=1.0, then BOTH deposit pheromone:
ΞΟ = 2 ants Γ ΞΆ Γ f_best / f_worst = 2 Γ 2 Γ (β12)/(β9.75) = 4.9231 So the best path gets DOUBLE the pheromone deposit!
ACO stops when ALL ants choose the same path. That means the pheromone on one road is so strong that every ant follows it. This is called convergence.
For Example 13.5, the answer converges to x = 1.0, f = β12.0
Run the optimization to see results.
| Iter | Best x | f_best | f_worst | Converged? |
|---|
Run the optimization to see detailed iteration computations.