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: most tables use data[entity_idx * n_stages + stage_idx].
The thermal table uses an extended stride
data[thermal_idx * thermal_stage_axis_len + stage_idx] with
thermal_stage_axis_len = n_stages + k_max, where k_max is the maximum
lead-stages across anticipated thermals. The padded region
[n_stages, n_stages + k_max) is reserved for delivery-stage lookups by
anticipated-decision columns.
§Examples
use cobre_core::resolved::{
BoundsCountsSpec, BoundsDefaults, 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, cost_per_mwh: 50.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(
&BoundsCountsSpec { n_hydros: 2, n_thermals: 1, n_lines: 1, n_pumping: 1, n_contracts: 1, n_stages: 3, k_max: 0 },
&BoundsDefaults { hydro: hydro_default, thermal: thermal_default, line: line_default, pumping: pumping_default, contract: 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(counts: &BoundsCountsSpec, defaults: &BoundsDefaults) -> Self
pub fn new(counts: &BoundsCountsSpec, defaults: &BoundsDefaults) -> Self
Allocate a new resolved-bounds table filled with the given defaults.
counts.n_stages must be > 0. Entity counts may be 0.
§Arguments
counts— entity counts grouped intoBoundsCountsSpecdefaults— default per-stage bound values grouped intoBoundsDefaults
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.
stage_index is valid in [0, thermal_stage_axis_len()), which equals
n_stages() + k_max. Indices >= n_stages() access the padded region
reserved for delivery-stage lookups by anticipated-decision columns.
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.
stage_index is valid in [0, thermal_stage_axis_len()). Indices
>= n_stages() write into the padded region reserved for
delivery-stage lookups by anticipated-decision columns.
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.
Sourcepub fn thermal_stage_axis_len(&self) -> usize
pub fn thermal_stage_axis_len(&self) -> usize
Return the stride used to index the thermal Vec.
Equals n_stages() + k_max, where k_max is the maximum lead-stages
across anticipated thermals. When k_max == 0 this equals
n_stages(). The thermal table reserves indices
[n_stages(), thermal_stage_axis_len()) for delivery-stage lookups by
anticipated-decision columns.
Trait Implementations§
Source§impl Clone for ResolvedBounds
impl Clone for ResolvedBounds
Source§fn clone(&self) -> ResolvedBounds
fn clone(&self) -> ResolvedBounds
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResolvedBounds
impl Debug for ResolvedBounds
Source§impl PartialEq for ResolvedBounds
impl PartialEq for ResolvedBounds
Source§fn eq(&self, other: &ResolvedBounds) -> bool
fn eq(&self, other: &ResolvedBounds) -> bool
self and other values to be equal, and is used by ==.