Skip to content

Commit 3088fb5

Browse files
committed
Ignore secondary outputs when adjusting demand profiles
1 parent 07f1f53 commit 3088fb5

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/simulation/investment.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ fn flatten_preset_demands_for_year(
189189
}
190190

191191
/// Update demand map with flows from a set of assets
192+
///
193+
/// Non-primary output flows are ignored. This way, demand profiles aren't affected by production
194+
/// of side-products from other assets. The result is that all commodity demands must be met by
195+
/// assets with that commodity as their primary output. Effectively, agents do not see production of
196+
/// side-products from other assets when making investment decisions.
197+
///
198+
/// TODO: this is a very flawed approach. The proper solution might be for agents to consider
199+
/// multiple commodities simultaneously, but that would require substantial work to implement.
192200
fn update_demand_map(demand: &mut AllDemandMap, flows: &FlowMap, assets: &[AssetRef]) {
193201
for ((asset, commodity_id, time_slice), flow) in flows {
194202
if assets.contains(asset) {
@@ -198,6 +206,15 @@ fn update_demand_map(demand: &mut AllDemandMap, flows: &FlowMap, assets: &[Asset
198206
time_slice.clone(),
199207
);
200208

209+
// Only consider output flows from the primary commodity
210+
if flow > &Flow(0.0)
211+
&& asset
212+
.primary_output()
213+
.is_some_and(|p| &p.commodity.id != commodity_id)
214+
{
215+
continue;
216+
}
217+
201218
// Note: we use the negative of the flow as input flows are negative in the flow map.
202219
demand
203220
.entry(key)

0 commit comments

Comments
 (0)