======== SIDARTHE ======== SIDARTHE :footcite:`Giordano_2020` is an epidemic model developed during the SARS-CoV-2 epidemic. Its main novelty is the number of stages used: Susceptible, Infected, Diagnosed, Ailing, Recognized, Threatened, Healed, and Extinct. -------------------- Model implementation -------------------- The original model is provided as a MATLAB_ project. The model performs all the calculations inside a function :code:`sidarthe`, which receives the following parameters: - params1: A list composed by the following values: alpha1, beta1, gamma1, delta1, epsilon1, theta1, zeta1, eta1, mu1, nu1, tau1, lambda1, rho1, kappa1, xi1, sigma1 - params2: A list composed by the following values: alpha2, beta2, gamma2, delta2 - params3: A list composed by the following values: epsilon3 - params4: A list composed by the following values: alpha4, beta4, gamma4, delta4, mu4, nu4, zeta4, eta4, lambda4, rho4, kappa4, xi4, sigma4 - params5: A list composed by the following values: alpha5, gamma5 - params6: A list composed by the following values: epsilon6, rho6, kappa6, xi6, sigma6, zeta6, eta6 - cost_days: A list composed by the first day to evaluate and the last day. We reefer to the original paper for the details of each parameter. The original file also contains the data for the COVID-19 epidemic during 20th February, 2020 - 5th April, 2020 in Italy. For simplicity, we keep the data in the file, so we will calibrate against an empty datafile. To do so, we will create an empty file in the folder **project/data**. The first step is to set the python :code:`model` function in the *model.py* file from the template. First, we add the configurable parameters for this model. In particular, those will be the parameters from *params1* to *params6* enumerated previously. We set this function as follows: .. literalinclude:: model1_params.py :language: python Then, we use Octave_ (an open source alternative to MATLAB_) and the python bindings Oct2Py_ to call the :code:`sidarthe` function using Oct2Py_. First, we add to Octave's path the directory where our **sidarthe.m** file is, so we Octave_ can find it. Then, we create an :code:`Oct2Py` object, and we call the MATLAB_ function :code:`sidarthe` from within python, passing the parameters. Finally, we return the computed fit error (or cost) reported by MATLAB_. .. literalinclude:: model2_call.py :language: python ------------------------------------------ Preparing the model to be run using docker ------------------------------------------ In order to execute the model, we have to modify two extra files: Dockerfile: As the model uses Octave_, we have to modify the Dockerfile to install this software. To do so, we uncomment and modify the lines: .. code-block:: docker ENV DEBIAN_FRONTEND noninteractive ENV MODEL_DEPENDENCIES "octave" RUN apt-get update \ && apt-get -y install \ ${MODEL_DEPENDENCIES} \ && apt-get clean requirements.txt: The **model.py** file uses the Oct2Py_ python package. We add it to the requirements file: .. code-block:: optilog==0.3.5 oct2py==5.5.1 ----------------- Example of output ----------------- The relevant information is printed at the end of the execution. We can see: - The cost (fit error) of the best parameters found in :code:`Last winner objective: XXXX` - The list of the parameters with the best values for each function (usually only the model function) - The best configuration JSON, which can be used to inject the parameters using OptiLog. .. code-block:: [...] ******************************************************************************** Number of finished generations: 2831 Last winner genome Id: 130730 Last winner objective: 561.0960961546258 [...] Tuning process finished. ======================== Best parameters: - model(alfa1): 0.6329735543235085 - model(tau1): 0.008353880715401947 [...] - model(mu1): 0.013057775284658034 - model(nu1): 0.013305932850534396 ======================== Best Config JSON: {'_0_0__alfa1': 0.6329735543235085, '_10_0__tau1': 0.008353880715401947, [...]} ----------------------- Full MATLAB source code ----------------------- .. literalinclude:: sidarthe.m :language: matlab .. rubric:: References .. footbibliography::