muse2/simulation/
investment.rs

1//! Code for performing agent investment.
2use super::optimisation::Solution;
3use super::CommodityPrices;
4use crate::asset::AssetPool;
5use crate::model::Model;
6use log::info;
7use std::collections::HashSet;
8
9/// Perform agent investment to determine capacity investment of new assets for next milestone year.
10///
11/// # Arguments
12///
13/// * `model` - The model
14/// * `solution` - The solution to the dispatch optimisation
15/// * `prices` - Commodity prices
16/// * `assets` - The asset pool
17pub fn perform_agent_investment(
18    _model: &Model,
19    solution: &Solution,
20    _prices: &CommodityPrices,
21    assets: &mut AssetPool,
22) {
23    info!("Performing agent investment...");
24
25    let mut assets_to_keep = HashSet::new();
26    for (asset_id, _commodity_id, _time_slice, _flow) in solution.iter_commodity_flows_for_assets()
27    {
28        if assets.get(asset_id).is_none() {
29            // Asset has been decommissioned
30            continue;
31        }
32
33        // **TODO**: Implement agent investment. For now, just keep all assets.
34        assets_to_keep.insert(asset_id);
35    }
36
37    // Decommission non-selected assets
38    assets.retain(&assets_to_keep);
39}