use super::super::{Evaluation, Problem};
pub trait IterHook<P: Problem> {
fn iterated(&mut self, _new: &Evaluation<P>) {}
fn better_changed(&mut self, _old: &Evaluation<P>, _new: &Evaluation<P>) {}
}
pub struct Empty;
impl<P: Problem> IterHook<P> for Empty {}
pub struct Print(usize);
impl Print {
pub fn new() -> Self {
Self(0)
}
}
impl Default for Print {
fn default() -> Self {
Self::new()
}
}
impl<P: Problem> IterHook<P> for Print
where
P::Value: std::fmt::Display,
{
fn iterated(&mut self, new: &Evaluation<P>) {
self.0 += 1;
eprintln!("ITER {} VALUE {}", self.0, new.value());
}
}