Skip to main content

compute_unmet_demand

Function compute_unmet_demand 

Source
fn compute_unmet_demand(
    demand: &DemandMap,
    activity: &IndexMap<TimeSliceID, Activity>,
    commodity: &Commodity,
    asset: &AssetRef,
    time_slice_info: &TimeSliceInfo,
) -> DemandMap
Expand description

Computes remaining unmet demand per time slice after a solve.

For each time-slice selection at the commodity’s balance level, the selection-level residual (demand_total - supply_total, clamped to zero) is divided equally across the time slices in the selection.

The exact per-time-slice distribution is arbitrary: all downstream consumers sum values back up to the selection level before using them (e.g. the next round’s demand constraint, and is_any_remaining_demand), so only the selection-level total needs to be correct.