← Back to GSA docs

teeline · algorithms/gsa

Gravitational Search Algorithm

Each candidate TSP tour is an agent with a mass proportional to its fitness — better tours weigh more. Every step, the active agent is pulled toward the k-best (heaviest) neighbours via swap-move velocity. The gravitational constant G decays over epochs, shifting the swarm from broad exploration toward fine-grained exploitation.

01234567891011
Agents
02106
#0 · dist=2106 · mass=0.147
12202
#1 · dist=2202 · mass=0.120
22289
#2 · dist=2289 · mass=0.095
32451
#3 · dist=2451 · mass=0.050
41838
#4 · dist=1838 · mass=0.222
52628
#5 · dist=2628 · mass=0.000
61872
#6 · dist=1872 · mass=0.212
72079
#7 · dist=2079 · mass=0.154
gbest tour active agent swarm city kbest source
Press Step or Run to begin
G (gravitational constant) = 20.00
High — broad exploration
epoch
0
step
0/8
gbest dist
1837.8
avg dist
2183
Balanced swarm size
cities: 12agents: 8G₀: 20α: 1kbest: ⌈8/2⌉=4