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:
- Initialise an
InvestmentGraphfrom the set of originalCommodityGraphs for the given year, filtering to only include SVD/SED commodities and primary edges.CommodityGraphs from all regions are combined into a singleInvestmentGraph. 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. - Condense strongly connected components (cycles) into
InvestmentSet::Cyclenodes. - Perform a topological sort on the condensed graph.
- 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 frombuild_commodity_graphs_for_modelcommodities- All commodities with their types and demand specificationsyear- 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.