Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | Jan Snajder <jan.snajder@fer.hr> |
Safe Haskell | Safe-Inferred |
An interface to genetically programmable expressions.
Documentation
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
.
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.
Number of nodes an expression has.
The depth of an expression. Equals 1 for single-node expressions.