Skip to main content

ResolvedBounds

Struct ResolvedBounds 

Source
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

Source

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);
Source

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 plants
  • n_thermals — number of thermal units
  • n_lines — number of transmission lines
  • n_pumping — number of pumping stations
  • n_contracts — number of energy contracts
  • n_stages — number of study stages
  • hydro_default — initial value for all (hydro, stage) cells
  • thermal_default — initial value for all (thermal, stage) cells
  • line_default — initial value for all (line, stage) cells
  • pumping_default — initial value for all (pumping, stage) cells
  • contract_default — initial value for all (contract, stage) cells
Source

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.

Source

pub fn thermal_bounds( &self, thermal_index: usize, stage_index: usize, ) -> ThermalStageBounds

Return the resolved bounds for a thermal unit at a specific stage.

Source

pub fn line_bounds( &self, line_index: usize, stage_index: usize, ) -> LineStageBounds

Return the resolved bounds for a transmission line at a specific stage.

Source

pub fn pumping_bounds( &self, pumping_index: usize, stage_index: usize, ) -> PumpingStageBounds

Return the resolved bounds for a pumping station at a specific stage.

Source

pub fn contract_bounds( &self, contract_index: usize, stage_index: usize, ) -> ContractStageBounds

Return the resolved bounds for an energy contract at a specific stage.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn n_stages(&self) -> usize

Return the number of stages in this table.

Trait Implementations§

Source§

impl Clone for ResolvedBounds

Source§

fn clone(&self) -> ResolvedBounds

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResolvedBounds

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ResolvedBounds

Source§

fn eq(&self, other: &ResolvedBounds) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ResolvedBounds

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.