/// <summary> /// Runs the simulation, returning the number of students who were over-exposed /// to a particular student (for simplicity, student id #1). /// </summary> public static int RunSimulationForOneStudent() { // Run the simulation (several iterations) TimekeepingDictionary <StudentPair> tkDict = new TimekeepingDictionary <StudentPair>(); for (int i = 0; i < IterationCount; i++) { RunSingleIteration(tkDict); } // Find each pair who exceeded "risky" exposure level, and count the // number of pairs which involve student #1. return(tkDict .Where(entry => entry.Value >= ExposureRiskThreshold) .Where(entry => entry.Key.GetStudentIds().Contains(1)) .Select(entry => entry.Key) .Distinct() .Count()); }
/// <summary> /// Runs the simulation, returning the number of students (not student pairs) /// whose total exposure to any other single student exceeds the specified /// CDC risk leel. /// </summary> public static int RunSimulationForAllStudents(out bool wasTrackedStudentOverexposed) { // Run the simulation (several iterations) TimekeepingDictionary <StudentPair> tkDict = new TimekeepingDictionary <StudentPair>(); for (int i = 0; i < IterationCount; i++) { RunSingleIteration(tkDict); } // Now count the number of students who exceeded risky exposure level HashSet <int> idsOfStudentsAtRisk = tkDict .Where(entry => entry.Value >= ExposureRiskThreshold) .SelectMany(entry => entry.Key.GetStudentIds()) .ToHashSet(); // Assuming we're tracking a single student (say, student id #1), // out a value stating whether this particular student was overexposed // to any other student. wasTrackedStudentOverexposed = idsOfStudentsAtRisk.Contains(1); return(idsOfStudentsAtRisk.Count); }