pub enum Mutations {
    ChangeWeights {
        chance: f64,
        percent_perturbed: f64,
        standard_deviation: f64,
    },
    ChangeActivation {
        chance: f64,
        activation_pool: Vec<Activation>,
    },
    AddNode {
        chance: f64,
        activation_pool: Vec<Activation>,
    },
    AddConnection {
        chance: f64,
    },
    AddRecurrentConnection {
        chance: f64,
    },
    RemoveNode {
        chance: f64,
    },
    RemoveConnection {
        chance: f64,
    },
    RemoveRecurrentConnection {
        chance: f64,
    },
    DuplicateNode {
        chance: f64,
    },
}
Expand description

Lists all possible mutations with their corresponding parameters.

Each mutation acts as a self-contained unit and has to be listed in the crate::Parameters::mutations field in order to take effect when calling [crate::Genome::mutate_with].

Variants§

§

ChangeWeights

Fields

§chance: f64
§percent_perturbed: f64
§standard_deviation: f64
§

ChangeActivation

Fields

§chance: f64
§activation_pool: Vec<Activation>
§

AddNode

Fields

§chance: f64
§activation_pool: Vec<Activation>
§

AddConnection

Fields

§chance: f64
§

AddRecurrentConnection

Fields

§chance: f64
§

RemoveNode

Fields

§chance: f64
§

RemoveConnection

Fields

§chance: f64
§

RemoveRecurrentConnection

Fields

§chance: f64
§

DuplicateNode

Fields

§chance: f64

Implementations§

source§

impl Mutations

source

pub fn add_connection(genome: &mut Genome, rng: &mut impl Rng) -> MutationResult

This mutation adds a new feed-forward connection to the genome, should it be possible. It is possible when any two nodes1 are not yet connected with a feed-forward connection.


  1. “any two nodes” is technically not correct as the start node for the connection has to come from the intersection of input and hidden nodes and the end node has to come from the intersection of the hidden and output nodes. 

source§

impl Mutations

source

pub fn add_node( activation_pool: &[Activation], genome: &mut Genome, rng: &mut impl Rng )

This mutation adds a new node to the genome by “splitting” an existing connection, i.e. the existing connection gets “re-routed” via the new node and the weight of the split connection is set to zero. The connection leading into the new node is of weight 1.0 and the connection originating from the new node has the same weight as the split connection (before it is zeroed).

source§

impl Mutations

source

pub fn add_recurrent_connection( genome: &mut Genome, rng: &mut impl Rng ) -> MutationResult

This mutation adds a recurrent connection to the genome when possible. It is possible when any two nodes 1 are not yet connected with a recurrent connection.


  1. “any two nodes” is technically not correct as the end node has to come from the intersection of the hidden and output nodes. 

source§

impl Mutations

source

pub fn change_activation( activation_pool: &[Activation], genome: &mut Genome, rng: &mut impl Rng )

This mutation changes the activation function of one random hidden node to any other choosen from activation_pool. If the pool is empty (the current activation function is excluded) nothing is changed.

source§

impl Mutations

source

pub fn change_weights( percent_perturbed: f64, standard_deviation: f64, genome: &mut Genome, rng: &mut impl Rng )

This mutation alters percent_perturbed connection weights sampled from a gaussian distribution with given standard_deviation.

source§

impl Mutations

source

pub fn duplicate_node( genome: &mut Genome, rng: &mut impl Rng ) -> Result<(), MutationError>

This mutation adds a new node to the genome by “duplicating” an existing node, i.e. all incoming and outgoing connections to that node are duplicated as well.

The weight of all outgoing connections is half the initial weight so the mutation starts out functionally equivalent to the genome without the mutation. By duplicating a node and its connections small local symetry can develop. It draws inspiration from the concept of gene duplication and cell division.

source§

impl Mutations

source

pub fn remove_connection( genome: &mut Genome, rng: &mut impl Rng ) -> MutationResult

Removes a connection, should this be possible without introducing dangling structure. Dangling means the in- or out-degree of any hidden node is zero, i.e. it neither can receive nor propagate a signal. If it is not possible, no connection will be removed.

source§

impl Mutations

source

pub fn remove_node(genome: &mut Genome, rng: &mut impl Rng) -> MutationResult

Removes a node and all incoming and outgoing connections, should this be possible without introducing dangling structure. Dangling means the in- or out-degree of any hidden node is zero, i.e. it neither can receive nor propagate a signal. If it is not possible, no node will be removed.

source§

impl Mutations

source

pub fn remove_recurrent_connection( genome: &mut Genome, rng: &mut impl Rng ) -> MutationResult

Removes a recurrent connection if at least one is present in the genome. Does nothing when no recurrent connections exist.

source§

impl Mutations

source

pub fn mutate(&self, genome: &mut Genome, rng: &mut impl Rng) -> MutationResult

Mutate a Genome but respects the associate chance field of the Mutations enum variants. The user needs to supply some RNG manually when using this method directly. Use crate::Genome::mutate as the default API.

Trait Implementations§

source§

impl Clone for Mutations

source§

fn clone(&self) -> Mutations

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Mutations

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Mutations

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Mutations

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,