use niches_beta_rate::NichesBetaRates::*;
use slope_params::SlopeParams;
pub trait NichesBetaRate: Send + Sync {
fn rate(&self, generation: u64, progress: f64, n_solutions: usize) -> f64;
}
pub enum NichesBetaRates {
Constant(f64),
Linear(SlopeParams),
Quadratic(SlopeParams),
}
impl NichesBetaRate for NichesBetaRates {
fn rate(&self, generation: u64, _progress: f64, _n_solutions: usize) -> f64 {
match self {
Constant(c) => *c,
Linear(sp) => sp.check_bound(sp.coefficient * generation as f64 + sp.start),
Quadratic(sp) => {
sp.check_bound(sp.coefficient * generation as f64 * generation as f64 + sp.start)
}
}
}
}