Planning & Search in Rust
Esc

Loading…

↑↓ move ↵ open Esc close
Colour theme
All algorithms

Genetic Programming

Also known as GP, Tree-based GP

optimization evolutionary-planning

Genetic programming (GP) evolves programs instead of fixed-length parameter vectors. A program is a tree: inner nodes are functions such as if or add, and leaves are terminals such as sensor readings or actions; the caller's grammar gives each symbol its number of children (its arity). Ramped half-and-half creates the first trees: half are full trees and half grow at random, over a range of depths, for a varied start. Subtree crossover swaps random subtrees of two parents, subtree mutation replaces a subtree by a new random one, and point mutation swaps one symbol for another of the same arity; depth and size limits stop trees from growing without bound. Use it to evolve small policies, for example reactive navigation rules; it is a heuristic search with no optimality guarantee.

Pseudocode

algorithm GP(grammar, d-min, d-max, f)input: symbol arities grammar, depth range d-min … d-max, cost function f of a programoutput: the cheapest program found when the budget endsP ← programs from RampedHalfAndHalf(grammar, d-min, d-max)repeat                                          ▷ a GA loop over program treesa, b ← select(P, 2)c₁, c₂ ← SubtreeCrossover(a, b)for each c in ⟨c₁, c₂⟩ doSubtreeMutation(c), or PointMutation(c)add (c, f(c)) to the next populationuntil budget exhaustedreturn the cheapest program evaluatedfunction RampedHalfAndHalf(grammar, d-min, d-max)d ← uniform in d-min … d-maxfull ← true or false with equal probabilityreturn generate(d, full)function generate(d, full)if d = 0 or (not full and random() < share of terminals in grammar) thenreturn ⟨a random terminal⟩g ← a random functionreturn ⟨g, generate(d − 1, full) for each of the arity(g) children⟩function SubtreeCrossover(a, b)i, j ← a crossover point in a and in b         ▷ an inner node with probability 0.9c₁ ← a with the subtree at i replaced by the subtree of b at jc₂ ← b with the subtree at j replaced by the subtree of a at iif c₁ breaks the depth or size limit thenc₁ ← aif c₂ breaks the depth or size limit thenc₂ ← breturn c₁, c₂

In the crates

Papers

  1. Evolutionary Programmer: Autonomously Creating Path Planning Programs based on Evolutionary Algorithms Jiabin Lou, Rong Ding, Wenjun Wu · 2022 applies arXiv 2204.02970