Expand description
§Gemla
Gemla is a Rust library for simulating and evolving populations using genetic algorithms. It provides a flexible framework for evolutionary computation, supporting custom node types, tournament bracket simulations, and persistent state management.
§Features
- Tournament-style genetic algorithm simulation evaluating populations via nodes
- Asynchronous and concurrent simulation using Tokio
- Customizable node logic via the
GeneticNode
trait - Persistent, file-backed simulation state with the
file_linked
crate - Utilities for binary tree management
§Modules
tree
: Defines an unbalanced binary tree structure and macros for tree construction.core
: Contains the main simulation logic, including theGemla
struct, configuration, and node management.error
: Provides unified error types and logging utilities for the crate.
§Example
ⓘ
#[derive(Clone, Debug)]
struct MyNode { /* ... */ }
// Implement GeneticNode for MyNode...
#[tokio::main]
async fn main() {
let mut gemla = Gemla::<MyNode>::new(
&PathBuf::from("state.json"),
GemlaConfig { overwrite: true },
DataFormat::Json,
).await.unwrap();
// Grows simulation tree by 5 levels
gemla.simulate(5).await.unwrap();
}
§Crate Organization
- All core simulation logic is in
core
. - Tree structures and macros are in
tree
. - Error types and helpers are in
error
.
§Getting Started
- Define your node type and implement the
GeneticNode
trait. - Create a
Gemla
instance and run simulations. - Use the provided error handling and tree utilities as needed.
Modules§
- core
- This module provides the core logic for simulating genetic algorithms using a tournament bracket structure.
- error
- Error handling utilities and error type for the Gemla crate.
- tree
- An unbalanced binary tree type where each node has an optional left and right child.
Macros§
- btree
- Short-hand for constructing Trees.
btree!
takes 3 arguments, the first being the value of the root node, and the other two being child nodes. The last two arguments are optional.