mrc-ide / covid-sim

This is the COVID-19 CovidSim microsimulation model developed by the MRC Centre for Global Infectious Disease Analysis hosted at Imperial College, London.
GNU General Public License v3.0
1.23k stars 256 forks source link

Wes/param refactor #477

Closed weshinsley closed 3 years ago

weshinsley commented 3 years ago

So, this slightly gnarly PR does the following...

  1. Params.h and Params.cpp contain functions to do with... a. Reading an ini-style param file into a C++ map<string, string>, and b. Parsing values from that map into all required combinations of {int, double, string} and {scalar, vector, matrix}. c. Various ways of setting default values, to reduce the (if (!GetInput, ....) set...) pattern, which is especially beneficial for vectors and matrices.

  2. Warnings are shown if the number of elements available in the parameter file differs from those expected. There are legitimate reasons why this may be so - eg, you may have a list of time-specific interventions, and only use the first couple of them. On the other hand, the warnings might show up a mismatch between what is expected, and what's in the params...

  3. A side consequence of this: I had to convert a handful of double[][] into double** in Param.h, since [][] are untidy to pass to functions.

  4. The various GetInputParameter functions are now replaced, and instead of large numbers of reads through the text files, we are now just looking up the map,.