Skip to main content

swarm_engine_eval/
run.rs

1//! EvalRun - Single evaluation run result
2
3use serde::{Deserialize, Serialize};
4
5use crate::metrics::RunMetrics;
6
7/// Termination reason for an evaluation run
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub enum TerminationReason {
10    /// Successfully completed (success condition met)
11    Success,
12    /// Failed (failure condition met)
13    Failure,
14    /// Timed out (max ticks reached)
15    Timeout,
16    /// Manually stopped
17    Stopped,
18}
19
20impl std::fmt::Display for TerminationReason {
21    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22        match self {
23            Self::Success => write!(f, "success"),
24            Self::Failure => write!(f, "failure"),
25            Self::Timeout => write!(f, "timeout"),
26            Self::Stopped => write!(f, "stopped"),
27        }
28    }
29}
30
31/// Single evaluation run result
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct EvalRun {
34    /// Run index (0-based)
35    pub index: usize,
36
37    /// Seed used for this run
38    pub seed: u64,
39
40    /// Whether the run was successful
41    pub success: bool,
42
43    /// Termination reason
44    pub termination_reason: TerminationReason,
45
46    /// Run metrics
47    pub metrics: RunMetrics,
48}
49
50impl EvalRun {
51    /// Create new run result
52    pub fn new(
53        index: usize,
54        seed: u64,
55        success: bool,
56        termination_reason: TerminationReason,
57        metrics: RunMetrics,
58    ) -> Self {
59        Self {
60            index,
61            seed,
62            success,
63            termination_reason,
64            metrics,
65        }
66    }
67}