Skip to content

pkalivas/radiate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2,574 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Radiate

Radiate Logo

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

For more details check radiate's user guide or cargo docs.

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.

  • Traditional genetic algorithm implementation.
  • Single & Multi-objective optimization support.
  • Neuroevolution (graph-based representation - evolving neural networks) support. Opt-in NEAT implementation.
  • Genetic programming support (tree-based representation)
  • Built-in support for parallelism.
  • Extensive selection, crossover, and mutation operators.
  • Opt-in speciation for maintaining diversity.
  • Novelty search support.
  • First-class metric tracking.
  • Dynamic Expression DSL for dynamic rates & custom metrics

Installation

Rust

Add this to your Cargo.toml:

[dependencies]
radiate = { version = "1.2.22", features = ["x"] }

Python

pip install radiate # --or-- uv add radiate

Examples

Lets see a simple 'Hello World' example of using radiate to evolve a simple string - Hello, Radiate!. See the examples directory for a much more comprehensive set of examples in both languages.

import radiate as rd

target = "Hello, Radiate!"

engine = (
    rd.Engine.char(len(target))
    .fitness(
        lambda member: sum(1 for i in range(len(target)) if member[i] == target[i])
    )
    .limit(rd.Limit.score(len(target)))
)

result = engine.run(log=True)

print("Best solution:", "".join(result.value()))

Or in rust:

use radiate::prelude::*;

let target = "Hello, Radiate!";

let engine = GeneticEngine::builder()
    .codec(CharCodec::vector(target.len()))
    .fitness_fn(|geno: Vec<char>| {
        geno.into_iter().zip(target.chars()).fold(
            0,
            |acc, (allele, targ)| {
                if allele == targ { acc + 1 } else { acc }
            },
        )
    })
    .build();

engine
    .iter()
    .logging()
    .until_score(target.len())
    .last()
    .unwrap();

Building & running from source

git clone https://github.com/pkalivas/radiate.git
cd radiate

Radiate uses Just as a build tool, you can install it from here. The core build options are below, there are a few others that can be found through the just help command.

  • just develop faster build time for development with debug symbols and minimal optimizations.
  • just release slower build time for optimized runtime performance.

Both the above have an optional argument py to build the python package for a specific python version (e.g. just develop 3.12, just develop 3.13t for free-threading interpreter).

  • just test-rs to run tests for rust
  • just test-py to run tests for python package
  • just test to run tests for both.
  • just clean to nuke the build artifacts

Run examples with just example to run a small python script which shows & runs selected examples.

Packages

 
 
 

Contributors