Skip to main content

fcmaes_core/
lib.rs

1#![doc = include_str!("../README.md")]
2
3pub mod biteopt;
4pub mod cmaes;
5pub mod crfmnes;
6pub mod da;
7pub mod de;
8pub mod fitness;
9pub mod mapelites;
10pub mod mode;
11pub mod moretry;
12pub mod pgpe;
13pub mod retry;
14pub mod rng;
15
16pub use biteopt::{
17    BiteOpt, BiteParams, BiteResult, DeepBiteOpt, optimize_bite, validate_bite_inputs,
18};
19pub use cmaes::{AcmaResult, Cmaes, CmaesParams};
20pub use crfmnes::{Crfmnes, CrfmnesParams, CrfmnesResult};
21pub use da::{DaParams, DaResult, optimize_da};
22pub use de::{De, DeParams, DeResult};
23pub use fitness::{Fitness, NAN_REPLACEMENT, Objective, parallel_batch};
24pub use mapelites::{
25    Archive, DiversifierParams, MapElitesParams, QdBatchFitness, QdFitness, diversify,
26    diversify_batch, map_elites, map_elites_batch, map_elites_batch_with_progress,
27};
28pub use mode::{Mode, ModeParams, ModeResult};
29pub use moretry::{
30    MoRetryConfig, MoRetryEntry, MoRetryResult, MultiObjective, WeightedObjective, moretry,
31    pareto_indices, scalarize,
32};
33pub use pgpe::{Pgpe, PgpeParams, PgpeResult};
34pub use retry::{
35    AdvancedRetryConfig, RetryBounds, RetryConfig, RetryContext, RetryEntry, RetryImprovement,
36    RetryResult, RetryRunResult, advanced_retry, retry,
37};
38pub use rng::Rng;
39
40/// Version string of the core crate, surfaced through the Python build-info.
41pub const CORE_VERSION: &str = env!("CARGO_PKG_VERSION");
42
43/// Sum of a slice of f64 — the Phase 0 probe used to prove the
44/// Python → PyO3 → core call path is wired end to end.
45pub fn probe_sum(values: &[f64]) -> f64 {
46    values.iter().sum()
47}
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn probe_sum_adds_values() {
55        assert_eq!(probe_sum(&[1.0, 2.0, 3.5]), 6.5);
56    }
57
58    #[test]
59    fn probe_sum_empty_is_zero() {
60        assert_eq!(probe_sum(&[]), 0.0);
61    }
62}