Skip to content

Commit 195c94c

Browse files
authored
Merge pull request #1092 from EnergySystemsModellingLab/appraisal_groups
Limit appraisal to one unit per group
2 parents 2ab6626 + dd6a3f7 commit 195c94c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/simulation/investment.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use indexmap::IndexMap;
1414
use itertools::{Itertools, chain};
1515
use log::debug;
1616
use std::cmp::Ordering;
17-
use std::collections::HashMap;
17+
use std::collections::{HashMap, HashSet};
1818
use std::fmt::Display;
1919

2020
pub mod appraisal;
@@ -703,6 +703,10 @@ fn select_best_assets(
703703
&commodity.id
704704
);
705705

706+
// Since all assets with the same `group_id` are identical, we only need to appraise one
707+
// from each group.
708+
let mut seen_groups = HashSet::new();
709+
706710
// Appraise all options
707711
let mut outputs_for_opts = Vec::new();
708712
for asset in &opt_assets {
@@ -715,6 +719,13 @@ fn select_best_assets(
715719
max_capacity.min(remaining_capacity)
716720
});
717721

722+
// Skip any assets from groups we've already seen
723+
if let Some(group_id) = asset.group_id()
724+
&& !seen_groups.insert(group_id)
725+
{
726+
continue;
727+
}
728+
718729
let output = appraise_investment(
719730
model,
720731
asset,

0 commit comments

Comments
 (0)