solve_investment_order_for_year

Function solve_investment_order_for_year 

Source
fn solve_investment_order_for_year(
    graphs: &IndexMap<(RegionID, u32), CommoditiesGraph>,
    commodities: &CommodityMap,
    year: u32,
) -> Vec<InvestmentSet>
Expand description

Analyse the commodity graphs for a given year to determine the order in which investment decisions should be made.

Steps:

  1. Initialise an InvestmentGraph from the set of original CommodityGraphs for the given year, filtering to only include SVD/SED commodities and primary edges. CommodityGraphs from all regions are combined into a single InvestmentGraph. TODO: at present there can be no edges between regions; in future we will want to implement trade as edges between regions, but this will have no impact on the following steps.
  2. Condense strongly connected components (cycles) into InvestmentSet::Cycle nodes.
  3. Perform a topological sort on the condensed graph.
  4. Compute layers for investment based on the topological order, grouping independent sets into InvestmentSet::Layers.

Arguments:

  • graphs - Commodity graphs for each region and year, outputted from build_commodity_graphs_for_model
  • commodities - All commodities with their types and demand specifications
  • year - The year to solve the investment order for

ยงReturns

A Vec of InvestmentSets in the order they should be solved, with cycles grouped into InvestmentSet::Cycles and independent sets grouped into InvestmentSet::Layers.