public Ward(WardRecord ward, string areaType, CovidPopulation environment, CovidSimulation simulation) : base(ward.WardId.ToString(), ward.WardId.ToString(), areaType, environment) { WardRecord = ward; WardId = ward.WardId; OwnerSimulation = simulation; CovidEnvironment = environment; }
public void AddContacts(CovidPopulation populationDynamics) { for (var i = 0; i < Members.Count; i++) { var agent1 = Members[i]; for (var j = i + 1; j < Members.Count; j++) { var agent2 = Members[j]; if (agent1 == agent2) { throw new Exception("This would create a self loop!"); } populationDynamics.AddConnection(agent1, agent2, ContactSetting.Home); } } }
public void GenerateGraph(CovidPopulation populationDynamics, IEnumerable <Ward> localAreas, TravelMatrix travelMatrix, ContactMatrix contactMatrix, IRandomProvider random) { var allAgents = populationDynamics.EnumeratePopulation(); foreach (var agent in allAgents) { var travelWardId = travelMatrix.RandomDestination(agent.WardId, random); var destinationWard = localAreas.First(p => p.WardId == travelWardId); var potentialContacts = populationDynamics.OtherAgentsInArea(destinationWard, agent.HouseHold.Members); if (potentialContacts.Count > 0) { var p = contactMatrix.ContactWeightedAgentList(potentialContacts, populationDynamics, agent); var numberOfContacts = contactMatrix.SampleNoOfContacts(agent, random); var selected = CovidPopulation.SampleWeightedAgents(potentialContacts, p, numberOfContacts, random); foreach (var contact in selected) { populationDynamics.AddConnection(agent.Id, contact, ContactSetting.Other); } } } }