select_assets_for_cycle

Function select_assets_for_cycle 

Source
fn select_assets_for_cycle(
    model: &Model,
    markets: &[(CommodityID, RegionID)],
    year: u32,
    demand: &IndexMap<(CommodityID, RegionID, TimeSliceID), Flow>,
    existing_assets: &[AssetRef],
    prices: &CommodityPrices,
    seen_markets: &[(CommodityID, RegionID)],
    previously_selected_assets: &[AssetRef],
    writer: &mut DataWriter,
) -> Result<Vec<AssetRef>>
Expand description

Iterates through the a pre-ordered set of markets forming a cycle, selecting assets for each market in turn.

Dispatch optimisation is performed after each market is visited to rebalance demand. While dispatching, newly selected (Selected) assets are given flexible capacity (bounded by capacity_margin) so small demand shifts caused by later markets can be absorbed. After all markets have been visited once, the final set of assets is returned, applying any capacity adjustments from the final full-system dispatch optimisation.

Dispatch may fail at any point if new demands are encountered for previously visited markets, and the capacity_margin is not sufficient to absorb the demand shift. At this point, the simulation is terminated with an error prompting the user to increase the capacity_margin. A longer-term solution (TODO) may be to trigger re-investment for the affected markets. Other yet-to-implement features may also help to stabilise the cycle, such as capacity growth limits.