=========================================================================================
- Description of the replication files for "Pandemic Recessions and Contact Tracing"
- by Leonardo Melosi and Matthias Rottner
- Journal of the European Economic Association, forthcoming
- Date: January 25, 2023
=========================================================================================


=======================================
Overview
=======================================

  This replication package replicates the results of the paper by solving the model     
  with numerical methods. It calculates all numerical results of the paper, that is 
  Table 2 and Figure 2-4 as well as all the figures of the Online Appendix.


=======================================
Instructions to Replicators
=======================================

  To replicate all results run the file main_run.m

  The file main_run calculates the numerical results of the paper, in particular Table 2 and Figures 2-4.
  It also calculates all the figures of the Online Appendix.

  Note that we did not set a seed because we use the parallelize option in the Matlab build-in function fmincon.
  The fmincon function is used to numerically derive the optimal social distancing measures (see line 26 to 135 in main_run.m). 
  As the problem of the macro-epidemiological  economy is highly nonlinear, especially with limited testing,
  and the maximization includes up to 150 variables, there can be slight discrepancies in the numerical solution
  resulting from the maximization routine.
  

=======================================
Important Details of the Code
=======================================

Note that some calculations can take quite some time. In such a case, the default option is to load in precalculated
results. The precalculated results are stored in the folder Simulations. The option can be changed to do own calculations.
This can be done by adapting the following lines (We allow to change each option singular to provide maximum flexibility.):
	- opt_cal1 = 1 (line 44) in the file main_run
	- opt_cal2 = 1 (line 70) in the file main_run
	- opt_calG4 = 1 (line 15) in the file FigureG2_main_run (see folder files)
	- opt_calH5 = 1 (line 32) in the file FigureH1_main_run (see folder files)


=======================================
Structure of Replication Package
=======================================

  - main_run.m (file): generates all results

  - Figures (folder): contains the generated figures

  - Files (folder): contains the other m files that are called within main_run to generate the results

  - ExternalFiles (folder): contains the file csolve from Chris Sims that is called within the main_run file 
			 The file can be downloaded also here http://sims.princeton.edu/yftp/optimize/mfiles/ 

  - Simulations (folder): saves some of the generated paths and dynamics to produce the figures





=======================================
Runtime, Software and Hardware
=======================================

The files were generated and tested using Matlab 2020b. 
We also used the Parallel Computing Toolbox. (Note this toolbox is not necessary if precalculated results are used)
The processor used in the computations is an Intel Xeon W-2295 CPU (24.75M Cache, 3.00 GHz).
The run time was 16.4 hours (58979 seconds) without loading precalculated results. The calculation was done by parallelizing using 36 workers.
The run time was 0.16 hours (572 seconds) with loading precalculated results. Note that the latter is the default setup in the replication code. 



