← 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
01879
#0 · dist=1879 · mass=0.220
12266
#1 · dist=2266 · mass=0.005
22038
#2 · dist=2038 · mass=0.132
31953
#3 · dist=1953 · mass=0.179
42196
#4 · dist=2196 · mass=0.044
52275
#5 · dist=2275 · mass=0.000
62028
#6 · dist=2028 · mass=0.138
71768
#7 · dist=1768 · mass=0.282
● 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
1768.5
avg dist
2050
Balanced swarm size
cities: 12agents: 8G₀: 20α: 1kbest: ⌈8/2⌉=4