Population

Overview Structs

Overview Functions

Constructors

GEMS.PopulationType
Population

A Type for a simple population. Acts as a container for a collection of individuals.

Fields

  • individuals::Vector{Individual}: List of associated individuals
  • maxage: Age of the oldest individual
GEMS.PopulationMethod
Population(individuals::Vector{Individual})

Creates a Population object from a vector of Individuals.

GEMS.PopulationMethod
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.PopulationMethod
Population(path::String)

Creates a Population object from a CSV- or JLD2 file (path).

GEMS.PopulationMethod
Population(; 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!Method
add!(population::Population, individual::Individual)

Appends specified individual to a population.

Base.countMethod
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.dataframeMethod
dataframe(population::Population)

Returns a DataFrame representing the given population.

Returns

  • DataFrame with the following columns:
NameTypeDescription
idInt32Individual id
sexInt8Individual sex
ageInt8Individual age
educationInt8Individual education level
occupationInt8Individual occupation group
householdInt32Individual associated household
officeInt32Individual associated office
schoolInt32Individual associated school
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.firstMethod
first(population::Population)

Returns the first individual of the internal vector.

GEMS.get_individual_by_idMethod
get_individual_by_id(population::Population, ind::Int32)

Returns an individual contained in the Population selected by its id.

GEMS.individualsMethod
individuals(population::Population)

Return the individuals associated with the population.

Base.issubsetMethod
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.maxageMethod
maxage(population::Population)

Returns the maximum age of any individual in the population

GEMS.num_of_infectedMethod
num_of_infected(population::Population)

Returns the number of infected individuals in a given population.

GEMS.paramsMethod
params(population::Population)

Returns the parameters that were used to generate this population.

GEMS.populationfileMethod
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.saveMethod
save(population::Population, path::AbstractString)

Saves the given population as a CSV-file at path.

Base.sizeMethod
size(population::Population)

Returns the number of individuals in a given population.