Skip to main content

evolutionary_planning/
lib.rs

1//! # Evolutionary planning
2//!
3//! Genetic algorithms, evolution strategies and multi-objective evolutionary search over
4//! plans, paths and trajectories, for `no_std` + `alloc`.
5//!
6//! Every objective is **minimised**; costs are `f64` and NaN counts as `+∞`. All randomness
7//! comes from a caller-provided [`rand_core::Rng`] (the crate ships [`SplitMix64`]), so a
8//! seed reproduces a run. Every run takes a [`Budget`] that is asked before each evaluation;
9//! [`Limits`] covers evaluations, generations and a target cost.
10//!
11//! # Modules
12//!
13//! | Family | Modules |
14//! |---|---|
15//! | Core | [`operators`] (traits and representations), [`budget`], [`observer`], [`rng`], [`cost`], [`objective`], [`problems`] |
16//! | Single objective | [`ga`], [`diffusion`], [`hill_climb`], [`es`], [`cmaes`], [`de`], [`memetic`] |
17//! | Multi objective | [`pareto`], [`nsga2`], [`nsga3`], [`moead`] |
18//! | Quality diversity | [`map_elites`] |
19//! | Planning | [`rhea`], [`stl`], [`trajectory`], [`graph_path`], `sas` (feature `sas-plus`), [`programmer`], [`gp`] |
20//!
21//! ```mermaid
22//! graph TD
23//!     core[rng, cost, budget, observer] --> ops[operators]
24//!     ops --> single[ga, diffusion, hill_climb, es, cmaes, de]
25//!     single --> memetic
26//!     ops --> multi[pareto, nsga2, nsga3, moead]
27//!     ops --> qd[map_elites]
28//!     single --> planning[rhea, stl, trajectory, graph_path, sas, programmer, gp]
29//! ```
30//!
31//! # Example
32//!
33//! ```
34//! use evolutionary_planning::cmaes::{CmaEs, Config};
35//! use evolutionary_planning::problems::single::ellipsoid;
36//! use evolutionary_planning::{Limits, SplitMix64};
37//!
38//! let mut cma = CmaEs::new(vec![1.0; 6], 0.5, Config::default());
39//! let mut objective = |x: &Vec<f64>| ellipsoid(x);
40//! let outcome = cma.minimize(&mut objective, &mut Limits::evaluations(10_000).with_target(1e-10), &mut (), &mut SplitMix64::new(7));
41//! assert!(outcome.best_cost() <= 1e-10);
42//! ```
43//!
44//! See `docs/design.md` in the repository for the architecture, the paper table, the design
45//! rules and the deviations from the source papers.
46//!
47//! Repository: <https://github.com/sunsided/evolutionary-planning>
48
49#![no_std]
50#![forbid(unsafe_code)]
51
52extern crate alloc;
53
54pub mod budget;
55pub mod cmaes;
56pub mod cost;
57pub mod de;
58pub mod diffusion;
59pub mod es;
60mod evaluator;
61pub mod ga;
62pub mod gp;
63pub mod graph_path;
64pub mod hill_climb;
65pub mod map_elites;
66pub mod memetic;
67pub mod moead;
68mod multi;
69pub mod nsga2;
70pub mod nsga3;
71pub mod objective;
72pub mod observer;
73pub mod operators;
74pub mod pareto;
75pub mod problems;
76pub mod programmer;
77pub mod rhea;
78pub mod rng;
79#[cfg(feature = "sas-plus")]
80pub mod sas;
81pub mod stl;
82pub mod trajectory;
83
84pub use budget::{Budget, Limits, Stats, Stop};
85pub use cost::{Individual, ranking, sanitize};
86pub use evaluator::Outcome;
87pub use multi::MultiOutcome;
88pub use objective::{MultiObjective, MultiObjectiveFn, Objective, multi_objective_fn};
89pub use observer::{Event, Observer, ObserverFn, observer_fn};
90pub use rng::{SplitMix64, below, chance, standard_normal, uniform, unit_f64};
91
92/// Doctests for the code examples in README.md (not part of the API).
93#[cfg(doctest)]
94#[doc = include_str!("../README.md")]
95mod readme_doctests {}