pub struct Config {
pub schema: Option<String>,
pub modeling: ModelingConfig,
pub training: TrainingConfig,
pub upper_bound_evaluation: UpperBoundEvaluationConfig,
pub policy: PolicyConfig,
pub simulation: SimulationConfig,
pub exports: ExportsConfig,
pub estimation: EstimationConfig,
}Expand description
Top-level deserialized representation of config.json.
All sections except training are optional; their defaults are applied by
serde when the section is absent from the JSON.
Fields§
§schema: Option<String>JSON schema URI — informational, not validated.
modeling: ModelingConfigModeling options (inflow non-negativity treatment).
training: TrainingConfigTraining parameters — contains mandatory fields.
upper_bound_evaluation: UpperBoundEvaluationConfigUpper-bound evaluation via inner approximation.
policy: PolicyConfigPolicy directory settings (warm-start / resume).
simulation: SimulationConfigPost-training simulation settings.
exports: ExportsConfigExport flags controlling which outputs are written to disk.
estimation: EstimationConfigTime series estimation settings for automatic model parameter fitting.
Implementations§
Source§impl Config
impl Config
Sourcepub fn training_scenario_source(
&self,
path: &Path,
) -> Result<ScenarioSource, LoadError>
pub fn training_scenario_source( &self, path: &Path, ) -> Result<ScenarioSource, LoadError>
Resolve the training-phase ScenarioSource.
When training.scenario_source is absent, returns ScenarioSource::default()
(all classes InSample, no seed, no historical years).
§Errors
Returns LoadError::SchemaError if the raw config contains an invalid
scheme string, Historical on a non-inflow class, or seed/year validation
failures.
§Examples
use cobre_io::config::parse_config;
use std::path::Path;
let cfg = parse_config(Path::new("case/config.json")).unwrap();
let source = cfg.training_scenario_source(Path::new("case/config.json")).unwrap();Sourcepub fn simulation_scenario_source(
&self,
path: &Path,
) -> Result<ScenarioSource, LoadError>
pub fn simulation_scenario_source( &self, path: &Path, ) -> Result<ScenarioSource, LoadError>
Resolve the simulation-phase ScenarioSource.
Falls back to training_scenario_source() when
simulation.scenario_source is absent.
§Errors
Returns LoadError::SchemaError on validation failures in either the
simulation or training scenario source.
§Examples
use cobre_io::config::parse_config;
use std::path::Path;
let cfg = parse_config(Path::new("case/config.json")).unwrap();
let source = cfg.simulation_scenario_source(Path::new("case/config.json")).unwrap();Sourcepub fn training_openings(&self) -> Option<&Openings>
pub fn training_openings(&self) -> Option<&Openings>
The training-phase openings source declaration, or None when absent
(equivalent to generated). Single owner of the training openings
lookup that downstream opening-tree selection reads.
Sourcepub fn resolve_forward_passes(&self) -> Option<ForwardPassesResolution>
pub fn resolve_forward_passes(&self) -> Option<ForwardPassesResolution>
Resolve the effective training forward-pass method from
training.selection.
Returns None when selection is absent, leaving the mandatory-count
rejection to [validate_config]. An enumerated selection resolves to
ForwardPassesResolution::Enumerated — config load holds no policy
graph, so the count itself is derived downstream.
Sourcepub fn resolve_num_scenarios(&self) -> NumScenariosResolution
pub fn resolve_num_scenarios(&self) -> NumScenariosResolution
Resolve the effective simulation scenario-count method from
simulation.selection, defaulting to [DEFAULT_NUM_SCENARIOS] when
absent.
An enumerated selection resolves to
NumScenariosResolution::Enumerated — config load holds no policy
graph, so the derived count happens downstream.
Sourcepub fn with_overrides(
base: &Value,
overrides: &Map<String, Value>,
) -> Result<Config, LoadError>
pub fn with_overrides( base: &Value, overrides: &Map<String, Value>, ) -> Result<Config, LoadError>
Deep-merge a flat map of dotted-key overrides into base and re-deserialize
the result into a validated Config.
base is the parsed-but-not-typed config.json (a serde_json::Value::Object).
overrides is a flat map whose keys are dotted paths into the config schema
(e.g. "training.tree_seed", "policy.checkpointing.compress"). Intermediate
objects are reused rather than replaced, so setting policy.checkpointing.compress
does not clobber sibling keys under policy or policy.checkpointing.
After merging, the value is re-deserialized into Config. Because Config
is #[serde(deny_unknown_fields)], an override key that does not exist in the
schema (a typo such as trainning.tree_seed) fails loudly. The same
post-deserialization checks as parse_config then run via validate_config.
All errors carry the synthetic path "<config_overrides>" so callers can
recognize override-originated failures.
§Errors
LoadError::SchemaErrorifbaseis not a JSON object.LoadError::SchemaErrorif any override key contains an empty path segment (e.g."training..seed"or a leading/trailing dot).LoadError::SchemaErrorif the merged value fails to deserialize intoConfig(e.g. an unknown field) or failsvalidate_config.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more