public override void CalculateAdjustedFecundity( ) { var lostFecunditySum = AllGroups.Sum(x => x.LostFecundity); var totalFecunditySum = AllGroups.Sum(x => x.TotalFecundity); foreach (var group in AllGroups.Where(x => x.TotalFecundity != 0)) { var term2 = (1d - V.R) * V.Y * lostFecunditySum / totalFecunditySum; var term1 = V.R * V.Y * group.LostFecundity / group.TotalFecundity; var multiplier = 1d + term1 + term2; foreach (var individual in group) { individual.AdjustedFecundity = individual.Fecundity * multiplier; } } if (IsLoggingEnabled) { Logger.Debug("\n\nCalculate Adjusted Fecundity:\n"); foreach (var group in AllGroups) { Logger.Debug(group.ToTable( x => new { _1_Id = x.Id, _2_Qp = $"{x.PhenotypicQuality:F4}", _3_Fecundity = $"{x.Fecundity:F4}", _4_AdjustedFecundity = $"{x.AdjustedFecundity:F4}" } ) ); } } }