Enum set_genome::Mutations
source · 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
ChangeActivation
AddNode
See Mutations::add_node
.
AddConnection
AddRecurrentConnection
RemoveNode
RemoveConnection
RemoveRecurrentConnection
DuplicateNode
Implementations§
source§impl Mutations
impl Mutations
sourcepub fn add_connection(genome: &mut Genome, rng: &mut impl Rng) -> MutationResult
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.
“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
impl Mutations
sourcepub fn add_node(
activation_pool: &[Activation],
genome: &mut Genome,
rng: &mut impl Rng
)
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
impl Mutations
sourcepub fn add_recurrent_connection(
genome: &mut Genome,
rng: &mut impl Rng
) -> MutationResult
pub fn add_recurrent_connection( genome: &mut Genome, rng: &mut impl Rng ) -> MutationResult
source§impl Mutations
impl Mutations
sourcepub fn change_activation(
activation_pool: &[Activation],
genome: &mut Genome,
rng: &mut impl Rng
)
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
impl Mutations
sourcepub fn duplicate_node(
genome: &mut Genome,
rng: &mut impl Rng
) -> Result<(), MutationError>
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
impl Mutations
sourcepub fn remove_connection(
genome: &mut Genome,
rng: &mut impl Rng
) -> MutationResult
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
impl Mutations
sourcepub fn remove_node(genome: &mut Genome, rng: &mut impl Rng) -> MutationResult
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
impl Mutations
sourcepub fn remove_recurrent_connection(
genome: &mut Genome,
rng: &mut impl Rng
) -> MutationResult
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
impl Mutations
sourcepub fn mutate(&self, genome: &mut Genome, rng: &mut impl Rng) -> MutationResult
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<'de> Deserialize<'de> for Mutations
impl<'de> Deserialize<'de> for Mutations
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Auto Trait Implementations§
impl RefUnwindSafe for Mutations
impl Send for Mutations
impl Sync for Mutations
impl Unpin for Mutations
impl UnwindSafe for Mutations
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.