5. ODE
Consider the so-called SEIR model of the spread of an infectious disease (and note: all models are wrong).
In this model, a population is split up into four 'compartments':
- s is the fraction that is susceptible to the disease,
- e is the fraction that has been exposed to the disease,
- i is the fraction that is infectious,
- r is the fraction that has recovered.
All fractions are between 0 and 1 and the sum of s, e, i, and r is equal to 1.
In the SEIR model without births or deaths, these fractions satisfy the following set of ODEs:
$$\frac{ds}{dt} = -\beta(i(t))\,i(t)\,s(t)$$
$$\frac{de}{dt} = \beta(i(t))\,i(t)\,s(t) - \alpha\, e(t)$$
$$\frac{di}{dt} = \alpha\, e(t) - \gamma\, i(t) $$
$$\frac{dr}{dt} = \gamma\, i(t)$$
where
- \(\alpha\) is the incubation rate,
- \(\gamma\) is the recovery rate.
- \(\beta\) is the infectious rate. In this assignment, it
varies to model preventive measures that may have been taken based on
the fraction of infectious people in the population. In particular, we will use
\( \beta(i) = \beta_0 \exp( -i^2/\delta^2)\)
- \(\delta \) can be viewed as the typical infection fraction at which preventative measures would start to be taken (distancing, masking, stay-at-home, etc.).
$$\alpha=0.2$$
$$\beta_0 = 2$$
$$\gamma=0.06$$
$$\delta = 0.16$$
You need to write a code numerically solve this four-dimensional ODE with an absolute tolerance of 10-8 over a time T=160 starting from the initial conditions:
$$s(0) = 0.999$$
$$e(0) = 0.001$$
$$ i(0) = 0$$
$$ r(0) = 0$$
Your code should output 161 time points between t=0 and t=160 to a file. Each time point should be a line in this file, with the values of the time, s, e, i, and r, separated by a space.
Use either the GSL library or the BOOST odeint library to accomplish this.
Next, you will profile this code to see where it spends most time. You will notice that the program runs very quickly, which makes profile sampling difficult. Make your code arbitrarily slower by, within the code, doing the same calculation 10,000 times.
Then, profile your code with MAP and with the Performance Reports.
As in previous assignment, you should use git version control for your code, it should be well commented, and have a Makefile.
Submit your git2zip-ed repo, along with the screenshot of the MAP application's analysis of the code and also the html version of the performance report, by midnight Thu February 25th, 2021. The late policy can be found in the syllabus.