Stride Reference Manual
1.0
|
Main class that contains and direct the virtual world. More...
#include <Simulator.h>
Public Types | |
using | GlobalInformationPolicy = NoGlobalInformation |
using | LocalInformationPolicy = NoLocalInformation |
using | BeliefPolicy = NoBelief |
using | BehaviourPolicy = NoBehaviour< BeliefPolicy > |
using | PersonType = Person< BehaviourPolicy, BeliefPolicy > |
using | TravellerType = Traveller< PersonType > |
![]() | |
using | EventType = Simulator |
using | CallbackType = std::function< void(const EventType &)> |
Public Member Functions | |
Simulator () | |
Default constructor for empty Simulator. More... | |
const std::shared_ptr< const Population > | getPopulation () const |
Get the population. More... | |
void | setTrackIndexCase (bool track_index_case) |
Change track_index_case setting. More... | |
void | setName (string name) |
string | getName () const |
void | setCommunicationMap (const std::map< string, AsyncSimulator * > &comm_map) |
SimulatorStatus | timeStep () |
Run one time step, computing full simulation (default) or only index case. More... | |
const Calendar & | getCalendar () const |
Return the calendar of this simulator. More... | |
const std::vector< Cluster > & | getClusters (ClusterType cluster_type) const |
Get the clusters of this simulator based on the cluster type This is rather for testing purposes. More... | |
std::vector< std::string > | getRngStates () const |
Retrieve the states of the rng's. More... | |
void | setRngStates (std::vector< std::string > states) |
Set the states of the rng's. More... | |
uint | chooseCluster (const GeoCoordinate &coordinate, const vector< Cluster > &clusters, double influence) |
Return an index to a cluster in the given vector Current policy: search for the first cluster with equal coordinates Return the size of the vector if you can't find any. More... | |
bool | hostForeignTravellers (const vector< Simulator::TravellerType > &travellers, uint days, string destination_district, string destination_facility) |
Receive travellers travellers: the travellers this simulator has to host. More... | |
bool | welcomeHomeTravellers (const vector< uint > &travellers_indices, const vector< Health > &health_status) |
Return people that were abroad travellers_indices: contains the indices (in the m_population->m_original vector) of the returning people health_status: The Health of the returning people (equal size as travellers_indices, health_status.at(i) belongs to travellers_indices.at(i)) TODO: future return value? More... | |
void | returnForeignTravellers () |
Return people that are here FROM abroad. More... | |
void | sendNewTravellers (uint amount, uint days, const string &destination_sim_id, string destination_district, string destination_facility) |
const SimplePlanner< Traveller< Simulator::PersonType > > & | getPlanner () const |
const std::vector< Cluster > & | getHouseholds () const |
const std::vector< Cluster > & | getSchoolClusters () const |
const std::vector< Cluster > & | getWorkClusters () const |
const std::vector< Cluster > & | getPrimaryCommunities () const |
const std::vector< Cluster > & | getSecondaryCommunities () const |
const std::vector< District > & | getDistricts () const |
![]() | |
virtual | ~Subject () |
void | registerObserver (const std::shared_ptr< U > &u, CallbackType f) |
void | unregister (const std::shared_ptr< U > &u) |
void | unregisterAll () |
void | notify (const EventType &e) |
Private Types | |
using | RandomRef = util::Random * |
Private Member Functions | |
template<LogMode log_level, bool track_index_case = false> | |
void | updateClusters () |
Update the contacts in the given clusters. More... | |
Private Attributes | |
std::map< unsigned int, Simulator::TravellerType > | m_trav_elsewhere |
std::map< unsigned int, Simulator::TravellerType > | m_trav_hosting |
unsigned int | m_num_threads |
The number of threads(as a hint) More... | |
decltype(Parallel().with< RandomRef >()) | m_parallel |
std::shared_ptr< util::Random > | m_rng |
LogMode | m_log_level |
Specifies logging mode. More... | |
std::shared_ptr< Calendar > | m_calendar |
Management of calendar. More... | |
boost::property_tree::ptree | m_config_pt |
Configuration property tree. More... | |
boost::property_tree::ptree | m_config_pop |
std::shared_ptr< spdlog::logger > | m_logger |
std::shared_ptr< Population > | m_population |
Pointer to the Population. More... | |
std::vector< Cluster > | m_households |
Container with household Clusters. More... | |
std::vector< Cluster > | m_school_clusters |
Container with school Clusters. More... | |
std::vector< Cluster > | m_work_clusters |
Container with work Clusters. More... | |
std::vector< Cluster > | m_primary_community |
Container with primary community Clusters. More... | |
std::vector< Cluster > | m_secondary_community |
Container with secondary community Clusters. More... | |
std::vector< District > | m_districts |
Container with districts (villages and cities). More... | |
std::map< string, AsyncSimulator * > | m_communication_map |
Communication between the simulator and the senders. More... | |
DiseaseProfile | m_disease_profile |
Profile of disease. More... | |
bool | m_track_index_case |
General simulation or tracking index case. More... | |
uint | m_next_id |
The ID of the next traveller that arrives. More... | |
uint | m_next_hh_id |
The household ID of the next traveller that arrives. More... | |
string | m_name |
Name of the simulator (the region it simulates) More... | |
SimplePlanner< Traveller< Simulator::PersonType > > | m_planner |
The Planner, responsible for the timing of travellers (when do they return home?). More... | |
Friends | |
class | SimulatorBuilder |
class | LocalSimulatorAdapter |
class | Hdf5Saver |
class | Hdf5Loader |
class | run::Runner |
Main class that contains and direct the virtual world.
Definition at line 64 of file Simulator.h.
Definition at line 66 of file Simulator.h.
Definition at line 67 of file Simulator.h.
Definition at line 69 of file Simulator.h.
Definition at line 71 of file Simulator.h.
Definition at line 72 of file Simulator.h.
Definition at line 74 of file Simulator.h.
|
private |
Definition at line 163 of file Simulator.h.
stride::Simulator::Simulator | ( | ) |
Default constructor for empty Simulator.
Definition at line 43 of file Simulator.cpp.
References m_parallel, and m_rng.
const shared_ptr< const Population > stride::Simulator::getPopulation | ( | ) | const |
void stride::Simulator::setTrackIndexCase | ( | bool | track_index_case | ) |
Change track_index_case setting.
Definition at line 60 of file Simulator.cpp.
References m_track_index_case.
|
inline |
Definition at line 85 of file Simulator.h.
|
inline |
Definition at line 87 of file Simulator.h.
Referenced by stride::run::Runner::initOutputs().
|
inline |
Definition at line 89 of file Simulator.h.
SimulatorStatus stride::Simulator::timeStep | ( | ) |
Run one time step, computing full simulation (default) or only index case.
Definition at line 77 of file Simulator.cpp.
References stride::Contacts, m_calendar, m_districts, m_log_level, m_population, m_track_index_case, stride::None, stride::util::Subject< Simulator >::notify(), and stride::Transmissions.
Referenced by stride::LocalSimulatorAdapter::timeStep().
|
inline |
Return the calendar of this simulator.
Definition at line 95 of file Simulator.h.
const vector< Cluster > & stride::Simulator::getClusters | ( | ClusterType | cluster_type | ) | const |
Get the clusters of this simulator based on the cluster type This is rather for testing purposes.
Definition at line 135 of file Simulator.cpp.
References stride::Household, m_households, m_primary_community, m_school_clusters, m_secondary_community, m_work_clusters, stride::PrimaryCommunity, stride::School, stride::SecondaryCommunity, and stride::Work.
vector< string > stride::Simulator::getRngStates | ( | ) | const |
void stride::Simulator::setRngStates | ( | std::vector< std::string > | states | ) |
uint stride::Simulator::chooseCluster | ( | const GeoCoordinate & | coordinate, |
const vector< Cluster > & | clusters, | ||
double | influence | ||
) |
Return an index to a cluster in the given vector Current policy: search for the first cluster with equal coordinates Return the size of the vector if you can't find any.
Definition at line 164 of file Simulator.cpp.
References stride::util::GeoCoordCalculator::getInstance(), and m_rng.
Referenced by hostForeignTravellers().
bool stride::Simulator::hostForeignTravellers | ( | const vector< Simulator::TravellerType > & | travellers, |
uint | days, | ||
string | destination_district, | ||
string | destination_facility | ||
) |
Receive travellers travellers: the travellers this simulator has to host.
Contains the data needed to identify a person in the home simulator days: The amount of days the travellers will stay in this simulator destination_district: The name of the city in which the airport / facility is located e.g. "Antwerp" destination_facility: The name of the facility / airport e.g. "ANR" TODO: future return value?
Definition at line 195 of file Simulator.cpp.
References chooseCluster(), stride::Person< BehaviourPolicy, BeliefPolicy >::getHealth(), stride::Traveller< PersonType >::getNewPerson(), m_districts, m_next_hh_id, m_next_id, m_planner, m_population, m_primary_community, m_secondary_community, m_work_clusters, and stride::Person< BehaviourPolicy, BeliefPolicy >::setOnVacation().
Referenced by stride::LocalSimulatorAdapter::hostForeignTravellers().
bool stride::Simulator::welcomeHomeTravellers | ( | const vector< uint > & | travellers_indices, |
const vector< Health > & | health_status | ||
) |
Return people that were abroad travellers_indices: contains the indices (in the m_population->m_original vector) of the returning people health_status: The Health of the returning people (equal size as travellers_indices, health_status.at(i) belongs to travellers_indices.at(i)) TODO: future return value?
Definition at line 278 of file Simulator.cpp.
References m_population.
Referenced by stride::LocalSimulatorAdapter::welcomeHomeTravellers().
void stride::Simulator::returnForeignTravellers | ( | ) |
Return people that are here FROM abroad.
Definition at line 288 of file Simulator.cpp.
References stride::Person< BehaviourPolicy, BeliefPolicy >::getClusterId(), stride::Person< BehaviourPolicy, BeliefPolicy >::getId(), m_communication_map, m_planner, m_population, m_primary_community, m_secondary_community, m_work_clusters, stride::PrimaryCommunity, stride::SecondaryCommunity, and stride::Work.
Referenced by stride::LocalSimulatorAdapter::returnForeignTravellers().
void stride::Simulator::sendNewTravellers | ( | uint | amount, |
uint | days, | ||
const string & | destination_sim_id, | ||
string | destination_district, | ||
string | destination_facility | ||
) |
Definition at line 328 of file Simulator.cpp.
References stride::Person< BehaviourPolicy, BeliefPolicy >::getClusterId(), stride::Person< BehaviourPolicy, BeliefPolicy >::getId(), stride::Person< BehaviourPolicy, BeliefPolicy >::isOnVacation(), m_communication_map, m_name, stride::Population::m_original, m_population, m_rng, stride::Person< BehaviourPolicy, BeliefPolicy >::setOnVacation(), and stride::Work.
Referenced by stride::LocalSimulatorAdapter::sendNewTravellers().
|
inline |
Definition at line 134 of file Simulator.h.
|
inline |
Definition at line 137 of file Simulator.h.
Referenced by stride::ClusterCalculator< ClusterType::Household >::calculateSurface(), stride::ClusterCalculator< ClusterType::Household >::getClusterMap(), and stride::ClusterSaver::saveClustersCSV().
|
inline |
Definition at line 139 of file Simulator.h.
Referenced by stride::ClusterCalculator< ClusterType::School >::calculateSurface(), stride::ClusterCalculator< ClusterType::School >::getClusterMap(), and stride::ClusterSaver::saveClustersCSV().
|
inline |
Definition at line 141 of file Simulator.h.
Referenced by stride::ClusterCalculator< ClusterType::Work >::calculateSurface(), stride::ClusterCalculator< ClusterType::Work >::getClusterMap(), and stride::ClusterSaver::saveClustersCSV().
|
inline |
Definition at line 143 of file Simulator.h.
Referenced by stride::ClusterCalculator< ClusterType::PrimaryCommunity >::calculateSurface(), stride::ClusterSaver::getAgeMap(), stride::ClusterCalculator< ClusterType::PrimaryCommunity >::getClusterMap(), stride::ClusterSaver::getPopCount(), and stride::ClusterSaver::saveClustersCSV().
|
inline |
Definition at line 145 of file Simulator.h.
Referenced by stride::ClusterCalculator< ClusterType::SecondaryCommunity >::calculateSurface(), stride::ClusterCalculator< ClusterType::SecondaryCommunity >::getClusterMap(), and stride::ClusterSaver::saveClustersCSV().
|
inline |
Definition at line 147 of file Simulator.h.
Referenced by stride::ClusterSaver::saveTransportationFacilities().
|
private |
Update the contacts in the given clusters.
Definition at line 65 of file Simulator.cpp.
References stride::Infector< log_level, track_index_case, local_information_policy >::execute(), m_calendar, m_disease_profile, m_households, m_logger, m_parallel, m_primary_community, m_school_clusters, m_secondary_community, and m_work_clusters.
|
friend |
Definition at line 201 of file Simulator.h.
|
friend |
Definition at line 203 of file Simulator.h.
|
friend |
Definition at line 205 of file Simulator.h.
|
friend |
Definition at line 207 of file Simulator.h.
|
friend |
Definition at line 209 of file Simulator.h.
|
private |
Definition at line 151 of file Simulator.h.
|
private |
Definition at line 152 of file Simulator.h.
|
private |
The number of threads(as a hint)
Definition at line 160 of file Simulator.h.
Definition at line 168 of file Simulator.h.
Referenced by Simulator(), and updateClusters().
|
private |
Definition at line 170 of file Simulator.h.
Referenced by chooseCluster(), getRngStates(), sendNewTravellers(), setRngStates(), and Simulator().
|
private |
|
private |
Management of calendar.
Definition at line 172 of file Simulator.h.
Referenced by timeStep(), and updateClusters().
|
private |
Configuration property tree.
Definition at line 175 of file Simulator.h.
Referenced by stride::run::Runner::initOutputs().
|
private |
Definition at line 176 of file Simulator.h.
|
private |
Definition at line 177 of file Simulator.h.
Referenced by stride::run::Runner::initOutputs(), and updateClusters().
|
private |
Pointer to the Population.
Definition at line 178 of file Simulator.h.
Referenced by getPopulation(), hostForeignTravellers(), returnForeignTravellers(), sendNewTravellers(), timeStep(), and welcomeHomeTravellers().
|
private |
Container with household Clusters.
Definition at line 180 of file Simulator.h.
Referenced by getClusters(), and updateClusters().
|
private |
Container with school Clusters.
Definition at line 181 of file Simulator.h.
Referenced by getClusters(), and updateClusters().
|
private |
Container with work Clusters.
Definition at line 182 of file Simulator.h.
Referenced by getClusters(), hostForeignTravellers(), returnForeignTravellers(), and updateClusters().
|
private |
Container with primary community Clusters.
Definition at line 183 of file Simulator.h.
Referenced by getClusters(), hostForeignTravellers(), returnForeignTravellers(), and updateClusters().
|
private |
Container with secondary community Clusters.
Definition at line 184 of file Simulator.h.
Referenced by getClusters(), hostForeignTravellers(), returnForeignTravellers(), and updateClusters().
|
private |
Container with districts (villages and cities).
Definition at line 186 of file Simulator.h.
Referenced by hostForeignTravellers(), and timeStep().
|
private |
Communication between the simulator and the senders.
Definition at line 188 of file Simulator.h.
Referenced by returnForeignTravellers(), and sendNewTravellers().
|
private |
|
private |
General simulation or tracking index case.
Definition at line 192 of file Simulator.h.
Referenced by setTrackIndexCase(), and timeStep().
|
private |
The ID of the next traveller that arrives.
Definition at line 194 of file Simulator.h.
Referenced by hostForeignTravellers().
|
private |
The household ID of the next traveller that arrives.
Definition at line 195 of file Simulator.h.
Referenced by hostForeignTravellers().
|
private |
Name of the simulator (the region it simulates)
Definition at line 196 of file Simulator.h.
Referenced by sendNewTravellers().
|
private |
The Planner, responsible for the timing of travellers (when do they return home?).
Definition at line 198 of file Simulator.h.
Referenced by hostForeignTravellers(), and returnForeignTravellers().