Пример #1
0
        internal static TravelMatrix LoadFromCsv(string fileName)
        {
            var matrixEntries = LoadMatrixEntries(fileName);

            var travelMatrix = new TravelMatrix();

            foreach (var record in matrixEntries)
            {
                travelMatrix.AddEntry(record);
            }

            return(travelMatrix);
        }
Пример #2
0
        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);
                    }
                }
            }
        }