Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 3 additions & 35 deletions src/simulation/prices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,13 @@ pub fn calculate_prices_and_reduced_costs(

let (new_prices, reduced_costs_for_candidates) = match model.parameters.pricing_strategy {
// Use raw shadow prices and reduced costs
PricingStrategy::ShadowPrices => (
shadow_prices.with_levies(model, year),
reduced_costs_for_candidates,
),
PricingStrategy::ShadowPrices => (shadow_prices, reduced_costs_for_candidates),
// Adjust prices for scarcity and then remove this adjustment from reduced costs
PricingStrategy::ScarcityAdjusted => {
let adjusted_prices = shadow_prices
.clone()
.with_scarcity_adjustment(solution.iter_activity_duals())
.with_levies(model, year);
let unadjusted_prices = shadow_prices.with_levies(model, year);
.with_scarcity_adjustment(solution.iter_activity_duals());
Comment thread
alexdewar marked this conversation as resolved.
let unadjusted_prices = shadow_prices;
let mut reduced_costs_for_candidates = reduced_costs_for_candidates;

// Remove adjustment
Expand Down Expand Up @@ -160,34 +156,6 @@ pub fn calculate_prices_and_reduced_costs(
pub struct CommodityPrices(BTreeMap<(CommodityID, RegionID, TimeSliceID), MoneyPerFlow>);

impl CommodityPrices {
/// Add prices based on levies/incentives.
///
/// If a commodity already has a price based on the previous dual-based calculation, we choose
/// the higher of the two.
///
/// # Arguments
///
/// * `model` - The model
/// * `year` - The milestone year of interest
fn with_levies(mut self, model: &Model, year: u32) -> Self {
for (region_id, time_slice) in
iproduct!(model.iter_regions(), model.time_slice_info.iter_ids())
{
let levy_key = (region_id.clone(), year, time_slice.clone());
for commodity in model.commodities.values() {
if let Some(levy) = commodity.levies.get(&levy_key) {
let key = (commodity.id.clone(), region_id.clone(), time_slice.clone());
self.0
.entry(key)
.and_modify(|price| *price = price.max(levy.value))
.or_insert(levy.value);
}
}
}

self
}

/// Remove the impact of scarcity on prices.
///
/// # Arguments
Expand Down
12 changes: 6 additions & 6 deletions tests/data/missing_commodity/assets.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ asset_id,process_id,region_id,agent_id,commission_year,decommission_year,capacit
3,GASCGT,GBR,A0_ELC,2020,2040,2.43
4,RGASBR,GBR,A0_RES,2020,2040,2900.0
5,RELCHP,GBR,A0_RES,2020,2040,399.98
6,RBIOBL,GBR,A0_RES,2030,,355.83840587648046
6,RBIOBL,GBR,A0_RES,2030,,365.58184058764806
7,GASCGT,GBR,A0_ELC,2030,2040,0.7616137306985262
8,BIOPLL,GBR,A0_BPL,2030,,449.480091633449
9,BIOPRO,GBR,A0_BPD,2030,,448.35639140436535
10,RBIOBL,GBR,A0_RES,2040,,3655.8189696
11,BIOPLL,GBR,A0_BPL,2040,,2282.060105834934
12,BIOPRO,GBR,A0_BPD,2040,,2276.354955570347
8,BIOPLL,GBR,A0_BPL,2030,,461.7875881107132
9,BIOPRO,GBR,A0_BPD,2030,,460.6331191404365
10,RBIOBL,GBR,A0_RES,2040,,3646.0755348888324
11,BIOPLL,GBR,A0_BPL,2040,,2269.7526093576694
12,BIOPRO,GBR,A0_BPD,2040,,2264.078227834276
Loading