Configuration Files

The pandemia configuration file is a yaml file. An annotated example is shown below.

The example given is of the Heterogeneous Mixing scenerio with interventions. The user can create a new example by making a copy of one of the yaml files provided, before editing the values contained within. The configuration files are divided into sections, reflecting the structure of the Pandemia model.

Basic Parameters

######################################

# [KEY PARAMETER] Scale factor. This rescales the number of individuals, locations, and other
# relevant quantities appearing in the world and simulation components.
scale_factor: 0.0005
# Profiler. If True then performance data is saved in a file called profiler_output. The parameter
# pstats_records determines how many lines to print in the profiler report.
profile: False
pstats_records: 100
# [KEY PARAMETER] Random seed. Pandemia is stochastic and therefore requires a random seed.
random_seed: 1
# Parallel processing. The parameter num_jobs sets the maximum number of CPUs to used by the
# simulator. If num_jobs < 1 then this maximum is os.cpu_count().
enable_parallel: True
num_jobs: -1

# ########################################

Clock

#################################################

# Length of time step, in seconds. Must divide the day length (86400 seconds).
tick_length_s: 28800
# [KEY PARAMETER] Length of the simulation, in days.
simulation_length_days: 365
# [KEY PARAMETER] The date on which the simulation starts.
epoch: 1st January 2020

# ########################################

World

#################################################

# The Pandemia simulator acts on a world. The world consists of regions, with each region consisting
# of individuals, locations and activities. The world additionally consists of a travel matrix,
# indicating how many individuals travel from each region to each other region each day. The world
# is built using a world factory. The choice of world factory, and its configuration, are made here.

world_factory:
  # The HeterogeneousWorldFactory builds a world consisting of, at most, around two hundred regions,
  # with each region representing a real-world country. The recommended scale factor is therefore
  # 0.0005. It implements a simple model of hetergeneous mixing, based on average household size and
  # population density grids.
  __type__: heterogeneous_world_factory.HeterogeneousWorldFactory
  # The time discretization (should match with tick_length_s)
  ticks_in_day_world: 3
  # [KEY PARAMETER] This world factory is stochastic, and therefore gets its own random seed.
  random_seed: 1
  # Filepath to country data, including age structure and population sizes. The actual number of
  # agents is given by multiplying this data by the scale_factor.
  regions_data_file:
    Scenarios/Heterogeneous/data/country_data.csv
  # Filepath to shapefiles for the regions, used for rendering and calculating country adjacency.
  regions_shape_data_file:
    Scenarios/Heterogeneous/data/country_data_shapefiles/CNTR_RG_60M_2020_4326.shp
  # Filepath to population density grids for each country.
  population_dist_data_folder:
    Scenarios/Heterogeneous/data/country_data_population_distribution/processed/density_grids
  # Filepath to grids for each country indicating which grid squares belong to each country, even if
  # not populated, for rendering purposes.
  population_id_data_folder:
    Scenarios/Heterogeneous/data/country_data_population_distribution/processed/id_grids
  # [KEY PARAMETER] Regions to simulate. If list empty, simulates all regions.
  regions_to_simulate: [] # ['KP', 'KR'] # ['FR', 'BE', 'LU', 'DE', 'GB', 'NL', 'IE']
  # There are two locations types, House and Square. A Square refers to a square in the grid data.
  house_location_type: House
  square_location_type: Square
  # There are two activities, Home_Activity and Community_Activity. Individuals perform the
  # Home_Activity in their assigned House, while they perform the Community_Activity in randomly
  # selected grid squares, with the random selection being weighted by distance. Individuals
  # above or below certain ages do not perform the Community_Activity. Those who do perform the
  # Community_Activity do so for 8 hours each weekday, between 8am and 4pm.
  home_activity: Home_Activity
  community_activity: Community_Activity
  min_age_community_activity: 4
  max_age_community_activity: 64
  # When performing Community_Activity, each individual gets this many grid squares to choose from.
  # The grid square containing their House is always included in this list.
  num_locs_for_community_activity: 10
  # The list of grid squares for each individual is obtained by sampling from a subset of all
  # such squares in the region. The subset contains the local_sample_size squares nearest their
  # House, in addition to nonlocal_sample_size squares randomly sampled from all over the region.
  # Then num_locs_for_community_activity square are randomly sampled from this subet.
  local_sample_size: 500
  nonlocal_sample_size: 500
  # For an individual with House in Square1, the weight attached to a Square2 is given by the
  # gravity model formula:
  #   weight = population_size(Square2) / (1 + distance(Square1, Square2)^gamma)
  # where gamma = gravity_model_exponent.
  gravity_model_exponent: 0.5
  # Individuals travel between regions either by air or not. If not, then travel is between adjacent
  # regions, with this parameter determining the proportion of each population travelling to
  # adjacent regions each day.
  local_travel_prob_per_day: 0.0
  # This is used to determine region adjacency, in the units of the shape file.
  distance_threshold: 10
  # The number of individuals travelling by air is configured using data. These are the filepaths:
  airport_data_file: Scenarios/Heterogeneous/data/airport_data.csv
  air_travel_data_file: Scenarios/Heterogeneous/data/air_travel_data.csv

