Skip to content
tachsinatalay-codePublic
forked from tachsin/genoxide

About

Evolutionary computation for Rust (and Python): genetic algorithms, evolution strategies, multi-objective optimization. Fast, correct, reproducible.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

genoxide: optimization for Rust and Python

Crates.io PyPI Docs.rs CI License Benchmarks

Optimization for Rust: genetic algorithms, evolution strategies, differential evolution, particle swarms, local search and multi-objective optimization in one library.

Install

cargo add genoxide

It adds the latest release to your Cargo.toml (the version is on the crates.io badge above). The Python package: pip install genoxide.

use genoxide::prelude::*;

fn main() -> genoxide::Result<()> {
    // OneMax: find the 100-bit string with the most ones
    let ga = Ga::builder(Binary::new(100)?)
        .population_size(100)
        .select(Tournament::new(3)?)
        .crossover(UniformCrossover::new())
        .mutate(BitFlip::per_gene(0.01)?)
        .seed(42)
        .build()?;

    let outcome = Engine::new(ga, |genome: &Bits| genome.count_ones() as f64)
        .stop_when(Stop::target(100.0).or(Stop::generations(1_000)))
        .run()?;

    println!("best: {} after {} generations", outcome.best_fitness(), outcome.generations());
    Ok(())
}

What's in it

  • Genomes: binary (bit-packed), integer, real, permutation, and real with a self-adaptive step size.
  • Genetic algorithms: generational, steady-state, (μ+λ), (μ,λ) and memetic schemes, with the classic operators.
  • Evolution strategies, CMA-ES, differential evolution, particle swarms: with IPOP and BIPOP restarts, JADE, SHADE and L-SHADE.
  • Local search: hill climbing, simulated annealing, tabu search, iterated local search.
  • Multi-objective: NSGA-II, NSGA-III, SPEA2, MOEA/D and SMS-EMOA, with quality indicators.
  • Test problems: classic continuous functions such as Rastrigin, Rosenbrock and Branin, with their bounds, known optima and references; constrained ones, CEC 2006's g01-g24 and engineering designs such as the welded beam and the pressure vessel; multi-objective ones such as ZDT, DTLZ and the constrained BNH and OSY, with their optimal fronts.
  • Engine: parallel, batch and asynchronous evaluation, island models, constraints, checkpoints, reproducible seeds.
  • Beyond Rust: a Python package, and a command-line program for fitness functions in any language.

The full list is in docs/features.md.

Python

pip install genoxide: wheels for Linux, macOS and Windows, CPython 3.10 and later.

import genoxide as gx

ga = gx.Ga(gx.Binary(100), population_size=100, select=gx.Tournament(3),
           crossover=gx.UniformCrossover(), mutation=gx.BitFlip(rate=0.01), seed=42)
result = ga.run(lambda bits: bits.sum(), target=100, generations=1_000)

See python/README.md for the algorithms, operators and numpy fitness functions.

Benchmarks

genoxide and its Python package are benchmarked on a small, matched suite: three problems, one method each, under public rules. Every library runs a problem only with its own implementation of that problem's method, set to the same written definition, so the results compare implementations of the same algorithm rather than each library's pick of a method: a GA on OneMax 1000, DE/rand/1/bin on Rastrigin 30 (a fixed budget, measured by the time for it and the error at the end) and CMA-ES on Rosenbrock 10. Single-threaded on the same machine, 10 seeds each. More problems, and multi-objective ones, come back after these.

Expected time to target: a panel per problem, a bar per library

genoxide's own releases are compared on the same runs by the CPU instructions Callgrind counts, exact whatever the machine's load: genoxide_versions.svg (rule 10).

Interactive results, a card per problem: tachsin.gr/projects/genoxide/benchmarks. The methodology, each method's definition and the page for each library give the configurations and their differences, and results.md has the full tables.

Links

Status

Alpha, pre-1.0: the API may change between 0.x versions. See the roadmap.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in genoxide by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Evolutionary computation for Rust (and Python): genetic algorithms, evolution strategies, multi-objective optimization. Fast, correct, reproducible.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages