[−][src]Struct radiate::models::evtree::evtree::Evtree
A tree struct to encapsulate a bidirectional binary tree.AsMut
Each node within the tree has three pointers to its parent, left, and right child. They also have a randomly generated neural network and an output option (classification).
This struct holds the root of the tree as a raw mutable pointer and thus this structure is enherintly unsafe, however most if not all of that funtionality is encapsulated within the implementation. The tree also contains a size which represents the number of nodes in the tree, an input size which is the size of the input vector (1D), and is used to generate nodes alone with the output options which is an owned vec of i32s represnting different outputs of the classification.
Methods
impl Evtree
[src]
implement the tree
pub fn new() -> Self
[src]
Create a new default Tree given an input size and a vec of possible outputs
Returns the newly created Tree with a null raw mutable pointer as a root, a size of 0 and an owned input_size and output_options.
ⓘImportant traits for IterMut<'a>pub fn iter_mut(&mut self) -> IterMut
[src]
return an in order iterator which allows for the nodes in the tree to be mutatued while iterating
ⓘImportant traits for LevelOrderIterator<'a>pub fn level_order_iter(&self) -> LevelOrderIterator
[src]
Return a level order iterator Iterators over the tree from top to bottom, going from parent, to it's left child then it's right child. Each node that the iterator yields is a reference to a Node struct
ⓘImportant traits for InOrderIterator<'a>pub fn in_order_iter(&self) -> InOrderIterator
[src]
Return an in order iterator Iterates over the tree in order, from left to right with the root in the middle (assuming balanced) Each node that the iterator yields is a reference to a Node struct
pub fn len(&self) -> &i32
[src]
the len of the tree is it's size, the numbr of nodes
pub fn height(&self) -> i32
[src]
return the height of the tree from the root
pub fn get(&mut self, index: usize) -> &mut Node
[src]
Get a node from the tree at a given index and return an option with either the node in it, or none.
Panic! if the index is greater than the size of the tree.
pub fn index_of(&self, node: &Node) -> usize
[src]
Get the index of a given node in the tree
pub fn insert_random(&mut self, input_size: i32, outputs: &Vec<i32>)
[src]
Insert a node to the tree randomly extracting away all of the unsafe code required to iterate through the tree and check for null raw mutable pointers and increase the size by 1 each time.
pub fn display(&self)
[src]
display the tree by calling the recursive display method within the node implementation at level 0. If the root is a null raw mutable pointer, panic!
pub fn balance(&mut self)
[src]
Balance the tree by thin copying each node then calling a private recursive function to build the tree structure.
Return an option in order to use '?' instead of 'unwrap()' in the function body.
pub fn get_biased_level<'a>(&'a self) -> Vec<&'a Node>
[src]
get a vec of node references in a bised sense where nodes at a lower level are favored
pub fn get_biased_random_node<'a>(&'a self) -> &'a Node
[src]
Get a biased random node from the tree by gathering a biased random level towards the bottom of the tree, then returning a reference to the chosen node
pub fn gut_random_node(&mut self, r: &mut ThreadRng)
[src]
Gut a random node from the tree. Get a random index from the tree then give that node a new neural network.
pub fn shuffle_tree(&mut self, r: &mut ThreadRng)
[src]
Shuffel the tree by gathering a list of the nodes then shuffling the list and then balancing the tree again from that list
pub fn edit_random_node_networks(
&mut self,
weight_mutate: f32,
weight_transform: f32,
layer_mutate: f32
)
[src]
&mut self,
weight_mutate: f32,
weight_transform: f32,
layer_mutate: f32
)
Go through each of the nodes in the tree and randomly mutate the weights and biases within the network
pub fn asymmetry(&self) -> f32
[src]
Compute the asymmetry for a single tree by adding the height times the neural network weight sum of the tree and putting it through the sine function to compress the number between (-1, 1)
pub fn propagate(&self, inputs: Matrix<f32>) -> u8
[src]
Trait Implementations
impl Clone for Evtree
[src]
Return a new copy of the tree, calling deep copy from the root node and copying over the size, input size, and output options in the most effecient way. TODO: this looks like messy.. is there a way to clean up?
impl Debug for Evtree
[src]
implemented a display function for the Tree just for easier debugging
impl Default for Evtree
[src]
implement a function for getting a base default Evtree which is completetly empty There are multiple places within the struct implementation which will panic! if this default Evtree is passed through it.
impl Drop for Evtree
[src]
Because the tree is made out of raw mutable pointers, if those pointers are not dropped, there is a severe memory leak, like possibly gigs of ram over only a few generations depending on the size of the generation This drop implementation will recursivley drop all nodes in the tree
impl Genome<Evtree, TreeEnvionment> for Evtree
[src]
fn crossover(
one: &Evtree,
two: &Evtree,
settings: &Arc<RwLock<TreeEnvionment>>,
crossover_rate: f32
) -> Option<Evtree>
[src]
one: &Evtree,
two: &Evtree,
settings: &Arc<RwLock<TreeEnvionment>>,
crossover_rate: f32
) -> Option<Evtree>
one should be the more fit Evtree and two should be the less fit Evtree. This function should attemp to produce a Evtree which is no higher than the specified max height of a Evtree.
fn base(settings: &mut TreeEnvionment) -> Evtree
[src]
Implement the base trait for the tree This provides a generic way to get a base tree for starting the evolution process Get the base tree type and return a randomly generated base tree created through the tree settings given to it at its new() call
fn distance(
one: &Evtree,
two: &Evtree,
_settings: &Arc<RwLock<TreeEnvionment>>
) -> f32
[src]
one: &Evtree,
two: &Evtree,
_settings: &Arc<RwLock<TreeEnvionment>>
) -> f32
takes in a Rc<RefCell<Self in order to make it simpler for the Generation to throw types it already has inside the function by simplmy cloing them. This function will drop the references to the Self traits at the end of this function's scope
impl PartialEq<Evtree> for Evtree
[src]
impl Send for Evtree
[src]
These must be implemneted for the tree or any type to be used within seperate threads. Because implementing the functions themselves is dangerious and unsafe and i'm not smart enough to do that from scratch, these "implmenetaions" will get rid of the error and realistically they don't need to be implemneted for the program to work
impl StructuralPartialEq for Evtree
[src]
impl Sync for Evtree
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,