Trait evco::gp::tree::Tree
[−]
[src]
pub trait Tree where Self: Sized + Debug + Clone { type Environment; type Action; fn branch<R: Rng>(tg: &mut TreeGen<R>,
current_depth: usize)
-> BoxTree<Self>; fn leaf<R: Rng>(tg: &mut TreeGen<R>, current_depth: usize) -> BoxTree<Self>; fn count_children(&mut self) -> usize; fn children(&self) -> Vec<&BoxTree<Self>>; fn children_mut(&mut self) -> Vec<&mut BoxTree<Self>>; fn evaluate(&self, env: &Self::Environment) -> Self::Action; fn tree<R: Rng>(tg: &mut TreeGen<R>) -> BoxTree<Self> { ... } fn child<R: Rng>(tg: &mut TreeGen<R>, current_depth: usize) -> BoxTree<Self> { ... } }
Trait to be implemented by Genetic Programs trees.
Associated Types
type Environment
Type of input when evaluating the tree.
type Action
The type the tree will evaluate to.
Required Methods
fn branch<R: Rng>(tg: &mut TreeGen<R>, current_depth: usize) -> BoxTree<Self>
Generate a branch node (a node with at least one Tree child).
fn leaf<R: Rng>(tg: &mut TreeGen<R>, current_depth: usize) -> BoxTree<Self>
Generate a leaf node (a node without any Tree children).
fn count_children(&mut self) -> usize
Count Self
children of this node.
fn children(&self) -> Vec<&BoxTree<Self>>
Get children of this node.
fn children_mut(&mut self) -> Vec<&mut BoxTree<Self>>
Get mutable children of this node.
fn evaluate(&self, env: &Self::Environment) -> Self::Action
Get indexed child of this node. Number children from 0; suggested to go left-to-right. Used to evaluate the root node of a tree.
Provided Methods
fn tree<R: Rng>(tg: &mut TreeGen<R>) -> BoxTree<Self>
Generate a new tree within the bounds specified by TreeGen.
fn child<R: Rng>(tg: &mut TreeGen<R>, current_depth: usize) -> BoxTree<Self>
Generate a random new node to go into a tree.