Generate

Struct Generate 

Source
pub struct Generate<InputParameters, ReturnValue, T: Callable<InputParameters, ReturnValue>, U: Callable<InputParameters, ReturnValue> + Mutate + Crossover> { /* private fields */ }
Expand description

A genetic algorithm for finding good functions

Implementations§

Source§

impl<InputParameters: Vals, ReturnValue: Vals, T: Callable<InputParameters, ReturnValue>, U: Callable<InputParameters, ReturnValue> + Mutate + Crossover + Clone + Disassemble> Generate<InputParameters, ReturnValue, T, U>

Source

pub fn new(target_function: T) -> Self

Constructs a new GeneticSearch

Source

pub fn population_size(&mut self, population_size: usize)

Sets the population size

Source

pub fn crossover_rate(&mut self, crossover_rate: f64)

Sets the crossover_rate (the default is 2.0)

Source

pub fn mutation_rate(&mut self, mutation_rate: f64)

Sets the mutation_rate (the default is 1.0)

Source

pub fn selection(&mut self)

Keeps the best specimens and removes the worst ones

Source

pub fn next_generation(&mut self)

computes the next generation of the search

Source

pub fn search(&mut self) -> U

Returns one specimen having a score of 0.0, removing it from the population. If no such specimen exists, then .next_generation() is called until one is found.

Trait Implementations§

Source§

impl<InputParameters: Debug, ReturnValue: Debug, T: Debug + Callable<InputParameters, ReturnValue>, U: Debug + Callable<InputParameters, ReturnValue> + Mutate + Crossover> Debug for Generate<InputParameters, ReturnValue, T, U>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<InputParameters, ReturnValue, T, U> Freeze for Generate<InputParameters, ReturnValue, T, U>
where T: Freeze,

§

impl<InputParameters, ReturnValue, T, U> RefUnwindSafe for Generate<InputParameters, ReturnValue, T, U>
where T: RefUnwindSafe, InputParameters: RefUnwindSafe, ReturnValue: RefUnwindSafe, U: RefUnwindSafe,

§

impl<InputParameters, ReturnValue, T, U> Send for Generate<InputParameters, ReturnValue, T, U>
where T: Send, InputParameters: Send, ReturnValue: Send, U: Send,

§

impl<InputParameters, ReturnValue, T, U> Sync for Generate<InputParameters, ReturnValue, T, U>
where T: Sync, InputParameters: Sync, ReturnValue: Sync, U: Sync,

§

impl<InputParameters, ReturnValue, T, U> Unpin for Generate<InputParameters, ReturnValue, T, U>
where T: Unpin, InputParameters: Unpin, ReturnValue: Unpin, U: Unpin,

§

impl<InputParameters, ReturnValue, T, U> UnwindSafe for Generate<InputParameters, ReturnValue, T, U>
where T: UnwindSafe, InputParameters: UnwindSafe, ReturnValue: UnwindSafe, U: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToTrace for T

Source§

fn trace(self) -> Trace<Self>
where Self: Sized + Clone + Disassemble,

Wraps an object up in a Trace, so that each mutation is printed to stdout.
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V