Heuristic — constructive

Kohonen Self-Organizing Map

Aliassom, kohonen
TypeHeuristic — constructive
ComplexityO(epochs · N · n) per run

Description

Uses a 1-D ring of neurons — a neural network — that learns a topology-preserving mapping from 2-D city space onto a cyclic ordering. Each neuron holds a position in the same plane as the cities. The ring is initialised as a small circle near the centroid and trained so that it wraps around all the cities; the ordering of neurons on the ring then gives the tour.

Training

City coordinates are first normalised to the unit box [0, 1]² for numerical stability. N = n_cities × neuron_multiplier neurons are placed uniformly on a small circle (radius 0.1) centred at the normalised centroid.

Each epoch:

  1. Anneal learning rate and neighbourhood radius:
    η  = learning_rate × exp(−t / epochs)
    σ  = max(radius_fraction × N × exp(−t / epochs), 1.0)
    
  2. Pick a random city c (with replacement).
  3. Find the Best Matching Unit (BMU) — the neuron nearest to c; ties broken by lowest index.
  4. Pull every neuron toward c weighted by a Gaussian over ring distance:
    h(i) = exp(−ring_dist(i, bmu)² / 2σ²)
    neurons[i] += η · h(i) · (c − neurons[i])
    
    Neurons with h < 0.001 are skipped for performance.

Tour extraction

After training, each city is assigned to its closest neuron (BMU). Cities are sorted by their neuron's ring index. Collisions (two cities mapping to the same neuron) are resolved by distance to the neuron, with city-array index as the final tie-breaker, guaranteeing a valid Hamiltonian tour regardless of convergence quality.

Options

FieldDefaultRangeDescription
epochs100 000≥ 1Number of training iterations
learning_rate0.8(0, 1]Initial learning rate η₀
radius_fraction0.1(0, 1]Initial neighbourhood radius as fraction of neuron count
neuron_multiplier8≥ 1Neuron count = n_cities × multiplier; higher reduces dead neurons

Usage

# standalone
teeline solve som -i ./data/tsplib/berlin52.tsp

# recommended: pipe into local search
teeline pipeline --steps=som,2opt -i ./data/tsplib/berlin52.tsp
teeline pipeline --steps=som,sa   -i ./data/tsplib/berlin52.tsp

# custom training schedule
teeline solve som --epochs=200000 --learning_rate=0.9 -i ./data/tsplib/berlin52.tsp

Notes

References