Crate moonlander_gp [] [src]

Generic Genetic Programming framework routines

This crate supplies a generic framework for solving GP programs. As a consumer, you'll need to supply the following:

  • Enums to encode the various AST node types.
  • Implementations of AstNode, Mutatable and RandNode traits (which can usually be autogenerated using impl_astnode!()).
  • A fitness function evaluating the success of a given program.

Create random_population from your types, then call evolve repeatedly to improve the fitness of the population.

For a working example, see the santa_fe_ant in the examples/ directory.

Reexports

pub use num::Number;

Modules

genetic

Genetic operation functions

num

Numeric helper functions

Macros

impl_astnode

Implement AstNode and RandNode trait for a node type.

pick

Randomly pick from a weighted list of alternatives.

Structs

NodeWeights

Weights to use when deciding between internal and leaf nodes.

Population

Collection of programs

ScoreCard

Immutable tagged list of scores.

Traits

AstNode

Main trait to be implemented for AST node types

Fitness

Trait that models fitness for an individual

Mutatable

Mutation trait for nodes

RandNode

Implement trait to generate random subtrees of a given type.

Functions

clone_or_replace

Helper function for use inside replace_children().

depth

Return the depth of an AST tree.

random_population

Generate a random population of size N.

retain_best

Take the best fraction of the population and fill back up to N with random programs.