#[derive(Debug, Clone, PartialEq)]
pub struct Solution {
pub x: Vec<f64>,
pub value: f64,
}
#[derive(Debug, Clone, PartialEq)]
pub struct MultiSolution {
pub x: Vec<f64>,
pub objectives: Vec<f64>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct ParetoFront {
pub solutions: Vec<MultiSolution>,
pub evaluations: usize,
}
impl ParetoFront {
pub fn len(&self) -> usize {
self.solutions.len()
}
pub fn is_empty(&self) -> bool {
self.solutions.is_empty()
}
pub fn objective_vectors(&self) -> impl Iterator<Item = &[f64]> {
self.solutions.iter().map(|s| s.objectives.as_slice())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum StopReason {
BudgetExhausted,
TargetReached,
Converged,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Report {
pub solution: Solution,
pub stop: StopReason,
pub evaluations: usize,
}
impl Report {
pub fn best(&self) -> &[f64] {
&self.solution.x
}
pub fn best_value(&self) -> f64 {
self.solution.value
}
pub fn best_value_maximized(&self) -> f64 {
-self.solution.value
}
}