pub struct System { /* private fields */ }Expand description
Top-level system representation: immutable and thread-safe after construction.
Entity collections are in canonical order (sorted by EntityId’s inner i32).
§Examples
use chrono::NaiveDate;
use cobre_core::{Bus, DeficitSegment, EntityId, SystemBuilder};
let bus = Bus {
id: EntityId(1),
name: "Main Bus".to_string(),
operational_start_date: NaiveDate::from_ymd_opt(2024, 1, 1).unwrap(),
deficit_segments: vec![],
excess_cost: 0.0,
};
let system = SystemBuilder::new()
.buses(vec![bus])
.build()
.expect("valid system");
assert_eq!(system.n_buses(), 1);
assert!(system.bus(EntityId(1)).is_some());Implementations§
Source§impl System
impl System
Sourcepub fn pumping_stations(&self) -> &[PumpingStation]
pub fn pumping_stations(&self) -> &[PumpingStation]
Returns all pumping stations in canonical ID order.
Sourcepub fn contracts(&self) -> &[EnergyContract]
pub fn contracts(&self) -> &[EnergyContract]
Returns all energy contracts in canonical ID order.
Sourcepub fn non_controllable_sources(&self) -> &[NonControllableSource]
pub fn non_controllable_sources(&self) -> &[NonControllableSource]
Returns all non-controllable sources in canonical ID order.
Sourcepub fn n_thermals(&self) -> usize
pub fn n_thermals(&self) -> usize
Returns the number of thermal plants in the system.
Sourcepub fn n_pumping_stations(&self) -> usize
pub fn n_pumping_stations(&self) -> usize
Returns the number of pumping stations in the system.
Sourcepub fn n_contracts(&self) -> usize
pub fn n_contracts(&self) -> usize
Returns the number of energy contracts in the system.
Sourcepub fn n_non_controllable_sources(&self) -> usize
pub fn n_non_controllable_sources(&self) -> usize
Returns the number of non-controllable sources in the system.
Sourcepub fn bus(&self, id: EntityId) -> Option<&Bus>
pub fn bus(&self, id: EntityId) -> Option<&Bus>
Returns the bus with the given ID, or None if not found.
Sourcepub fn line(&self, id: EntityId) -> Option<&Line>
pub fn line(&self, id: EntityId) -> Option<&Line>
Returns the line with the given ID, or None if not found.
Sourcepub fn hydro(&self, id: EntityId) -> Option<&Hydro>
pub fn hydro(&self, id: EntityId) -> Option<&Hydro>
Returns the hydro plant with the given ID, or None if not found.
Sourcepub fn thermal(&self, id: EntityId) -> Option<&Thermal>
pub fn thermal(&self, id: EntityId) -> Option<&Thermal>
Returns the thermal plant with the given ID, or None if not found.
Sourcepub fn pumping_station(&self, id: EntityId) -> Option<&PumpingStation>
pub fn pumping_station(&self, id: EntityId) -> Option<&PumpingStation>
Returns the pumping station with the given ID, or None if not found.
Sourcepub fn contract(&self, id: EntityId) -> Option<&EnergyContract>
pub fn contract(&self, id: EntityId) -> Option<&EnergyContract>
Returns the energy contract with the given ID, or None if not found.
Sourcepub fn non_controllable_source(
&self,
id: EntityId,
) -> Option<&NonControllableSource>
pub fn non_controllable_source( &self, id: EntityId, ) -> Option<&NonControllableSource>
Returns the non-controllable source with the given ID, or None if not found.
Sourcepub fn cascade(&self) -> &CascadeTopology
pub fn cascade(&self) -> &CascadeTopology
Returns a reference to the hydro cascade topology.
Sourcepub fn network(&self) -> &NetworkTopology
pub fn network(&self) -> &NetworkTopology
Returns a reference to the transmission network topology.
Sourcepub fn stages(&self) -> &[Stage]
pub fn stages(&self) -> &[Stage]
Returns all stages in canonical ID order (study and pre-study stages).
Sourcepub fn n_stages(&self) -> usize
pub fn n_stages(&self) -> usize
Returns the number of stages (study and pre-study) in the system.
Sourcepub fn stage(&self, id: i32) -> Option<&Stage>
pub fn stage(&self, id: i32) -> Option<&Stage>
Returns the stage with the given stage ID, or None if not found.
Stage IDs are i32. Study stages have non-negative IDs; pre-study
stages (used only for PAR model lag initialization) have negative IDs.
Sourcepub fn policy_graph(&self) -> &HorizonGraph
pub fn policy_graph(&self) -> &HorizonGraph
Returns a reference to the policy graph.
Sourcepub fn penalties(&self) -> &ResolvedPenalties
pub fn penalties(&self) -> &ResolvedPenalties
Returns a reference to the pre-resolved penalty table.
Sourcepub fn bounds(&self) -> &ResolvedBounds
pub fn bounds(&self) -> &ResolvedBounds
Returns a reference to the pre-resolved bounds table.
Sourcepub fn resolved_generic_bounds(&self) -> &ResolvedGenericConstraintBounds
pub fn resolved_generic_bounds(&self) -> &ResolvedGenericConstraintBounds
Returns a reference to the pre-resolved generic constraint RHS bound table.
Sourcepub fn resolved_load_factors(&self) -> &ResolvedLoadFactors
pub fn resolved_load_factors(&self) -> &ResolvedLoadFactors
Returns a reference to the pre-resolved per-block load scaling factors.
Sourcepub fn resolved_ncs_bounds(&self) -> &ResolvedNcsBounds
pub fn resolved_ncs_bounds(&self) -> &ResolvedNcsBounds
Returns a reference to the pre-resolved per-stage NCS available generation bounds.
Sourcepub fn resolved_ncs_factors(&self) -> &ResolvedNcsFactors
pub fn resolved_ncs_factors(&self) -> &ResolvedNcsFactors
Returns a reference to the pre-resolved per-block NCS generation scaling factors.
Sourcepub fn inflow_models(&self) -> &[InflowModel]
pub fn inflow_models(&self) -> &[InflowModel]
Returns all PAR(p) inflow models in canonical order (by hydro ID, then stage ID).
Sourcepub fn load_models(&self) -> &[LoadModel]
pub fn load_models(&self) -> &[LoadModel]
Returns all load models in canonical order (by bus ID, then stage ID).
Sourcepub fn load_noise_member_bus_ids(&self, scheme: SamplingScheme) -> Vec<EntityId>
pub fn load_noise_member_bus_ids(&self, scheme: SamplingScheme) -> Vec<EntityId>
Canonical load-noise-member bus IDs under scheme: LoadModel::is_noise_member
over load_models(), unioned with external_load_scenarios()’s own buses under
SamplingScheme::External — a bus with no load_seasonal_stats row is still a
noise member there. Sorted and deduplicated by EntityId for declaration-order
invariance. The single owner of this membership: every site deciding which buses
carry load noise calls this rather than re-deriving it.
Sourcepub fn ncs_models(&self) -> &[NcsModel]
pub fn ncs_models(&self) -> &[NcsModel]
Returns all NCS availability noise models in canonical order (by NCS ID, then stage ID).
Sourcepub fn ncs_noise_member_ids(&self, scheme: SamplingScheme) -> Vec<EntityId>
pub fn ncs_noise_member_ids(&self, scheme: SamplingScheme) -> Vec<EntityId>
Canonical NCS-noise-member IDs under scheme: every NCS in ncs_models()
(unfiltered — an NCS with std = 0 is still a member; dropping it would
shift the canonical noise-vector order), unioned with
external_ncs_scenarios()’s own NCS set under SamplingScheme::External
— an NCS with no non_controllable_stats row is still a noise member
there. Sorted and deduplicated by EntityId. NCS’s LP-structural
presence is a separate concern owned by Self::non_controllable_sources.
Sourcepub fn correlation(&self) -> &CorrelationModel
pub fn correlation(&self) -> &CorrelationModel
Returns a reference to the correlation model.
Sourcepub fn initial_conditions(&self) -> &InitialConditions
pub fn initial_conditions(&self) -> &InitialConditions
Returns a reference to the initial conditions.
Sourcepub fn generic_constraints(&self) -> &[GenericConstraint]
pub fn generic_constraints(&self) -> &[GenericConstraint]
Returns all generic constraints in canonical ID order.
Sourcepub fn inflow_history(&self) -> &[InflowHistoryRow]
pub fn inflow_history(&self) -> &[InflowHistoryRow]
Returns the raw historical inflow observations, sorted by (hydro_id, start_date).
Returns an empty slice when scenarios/inflow_history.parquet was absent
at case-load time.
Sourcepub fn external_scenarios(&self) -> &[ExternalScenarioRow]
pub fn external_scenarios(&self) -> &[ExternalScenarioRow]
Returns the raw external inflow scenario rows, sorted by (stage_id, scenario_id, hydro_id).
Returns an empty slice when no external inflow scenario file was present at case-load time.
Sourcepub fn external_load_scenarios(&self) -> &[ExternalLoadRow]
pub fn external_load_scenarios(&self) -> &[ExternalLoadRow]
Returns the raw external load scenario rows, sorted by (stage_id, scenario_id, bus_id).
Returns an empty slice when no external load scenario file was present at case-load time.
Sourcepub fn external_ncs_scenarios(&self) -> &[ExternalNcsRow]
pub fn external_ncs_scenarios(&self) -> &[ExternalNcsRow]
Returns the raw external NCS scenario rows, sorted by (stage_id, scenario_id, ncs_id).
Returns an empty slice when no external NCS scenario file was present at case-load time.
Sourcepub fn post_study_stages(&self) -> Option<&PostStudyStages>
pub fn post_study_stages(&self) -> Option<&PostStudyStages>
Returns the post-study boundary calendar and cost/bounds, or None when
post_study_stages.json was absent at case-load time.
Sourcepub fn with_scenario_models(
self,
inflow_models: Vec<InflowModel>,
correlation: CorrelationModel,
) -> Self
pub fn with_scenario_models( self, inflow_models: Vec<InflowModel>, correlation: CorrelationModel, ) -> Self
Replace inflow_models and correlation, returning the System with all
other fields preserved. The only supported post-construction update path for
these fields, which are not public outside this crate.
§Examples
use cobre_core::{EntityId, SystemBuilder};
use cobre_core::scenario::{InflowModel, CorrelationModel};
let system = SystemBuilder::new().build().expect("valid system");
let model = InflowModel {
hydro_id: EntityId(1),
stage_id: 0,
mean_m3s: 100.0,
std_m3s: 10.0,
ar_coefficients: vec![],
residual_std_ratio: 1.0,
annual: None,
};
let updated = system.with_scenario_models(vec![model], CorrelationModel::default());
assert_eq!(updated.inflow_models().len(), 1);