use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SolverStatus {
Optimal,
Infeasible,
Unbounded,
MaxIterationsReached,
}
impl SolverStatus {
pub fn is_optimal(&self) -> bool {
matches!(self, Self::Optimal)
}
pub fn description(&self) -> &'static str {
match self {
Self::Optimal => "Optimal solution found",
Self::Infeasible => "Problem is infeasible",
Self::Unbounded => "Problem is unbounded",
Self::MaxIterationsReached => "Maximum iteration limit reached",
}
}
}
impl fmt::Display for SolverStatus {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.description())
}
}