Planning & Search in Rust
Esc

Loading…

↑↓ move ↵ open Esc close
Colour theme
All algorithms

GA Path Planning

Also known as Genetic path planning

routing evolutionary-planning

GA path planning searches a short path from a start to a goal vertex in a graph or a grid with a genetic algorithm. Each genome is a simple path: a path that visits no vertex twice. Random depth-first searches create the first paths. Crossover cuts two parents at a vertex they share and swaps the tails; mutation replaces a stretch of a path by a random detour; repair cuts any loop that this creates. The cost is the sum of the edge costs. It finds good paths, but unlike Dijkstra's algorithm or A* it does not guarantee a shortest one; it is useful as a test bed or when the cost of a path is not a sum of edge costs.

Pseudocode

algorithm GA-Path(G, s, t)input: graph G with edge costs, start vertex s, goal vertex toutput: the shortest s–t path found, or failureP ← paths from random-path(G, s, t)              ▷ randomised depth-first searchrepeatP′ ← the 2 shortest paths of P                 ▷ elitismwhile |P′| < |P| doa, b ← tournament(P, 3), tournament(P, 3)if random() < 0.7 thenc₁, c₂ ← common-vertex(a, b)               ▷ cut at a shared vertex, swap tailselsec₁, c₂ ← a, bfor each c in ⟨c₁, c₂⟩ doif random() < 0.8 thenreroute(c)                               ▷ random detour between two vertices of cremove-loops(c)add (c, path-length(c)) to P′              ▷ ∞ if c does not join s to tP ← P′until budget exhaustedif no evaluated path reaches t thenreturn failurereturn the shortest path evaluated

In the crates

  • evolutionary-planning

    Genetic path planning on graphs and grids: simple paths from randomised depth-first search, recombined at shared vertices, mutated by rerouting and repaired by cutting loops.

    solve

Lineage

Comes from

specializes Genetic Algorithm

Led to

Evolutionary Programmer builds on it