Rustで遺伝的アルゴリズム

Rust 1.23.0です
遺伝的アルゴリズム書いてみました。

//src/main.rs
extern crate gene;
use gene::{colony, individual};

fn main() {
    let mut generations = colony::Colony::init_colony();
    let mut i = 0;

    loop {
        generations = generations.reviews();
        // std::thread::sleep(std::time::Duration::from_secs(1));

        generations.show();
        if colony::max_point(generations.get_colony(), 0) >= individual::GENE_COUNT as u32 {
            println!("HI");
            break;
        }
        generations = generations.delete()
            .make_children()
            .mutations();
        i += 1;
    }
}
//src/colony.rs
use individual::Individual;
use rand;
use rand::distributions::{IndependentSample, Range};

const GENERATIONS: usize = 20;
const DESTROY: usize = 5;

pub struct Colony {
    colony: Vec<Individual>
}

impl Colony {

    //初期化
    pub fn init_colony() -> Self {
        let mut colony: Vec<Individual> = Vec::new();
        for _ in 0..GENERATIONS {
            colony.push(Individual::init_gene());
        }
        Self {
            colony: colony
        }
    }

    pub fn show(&self) {
        println!("==============================");
        for i in 0..self.colony.len() {
            self.colony[i].show();
        }
    }

    pub fn get_colony(&self) -> Vec<Individual> {
        self.colony.clone()
    }

    // 全ての個体について評価する
    pub fn reviews(&self) -> Self {
        let mut colony = self.colony.clone();
        for i in 0..self.colony.len() {
            colony[i] = colony[i].review();
        }
        Self {
            colony: colony
        }
    }

    // ポイントの低い個体は削除
    pub fn delete(&self) -> Self {
        let mut colony = self.colony.clone();
        for _ in 0..DESTROY {
            let mut min_key = 0;
            let mut min_point = self.colony[0].get_point();
            for i in 1..colony.len() - 1 {
                let point = self.colony[i].get_point();
                if min_point > point {
                    min_key = i;
                    min_point = point;
                }
            }
            colony.remove(min_key);
        }
        Self {
            colony: colony
        }
    }

    pub fn make_children(&self) -> Self {
        let mut rnd = rand::thread_rng();
        let range = Range::new(0, GENERATIONS - DESTROY - 1);
        let mut colony = self.colony.clone();
        for _ in 0..DESTROY {
            let father = colony.get(range.ind_sample(&mut rnd)).unwrap().clone();
            let mother = colony.get(range.ind_sample(&mut rnd)).unwrap().clone();
            colony.push(Individual::make_child(father, mother));
        }
        Self {
            colony: colony
        }
    }

    // 突然変異させる
    pub fn mutations(&self) -> Self {
        let mut colony = self.colony.clone();
        for i in 0..self.colony.len() {
            if Range::new(0, 15).ind_sample(&mut rand::thread_rng()) == 1 {
                colony[i] = colony[i].mutation();
            }
        }
        Self {
            colony : colony
        }
    }
}


pub fn max_point(colony: Vec<Individual>, max: u32) -> u32 {
    let mut colony = colony.clone();
    if colony.len() > 0 {
        let point = colony.pop().unwrap().get_point();
        if max < point {
            max_point(colony, point)
        } else {
            max_point(colony, max)
        }
    }else{
        max
    }
}
//src/individual.rs
use rand;
use rand::distributions::{IndependentSample, Range};

pub const GENE_COUNT: usize = 18;
const CORRECT_GENE: [char; GENE_COUNT] = ['c', 'a', 'r', 'a', 'm', 'e', 'l', 'f', 'r', 'a', 'p', 'p', 'u', 'c', 'h', 'i', 'n', 'o'];
const ALPHABET: [char; 26] = [
    'a', 'b', 'c', 'd', 'e',
    'f', 'g', 'h', 'i', 'j',
    'k', 'l', 'm', 'n', 'o',
    'p', 'q', 'r', 's', 't',
    'u', 'v', 'w', 'x', 'y', 'z'
];

#[derive(Clone)]
pub struct Individual {
    point: u32,
    gene: [char; GENE_COUNT]
}


impl Individual {
    pub fn get_point(&self) -> u32{
        self.point
    }

    pub fn get_gene(&self) -> [char; GENE_COUNT] {
        self.gene
    }

    pub fn show(&self) {
        for i in self.gene.iter() {
            print!("{}", i);
        }
        println!(" - {}", self.point);
    }

    pub fn init_gene() -> Self {
        let mut gene = ['a'; GENE_COUNT];
        let range = Range::new(0, ALPHABET.len());
        for i in 0..gene.len() {
            gene[i] = ALPHABET[range.ind_sample(&mut rand::thread_rng())] as char;
        }

        Self {
            point: 0,
            gene: gene
        }
    }

    pub fn review(&self) -> Self {
        let mut point = 0;
        for i in 0..self.gene.len() {
            if self.gene[i] == CORRECT_GENE[i] {
                point += 1;
            }
        }

        Self {
            point: point,
            gene: self.gene
        }
    }

    pub fn mutation(&self) -> Self {
        let range: Range<usize> = Range::new(0, GENE_COUNT);
        let mut rng = rand::thread_rng();
        let rnd = range.ind_sample(&mut rng);
        let mut gene = self.gene;
        gene[rnd] = ALPHABET[range.ind_sample(&mut rng)] as char;
        Self {
            point: 0,
            gene: gene
        }
    }

    // 新しい個体を作る
    pub fn make_child(mother: Self, father: Self) -> Self {
        let cross_point = Range::new(0, GENE_COUNT).ind_sample(&mut rand::thread_rng());
        let mut gene = ['a'; GENE_COUNT];

        for i in 0..GENE_COUNT {
            if i > cross_point {
                gene[i] = mother.gene[i];
            }else{
                gene[i] = father.gene[i];
            }
        }
        Self {
            point: 0,
            gene: gene
        }
    }
}

なんか少し微妙かも
全て揃うまで結構かかります。。。