private static bool IsDiscernablyDifferent(ScenarioMetricsResultModel a, ScenarioMetricsResultModel b, KPIComparisonConfig KPIComparison) { return(Math.Abs( a.GetKPIValue(KPIComparison.KPIName).Value - b.GetKPIValue(KPIComparison.KPIName).Value) < KPIComparison.DiscernibleDifference); }
private static List <List <ScenarioMetricsResultModel> > GroupByDiscernableDifference(List <ScenarioMetricsResultModel> results, KPIComparisonConfig KPIComparison) { var resultGroups = new List <List <ScenarioMetricsResultModel> >(); var currentGroup = new List <ScenarioMetricsResultModel>(); resultGroups.Add(currentGroup); results.ForEach(item => { if (currentGroup.Count() == 0 || IsDiscernablyDifferent(currentGroup.First(), item, KPIComparison)) { currentGroup.Add(item); } else { currentGroup = new List <ScenarioMetricsResultModel>(); resultGroups.Add(currentGroup); currentGroup.Add(item); } }); return(resultGroups); }