# ########################################

Models Components

######################################

seasonal_effects_model:
  # The seasonal effects component of the Pandemia simulator can be used to configure monthly
  # updates to parameter values, for example the regional transmission multipliers. The
  # DefaultSeasonalEffectsModel calculates a transmission multiplier for each country for each
  # month. The default value of the multiplier is 1.0, meaning no reduction in transmission. The
  # alternative value is set by the parameter out_of_season_multiplier.
  __type__: default_seasonal_effects_model.DefaultSeasonalEffectsModel
  # Filepath to seasonal influenza data for each country.
  seasonal_multiplier_by_region_by_month: Scenarios/Homogeneous/data/country_data_seasonality.csv
  # [KEY PARAMETER] Outside of flu season, transmission probabilities are multiplied by this value.
  out_of_season_multiplier: 0.75

# ######################################### Health #################################################

health_model:
  # The DefaultHealthModel represents the health of an individual using five attributes:
  #  - strain (-1 if uninfected, else equal to the index of the strain)
  #  - disease (between 0 and 1, with 1 being dead)
  #  - infectiousness (0 if not infectious, else > 0)
  #  - sigma immunity (protection against infection)
  #  - rho immunity (protection against severe outcomes)
  # The immune system is represented using layers, with the outer layer (sigma immunity) determining
  # whether or not an infection is blocked, and the inner layers (rho immunity) determining the
  # severity of the outcome for infections that are not blocked.
  __type__: default_health_model.DefaultHealthModel
  # The number of strains of the pathogen.
  number_of_strains: 1
  # [KEY PARAMETER] Control parameters determining the transmission probability of each strain each
  # tick. This list should be of length equal to the number of strains.
  beta: [0.035]
  # A square matrix, whose rows should be probability vectors, indicating the probability of each
  # strain mutating into each other strain at the moment of infection.
  mutation_matrix: [[1.0]]
  # [KEY PARAMETER] A dictionary pairing region names to lists. These list should be of length equal
  # to the number of strains. The numbers in these lists indicate how many initial infections there
  # should for each strain in the indicated region.
  num_initial_infections_by_region_by_strain:
    'CN': [500000]
  # A dictionary pairing location types to location transmission multipliers. Can be null, in which
  # case all location transmission multiplier are 1.0.
  location_typ_multipliers:
    Square: 0.2
    House: 1.0
  # The proportion of infectious material able to pass through a face mask. For a perfect face mask,
  # this parameter would be 0.0. For a face mask with zero effectiveness, it would be 1.0.
  facemask_transmission_multiplier: 0.1
  # Immunity is not updated daily, but on a cycle of this length. Reducing this parameter decreases
  # performance.
  immunity_period_days: 30
  # [KEY PARAMETER] Filepaths to data recording, for each country and each strain, pre-existing
  # levels of sigma and rho immunity, and control parameters that multiply the numbers found in this
  # data (if provided).
  country_data_sigma_immunity_fp:
    Scenarios/Heterogeneous/data/immunity_data/country_data_sigma_immunity.csv
  country_data_rho_immunity_fp:
    Scenarios/Heterogeneous/data/immunity_data/country_data_rho_immunity.csv
  preexisting_sigma_multiplier: 0.5
  preexisting_rho_multiplier: 0.5
  # Each agent is assigned a health preset, describing how they will respond to an infection should
  # one occur. To each preset is associated a number of layers. Each layer encodes step functions
  # describing how the five health attributes change over time following an infection. See the
  # Health section of the User Guide for more details.
  health_presets:
    preset_0: # Preset name
      0: # Preset layer
        rho_immunity_failure:
          [[[[-1, 15, 30, 90, 180], [[1.0, 0.0], [1.0, 0.0], [1.0, 0.0], [1.0, 0.0], [1.0, 0.0]]]]]
        sigma_immunity_failure:
          [[[[-1, 15, 30, 90, 135, 180], [1.0, 0.0, 0.0, 0.35, 0.55, 0.90]]]]
        infectiousness:
          [[[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
            [0.000000000, 0.000000000, 0.000000000, 0.000177828, 0.007943284,
             0.562341455, 1.000000000, 0.944061094, 0.794328418, 0.562341455,
             0.316227839, 0.177827982, 0.079432842, 0.031622784, 0.010000002,
             0.004466837, 0.000000000]]]
        disease:
          [[[-1, 0, 15], [0.0, 0.15, 0.0]]]
        strain:
          [[[-1, 0, 15], [-1, 0, -1]]]
      1:
        rho_immunity_failure:
          [[[[-1, 15, 30, 90, 180], [[1.0, 0.0], [1.0, 0.0], [1.0, 0.0], [1.0, 0.0], [1.0, 0.0]]]]]
        sigma_immunity_failure:
          [[[[-1, 15, 30, 90, 135, 180], [1.0, 0.0, 0.0, 0.35, 0.55, 0.90]]]]
        infectiousness:
          [[[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
            [0.000000000, 0.000000000, 0.000000000, 0.000177828, 0.007943284,
             0.562341455, 1.000000000, 0.944061094, 0.794328418, 0.562341455,
             0.316227839, 0.177827982, 0.079432842, 0.031622784, 0.010000002,
             0.004466837, 0.000000000]]]
        disease:
          [[[-1, 0, 15], [0.0, 0.15, 0.0]]]
        strain:
          [[[-1, 0, 15], [-1, 0, -1]]]
    preset_1:
      0:
        rho_immunity_failure:
          [[[[-1, 15, 30, 90, 180], [[1.0, 0.0], [1.0, 0.0], [1.0, 0.0], [1.0, 0.0], [1.0, 0.0]]]]]
        sigma_immunity_failure:
          [[[[-1, 15, 30, 90, 135, 180], [1.0, 0.0, 0.0, 0.35, 0.55, 0.90]]]]
        infectiousness:
          [[[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
            [0.000000000, 0.000000000, 0.000000000, 0.000177828, 0.007943284,
             0.562341455, 1.000000000, 0.944061094, 0.794328418, 0.562341455,
             0.316227839, 0.177827982, 0.079432842, 0.031622784, 0.010000002,
             0.004466837, 0.000000000]]]
        disease:
          [[[-1, 0, 15], [0.0, 0.15, 0.0]]]
        strain:
          [[[-1, 0, 15], [-1, 0, -1]]]
      1:
        rho_immunity_failure:
          [[[[-1, 15, 30, 90, 180], [[1.0, 0.0], [1.0, 0.0], [1.0, 0.0], [1.0, 0.0], [1.0, 0.0]]]]]
        sigma_immunity_failure:
          [[[[-1, 15, 30, 90, 135, 180], [1.0, 0.0, 0.0, 0.35, 0.55, 0.90]]]]
        infectiousness:
          [[[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
            [0.000000000, 0.000000000, 0.000000000, 0.000177828, 0.007943284,
             0.562341455, 1.000000000, 0.944061094, 0.794328418, 0.562341455,
             0.316227839, 0.177827982, 0.079432842, 0.031622784, 0.010000002,
             0.004466837, 0.000000000]]]
        disease:
          [[[-1, 0, 15], [0.0, 0.15, 1.0]]]
        strain:
          [[[-1, 0, 15], [-1, 0, -1]]]
  # The assignment of presets is random and based on age.
  preset_weights_by_age:
    0:  {preset_0: 1.0000, preset_1: 0.0000}
    5:  {preset_0: 0.9999, preset_1: 0.0001}
    10: {preset_0: 0.9999, preset_1: 0.0001}
    15: {preset_0: 0.9998, preset_1: 0.0002}
    20: {preset_0: 0.9998, preset_1: 0.0002}
    25: {preset_0: 0.9996, preset_1: 0.0004}
    30: {preset_0: 0.9994, preset_1: 0.0006}
    35: {preset_0: 0.9991, preset_1: 0.0009}
    40: {preset_0: 0.9985, preset_1: 0.0015}
    45: {preset_0: 0.9977, preset_1: 0.0023}
    50: {preset_0: 0.9964, preset_1: 0.0036}
    55: {preset_0: 0.9943, preset_1: 0.0057}
    60: {preset_0: 0.9911, preset_1: 0.0089}
    65: {preset_0: 0.9861, preset_1: 0.0139}
    70: {preset_0: 0.9783, preset_1: 0.0217}
    75: {preset_0: 0.9661, preset_1: 0.0339}
    80: {preset_0: 0.9470, preset_1: 0.0530}
    85: {preset_0: 0.9172, preset_1: 0.0828}
    90: {preset_0: 0.8381, preset_1: 0.1619}
  # This option implements homogeneous mixing, as found in SIR models, by mutliplying all
  # transmission probabilities by the reciprocal of the tick length, in days, divided by the number
  # of agents in each location.
  sir_rescaling: False
  # Contact matrices for age groups. Can be null, otherwise provide a filepath to the matrices.
  age_mixing_matrices: null
  age_group_interval: 5
  # If auto_generate_presets = True, then the presets dict above is ignored, with the presets being
  # instead generated systematically, using the geometric distributions of the SIR model. This only
  # works if number_of_strains = 1.
  auto_generate_presets: False
  sir_beta: null # Units: days^{-1}
  sir_gamma_inverse: null # Units: days
  sir_disease_level: null # The level of disease to be recorded for infected agents
  sir_max_dist_days: null # Maximum infectiousness period, curtailing the geometric distribution

# ######################################### Movement ###############################################

movement_model:
  # In the default movement model, individuals perform sequences of activities and select locations
  # at random using the weights assigned to them by the world factory. The default movement model
  # requires a world featuring a home location for each agent.
  __type__: default_movement_model.DefaultMovementModel
  # Whether or not to use the weights.
  weighted_sampling: True
  # The default home activity.
  home_activity: "Home_Activity"
  # If an individual is in a location of one of these types, performing one of the activities listed
  # for the type, then the individual is except from interventions on movement, for example
  # lockdowns.
  location_closure_exemptions:
    House: ["Home_Activity"]
  # For which activities might an individual wear a facemask.
  facemask_activities: ["Community_Activity"]
  # Facemask hesitancy by age group. A probability 1.0 means that nobody in that age group wears a
  # mask, a probability 0.0 means that everyone does.
  age_groups:         [  0,  18,  65]
  facemask_hesitancy: [0.9, 0.5, 0.2]

# ######################################### Hospitalization and Death ##############################

hospitalization_and_death_model:
  __type__: void_hospitalization_and_death_model.VoidHospitalizationAndDeathModel

# ######################################### Testing and Contact Tracing ############################

testing_and_contact_tracing_model:
  # The default testing and contact tracing model requires the default health model and a world
  # featuring a home location for each agent. The model implements testing and contact tracing,
  # directing at risk individuals to self-isolate at home.
  __type__: default_testing_and_contact_tracing_model.DefaultTestingAndContactTracingModel
  # The length of time to self-isolate at home.
  quarantine_period_days: 14
  # The level above which the disease of an individual is considered symptomatic
  symptomatic_disease_threshold: 0.2
  # Probability that an individual with symptoms self-isolates without being tested.
  prob_quarantine_with_symptoms_without_test: 0.0
  # Probability that an individual self-isolates having been identified as at risk by the contact
  # tracing system but without being tested.
  prob_quarantine_with_contact_without_test: 0.0
  # The level of infectiousness of an individual above which the test should produce a positive
  # result.
  test_threshold: 0.4
  # The probability of a false negative.
  test_false_negative: 0.01
  # The maximum number of contacts to test.
  max_regular_contacts_to_test: 10

# ######################################### Vaccination ############################################

vaccination_model:
  # In the DefaultVaccinationModel, vaccination updates individual immunity following the exact same
  # multiplicative procedure that results from an infection in the DefaultHealthModel.
  __type__: default_vaccination_model.DefaultVaccinationModel
  # The number of vaccines.
  number_of_vaccines: 2
  # Age groups and associated vaccine hesitancy. Lower hesitancy means greater coverage.
  age_groups:        [  0,  18,  65]
  vaccine_hesitancy: [0.8, 0.4, 0.1]
  # The minimum time between doses.
  booster_waiting_time_days: 60
  # The impact of the vaccines on the immune system for each strain.
  vaccines:
    vaccine_0:
      rho_immunity_failure:
        [[[-1, 0, 180], [[1.0, 0.0], [0.5, 0.0], [1.0, 0.0]]]]
      sigma_immunity_failure:
        [[[-1, 0, 180], [1.0, 0.1, 1.0]]]
    vaccine_1:
      rho_immunity_failure:
        [[[-1, 0, 180], [[1.0, 0.0], [0.5, 0.0], [1.0, 0.0]]]]
      sigma_immunity_failure:
        [[[-1, 0, 180], [1.0, 0.1, 1.0]]]

# ######################################### Regional Mixing ########################################

travel_model:
  # The travel component models the movement of individuals between regions each day. In the
  # DefaultTravelModel, only uninfected individuals are eligible to travel. The numbers of
  # travellers is given by the world travel matrix. Transmission is determined by the average
  # infectiousness of the destination region.
  __type__: default_travel_model.DefaultTravelModel
  # [KEY PARAMETER] Travellers mix homogeneously with the entire population of the destination
  # region, with transmission probabilities divided by the number of agents in that region. This
  # parameter is a control parameter which multiplies that ratio.
  travel_transmission_multiplier: 600.0
  # This parameter, between 0.0 and 1.0, boosts the numbers travelling internationally. If 0.0 then
  # the number of travellers is as in the travel matrix. If 1.0 then the entire population travels
  # each day. Values in between interpolate between these numbers.
  interpolation: 0.0

# ######################################### Policy Maker ###########################################

policy_maker_model:
  # The policy maker component determines the level of interventions in each region each day. In the
  # DefaultPolicyMakerModel, a data file for each country is used to determine the level of each
  # intervention for that country each day.
  __type__: default_policy_maker_model.DefaultPolicyMakerModel
  # The data files are found in the following folder.
  policy_data_filepath: Scenarios/Heterogeneous/policy_data/

# ########################################

Outputs

################################################

# Reporters collect simulation data and produce output.

# The user can omit regions and groups of regions from the final counts.
regions_omitted_from_death_counts: []
super_regions_omitted_from_deaths_counts: []
# Historical data used to calculate the difference (in l^2 norm) between simulation deaths and
# historical deaths. Can be set to null.
historical_data_filepath: null

# Items in this dictionary report on the simulation. To disable a reporter, simply comment out.
reporters:

  # The reporter outputs a command line progress bar.
  cli.TimeReporter: {}

  # This reporter outputs a csv file, recording the numbers infected with each strain in each region
  # each day.
  csv.StrainCounts:
    # Where the user would like the csv saved.
    filename: /tmp/strain_counts_heterogeneous.csv

  # This reporter plots the number of individuals infected each day.
  plot.PlotInfected:
    show: False
    savefig: True
    # Where the user would like the plot saved.
    filename: /tmp/infected_heterogeneous.png

  # This reporter plots the number of new deaths each day and also cumulative deaths each day.
  plot.PlotDeaths:
    show: False
    savefig: True
    # Where the user would like the plots saved.
    daily_deaths_filename: /tmp/daily_deaths_heterogeneous.png
    cumulative_deaths_filename: /tmp/cumulative_deaths_heterogeneous.png
    # If a filepath is provided, the reporter also outputs a csv, recording total deaths by region.
    deaths_by_country_filename: null
    # If a filepath is provided here, the plots will include curves of historical deaths.
    historical_data: null

  # This report plots a real-time visualization of either prevalence or the absolute number of
  # infections, using the coordinates of each location in each region.
  pygame_coords.PygameCoords:
    fullscreen: True
    font_size: 20
    # Prevalence is calculated as a number between 0.0 and 1.0, with regions coloured accordingly.
    # The max_prev_to_plot parameter allows the user to rescale the colour map, by adjusting the
    # maximum detected prevalence. This can help visualize regions where prevalence is low.
    plot_prevalence: False
    max_prev_to_plot: 1.0
    # The max_num_inf_to_plot parameter allows the user to rescale the colour map, by adjusting the
    # maximum detected number of infections. This can help visualize locations where the number of
    # infections is low.
    plot_num_infected: True
    max_num_inf_to_plot: 10
    # Refresh rate.
    refresh_rate: 60
    # If fullscreen is False, then this sets the resolution of the plot.
    display_width: 1500
    display_height: 700
    # The width of grid squares recorded in region_coordinates.
    cellsize: 0.0416666666667
    # The preferred colour map.
    cmap: "Oranges"

# ########################################

Logging

###############################################

# Format is https://docs.python.org/3/library/logging.config.html#logging-config-dictschema
logging:
  version: 1
  disable_existing_loggers: False
  formatters:
    standard:
      # format: '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
      format: '[%(levelname)s] %(name)s: %(message)s'
  handlers:
    default:
      level: INFO
      formatter: standard
      class: logging.StreamHandler
      stream: 'ext://sys.stdout'  # Default is stderr
  loggers:
    '':   # root logger
      handlers: ['default']
      level: INFO
      propagate: False
#    'my.packg':
#      handlers: ['default']
#      level: INFO
#      propagate: False
#    '__main__':
#        handlers': ['default']
#        level: DEBUG
#        propagate: False