33 #include <boost/property_tree/ptree.hpp> 34 #include <initializer_list> 46 StanController::StanController(
const ptree& config,
const string& name) :
ControlHelper(config, name) {}
61 const auto stanCount =
m_config.get<
unsigned int>(
"run.stan_count");
63 vector<unsigned int> rd_values;
65 for (
unsigned int i = 0; i < 4 * stanCount; i++) {
66 rd_values.emplace_back(rd());
68 for (
unsigned int i = 0; i < stanCount; i++) {
69 seeds.emplace_back(
ToString(rd_values[2 * i]) +
"," +
ToString(rd_values[2 * i + 1]) +
"," 72 vector<vector<unsigned int>> results(stanCount);
80 #pragma omp parallel for num_threads(ConfigInfo::NumberAvailableThreads()) 81 for (
unsigned int i = 0U; i < stanCount; ++i) {
87 configPt.put(
"run.rng_seed", seeds[i]);
104 auto runner = make_shared<SimRunner>(configPt, sim);
105 auto iViewer = make_shared<viewers::InfectedViewer>(runner);
108 results[i] = iViewer->GetInfectionCounts();
111 for (
unsigned int i = 0U; i < stanCount; ++i) {
112 m_stride_logger->info(
"For run with seed {} final infected count is: {}", seeds[i], results[i].back());
118 const auto numDays =
m_config.get<
unsigned int>(
"run.num_days");
120 for (
unsigned int i = 0U; i < numDays + 1; ++i) {
121 vector<unsigned int> v;
122 for (
const auto& res : results) {
123 v.emplace_back(res[i]);
125 csv.AddRow(v.begin(), v.end());
void Control()
Actual run of the simulator.
Observer for infection count at each sim step.
void Update(sim_event::Id id)
Let viewer perform update.
boost::property_tree::ptree m_config
Main configuration for run and sim.
void CheckEnv()
Check install environment.
static std::shared_ptr< Population > Create()
Create an empty Population, used in gengeopop.
Utilities for the project.
string ToString(Id l)
Converts a LogMode value to corresponding name.
std::shared_ptr< spdlog::logger > m_stride_logger
General logger.
void LogStartup()
Logs info on setup for cli environment to stride_logger.
static std::shared_ptr< Sim > Create(const boost::property_tree::ptree &config, std::shared_ptr< Population > pop, util::RnMan rnMan)
Create Sim initialized by the configuration in property tree and population.
Header file for BoxPlotData.
static filesys::path BuildPath(const std::string &output_prefix, const std::string &filename)
Interpret prefix (directory or filename prefix) and return appropriate path.
Header for the St(ochastic)an(alysis)Controller.
Header file for the core Population class.
Controls a simulation run initiated with the command line interface (cli).
Miscellaneous string utilities.
Header for the Simulator class.
Interface for install directory queries.
A collection of CSVRow elements.
Namespace for the simulator and related classes.
Header file of base class for config that needs to be read from a file.
Information on random number management state.
void InstallLogger()
Make the appropriate logger for cli environment and register as stride_logger.
Header for the SimRunner class.