use std::fmt::Debug;
pub trait PsoParticle<T> {
fn get_performance(&self) -> f64;
fn update_position(&mut self, position: &Vec<T>) -> Option<Vec<T>>;
fn init(position: Vec<T>) -> Self;
}
pub trait PsoAcc<N, T, X>
where
X: Debug + Clone,
N: PsoNode<T>
{
fn get_value(&self, generation: &usize, this_node: &N) -> X;
fn init_value(&self) -> X;
}
pub trait PsoNode<T> {
fn get_position(&self) -> &Vec<T>;
fn get_performance(&self) -> f64;
fn get_best_position(&self) -> &Vec<T>;
fn get_best_performance(&self) -> f64;
fn get_speed(&self) -> &Vec<f64>;
fn update_position(
&mut self,
rng: &mut rand::rngs::ThreadRng,
vlimit: &Vec<(f64, f64)>,
inertia: &f64,
lfactor1: &f64,
lfactor2: &f64,
global_best: &Vec<T>,
) -> f64;
}
pub trait PsoHandler<T> {
fn get_global_best_position(&self) -> &Vec<T>;
fn get_global_best_performance(&self) -> f64;
fn start(&mut self, generation: usize);
}