pub struct ResolvedPenalties { /* private fields */ }Expand description
Pre-resolved penalty table for all entities across all stages.
Populated by cobre-io after the three-tier penalty cascade is applied.
Provides O(1) lookup via direct array indexing.
Internal layout: data[entity_idx * n_stages + stage_idx] — iterating
stages for a fixed entity accesses a contiguous memory region.
§Construction
Use ResolvedPenalties::new to allocate the table with a given default
value, then populate by writing into the flat slice returned by the internal
accessors. cobre-io is responsible for filling the data.
§Examples
use cobre_core::resolved::{
BusStagePenalties, HydroStagePenalties, LineStagePenalties,
NcsStagePenalties, ResolvedPenalties,
};
let hydro_default = HydroStagePenalties {
spillage_cost: 0.01,
diversion_cost: 0.02,
fpha_turbined_cost: 0.03,
storage_violation_below_cost: 1000.0,
filling_target_violation_cost: 5000.0,
turbined_violation_below_cost: 500.0,
outflow_violation_below_cost: 500.0,
outflow_violation_above_cost: 500.0,
generation_violation_below_cost: 500.0,
evaporation_violation_cost: 500.0,
water_withdrawal_violation_cost: 500.0,
};
let bus_default = BusStagePenalties { excess_cost: 100.0 };
let line_default = LineStagePenalties { exchange_cost: 5.0 };
let ncs_default = NcsStagePenalties { curtailment_cost: 50.0 };
let table = ResolvedPenalties::new(
3, 2, 1, 4, 5,
hydro_default, bus_default, line_default, ncs_default,
);
// Hydro 1, stage 2 returns the default penalties.
let p = table.hydro_penalties(1, 2);
assert!((p.spillage_cost - 0.01).abs() < f64::EPSILON);Implementations§
Source§impl ResolvedPenalties
impl ResolvedPenalties
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Return an empty penalty table with zero entities and zero stages.
Used as the default value in System when no penalty
resolution has been performed yet (e.g., when building a System from
raw entity collections without cobre-io).
§Examples
use cobre_core::ResolvedPenalties;
let empty = ResolvedPenalties::empty();
assert_eq!(empty.n_stages(), 0);Sourcepub fn new(
n_hydros: usize,
n_buses: usize,
n_lines: usize,
n_ncs: usize,
n_stages: usize,
hydro_default: HydroStagePenalties,
bus_default: BusStagePenalties,
line_default: LineStagePenalties,
ncs_default: NcsStagePenalties,
) -> Self
pub fn new( n_hydros: usize, n_buses: usize, n_lines: usize, n_ncs: usize, n_stages: usize, hydro_default: HydroStagePenalties, bus_default: BusStagePenalties, line_default: LineStagePenalties, ncs_default: NcsStagePenalties, ) -> Self
Allocate a new resolved-penalties table filled with the given defaults.
n_stages must be > 0. Entity counts may be 0 (empty vectors are valid).
§Arguments
n_hydros— number of hydro plantsn_buses— number of busesn_lines— number of transmission linesn_ncs— number of non-controllable sourcesn_stages— number of study stageshydro_default— initial value for all (hydro, stage) cellsbus_default— initial value for all (bus, stage) cellsline_default— initial value for all (line, stage) cellsncs_default— initial value for all (ncs, stage) cells
Sourcepub fn hydro_penalties(
&self,
hydro_index: usize,
stage_index: usize,
) -> HydroStagePenalties
pub fn hydro_penalties( &self, hydro_index: usize, stage_index: usize, ) -> HydroStagePenalties
Return the resolved penalties for a hydro plant at a specific stage.
Sourcepub fn bus_penalties(
&self,
bus_index: usize,
stage_index: usize,
) -> BusStagePenalties
pub fn bus_penalties( &self, bus_index: usize, stage_index: usize, ) -> BusStagePenalties
Return the resolved penalties for a bus at a specific stage.
Sourcepub fn line_penalties(
&self,
line_index: usize,
stage_index: usize,
) -> LineStagePenalties
pub fn line_penalties( &self, line_index: usize, stage_index: usize, ) -> LineStagePenalties
Return the resolved penalties for a line at a specific stage.
Sourcepub fn ncs_penalties(
&self,
ncs_index: usize,
stage_index: usize,
) -> NcsStagePenalties
pub fn ncs_penalties( &self, ncs_index: usize, stage_index: usize, ) -> NcsStagePenalties
Return the resolved penalties for a non-controllable source at a specific stage.
Sourcepub fn hydro_penalties_mut(
&mut self,
hydro_index: usize,
stage_index: usize,
) -> &mut HydroStagePenalties
pub fn hydro_penalties_mut( &mut self, hydro_index: usize, stage_index: usize, ) -> &mut HydroStagePenalties
Return a mutable reference to the hydro penalty cell for in-place update.
Used by cobre-io during penalty cascade resolution to set resolved values.
Sourcepub fn bus_penalties_mut(
&mut self,
bus_index: usize,
stage_index: usize,
) -> &mut BusStagePenalties
pub fn bus_penalties_mut( &mut self, bus_index: usize, stage_index: usize, ) -> &mut BusStagePenalties
Return a mutable reference to the bus penalty cell for in-place update.
Sourcepub fn line_penalties_mut(
&mut self,
line_index: usize,
stage_index: usize,
) -> &mut LineStagePenalties
pub fn line_penalties_mut( &mut self, line_index: usize, stage_index: usize, ) -> &mut LineStagePenalties
Return a mutable reference to the line penalty cell for in-place update.
Sourcepub fn ncs_penalties_mut(
&mut self,
ncs_index: usize,
stage_index: usize,
) -> &mut NcsStagePenalties
pub fn ncs_penalties_mut( &mut self, ncs_index: usize, stage_index: usize, ) -> &mut NcsStagePenalties
Return a mutable reference to the NCS penalty cell for in-place update.
Trait Implementations§
Source§impl Clone for ResolvedPenalties
impl Clone for ResolvedPenalties
Source§fn clone(&self) -> ResolvedPenalties
fn clone(&self) -> ResolvedPenalties
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more