pub struct CommodityPrices(IndexMap<(CommodityID, RegionID, TimeSliceID), MoneyPerFlow>);Expand description
A map relating commodity ID + region + time slice to current price (endogenous)
Tuple Fields§
§0: IndexMap<(CommodityID, RegionID, TimeSliceID), MoneyPerFlow>Implementations§
Source§impl CommodityPrices
impl CommodityPrices
Sourcepub fn insert(
&mut self,
commodity_id: &CommodityID,
region_id: &RegionID,
time_slice: &TimeSliceID,
price: MoneyPerFlow,
)
pub fn insert( &mut self, commodity_id: &CommodityID, region_id: &RegionID, time_slice: &TimeSliceID, price: MoneyPerFlow, )
Insert/update a price for the given commodity, region and time slice.
Sourcefn extend_selection_prices(
&mut self,
group_prices: &IndexMap<(CommodityID, RegionID, TimeSliceSelection), MoneyPerFlow>,
time_slice_info: &TimeSliceInfo,
)
fn extend_selection_prices( &mut self, group_prices: &IndexMap<(CommodityID, RegionID, TimeSliceSelection), MoneyPerFlow>, time_slice_info: &TimeSliceInfo, )
Extend/update this map by applying each selection-level price to all time slices contained in that selection.
Sourcepub fn iter(
&self,
) -> impl Iterator<Item = (&CommodityID, &RegionID, &TimeSliceID, MoneyPerFlow)>
pub fn iter( &self, ) -> impl Iterator<Item = (&CommodityID, &RegionID, &TimeSliceID, MoneyPerFlow)>
Iterate over the map.
§Returns
An iterator of tuples containing commodity ID, region ID, time slice and price.
Sourcepub fn get(
&self,
commodity_id: &CommodityID,
region_id: &RegionID,
time_slice: &TimeSliceID,
) -> Option<MoneyPerFlow>
pub fn get( &self, commodity_id: &CommodityID, region_id: &RegionID, time_slice: &TimeSliceID, ) -> Option<MoneyPerFlow>
Get the price for the specified commodity for a given region and time slice
Sourcepub fn keys(
&self,
) -> Keys<'_, (CommodityID, RegionID, TimeSliceID), MoneyPerFlow>
pub fn keys( &self, ) -> Keys<'_, (CommodityID, RegionID, TimeSliceID), MoneyPerFlow>
Iterate over the price map’s keys
Sourcefn time_slice_weighted_averages(
&self,
time_slice_info: &TimeSliceInfo,
) -> HashMap<(CommodityID, RegionID), MoneyPerFlow>
fn time_slice_weighted_averages( &self, time_slice_info: &TimeSliceInfo, ) -> HashMap<(CommodityID, RegionID), MoneyPerFlow>
Calculate time slice-weighted average prices for each commodity-region pair
This method aggregates prices across time slices by weighting each price by the duration of its time slice, providing a more representative annual average.
Note: this assumes that all time slices are present for each commodity-region pair, and that all time slice lengths sum to 1. This is not checked by this method.
Sourcepub fn within_tolerance_weighted(
&self,
other: &Self,
tolerance: Dimensionless,
time_slice_info: &TimeSliceInfo,
) -> bool
pub fn within_tolerance_weighted( &self, other: &Self, tolerance: Dimensionless, time_slice_info: &TimeSliceInfo, ) -> bool
Check if time slice-weighted average prices are within relative tolerance of another price set.
This method calculates time slice-weighted average prices for each commodity-region pair and compares them. Both objects must have exactly the same set of commodity-region pairs, otherwise it will panic.
Additionally, this method assumes that all time slices are present for each commodity-region pair, and that all time slice lengths sum to 1. This is not checked by this method.
Trait Implementations§
Source§impl Clone for CommodityPrices
impl Clone for CommodityPrices
Source§fn clone(&self) -> CommodityPrices
fn clone(&self) -> CommodityPrices
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for CommodityPrices
impl Default for CommodityPrices
Source§fn default() -> CommodityPrices
fn default() -> CommodityPrices
Source§impl<'a> FromIterator<(&'a CommodityID, &'a RegionID, &'a TimeSliceID, MoneyPerFlow)> for CommodityPrices
impl<'a> FromIterator<(&'a CommodityID, &'a RegionID, &'a TimeSliceID, MoneyPerFlow)> for CommodityPrices
Source§impl IntoIterator for CommodityPrices
impl IntoIterator for CommodityPrices
Source§type Item = ((CommodityID, RegionID, TimeSliceID), MoneyPerFlow)
type Item = ((CommodityID, RegionID, TimeSliceID), MoneyPerFlow)
Source§type IntoIter = IntoIter<(CommodityID, RegionID, TimeSliceID), MoneyPerFlow>
type IntoIter = IntoIter<(CommodityID, RegionID, TimeSliceID), MoneyPerFlow>
Auto Trait Implementations§
impl Freeze for CommodityPrices
impl RefUnwindSafe for CommodityPrices
impl !Send for CommodityPrices
impl !Sync for CommodityPrices
impl Unpin for CommodityPrices
impl UnsafeUnpin for CommodityPrices
impl UnwindSafe for CommodityPrices
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more