mahf/components/utils/
mod.rs

1//! Utility components.
2
3use serde::Serialize;
4
5use crate::{component::ExecResult, components::Component, Problem, State};
6
7pub mod debug;
8pub mod improvement;
9pub mod populations;
10
11/// Doesn't do anything.
12///
13/// Can be used as a placeholder in e.g. [heuristic templates].
14///
15/// [heuristic templates]: crate::heuristics
16#[derive(Clone, Serialize)]
17pub struct Noop;
18
19impl Noop {
20    pub fn from_params() -> Self {
21        Self
22    }
23
24    pub fn new<P: Problem>() -> Box<dyn Component<P>> {
25        Box::new(Self::from_params())
26    }
27}
28
29impl<P: Problem> Component<P> for Noop {
30    fn execute(&self, _problem: &P, _state: &mut State<P>) -> ExecResult<()> {
31        Ok(())
32    }
33}