Louis Béziaud, 2022
Reardon, S.F., Baker, R., Kasman, M., Klasik, D. and Townsend, J.B. (2018), What Levels of Racial Diversity Can Be Achieved with Socioeconomic-Based Affirmative Action? Evidence from a Simulation Model. J. Pol. Anal. Manage., 37: 630-657. https://doi.org/10.1002/pam.22056
See https://github.com/lbeziaud/re-reardon2018 for details on the replication.
The main model is model.py. Figures are generated by figures.ipynb. The file utils_figs.py contains auxiliary functions used for launching the experiments, with pre_run allowing to run all experiments in parallel.
This code has been written with Python 3.9. Required packages are listed in requirements.txt
-
Clone the repository:
$ git clone https://github.com/lbeziaud/mosaic $ cd mosaic
-
Install dependencies in a virtual environment:
$ python3.9 -m venv venv # create venv $ source venv/bin/activate # activate venv (venv) $ pip install -r requirements.txt
-
Generate all the figures (in headless mode):
(venv) $ jupyter nbconvert --ExecutePreprocessor.timeout=-1 --to notebook --inplace --execute figures.ipynbThe whole notebook takes around 20 minutes to execute if the simulation files are already available (see below).
-
You can run all simulations required by the figures with:
(venv) $ python pre_run.pyThe script accepts parameters
-j <number of jobs to run in parallel>and-v/-vv/-vvvto control verbosity.Output is saved on disk in
results/(in human readable paths) as parquet files. Total size is 10 GB.Using 15 parallel jobs requires around 30 GB of memory and takes 20 minutes on AMD Ryzen 7 PRO 6850U.
-
Running the model is done by calling
model.run, which returns a tuple of dataframes:from model import run colleges, students, outcomes = run()
Several examples are provided in utils_figs.py on how to cache the run and on how to run and aggregate repeated experiments.