Skip to main content

solve_investment_order_for_year

Function solve_investment_order_for_year 

Source
fn solve_investment_order_for_year(
    graph: &CommoditiesGraph,
    commodities: &CommodityMap,
) -> Vec<MarketSet>
Expand description

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

Steps:

  1. Initialise an InvestmentGraph from the CommodityGraph for the given year, filtering to only include SVD/SED commodities (all edges between them, primary and secondary, are kept).
  2. Condense strongly connected components (cycles) into MarketSet::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 MarketSet::Layers.

Arguments:

  • graph - Commodity graph for this year, from build_commodity_graphs_for_model
  • commodities - All commodities with their types and demand specifications

ยงReturns

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