Skip to main content

swarm_engine_core/exploration/selection/
kind.rs

1//! SelectionKind - Selection アルゴリズムの種類
2//!
3//! Config や serde で使用するための enum。
4//! ロジック自体は各 Selection struct に実装される。
5
6/// Selection アルゴリズムの種類
7///
8/// Config での指定や動的切り替えに使用。
9/// 実際のロジックは各 Selection struct が持つ。
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
11pub enum SelectionKind {
12    /// FIFO: 先入れ先出し
13    #[default]
14    Fifo,
15    /// UCB1: Upper Confidence Bound
16    Ucb1,
17    /// Greedy: Confidence 最大を優先
18    Greedy,
19    /// Thompson: Thompson Sampling
20    Thompson,
21}
22
23impl std::fmt::Display for SelectionKind {
24    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25        match self {
26            Self::Fifo => write!(f, "FIFO"),
27            Self::Ucb1 => write!(f, "UCB1"),
28            Self::Greedy => write!(f, "Greedy"),
29            Self::Thompson => write!(f, "Thompson"),
30        }
31    }
32}
33
34#[cfg(test)]
35mod tests {
36    use super::*;
37
38    #[test]
39    fn test_selection_kind_display() {
40        assert_eq!(SelectionKind::Fifo.to_string(), "FIFO");
41        assert_eq!(SelectionKind::Ucb1.to_string(), "UCB1");
42        assert_eq!(SelectionKind::Greedy.to_string(), "Greedy");
43        assert_eq!(SelectionKind::Thompson.to_string(), "Thompson");
44    }
45
46    #[test]
47    fn test_selection_kind_default() {
48        assert_eq!(SelectionKind::default(), SelectionKind::Fifo);
49    }
50}