Population
Overview Structs
Overview Functions
Base.countBase.firstBase.issubsetBase.sizeGEMS.add!GEMS.dataframeGEMS.each!GEMS.get_individual_by_idGEMS.individualsGEMS.maxageGEMS.num_of_infectedGEMS.paramsGEMS.populationfileGEMS.remove!GEMS.save
Constructors
GEMS.Population — Type
PopulationA Type for a simple population. Acts as a container for a collection of individuals.
Fields
individuals::Vector{Individual}: List of associated individualsmaxage: Age of the oldest individualminid: smallest id of any individualmaxid: largest id of any individual
GEMS.Population — Method
Population(individuals::Vector{Individual})Creates a Population object from a vector of Individuals.
GEMS.Population — Method
Population(df::DataFrame)Creates a Population object from a DataFrame where each row corresponds to one individual. The dataframe column names must correspond to the fieldnames of the Individual struct. id (Int32), age (Int8), and sex (Int8) are required columns. Everything else is optional.
GEMS.Population — Method
Population(path::String)Creates a Population object from a CSV- or JLD2 file (path).
GEMS.Population — Method
Population(; n::Int64 = 100_000, avg_household_size::Real = 3.0, avg_office_size::Real = 5.0, avg_school_size::Real = 100.0)Creates a Population object without an explicit data source and randomly generates the individuals.
Parameters
n::Int64 = 100_000(optional): Number of individuals in the population (default =100_000)avg_household_size::Real = 3.0(optional): Average size of households (default =3)avg_office_size::Real = 5.0(optional): Average size of offices (default =5)avg_school_size::Real = 100.0(optional): Average size of schools (default =100)empty::Bool = false(optional): If true, overrides all other arguments and returns a completely empty population object
Functions
GEMS.add! — Method
add!(population::Population, individual::Individual)Appends specified individual to a population.
Base.count — Method
count(f, population::Population)Counts the occurences where the boolean expression f returns true when applied to an individual in the population.
Example
count(x -> age(x) < 20, pop) returns the number of individuals in the population model pop who are younger than 20 years.
GEMS.dataframe — Method
dataframe(population::Population)Returns a DataFrame representing the given population. If the population carries individual extensions (i.e. the individuals' boxed extensions are not nothing), the extension fields are appended as additional columns after the base columns. The extension schema is taken from the first individual that has extensions (populations are assumed homogeneous).
Returns
DataFramewith the following columns:
| Name | Type | Description |
|---|---|---|
id | Int32 | Individual id |
sex | Int8 | Individual sex |
age | Int8 | Individual age |
number_of_vaccinations | Int16 | Number of vaccinations received |
vaccination_tick | Int32 | Tick of last vaccination |
education | Int8 | Individual education level |
occupation | Int16 | Individual occupation group |
household | Int32 | Individual associated household |
office | Int32 | Individual associated office |
schoolclass | Int32 | Individual associated school class |
<extension fields> | (varies) | Any fields stored in Individual.extensions, appended dynamically |
GEMS.each! — Function
each!(f, population::Population)Applies function f to all individuals in the population.
Example
each!(i -> i.age = i.age + 1, pop) lets all individuals in the populaiton pop age by one year.
Base.first — Method
first(population::Population)Returns the first individual of the internal vector.
GEMS.get_individual_by_id — Method
get_individual_by_id(population::Population, ind::Int32)Returns an individual contained in the Population selected by its id.
GEMS.individuals — Method
individuals(population::Population)Return the individuals associated with the population.
Base.issubset — Method
issubset(individuals_a::Vector{Individual}, individuals_b::Vector{Individual})Checks whether a vector of individuals A is a subset of individuals B based on the individual's IDs. Does only work if all individuals have unique IDs.
GEMS.maxage — Method
maxage(population::Population)Returns the maximum age of any individual in the population
GEMS.num_of_infected — Method
num_of_infected(population::Population)Returns the number of infected individuals in a given population.
GEMS.params — Method
params(population::Population)Returns the parameters that were used to generate this population.
GEMS.populationfile — Method
populationfile(population::Population)Returns the population file that was used to generate this population.
GEMS.remove! — Method
remove!(population::Population, individual::Individual)Remove a specified individual from a population.
GEMS.save — Method
save(population::Population, path::AbstractString)Saves the given population as a CSV-file at path.
Base.size — Method
size(population::Population)Returns the number of individuals in a given population.