Heuristic — nature-inspired metaheuristic

▶ Open interactive explainer →

Flower Pollination Algorithm

Aliasfpa, flower_pollination
TypeHeuristic — nature-inspired metaheuristic
Auto-seeds fromshuffle (random flowers)

Description

Nature-inspired metaheuristic modelling the pollination process of flowering plants. Maintains a population of flowers (candidate tours). Each epoch, each flower applies either:

The switch probability controls the balance between exploitation (global) and exploration (local).

TSP-specific adaptations (deviations from Yang 2012):

AdaptationReason
Global pollination → Lévy-scaled prefix of swap sequence toward gbestPermutation analogue of the continuous update; preserves tour validity
Local pollination → ε-scaled prefix of swap diff between two random flowersPermutation analogue of local cross-pollination
switch_prob floored at 0.8 when mutation_probability < 0.01Prevents degeneration to 99.9 % local-only search under default CLI options

Auto-expands to pipeline(shuffle, fpa).

procedure FlowerPollination(cities, n_flowers, p, epochs):
    flowers ← initialize_flowers(n_flowers, cities)
    gbest ← best_tour(flowers)
    for epoch in 1..epochs:
        for each flower i:
            if random() < p:
                step ← levy_flight()
                candidate ← move_toward(flowers[i], gbest, step)
            else:
                j, k ← two random flower indices
                ε ← random()
                candidate ← local_crossover(flowers[i], flowers[j], flowers[k], ε)
            if length(candidate) < length(flowers[i]):
                flowers[i] ← candidate
        gbest ← best_tour(flowers)
    return gbest

Options

FlagDescriptionDefault
--epochsMaximum iterations10 000
--n_nearestNumber of flowers (floored at 25)25
--mutation_probabilitySwitch probability (global vs local pollination)0.8

Usage

teeline solve fpa -i ./data/tsplib/berlin52.tsp
teeline solve flower_pollination -i ./data/tsplib/berlin52.tsp --epochs=500
teeline solve fpa -i ./data/tsplib/berlin52.tsp --n_nearest=50 --mutation_probability=0.8

References