File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ use indexmap::IndexMap;
1414use itertools:: { Itertools , chain} ;
1515use log:: debug;
1616use std:: cmp:: Ordering ;
17- use std:: collections:: HashMap ;
17+ use std:: collections:: { HashMap , HashSet } ;
1818use std:: fmt:: Display ;
1919
2020pub 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,
You can’t perform that action at this time.
0 commit comments