pub fn build_and_validate_commodity_graphs_for_model(
processes: &ProcessMap,
commodities: &CommodityMap,
region_ids: &IndexSet<RegionID>,
years: &[u32],
time_slice_info: &TimeSliceInfo,
) -> Result<HashMap<(RegionID, u32), Vec<CommodityID>>>
Expand description
Builds and validates commodity graphs for the entire model.
This function creates commodity flow graphs for each region/year combination in the model, validates the graph structure against commodity type rules, and determines the optimal investment order for commodities.
The validation process checks three time slice levels:
- Annual: Validates annual-level commodities and processes
- Seasonal: Validates seasonal-level commodities and processes for each season
- Day/Night: Validates day/night-level commodities and processes for each time slice
§Arguments
processes
- All processes in the model with their flows and activity limitscommodities
- All commodities with their types and demand specificationsregion_ids
- Collection of regions to modelyears
- Years to analysetime_slice_info
- Time slice configuration (seasons, day/night periods)
§Returns
A map from (region, year)
to the ordered list of commodities for investment decisions. The
ordering ensures that leaf-node commodities (those with no outgoing edges) are solved first.
§Errors
Returns an error if:
- Any commodity graph contains cycles
- Commodity type rules are violated (e.g., SVD commodities being consumed)
- Demand cannot be satisfied