use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum RidgePolicy {
ExactFullObjective,
SolverOnly,
}
impl RidgePolicy {
pub const fn exact_full_objective() -> Self {
Self::ExactFullObjective
}
pub const fn solver_only() -> Self {
Self::SolverOnly
}
#[inline]
pub const fn accounts_for_objective(self) -> bool {
!matches!(self, Self::SolverOnly)
}
}
#[cfg(test)]
mod ridge_policy_tests {
use super::*;
#[test]
fn exact_policy_accounts_for_the_objective() {
assert!(RidgePolicy::exact_full_objective().accounts_for_objective());
}
#[test]
fn solver_only_policy_cannot_enter_objective_accounting() {
assert!(!RidgePolicy::solver_only().accounts_for_objective());
}
#[test]
fn the_policy_has_no_third_inhabitant() {
for policy in [
RidgePolicy::exact_full_objective(),
RidgePolicy::solver_only(),
] {
match policy {
RidgePolicy::ExactFullObjective | RidgePolicy::SolverOnly => {}
}
}
}
}