@@ -628,29 +628,35 @@ fn warn_on_equal_appraisal_outputs(
628628 commodity_id : & CommodityID ,
629629 region_id : & RegionID ,
630630) {
631- // Get all the outputs which are equal to the one after
632- let asset_details = outputs
631+ if outputs. is_empty ( ) {
632+ return ;
633+ }
634+
635+ // Count the number of identical (or nearly identical) appraisal outputs
636+ let num_identical = outputs[ 1 ..]
633637 . iter ( )
634- . tuple_windows ( )
635- . take_while ( |( a, b) | a. compare_metric ( b) . is_eq ( ) )
636- . map ( |( output, _) | {
637- let asset = & output. asset ;
638- format ! (
639- "Process id: '{}' (State: {}{}, Commission year: {})" ,
640- asset. process_id( ) ,
641- asset. state( ) ,
642- asset
643- . id( )
644- . map( |id| format!( ", Asset id: {id}" ) )
645- . unwrap_or_default( ) ,
646- asset. commission_year( )
647- )
648- } )
649- . join ( ", " ) ;
638+ . take_while ( |output| outputs[ 0 ] . compare_metric ( output) . is_eq ( ) )
639+ . count ( ) ;
650640
651- if !asset_details. is_empty ( ) {
641+ if num_identical > 0 {
642+ let asset_details = outputs[ ..=num_identical]
643+ . iter ( )
644+ . map ( |output| {
645+ let asset = & output. asset ;
646+ format ! (
647+ "Process ID: '{}' (State: {}{}, Commission year: {})" ,
648+ asset. process_id( ) ,
649+ asset. state( ) ,
650+ asset
651+ . id( )
652+ . map( |id| format!( ", Asset ID: {id}" ) )
653+ . unwrap_or_default( ) ,
654+ asset. commission_year( )
655+ )
656+ } )
657+ . join ( ", " ) ;
652658 debug ! (
653- "Found equally good appraisals for Agent id : {agent_id}, Commodity: '{commodity_id}', \
659+ "Found equally good appraisals for Agent ID : {agent_id}, Commodity: '{commodity_id}', \
654660 Region: {region_id}. Options: [{asset_details}]. Selecting first option.",
655661 ) ;
656662 }
0 commit comments