| Crates.io | elites |
| lib.rs | elites |
| version | 0.1.0 |
| created_at | 2025-01-15 23:23:11.760761+00 |
| updated_at | 2025-01-15 23:23:11.760761+00 |
| description | A fast and robust implementation of the Map-Elites algorithm in Rust |
| homepage | |
| repository | https://github.com/justrach/elites |
| max_upload_size | |
| id | 1518632 |
| size | 23,627 |
This repository provides a generic and efficient implementation of the Map-Elites algorithm, which is widely used to discover diverse, high-performing solutions across a feature space.
Add this crate to your Cargo.toml dependencies:
[dependencies]
elites = "0.1.0"
Below is an example of how to use this crate for solving a simple optimization problem:
use elites::{MapElites, MapElitesProblem};
// Define your problem
struct MyProblem;
impl MapElitesProblem for MyProblem {
type Genome = Vec<f64>;
fn random_genome(&self) -> Self::Genome {
vec![0.0, 0.0] // Simplified for example
}
fn evaluate(&self, genome: &Self::Genome) -> (f64, Vec<f64>) {
let fitness = -genome.iter().map(|x| x.powi(2)).sum::<f64>();
let features = vec![genome[0], genome[1]];
(fitness, features)
}
fn mutate(&self, genome: &Self::Genome) -> Self::Genome {
genome.clone() // Simplified for example
}
fn feature_dimensions(&self) -> usize { 2 }
fn bins_per_dimension(&self) -> usize { 10 }
}
// Use the algorithm
let problem = MyProblem;
let mut map_elites = MapElites::new(problem);
map_elites.run(1000);
You can customize the algorithm using the MapElitesConfig struct:
let config = MapElitesConfig {
initial_population: 200,
track_stats: true,
bin_boundaries: Some(vec![
vec![0.0, 0.5, 1.0], // Custom boundaries for the first dimension
vec![0.0, 0.5, 1.0], // Custom boundaries for the second dimension
]),
..Default::default()
};
Run the tests to validate the implementation:
cargo test
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.