Files
heuropt/src/prelude.rs
T
swaits 9d46cf9d65 feat(algorithms): add SPEA2 (Strength Pareto Evolutionary Algorithm 2)
Implementation of Zitzler, Laumanns, Thiele 2001 SPEA2 — the classic
Pareto MOEA built around an explicit external archive of fixed size.

Each generation:
1. Combine the current population and the archive into one pool.
2. For every member, compute strength S(i) = number of others that
   member dominates, then raw fitness R(i) = sum of S(j) over members
   j that dominate i.
3. Add a density estimator D(i) = 1/(σ_k + 2) where σ_k is the distance
   to the k-th nearest neighbor (k = floor(sqrt(|pool|))) in
   minimization-oriented objective space.
4. Final fitness F(i) = R(i) + D(i); lower is better.
5. Build the next archive by taking every non-dominated member
   (R(i) == 0). If too many, prune by repeatedly removing the member
   with the smallest k-th-nearest-neighbor distance. If too few, fill
   from the rest sorted by F ascending.
6. Generate the next population by binary tournament on F (lower wins),
   then variation, then evaluation.

Public API mirrors the other algorithms:

  Spea2Config { population_size, archive_size, generations, seed }
  Spea2 { config, initializer, variation }
  impl<P, I, V> Optimizer<P> for Spea2<I, V>

Re-exported from the prelude. Tests cover archive size invariants,
non-empty Pareto front on Schaffer N.1, deterministic reruns under
the same seed, and panic on population_size == 0.
2026-05-04 19:52:47 -06:00

28 lines
835 B
Rust

//! Common imports for users of `heuropt`.
//!
//! ```
//! use heuropt::prelude::*;
//! ```
pub use crate::core::{
Candidate, Direction, Evaluation, Objective, ObjectiveSpace, OptimizationResult,
Population, Problem, Rng, rng_from_seed,
};
pub use crate::traits::{Initializer, Optimizer, Variation};
pub use crate::pareto::{
Dominance, ParetoArchive, best_candidate, crowding_distance, non_dominated_sort,
pareto_compare, pareto_front,
};
pub use crate::operators::{
BitFlipMutation, BoundedGaussianMutation, CompositeVariation, GaussianMutation,
PolynomialMutation, RealBounds, SimulatedBinaryCrossover, SwapMutation,
};
pub use crate::algorithms::{
DifferentialEvolution, DifferentialEvolutionConfig, Nsga2, Nsga2Config, Paes, PaesConfig,
RandomSearch, RandomSearchConfig, Spea2, Spea2Config,
};