genprog-0.1.0.2: Genetic programming library

Portabilitynon-portable
Stabilityexperimental
MaintainerJan Snajder <jan.snajder@fer.hr>
Safe HaskellSafe-Inferred

GenProg.GenExpr

Description

An interface to genetically programmable expressions.

Synopsis

Documentation

class GenExpr e whereSource

This typeclass defines an interface to expressions that can be genetically programmed. The operations that must be provided by instances of this class are used for the generation of random individuals as well as crossover and mutation operations. (An instance for members of the Data typeclass is provided in GenProg.GenExpr.Data.)

Minimal complete definition: exchange, nodeMapM, nodeMapQ, and nodeIndices.

Methods

exchange :: e -> Int -> e -> Int -> (e, e)Source

Exchanges subtrees of two expressions: exchange e1 n1 e2 n2 replaces the subexpression of e1 rooted in node n1 with the subexpression of e2 rooted in n2, and vice versa.

nodeMapM :: Monad m => (e -> m e) -> e -> m eSource

Maps a monadic transformation function over the immediate children of the given node.

nodeMapQ :: (e -> a) -> e -> [a]Source

Maps a query function over the immediate children of the given node and returns a list of results.

nodeIndices :: e -> ([Int], [Int])Source

A list of indices of internal (functional) and external (terminal) nodes of an expression.

adjustM :: Monad m => (e -> m e) -> e -> Int -> m eSource

Adjusts a subexpression rooted at the given node by applying a monadic transformation function.

nodes :: e -> IntSource

Number of nodes an expression has.

depth :: e -> IntSource

The depth of an expression. Equals 1 for single-node expressions.

Instances

Data a => GenExpr a