Home

Awesome

<h1 align="center">Radiate</p> <img src="/docs/radiate.png" height=100>

master branch checks Crates.io Crates.io License Static badge

Readme as well as docs are under construction. Check examples for current usages.

Radiate is a powerful Rust library designed for implementing genetic algorithms and artificial evolution techniques. It provides a flexible framework for creating, evolving, and optimizing solutions to complex problems using principles inspired by natural selection and genetics. This library is suitable for researchers, developers, and enthusiasts interested in evolutionary computation and optimization.


Large insperation for this library coming from other genetic algorithm libraries: Jenetics: A Java implementatino of GAs. genevo: Popular rust GA. radiate_legacy: Previous implemenation of this library with direct encoding.

Usage

Add to cargo.toml

[dependencies]
radiate = "1.2.2"

Features

The implemenation of the GeneticEngine results in an extremely extensible and dynamic architecture. Mix and match any of these features together or add new features and algorithms with minimal effort. Check radiate-extensions for extensions to the core library.

Basic Usage

Evolve a string of characters to match the target (Chicago, IL)

use radiate::*;

fn main() {
    let target = "Chicago, IL";
    let codex = CharCodex::new(1, target.len());

    let engine = GeneticEngine::from_codex(&codex)
        .offspring_selector(RouletteSelector::new())
        .survivor_selector(TournamentSelector::new(3))
        .alterer(vec![
            Alterer::Mutator(0.01),
            Alterer::UniformCrossover(0.5)
        ])
        .fitness_fn(|genotype: String| {
            Score::from_usize(genotype.chars().zip(target.chars()).fold(
                0,
                |acc, (geno, targ)| {
                    if geno == targ {
                        acc + 1
                    } else {
                        acc
                    }
                },
            ))
        })
        .build();

    let result = engine.run(|output| {
        println!("[ {:?} ]: {:?}", output.index, output.best);

        output.score().as_usize() == target.len()
    });

    println!("{:?}", result);
}

Workflow

TODO - write out the general GA workflow provided by the library.

Future Features

Examples

The radiate-examples directory contains several examples demonstrating the capabilities of the library, including: