25 #include <boost/property_tree/ptree.hpp> 26 #include <boost/property_tree/xml_parser.hpp> 27 #include <initializer_list> 40 void RunConfigManager::CleanConfigFile(ptree pt)
43 const string sha1 = RunConfigManager::ToShortSha1(pt);
44 const string fName = sha1 +
".xml";
45 cout <<
"Rewriting config to file " << fName <<
" in current directory." << endl;
46 FileSys::WritePtreeFile(fName, pt);
49 ptree RunConfigManager::Create(
const std::string& configName)
51 static map<string, string (*)()> creators{
53 make_pair(
"BenchInfluenza", &CreateBenchInfluenza),
54 make_pair(
"BenchMeasles", &CreateBenchMeasles),
55 make_pair(
"Default", &CreateDefault),
56 make_pair(
"TestsInfluenza", &CreateTestsInfluenza),
57 make_pair(
"TestsMeasles", &CreateTestsMeasles)
62 void RunConfigManager::AddGeoPopConfig(ptree& pt)
64 const string geopop_str = R
"###( 66 <population_file>gengeopop.proto</population_file> 67 <population_type>generate</geopopulation_type> 69 <cities_file>flanders_cities.csv</cities_file> 70 <commuting_file>flanders_commuting.csv</commuting_file> 71 <fraction_college_commuters>0.5</fraction_college_commuters> 72 <fraction_workplace_commuters>0.5</fraction_workplace_commuters> 73 <household_file>households_flanders.csv</household_file> 74 <participation_college>0.5</participation_college> 75 <particpation_workplace>0.75</particpation_workplace> 76 <population_size>600000</population_size> 81 pt.put_child("run.population_file", geopop_ptree.get_child(
"run.population_file"));
82 pt.put_child(
"run.population_type", geopop_ptree.get_child(
"run.population_type"));
83 pt.put_child(
"run.geopop_gen", geopop_ptree.get_child(
"run.geopop_gen"));
86 string RunConfigManager::CreateBenchInfluenza()
89 <?xml version="1.0" encoding="utf-8"?> 91 <age_contact_matrix_file>contact_matrix_flanders_subpop.xml</age_contact_matrix_file> 92 <contact_log_level>None</contact_log_level> 93 <contact_output_file>false</contact_output_file> 94 <disease_config_file>disease_influenza.xml</disease_config_file> 95 <holidays_file>holidays_none.json</holidays_file> 96 <immunity_link_probability>0</immunity_link_probability> 97 <immunity_profile>Random</immunity_profile> 98 <immunity_rate>0</immunity_rate> 99 <num_days>10</num_days> 100 <num_participants_survey>10</num_participants_survey> 101 <num_threads>1</num_threads> 102 <output_prefix></output_prefix> 103 <population_file>pop_flanders600.csv</population_file> 104 <population_type>default</geopopulation_type> 105 <rng_seed>1097253,2387652,9963540,4730214</rng_seed> 107 <seeding_rate>0.001</seeding_rate> 108 <seeding_age_min>1</seeding_age_min> 109 <seeding_age_max>99</seeding_age_max> 110 <start_date>2017-01-01</start_date> 111 <stride_log_level>info</stride_log_level> 112 <track_index_case>false</track_index_case> 113 <use_install_dirs>true</use_install_dirs> 114 <vaccine_profile>None</vaccine_profile> 119 string RunConfigManager::CreateBenchMeasles()
122 <?xml version="1.0" encoding="utf-8"?> 124 <age_contact_matrix_file>contact_matrix_flanders_subpop.xml</age_contact_matrix_file> 125 <contact_log_level>None</contact_log_level> 126 <contact_output_file>false</contact_output_file> 127 <disease_config_file>disease_measles.xml</disease_config_file> 128 <holidays_file>holidays_none.json</holidays_file> 129 <immunity_profile>None</immunity_profile> 130 <immunity_rate>0.01</immunity_rate> 131 <num_days>30</num_days> 132 <num_participants_survey>10</num_participants_survey> 133 <num_threads>1</num_threads> 134 <output_prefix></output_prefix> 135 <population_file>pop_flanders600.csv</population_file> 136 <population_type>default</geopopulation_type> 137 <rng_seed>1097253,2387652,9963540,4730214</rng_seed> 139 <seeding_age_max>99</seeding_age_max> 140 <seeding_age_min>1</seeding_age_min> 141 <seeding_rate>0.05</seeding_rate> 142 <start_date>2017-01-01</start_date> 143 <stride_log_level>info</stride_log_level> 144 <track_index_case>false</track_index_case> 145 <use_install_dirs>true</use_install_dirs> 146 <vaccine_link_probability>0</vaccine_link_probability> 147 <vaccine_profile>Random</vaccine_profile> 148 <vaccine_rate>0</vaccine_rate> 153 string RunConfigManager::CreateDefault()
156 <?xml version="1.0" encoding="utf-8"?> 158 <age_contact_matrix_file>contact_matrix_flanders_subpop.xml</age_contact_matrix_file> 159 <contact_log_level>Transmissions</contact_log_level> 160 <contact_output_file>true</contact_output_file> 161 <disease_config_file>disease_measles.xml</disease_config_file> 162 <global_information_policy>NoGlobalInformation</global_information_policy> 163 <holidays_file>holidays_none.json</holidays_file> 164 <immunity_profile>None</immunity_profile> 165 <immunity_rate>0.8</immunity_rate> 166 <num_days>30</num_days> 167 <num_participants_survey>10</num_participants_survey> 168 <num_threads>1</num_threads> 169 <output_adopted>false</output_adopted> 170 <output_cases>true</output_cases> 171 <output_persons>false</output_persons> 172 <output_prefix></output_prefix> 173 <output_summary>false</output_summary> 174 <population_file>pop_flanders600.csv</population_file> 175 <population_type>default</geopopulation_type> 176 <rng_seed>1097253,2387652,9963540,4730214</rng_seed> 178 <seeding_age_max>99</seeding_age_max> 179 <seeding_age_min>1</seeding_age_min> 180 <seeding_rate>0.003</seeding_rate> 181 <start_date>2017-01-01</start_date> 182 <stride_log_level>info</stride_log_level> 183 <track_index_case>false</track_index_case> 184 <use_install_dirs>true</use_install_dirs> 185 <vaccine_link_probability>0</vaccine_link_probability> 186 <vaccine_profile>Random</vaccine_profile> 187 <vaccine_rate>0.8</vaccine_rate> 192 vector<unsigned int> RunConfigManager::CreateNumThreads(unsigned int maxNum)
194 maxNum = max(maxNum, ConfigInfo::NumberAvailableThreads());
195 vector<unsigned int> num{1U};
197 if (4 > maxNum && maxNum >= 2) {
200 if (8 > maxNum && maxNum >= 4) {
204 if (12 > maxNum && maxNum >= 8) {
209 if (16 > maxNum && maxNum >= 12) {
224 string RunConfigManager::CreateTestsInfluenza()
227 <?xml version="1.0" encoding="utf-8"?> 229 <age_contact_matrix_file>contact_matrix_flanders_subpop.xml</age_contact_matrix_file> 230 <contact_log_level>None</contact_log_level> 231 <contact_output_file>false</contact_output_file> 232 <disease_config_file>disease_influenza.xml</disease_config_file> 233 <holidays_file>holidays_none.json</holidays_file> 234 <immunity_link_probability>0</immunity_link_probability> 235 <immunity_profile>Random</immunity_profile> 236 <immunity_rate>0</immunity_rate> 237 <num_days>30</num_days> 238 <num_participants_survey>10</num_participants_survey> 239 <num_threads>1</num_threads> 240 <output_prefix></output_prefix> 241 <population_file>pop_flanders600.csv</population_file> 242 <population_type>default</geopopulation_type> 243 <rng_seed>1097253,2387652,9963540,4730214</rng_seed> 245 <seeding_rate>0.00089999999999999998</seeding_rate> 246 <seeding_age_min>1</seeding_age_min> 247 <seeding_age_max>99</seeding_age_max> 248 <start_date>2017-01-01</start_date> 249 <stride_log_level>info</stride_log_level> 250 <track_index_case>false</track_index_case> 251 <use_install_dirs>true</use_install_dirs> 252 <vaccine_profile>None</vaccine_profile> 257 string RunConfigManager::CreateTestsMeasles()
260 <?xml version="1.0" encoding="utf-8"?> 262 <age_contact_matrix_file>contact_matrix_flanders_subpop.xml</age_contact_matrix_file> 263 <contact_log_level>Transmissions</contact_log_level> 264 <contact_output_file>false</contact_output_file> 265 <disease_config_file>disease_measles.xml</disease_config_file> 266 <holidays_file>holidays_none.json</holidays_file> 267 <immunity_rate>0.80000000000000004</immunity_rate> 268 <immunity_profile>None</immunity_profile> 269 <num_days>50</num_days> 270 <num_participants_survey>10</num_participants_survey> 271 <num_threads>1</num_threads> 272 <output_prefix></output_prefix> 273 <population_file>pop_flanders600.csv</population_file> 274 <population_type>default</geopopulation_type> 275 <rng_seed>1097253,2387652,9963540,4730214</rng_seed> 276 <seeding_age_max>99</seeding_age_max> 277 <seeding_age_min>1</seeding_age_min> 278 <seeding_rate>0.002</seeding_rate> 279 <start_date>2017-01-01</start_date> 280 <stride_log_level>info</stride_log_level> 281 <track_index_case>false</track_index_case> 282 <use_install_dirs>true</use_install_dirs> 283 <vaccine_link_probability>0</vaccine_link_probability> 284 <vaccine_profile>Random</vaccine_profile> 285 <vaccine_rate>0.80000000000000004</vaccine_rate> 294 read_xml(is, pt, trim_whitespace);
301 write_xml(ss, pt, xml_writer_make_settings<ptree::key_type>(
' ', 8));
305 std::string RunConfigManager::ToSha1(
const boost::property_tree::ptree& pt) {
return sha1(
ToString(pt)); }
307 std::string RunConfigManager::ToShortSha1(
const boost::property_tree::ptree& pt,
unsigned int n)
309 return ToSha1(pt).substr(0, n);
T FromString(const std::string &s)
Builds a value of type T representation from a string.
string ToString(Id l)
Converts a LogMode value to corresponding name.
Produce run config ptree.
Interface for install directory queries.
Namespace for the simulator and related classes.