Radiate

Radiate is a powerful library for implementing genetic algorithms and artificial evolution techniques. It provides a fast and flexible framework for creating, evolving, and optimizing solutions to complex problems using principles inspired by natural selection and genetics. The core is written in Rust and is available for Python.
-
Ease of use
Intuitive API design allows users to easily configure and run genetic algorithms without needed to know the nuts and bolts of the complex operations underlying them.
-
Modular Design
The library architecture enables users to mix and match different components such as selection strategies, crossover methods, and mutation techniques to suit their specific needs.
-
Performance
Between Rust's performance capabilities, a multi-threaded architecture, and hours spent optimizing code, Radiate ensures efficient execution of genetic operations, even for large populations and complex problem spaces.
-
Flexibility
Out of the box support for a customizable genotypes and fitness functions, Radiate can be adapted to a wide range of problem domains, from single and multi optimization tasks to neuroevolution and machine learning applications.
Key Features
-
Genetic Engine: The central component orchestrating the genetic algorithm. It manages the ecosystem, evaluates fitness, and handles selection, crossover, and mutation processes. It is designed to be flexible and extensible, allowing customization to fit specific optimization requirements.
-
Codec: Responsible for encoding and decoding genetic information. It acts as a bridge between the problem space and the solution space, allowing the genetic algorithm to operate on abstract genetic representations while solving real-world problems.
-
Selectors: Used to choose individuals for reproduction and survival. They play a crucial role in determining the evolutionary pressure applied to the population.
-
Alterers: Crossover and mutation operators that introduce genetic diversity and enable exploration of the solution space. The library provides a variety of built-in alterers.
-
Fitness Function: Evaluates how well an individual solves the problem at hand. It is a critical component that guides the evolutionary process by assigning scores to individuals based on their performance.
Example
This simple maximizing problem demonstrates how to use Radiate to solve a string matching problem, where the goal is to evolve a genotype of chars to match a target string.
Hello, Radiate!
from typing import List
import radiate as rd
target = "Hello, Radiate!"
def fitness_func(x: List[str]) -> int:
return sum(1 for i in range(len(target)) if x[i] == target[i])
engine = rd.GeneticEngine(
codec=rd.CharCodec.vector(len(target)),
fitness_func=fitness_func,
offspring_selector=rd.BoltzmannSelector(4),
)
result = engine.run(rd.ScoreLimit(len(target)))
print(result)
use radiate::*;
fn main() {
let target = "Hello, Radiate!";
let mut engine = GeneticEngine::builder()
.codec(CharCodec::vector(target.len()))
.offspring_selector(BoltzmannSelector::new(4_f32))
.fitness_fn(|geno: Vec<char>| {
geno.into_iter().zip(target.chars()).fold(
0,
|acc, (allele, targ)| {
if allele == targ { acc + 1 } else { acc }
},
)
})
.build();
let result = engine.run(|ctx| {
let best_as_string = ctx.best.iter().collect::<String>();
println!("[ {:?} ]: {:?}", ctx.index(), best_as_string);
ctx.score().as_usize() == target.len()
});
println!("{:?}", result);
}
Outside Inspirations
Radiate is inspired from a multitude of other genetic algorithm libraries, all of which have their own unique features and capabilities. Some of the most notable inspirations include:
- carrot: An architecture-free neural network library built around neuroevolution built in javascript
- Genevo: A Rust library which provides building blocks to run simulations of optimization and search problems using genetic algorithms (GA).
- Sharpneat: A C# library for evolutionary computation, primarily focused on neuroevolution and artificial neural networks
- Jenetics: A Genetic Algorithm, Evolutionary Algorithm, Grammatical Evolution, Genetic Programming, and Multi-objective Optimization library, written in modern day Java