swarm-engine-core 0.1.6

Core types and orchestration for SwarmEngine
Documentation
//! SelectionKind - Selection アルゴリズムの種類
//!
//! Config や serde で使用するための enum。
//! ロジック自体は各 Selection struct に実装される。

/// Selection アルゴリズムの種類
///
/// Config での指定や動的切り替えに使用。
/// 実際のロジックは各 Selection struct が持つ。
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum SelectionKind {
    /// FIFO: 先入れ先出し
    #[default]
    Fifo,
    /// UCB1: Upper Confidence Bound
    Ucb1,
    /// Greedy: Confidence 最大を優先
    Greedy,
    /// Thompson: Thompson Sampling
    Thompson,
}

impl std::fmt::Display for SelectionKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Fifo => write!(f, "FIFO"),
            Self::Ucb1 => write!(f, "UCB1"),
            Self::Greedy => write!(f, "Greedy"),
            Self::Thompson => write!(f, "Thompson"),
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_selection_kind_display() {
        assert_eq!(SelectionKind::Fifo.to_string(), "FIFO");
        assert_eq!(SelectionKind::Ucb1.to_string(), "UCB1");
        assert_eq!(SelectionKind::Greedy.to_string(), "Greedy");
        assert_eq!(SelectionKind::Thompson.to_string(), "Thompson");
    }

    #[test]
    fn test_selection_kind_default() {
        assert_eq!(SelectionKind::default(), SelectionKind::Fifo);
    }
}