pub struct ResolvedBounds { /* private fields */ }Expand description
Pre-resolved bound table for all entities across all stages.
Populated by cobre-io after base bounds are overlaid with stage-specific
overrides. Provides O(1) lookup via direct array indexing.
Internal layout: data[entity_idx * n_stages + stage_idx].
§Examples
use cobre_core::resolved::{
ContractStageBounds, HydroStageBounds, LineStageBounds,
PumpingStageBounds, ResolvedBounds, ThermalStageBounds,
};
let hydro_default = HydroStageBounds {
min_storage_hm3: 0.0, max_storage_hm3: 100.0,
min_turbined_m3s: 0.0, max_turbined_m3s: 50.0,
min_outflow_m3s: 0.0, max_outflow_m3s: None,
min_generation_mw: 0.0, max_generation_mw: 30.0,
max_diversion_m3s: None,
filling_inflow_m3s: 0.0, water_withdrawal_m3s: 0.0,
};
let thermal_default = ThermalStageBounds { min_generation_mw: 0.0, max_generation_mw: 100.0 };
let line_default = LineStageBounds { direct_mw: 500.0, reverse_mw: 500.0 };
let pumping_default = PumpingStageBounds { min_flow_m3s: 0.0, max_flow_m3s: 20.0 };
let contract_default = ContractStageBounds { min_mw: 0.0, max_mw: 50.0, price_per_mwh: 80.0 };
let table = ResolvedBounds::new(
2, 1, 1, 1, 1, 3,
hydro_default, thermal_default, line_default, pumping_default, contract_default,
);
let b = table.hydro_bounds(0, 2);
assert!((b.max_storage_hm3 - 100.0).abs() < f64::EPSILON);Implementations§
Source§impl ResolvedBounds
impl ResolvedBounds
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Return an empty bounds table with zero entities and zero stages.
Used as the default value in System when no bound
resolution has been performed yet (e.g., when building a System from
raw entity collections without cobre-io).
§Examples
use cobre_core::ResolvedBounds;
let empty = ResolvedBounds::empty();
assert_eq!(empty.n_stages(), 0);Sourcepub fn new(
n_hydros: usize,
n_thermals: usize,
n_lines: usize,
n_pumping: usize,
n_contracts: usize,
n_stages: usize,
hydro_default: HydroStageBounds,
thermal_default: ThermalStageBounds,
line_default: LineStageBounds,
pumping_default: PumpingStageBounds,
contract_default: ContractStageBounds,
) -> Self
pub fn new( n_hydros: usize, n_thermals: usize, n_lines: usize, n_pumping: usize, n_contracts: usize, n_stages: usize, hydro_default: HydroStageBounds, thermal_default: ThermalStageBounds, line_default: LineStageBounds, pumping_default: PumpingStageBounds, contract_default: ContractStageBounds, ) -> Self
Allocate a new resolved-bounds table filled with the given defaults.
n_stages must be > 0. Entity counts may be 0.
§Arguments
n_hydros— number of hydro plantsn_thermals— number of thermal unitsn_lines— number of transmission linesn_pumping— number of pumping stationsn_contracts— number of energy contractsn_stages— number of study stageshydro_default— initial value for all (hydro, stage) cellsthermal_default— initial value for all (thermal, stage) cellsline_default— initial value for all (line, stage) cellspumping_default— initial value for all (pumping, stage) cellscontract_default— initial value for all (contract, stage) cells
Sourcepub fn hydro_bounds(
&self,
hydro_index: usize,
stage_index: usize,
) -> &HydroStageBounds
pub fn hydro_bounds( &self, hydro_index: usize, stage_index: usize, ) -> &HydroStageBounds
Return the resolved bounds for a hydro plant at a specific stage.
Returns a shared reference to avoid copying the 11-field struct on hot paths.
§Panics
Panics in debug builds if hydro_index >= n_hydros or stage_index >= n_stages.
Sourcepub fn thermal_bounds(
&self,
thermal_index: usize,
stage_index: usize,
) -> ThermalStageBounds
pub fn thermal_bounds( &self, thermal_index: usize, stage_index: usize, ) -> ThermalStageBounds
Return the resolved bounds for a thermal unit at a specific stage.
Sourcepub fn line_bounds(
&self,
line_index: usize,
stage_index: usize,
) -> LineStageBounds
pub fn line_bounds( &self, line_index: usize, stage_index: usize, ) -> LineStageBounds
Return the resolved bounds for a transmission line at a specific stage.
Sourcepub fn pumping_bounds(
&self,
pumping_index: usize,
stage_index: usize,
) -> PumpingStageBounds
pub fn pumping_bounds( &self, pumping_index: usize, stage_index: usize, ) -> PumpingStageBounds
Return the resolved bounds for a pumping station at a specific stage.
Sourcepub fn contract_bounds(
&self,
contract_index: usize,
stage_index: usize,
) -> ContractStageBounds
pub fn contract_bounds( &self, contract_index: usize, stage_index: usize, ) -> ContractStageBounds
Return the resolved bounds for an energy contract at a specific stage.
Sourcepub fn hydro_bounds_mut(
&mut self,
hydro_index: usize,
stage_index: usize,
) -> &mut HydroStageBounds
pub fn hydro_bounds_mut( &mut self, hydro_index: usize, stage_index: usize, ) -> &mut HydroStageBounds
Return a mutable reference to the hydro bounds cell for in-place update.
Used by cobre-io during bound resolution to set stage-specific overrides.
Sourcepub fn thermal_bounds_mut(
&mut self,
thermal_index: usize,
stage_index: usize,
) -> &mut ThermalStageBounds
pub fn thermal_bounds_mut( &mut self, thermal_index: usize, stage_index: usize, ) -> &mut ThermalStageBounds
Return a mutable reference to the thermal bounds cell for in-place update.
Sourcepub fn line_bounds_mut(
&mut self,
line_index: usize,
stage_index: usize,
) -> &mut LineStageBounds
pub fn line_bounds_mut( &mut self, line_index: usize, stage_index: usize, ) -> &mut LineStageBounds
Return a mutable reference to the line bounds cell for in-place update.
Sourcepub fn pumping_bounds_mut(
&mut self,
pumping_index: usize,
stage_index: usize,
) -> &mut PumpingStageBounds
pub fn pumping_bounds_mut( &mut self, pumping_index: usize, stage_index: usize, ) -> &mut PumpingStageBounds
Return a mutable reference to the pumping bounds cell for in-place update.
Sourcepub fn contract_bounds_mut(
&mut self,
contract_index: usize,
stage_index: usize,
) -> &mut ContractStageBounds
pub fn contract_bounds_mut( &mut self, contract_index: usize, stage_index: usize, ) -> &mut ContractStageBounds
Return a mutable reference to the contract bounds cell for in-place update.
Trait Implementations§
Source§impl Clone for ResolvedBounds
impl Clone for ResolvedBounds
Source§fn clone(&self) -> ResolvedBounds
fn clone(&self) -> ResolvedBounds
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more