pub struct SubtreeCrossover {
pub max_depth: Option<usize>,
pub function_probability: f64,
}Expand description
Subtree Crossover for genetic programming
Selects random subtrees from two parent trees and swaps them to create offspring. This is the standard crossover operator for GP.
Fields§
§max_depth: Option<usize>Maximum depth for offspring trees (to control bloat)
function_probability: f64Probability of selecting a function node (vs terminal)
Implementations§
Source§impl SubtreeCrossover
impl SubtreeCrossover
Sourcepub fn with_max_depth(self, max_depth: usize) -> Self
pub fn with_max_depth(self, max_depth: usize) -> Self
Create with a specific maximum depth limit
Sourcepub fn without_depth_limit(self) -> Self
pub fn without_depth_limit(self) -> Self
Create with no depth limit
Sourcepub fn with_function_probability(self, prob: f64) -> Self
pub fn with_function_probability(self, prob: f64) -> Self
Set the probability of selecting a function node
Trait Implementations§
Source§impl Clone for SubtreeCrossover
impl Clone for SubtreeCrossover
Source§fn clone(&self) -> SubtreeCrossover
fn clone(&self) -> SubtreeCrossover
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Terminal, F: Function> CrossoverOperator<TreeGenome<T, F>> for SubtreeCrossover
impl<T: Terminal, F: Function> CrossoverOperator<TreeGenome<T, F>> for SubtreeCrossover
Source§fn crossover<R: Rng>(
&self,
parent1: &TreeGenome<T, F>,
parent2: &TreeGenome<T, F>,
rng: &mut R,
) -> OperatorResult<(TreeGenome<T, F>, TreeGenome<T, F>)>
fn crossover<R: Rng>( &self, parent1: &TreeGenome<T, F>, parent2: &TreeGenome<T, F>, rng: &mut R, ) -> OperatorResult<(TreeGenome<T, F>, TreeGenome<T, F>)>
Apply crossover to two parents and produce two offspring
Source§fn crossover_probability(&self) -> f64
fn crossover_probability(&self) -> f64
Get the probability of crossover being applied
Source§impl Debug for SubtreeCrossover
impl Debug for SubtreeCrossover
Auto Trait Implementations§
impl Freeze for SubtreeCrossover
impl RefUnwindSafe for SubtreeCrossover
impl Send for SubtreeCrossover
impl Sync for SubtreeCrossover
impl Unpin for SubtreeCrossover
impl UnsafeUnpin for SubtreeCrossover
impl UnwindSafe for SubtreeCrossover
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for 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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.