Skip to main content

Generation

Struct Generation 

Source
pub struct Generation<C, T>
where C: Chromosome,
{ /* private fields */ }
Expand description

A Generation represents a single generation in the evolutionary process. It contains the ecosystem, the best solution, index, metrics, score, objective, and optionally the Pareto front for multi-objective problems.

This is the main structure returned by the engine after each epoch, and it provides access to all relevant information about that generation.

§Example

use radiate_core::*;
use radiate_engines::*;
use std::time::Duration;

let engine = GeneticEngine::builder()
    .codec(FloatChromosome::from((10, 0.0_f32..1.0_f32)))
    .fitness_fn(|vec: Vec<f32>| -vec.iter().map(|x| x * x).sum::<f32>())
    .build();

let generation = engine.iter().take(10).last().unwrap();

let ecosystem: &Ecosystem<FloatChromosome<f32>> = generation.ecosystem();

let population: &Population<FloatChromosome<f32>> = generation.population();
assert!(population.len() == 100);

let solution: &Vec<f32> = generation.value();
let index: usize = generation.index();
let score: &Score = generation.score();
let time: Duration = generation.time();

assert!(solution.len() == 10);
assert!(index == 10);

Implementations§

Source§

impl<C, T> Generation<C, T>
where C: Chromosome,

Source

pub fn score(&self) -> &Score

Source

pub fn front(&self) -> Option<&Front<Phenotype<C>>>

Source

pub fn value(&self) -> &T

Source

pub fn index(&self) -> usize

Source

pub fn metrics(&self) -> &MetricSet

Source

pub fn objective(&self) -> &Objective

Source

pub fn ecosystem(&self) -> &Ecosystem<C>

Source

pub fn population(&self) -> &Population<C>

Source

pub fn species(&self) -> Option<&[Species<C>]>

Source

pub fn time(&self) -> Duration

Source

pub fn seconds(&self) -> f64

Trait Implementations§

Source§

impl<C, T> Clone for Generation<C, T>
where C: Chromosome + Clone, T: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate 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<C, T> Debug for Generation<C, T>
where C: Chromosome, T: Debug,

Source§

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

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

impl<C, T> FromIterator<Generation<C, T>> for Front<Phenotype<C>>
where C: Chromosome + Clone,

Source§

fn from_iter<I: IntoIterator<Item = Generation<C, T>>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<C: Chromosome, T> Scored for Generation<C, T>

Source§

fn score(&self) -> Option<&Score>

Auto Trait Implementations§

§

impl<C, T> Freeze for Generation<C, T>
where T: Freeze,

§

impl<C, T> !RefUnwindSafe for Generation<C, T>

§

impl<C, T> Send for Generation<C, T>
where T: Send,

§

impl<C, T> Sync for Generation<C, T>
where T: Sync,

§

impl<C, T> Unpin for Generation<C, T>
where T: Unpin, C: Unpin,

§

impl<C, T> UnsafeUnpin for Generation<C, T>
where T: UnsafeUnpin,

§

impl<C, T> !UnwindSafe for Generation<C, T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

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 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more