use std::time::Duration;
use crate::explore::design::DesignKind;
use crate::explore::factor::FactorSpec;
use crate::explore::reducer::ReducerSpec;
use crate::explore::search::SearchSpec;
use crate::explore::seed::SeedScheme;
use crate::explore::stop::StopSpec;
pub const ACTION_COLUMN_PREFIX: &str = "action.";
#[derive(Debug, Clone, PartialEq)]
pub struct SweepSpec {
pub model: String,
pub fixed: Vec<(String, String)>,
pub run: RunSettings,
pub measure: MeasureSettings,
pub seeds: SeedSettings,
pub actions: Vec<ActionSpec>,
pub blocks: Vec<BlockSpec>,
pub search: Option<SearchSpec>,
}
impl SweepSpec {
pub fn new(model: impl Into<String>) -> Self {
Self {
model: model.into(),
fixed: Vec::new(),
run: RunSettings::default(),
measure: MeasureSettings::default(),
seeds: SeedSettings::default(),
actions: Vec::new(),
blocks: Vec::new(),
search: None,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ActionSpec {
pub id: String,
pub name: String,
pub tick: u64,
}
impl ActionSpec {
pub fn new(id: impl Into<String>, tick: u64) -> Self {
let id = id.into();
Self {
name: id.clone(),
id,
tick,
}
}
pub fn column_name(&self) -> String {
format!("{ACTION_COLUMN_PREFIX}{}", self.name)
}
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct BlockSpec {
pub design: DesignKind,
pub factors: Vec<FactorSpec>,
pub design_seed: Option<u64>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct RunSettings {
pub steps: u64,
pub warmup: u64,
pub replicates: u64,
pub stop: Option<StopSpec>,
pub timeout: Option<Duration>,
}
impl Default for RunSettings {
fn default() -> Self {
Self {
steps: 1000,
warmup: 0,
replicates: 1,
stop: None,
timeout: None,
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MeasureSettings {
pub stats_every: u64,
pub series_every: u64,
pub default_reducers: bool,
pub reducers: Vec<ReducerSpec>,
}
impl Default for MeasureSettings {
fn default() -> Self {
Self {
stats_every: 1,
series_every: 1,
default_reducers: true,
reducers: Vec::new(),
}
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct SeedSettings {
pub root: u64,
pub scheme: SeedScheme,
}