pub struct ResolvedLoadFactors { /* private fields */ }Expand description
Pre-resolved per-block load scaling factors.
Provides O(1) lookup of load block factors by (bus_index, stage_index, block_index). Returns 1.0 for absent entries (no scaling). Populated
by cobre-io during the resolution step and stored in crate::System.
Uses dense 3D storage (n_buses * n_stages * max_blocks) initialized to
1.0. The total size is small (typically < 10K entries) and the lookup is
on the LP-building hot path.
§Examples
use cobre_core::resolved::ResolvedLoadFactors;
let empty = ResolvedLoadFactors::empty();
assert!((empty.factor(0, 0, 0) - 1.0).abs() < f64::EPSILON);Implementations§
Source§impl ResolvedLoadFactors
impl ResolvedLoadFactors
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Create an empty load factors table. All lookups return 1.0.
Used as the default when no load_factors.json exists.
§Examples
use cobre_core::resolved::ResolvedLoadFactors;
let t = ResolvedLoadFactors::empty();
assert!((t.factor(5, 3, 2) - 1.0).abs() < f64::EPSILON);Sourcepub fn new(n_buses: usize, n_stages: usize, max_blocks: usize) -> Self
pub fn new(n_buses: usize, n_stages: usize, max_blocks: usize) -> Self
Create a new load factors table with the given dimensions.
All entries are initialized to 1.0 (no scaling). Use set to
populate individual entries.
Sourcepub fn set(
&mut self,
bus_idx: usize,
stage_idx: usize,
block_idx: usize,
value: f64,
)
pub fn set( &mut self, bus_idx: usize, stage_idx: usize, block_idx: usize, value: f64, )
Set the load factor for a specific (bus_idx, stage_idx, block_idx) triple.
§Panics
Panics if any index is out of bounds.
Sourcepub fn factor(&self, bus_idx: usize, stage_idx: usize, block_idx: usize) -> f64
pub fn factor(&self, bus_idx: usize, stage_idx: usize, block_idx: usize) -> f64
Look up the load factor for a (bus_idx, stage_idx, block_idx) triple.
Returns 1.0 when the table is empty or the computed flat index falls
past Vec::len.
Contract: the 1.0 identity fallback is only guaranteed when the flat
index (bus_idx * n_stages + stage_idx) * max_blocks + block_idx lands
past the end of the backing Vec. A per-dimension overflow that stays
within Vec::len — e.g. block_idx >= max_blocks while bus_idx is
small — aliases into a neighbouring cell rather than returning 1.0.
Callers (lp/builder/matrix.rs) only pass in-range dimensions, so this
is unreachable in practice; do not rely on the fallback for arbitrary
out-of-range dimension combinations.
Trait Implementations§
Source§impl Clone for ResolvedLoadFactors
impl Clone for ResolvedLoadFactors
Source§fn clone(&self) -> ResolvedLoadFactors
fn clone(&self) -> ResolvedLoadFactors
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 ResolvedLoadFactors
impl Debug for ResolvedLoadFactors
Source§impl PartialEq for ResolvedLoadFactors
impl PartialEq for ResolvedLoadFactors
Source§fn eq(&self, other: &ResolvedLoadFactors) -> bool
fn eq(&self, other: &ResolvedLoadFactors) -> bool
self and other values to be equal, and is used by ==.