Trait revonet::ea::EA [] [src]

pub trait EA<'a, P> where
    P: Problem
{ type IndType: Individual + Clone + Serialize + DeserializeOwned; fn breed(
        &self,
        ctx: &mut EAContext<Self::IndType>,
        sel_inds: &Vec<usize>,
        children: &mut Vec<Self::IndType>
    );
fn run(
        &mut self,
        settings: EASettings
    ) -> Result<&EAResult<Self::IndType>, ()>; fn run_multiple(
        &mut self,
        settings: EASettings,
        run_num: u32
    ) -> Result<EAResultMultiple<Self::IndType>, ()> { ... }
fn run_with_context(
        &self,
        ctx: &mut EAContext<Self::IndType>,
        problem: &P,
        gen_count: u32
    ) { ... }
fn evaluate(&self, ctx: &mut EAContext<Self::IndType>, problem: &P) { ... }
fn select(&self, ctx: &mut EAContext<Self::IndType>) -> Vec<usize> { ... }
fn next_generation(
        &self,
        ctx: &mut EAContext<Self::IndType>,
        children: &Vec<Self::IndType>
    ) { ... } }

Trait for an evolutionary algorithm. Defines functions which are typical for running a common EA. To implement a trait a function breed should be implemented.

Associated Types

Required Methods

Function to create children individuals using current context and selected individuals.

Arguments:

  • ctx - EAContext object containing information regarding current EA run.
  • sel_inds - vector of indices of individuals from ctx.population selected for breeding.
  • children - reference to the container to store resulting children individuals.

Run evolutionary algorithm and return EAResult object.

Arguments:

  • settings - EASettings object.

Provided Methods

"Main" function for the EA which runs a cycle for an evolutionary search.

Arguments:

  • ctx - EAContext object containing information regarding current EA run.
  • problem - reference to the Problem trait which specifies an objective function.
  • gen_count - number of generations (iterations) for search.

Function to evaluate current population for the given problem. In result of evaluation fitness for every individual is updated as well as statistics regarding mean, min, max fitness values.

Arguments:

  • ctx - EAContext object containing information regarding current EA run.
  • problem - reference to the Problem trait which specifies an objective function.

Function to select individuals for breeding. Updates given ctx.

Arguments:

  • ctx - EAContext object containing information regarding current EA run.

Function to prepare population for the next generation. By default copies children obtained in result of breed to the ctx.population.

Arguments:

  • ctx - EAContext object containing information regarding current EA run.
  • children - reference to the vector of children individuals which should get to the next generation.

Implementors