Population
Overview Structs
Overview Functions
Base.count
Base.first
Base.issubset
Base.size
GEMS.add!
GEMS.dataframe
GEMS.each!
GEMS.get_individual_by_id
GEMS.individuals
GEMS.maxage
GEMS.num_of_infected
GEMS.params
GEMS.populationfile
GEMS.remove!
GEMS.save
Constructors
GEMS.Population
— TypePopulation
A 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 individual
GEMS.Population
— MethodPopulation(individuals::Vector{Individual})
Creates a Population
object from a vector of Individual
s.
GEMS.Population
— MethodPopulation(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
— MethodPopulation(path::String)
Creates a Population
object from a CSV- or JLD2 file (path).
GEMS.Population
— MethodPopulation(; n::Int64 = 100_000, avg_household_size::Int64 = 3, avg_office_size::Int64 = 5, avg_school_size::Int64 = 100)
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::Int64 = 3
(optional): Average size of households (default =3
)avg_office_size::Int64 = 5
(optional): Average size of offices (default =5
)avg_school_size::Int64 = 100
(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!
— Methodadd!(population::Population, individual::Individual)
Appends specified individual to a population.
Base.count
— Methodcount(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
— Methoddataframe(population::Population)
Returns a DataFrame representing the given population.
Returns
DataFrame
with the following columns:
Name | Type | Description |
---|---|---|
id | Int32 | Individual id |
sex | Int8 | Individual sex |
age | Int8 | Individual age |
education | Int8 | Individual education level |
occupation | Int8 | Individual occupation group |
household | Int32 | Individual associated household |
office | Int32 | Individual associated office |
school | Int32 | Individual associated school |
GEMS.each!
— Functioneach!(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
— Methodfirst(population::Population)
Returns the first individual of the internal vector.
GEMS.get_individual_by_id
— Methodget_individual_by_id(population::Population, ind::Int32)
Returns an individual contained in the Population
selected by its id
.
GEMS.individuals
— Methodindividuals(population::Population)
Return the individuals associated with the population.
Base.issubset
— Methodissubset(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
— Methodmaxage(population::Population)
Returns the maximum age of any individual in the population
GEMS.num_of_infected
— Methodnum_of_infected(population::Population)
Returns the number of infected individuals in a given population.
GEMS.params
— Methodparams(population::Population)
Returns the parameters that were used to generate this population.
GEMS.populationfile
— Methodpopulationfile(population::Population)
Returns the population file that was used to generate this population.
GEMS.remove!
— Methodremove!(population::Population, individual::Individual)
Remove a specified individual from a population.
GEMS.save
— Methodsave(population::Population, path::AbstractString)
Saves the given population as a CSV-file at path
.
Base.size
— Methodsize(population::Population)
Returns the number of individuals in a given population.