CollateThreadOutputToSmoothOutput( SmoothOutput smoothOutput, ConcurrentBag <SmoothBatchOutput> batchAllThreadOutputCollection) { var spotIdsUsed = new HashSet <Guid>(); var spotIdsNotUsed = new HashSet <Guid>(); foreach (var batch in batchAllThreadOutputCollection) { batch.UnusedSpotIds.CopyDistinctTo(spotIdsNotUsed); batch.UsedSpotIds.CopyDistinctTo(spotIdsUsed); foreach (KeyValuePair <int, SmoothOutputForPass> item in batch.OutputByPass) { var(smoothPassSequence, passOutput) = (item.Key, item.Value); if (smoothOutput.OutputByPass.ContainsKey(smoothPassSequence)) { smoothOutput.OutputByPass[smoothPassSequence].CountSpotsSet += passOutput.CountSpotsSet; } else { var smoothPassOutput = new SmoothOutputForPass(passOutput.PassSequence) { CountSpotsSet = passOutput.CountSpotsSet }; smoothOutput.OutputByPass.Add(smoothPassSequence, smoothPassOutput); } } foreach (KeyValuePair <int, int> item in batch.SpotsByFailureMessage) { var(messageId, count) = (item.Key, item.Value); if (smoothOutput.SpotsByFailureMessage.ContainsKey(messageId)) { smoothOutput.SpotsByFailureMessage[messageId] += count; } else { smoothOutput.SpotsByFailureMessage.Add(messageId, count); } } smoothOutput.BookedSpotsUnplacedDueToRestrictions += batch.BookedSpotsUnplacedDueToRestrictions; smoothOutput.Breaks += batch.Breaks; smoothOutput.Failures += batch.Failures; smoothOutput.Recommendations += batch.Recommendations; smoothOutput.SpotsNotSetDueToExternalCampaignRef += batch.SpotsNotSetDueToExternalCampaignRef; smoothOutput.SpotsSetAfterMovingOtherSpots += batch.SpotsSetAfterMovingOtherSpots; smoothOutput.SpotsSet += batch.SpotsSet; } return(spotIdsUsed, spotIdsNotUsed); }
/// <summary> /// Appends figures to this /// </summary> /// <param name="smoothOutput"></param> public void Append(SmoothOutput smoothOutput) { Breaks += smoothOutput.Breaks; Recommendations += smoothOutput.Recommendations; SpotsNotSet += smoothOutput.SpotsNotSet; SpotsSet += smoothOutput.SpotsSet; SpotsNotSetDueToExternalCampaignRef += smoothOutput.SpotsNotSetDueToExternalCampaignRef; SpotsSetAfterMovingOtherSpots += smoothOutput.SpotsSetAfterMovingOtherSpots; BookedSpotsUnplacedDueToRestrictions += smoothOutput.BookedSpotsUnplacedDueToRestrictions; BreaksWithReducedOptimizerAvailForUnplacedSpots += smoothOutput.BreaksWithReducedOptimizerAvailForUnplacedSpots; Failures += smoothOutput.Failures; // Append pass counts foreach (var passSequence in smoothOutput.OutputByPass.Keys) { int outputCountSpotsSet = smoothOutput.OutputByPass[passSequence].CountSpotsSet; if (OutputByPass.ContainsKey(passSequence)) { OutputByPass[passSequence].CountSpotsSet += outputCountSpotsSet; } else { var outputForPass = new SmoothOutputForPass(passSequence) { CountSpotsSet = outputCountSpotsSet }; OutputByPass.Add(passSequence, outputForPass); } } // Append count of spots by failure message if (SpotsByFailureMessage is null) { SpotsByFailureMessage = new Dictionary <int, int>(); } foreach (int failureMessageId in smoothOutput.SpotsByFailureMessage.Keys) { int value = smoothOutput.SpotsByFailureMessage[failureMessageId]; if (SpotsByFailureMessage.ContainsKey(failureMessageId)) { SpotsByFailureMessage[failureMessageId] += value; } else { SpotsByFailureMessage.Add(failureMessageId, value); } } }