InstituteforDiseaseModeling / covasim

COVID-19 Agent-based Simulator (Covasim): a model for exploring coronavirus dynamics and interventions
https://covasim.org
MIT License
255 stars 224 forks source link

Add Aggregate Population to population.py #332

Closed edwardtang12 closed 3 years ago

edwardtang12 commented 3 years ago

Please note: this PR is part of a school project.

Why?

Covasim must instantiate and manage a population of people, where the people are from the module people.py. The module population.py serves this purpose, but it consists of a number of functions in the module that are called directly by the user when initializing the Covasim simulation.

In choosing an aggregate, we observe a sort of “has-a” relationship between a population (which is initialized with certain demographic patterns) and the people within it; a person can belong to a population group, but their lifecycle is not bound to it. This is the foundation for an aggregate Population.

Description of Changes

This PR implements a Population aggregate in population.py, creating a Population class responsible for generating a population of People. Now, the Population aggregate can be instantiated with given parameters, and the people are stored as a field. For example, in the Sim class in sim.py, the initialization of people in init_people now creates the Population aggregate and accesses the people through the aggregate root, the people field.