Struct revonet::ga::GA [] [src]

pub struct GA<'a, P: Problem + 'a> { /* fields omitted */ }

Baseline structure for Genetic Algorithm

Example: Running GA to solve minimization problem:

extern crate rand;
extern crate revonet;

use revonet::ea::*;
use revonet::ga::*;
use revonet::problem::*;
use revonet::settings::*;

fn main() {
    let pop_size = 20u32;
    let problem_dim = 10u32;
    let problem = SphereProblem{};

    let gen_count = 10u32;
    let settings = EASettings::new(pop_size, gen_count, problem_dim);
    let mut ga: GA<SphereProblem> = GA::new(&problem);
    let res = ga.run(settings).expect("Error during GA run");
    println!("\n\nGA results: {:?}", res);
}

Methods

impl<'a, P: Problem> GA<'a, P>
[src]

Create a new GA instance for the given problem.

Trait Implementations

impl<'a, P: Problem> EA<'a, P> for GA<'a, P>
[src]

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

Run evolutionary algorithm and return EAResult object. Read more

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

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. Read more

Function to select individuals for breeding. Updates given ctx. Read more

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