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

            
6
use crate::settings::SolverFamily;
7

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

            
19
    /// Solver time as measured by the solver itself
20
    /// This may be NaN if the solver or adaptor does not implement this statistic
21
    #[educe(Default = f64::NAN)]
22
    #[serde(rename = "solverTime_s")]
23
    pub solver_time_s: f64,
24

            
25
    // This is set by Solver, not SolverAdaptor
26
    /// The solver family used for this run.
27
    pub solver_family: Option<SolverFamily>,
28

            
29
    /// The solver adaptor used for this run.
30
    pub solver_adaptor: Option<String>,
31

            
32
    // NOTE (niklasdewally): these fields are copied from the list in Savile Row
33
    pub nodes: Option<u64>,
34
    pub satisfiable: Option<bool>,
35
    pub sat_vars: Option<u64>,
36
    pub sat_clauses: Option<u64>,
37
}
38

            
39
impl SolverStats {
40
    // Adds the conjure_solver_wall_time_s to the stats.
41
6430
    pub fn with_timings(self, wall_time_s: f64) -> SolverStats {
42
6430
        SolverStats {
43
6430
            conjure_solver_wall_time_s: wall_time_s,
44
6430
            ..self
45
6430
        }
46
6430
    }
47
}