1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! # 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 the [`Gemla`] struct, configuration, and node management.
//! - [`error`]: Provides unified error types and logging utilities for the crate.
//!
//! ## Example
//! ```rust,ignore
//! # use gemla::core::{Gemla, GemlaConfig};
//! # use gemla::core::genetic_node::{GeneticNode, GeneticNodeContext};
//! # use file_linked::constants::data_format::DataFormat;
//! # use std::path::PathBuf;
//!
//! #[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
//! 1. Define your node type and implement the [`GeneticNode`] trait.
//! 2. Create a [`Gemla`] instance and run simulations.
//! 3. Use the provided error handling and tree utilities as needed.
//!
//! [`Gemla`]: crate::core::Gemla
//! [`GeneticNode`]: crate::core::genetic_node::GeneticNode
//! [`tree`]: crate::tree
//! [`core`]: crate::core
//! [`error`]: crate::error