pub mod iterstate;
pub mod linearprogramstate;
pub mod populationstate;
pub use iterstate::IterState;
pub use linearprogramstate::LinearProgramState;
pub use populationstate::PopulationState;
use crate::core::{ArgminFloat, Problem, TerminationReason, TerminationStatus};
use std::collections::HashMap;
use web_time::Duration;
pub trait State {
type Param;
type Float: ArgminFloat;
fn new() -> Self;
fn update(&mut self);
fn get_param(&self) -> Option<&Self::Param>;
fn get_best_param(&self) -> Option<&Self::Param>;
fn get_max_iters(&self) -> u64;
fn increment_iter(&mut self);
fn get_iter(&self) -> u64;
fn get_cost(&self) -> Self::Float;
fn get_best_cost(&self) -> Self::Float;
fn get_target_cost(&self) -> Self::Float;
fn func_counts<O>(&mut self, problem: &Problem<O>);
fn get_func_counts(&self) -> &HashMap<String, u64>;
fn time(&mut self, time: Option<Duration>) -> &mut Self;
fn get_time(&self) -> Option<Duration>;
fn get_last_best_iter(&self) -> u64;
fn is_best(&self) -> bool;
#[must_use]
fn terminate_with(self, termination_reason: TerminationReason) -> Self;
fn get_termination_status(&self) -> &TerminationStatus;
fn get_termination_reason(&self) -> Option<&TerminationReason>;
fn terminated(&self) -> bool {
matches!(
self.get_termination_status(),
TerminationStatus::Terminated(_)
)
}
}