1
use schemars::JsonSchema;
2
use serde::Serialize;
3
use serde_with::skip_serializing_none;
4

            
5
use crate::solver::SolverFamily;
6

            
7
#[skip_serializing_none]
8
#[derive(Default, Serialize, Clone, JsonSchema)]
9
#[serde(rename_all = "camelCase")]
10
#[allow(dead_code)]
11
// Statistics for a run of a solver.
12
pub struct SolverStats {
13
    #[serde(rename = "conjureSolverWallTime_s")]
14
    /// Wall time as measured by Conjure-Oxide (not the solver).
15
    pub conjure_solver_wall_time_s: f64,
16

            
17
    // This is set by Solver, not SolverAdaptor
18
    /// The solver family used for this run.
19
    pub solver_family: Option<SolverFamily>,
20

            
21
    /// The solver adaptor used for this run.
22
    pub solver_adaptor: Option<String>,
23

            
24
    // NOTE (niklasdewally): these fields are copied from the list in Savile Row
25
    pub nodes: Option<u64>,
26
    pub satisfiable: Option<bool>,
27
    pub sat_vars: Option<u64>,
28
    pub sat_clauses: Option<u64>,
29
}
30

            
31
impl SolverStats {
32
    // Adds the conjure_solver_wall_time_s to the stats.
33
    pub fn with_timings(self, wall_time_s: f64) -> SolverStats {
34
        SolverStats {
35
            conjure_solver_wall_time_s: wall_time_s,
36
            ..self.clone()
37
        }
38
    }
39
}