@@ -199,6 +199,20 @@ impl CommodityPrices {
199199 }
200200 }
201201
202+ /// Extend this map by applying each selection-level price to all time slices
203+ /// contained in that selection.
204+ fn extend_selection_prices (
205+ & mut self ,
206+ group_prices : & IndexMap < ( CommodityID , RegionID , TimeSliceSelection ) , MoneyPerFlow > ,
207+ time_slice_info : & TimeSliceInfo ,
208+ ) {
209+ for ( ( commodity_id, region_id, selection) , & selection_price) in group_prices {
210+ for ( time_slice_id, _) in selection. iter ( time_slice_info) {
211+ self . insert ( commodity_id, region_id, time_slice_id, selection_price) ;
212+ }
213+ }
214+ }
215+
202216 /// Iterate over the map.
203217 ///
204218 /// # Returns
@@ -377,20 +391,6 @@ fn add_scarcity_adjusted_prices<'a, I>(
377391 }
378392}
379393
380- /// Extend an existing commodity/region/time-slice price map by applying each
381- /// selection-level price to all time slices within that selection.
382- fn extend_selection_prices (
383- prices : & mut CommodityPrices ,
384- group_prices : & IndexMap < ( CommodityID , RegionID , TimeSliceSelection ) , MoneyPerFlow > ,
385- time_slice_info : & TimeSliceInfo ,
386- ) {
387- for ( ( commodity_id, region_id, selection) , & selection_price) in group_prices {
388- for ( time_slice_id, _) in selection. iter ( time_slice_info) {
389- prices. insert ( commodity_id, region_id, time_slice_id, selection_price) ;
390- }
391- }
392- }
393-
394394/// Calculate marginal cost prices for a set of commodities and add to an existing prices map.
395395///
396396/// This pricing strategy aims to incorporate the marginal cost of commodity production into the price.
@@ -572,7 +572,7 @@ fn add_marginal_cost_prices<'a, I, J>(
572572 all_group_prices. extend ( cand_group_prices) ;
573573
574574 // Expand selection-level prices to individual time slices and add to the main prices map
575- extend_selection_prices ( existing_prices , & all_group_prices, time_slice_info) ;
575+ existing_prices . extend_selection_prices ( & all_group_prices, time_slice_info) ;
576576}
577577
578578/// Calculate annual activities for each asset by summing across all time slices
@@ -809,7 +809,7 @@ fn add_full_cost_prices<'a, I, J>(
809809 all_group_prices. extend ( cand_group_prices) ;
810810
811811 // Expand selection-level prices to individual time slices and add to the main prices map
812- extend_selection_prices ( existing_prices , & all_group_prices, time_slice_info) ;
812+ existing_prices . extend_selection_prices ( & all_group_prices, time_slice_info) ;
813813}
814814
815815#[ cfg( test) ]
0 commit comments