Skip to main content

conjure_cp_core/stats/
solver_stats.rs

1use educe::Educe;
2use schemars::JsonSchema;
3use serde::Serialize;
4use serde_with::skip_serializing_none;
5
6use crate::solver::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.
14pub 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
39impl SolverStats {
40    // Adds the conjure_solver_wall_time_s to the stats.
41    pub fn with_timings(self, wall_time_s: f64) -> SolverStats {
42        SolverStats {
43            conjure_solver_wall_time_s: wall_time_s,
44            ..self
45        }
46    }
47}