feat(traits): add Initializer, Variation, and Optimizer traits
The three operator-level traits the algorithms consume, plus the single trait users implement to add a new optimizer (`Optimizer<P>`). All take `&mut Rng` directly rather than being generic over the RNG (spec §7.8).
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
//! Trait for sampling initial decisions.
|
||||
|
||||
use crate::core::rng::Rng;
|
||||
|
||||
/// Generates initial decisions for a population.
|
||||
///
|
||||
/// Implementations should return exactly `size` decisions; if that is
|
||||
/// impossible, panic with a clear message in v1.
|
||||
pub trait Initializer<D> {
|
||||
/// Produce `size` initial decisions using the supplied RNG.
|
||||
fn initialize(&mut self, size: usize, rng: &mut Rng) -> Vec<D>;
|
||||
}
|
||||
Reference in New Issue
Block a user