alan-turing-institute / vivarium_population_spenser

Vivarium microsimulation tools used to model population evolution with the SPENSER project
GNU General Public License v3.0
3 stars 0 forks source link

Internal migration #38

Closed crangelsmith closed 3 years ago

crangelsmith commented 4 years ago

Internal migration implementation based on this document. This is a meta-issue.

The implementation is in the following steps:

Note: we use csv2sparse function in utilities.py to convert the OD matrices to sparse representations.

Refer to #48 , these are already implemented:

crangelsmith commented 4 years ago

Topics to discuss in meeting of 117th August:

  1. VPH framework:

    • Implement internal migration relocation in the same component that chooses the potential migrants
    • A function that reads the migrant initial location, age, gender and ethnicity and returns a new location
    • In the output data the location field gets re-writen but we have a new variable that saves the old locations and the time of migration.
  2. The assignment function:

  1. The data used to build the matrix.
crangelsmith commented 4 years ago

[

Screenshot 2020-08-17 at 10 56 00

](url)

kasra-hosseini commented 4 years ago

@crangelsmith please take a look and feel free to edit as you see fit.

In the meeting today (17th Aug), we talked about the following components:

  1. A data structure to efficiently extract a "distribution over destinations" for each (sex, age group, location).

input: Rows with internal_outmigration == True in:

Screenshot 2020-08-17 at 14 42 06

The relevant columns (sex, age, location, ...) should be selected, converted to meaningful keys for the data structure and finally:

output:

matrix:
Shape: N x d
N: number of rows with `internal_outmigration == True`
d: number of possible destinations
values: weights assigned to each possible destination
  1. The second component reads in the above matrix and performs the following steps:

output:

vector:
Shape: N x 1
N: number of rows with `internal_outmigration == True`
values: ids of next destination
crangelsmith commented 4 years ago

Notes from meeting on 19 August:

I'll will try to have all steps implemented in the code (with step 2 and 3 using dummy matrices) before I leave on holiday.

kasra-hosseini commented 4 years ago

Currently, we use one OD matrix (regardless of age/sex) to assign new MSOAs to migrants.

TODO:

NOTE: as already mentioned, we use one OD matrix now.

The plan is to use IPF to generate one OD matrix for each (age_group, sex). In the internal migration component and by using int_migration_pool, we should first detect the correct OD matrix (based on age_group and sex), find the relevant rows (based on origins), extract the rows and go to next step.

kasra-hosseini commented 4 years ago

I also added a new file: https://github.com/alan-turing-institute/vivarium_public_health_spenser/blob/features/44-internal-outmigration/persistant_data/Middle_Layer_Super_Output_Areas__December_2001__Population_Weighted_Centroids.csv

Using this file, we can convert migrant's MSOAs to geographic coordinates, so we can track the locations of migrants. In the following figure, the left column shows origins and the right column shows migrant's destinations.

Screenshot 2020-08-26 at 16 10 29

kasra-hosseini commented 4 years ago

I had to add a very large file (~100MB) to the repo as well: https://github.com/alan-turing-institute/vivarium_public_health_spenser/blob/features/44-internal-outmigration/persistant_data/OD_matrix_EW_no_intra_flows.csv

Maybe we should remove this from the commit history and upload it somewhere else?