pub struct Population<G>where
    G: Genome,{ /* private fields */ }
Expand description

A population is a collection of evaluated individuals (fitness).

Implementations§

source§

impl<G> Population<G>where G: Genome,

source

pub fn individuals(&self) -> &[Individual<G>]

Return a list of individuals in this population.

source

pub fn size(&self) -> usize

Return population size.

source

pub fn is_oversized(&self) -> bool

Return true of there are too many individuals in this population.

source

pub fn size_limit(&self) -> usize

Return population size limit.

source

pub fn evaluate_with<F: EvaluateFitness<G>>(&mut self, fitness: &mut F)

Re-evaluate individuals in population with fitness function.

source

pub fn weight_with(&mut self, weight: f64)

Re-evaluate individual fitness with individual weight.

source

pub fn build<F>(indvs: Vec<Individual<G>>, fitness: &mut F) -> Selfwhere F: EvaluateFitness<G>,

Build a population from individuals indvs and fitness function. The population size limit is set as the size of indvs.

source

pub fn with_size_limit(self, limit: usize) -> Self

Construct with population size limit.

source§

impl<G> Population<G>where G: Genome,

source

pub fn members(&self) -> impl Iterator<Item = Member<'_, G>>

Return a member view of individuals with associated fitness values.

source

pub fn best_member(&self) -> Option<Member<'_, G>>

Return a member view of the best individual in this population.

source§

impl<G> Population<G>where G: Genome,

source

pub fn survive(&mut self) -> usize

Remove some bad performing individuals to fit the population size limit constrain.

Returns
  • return the number of individuals to be removed.

Trait Implementations§

source§

impl<G> Clone for Population<G>where G: Genome + Clone,

source§

fn clone(&self) -> Population<G>

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<G> Debug for Population<G>where G: Genome + Debug,

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<G> RefUnwindSafe for Population<G>where G: RefUnwindSafe,

§

impl<G> Send for Population<G>

§

impl<G> Sync for Population<G>where G: Sync,

§

impl<G> Unpin for Population<G>where G: Unpin,

§

impl<G> UnwindSafe for Population<G>where G: UnwindSafe,

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
const: unstable · 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.
const: unstable · 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> GeneticOperator for Twhere T: Debug + Clone,