Stride Reference Manual  1.0
stride::Simulator Class Reference

Main class that contains and direct the virtual world. More...

#include <Simulator.h>

Inheritance diagram for stride::Simulator:
Inheritance graph
Collaboration diagram for stride::Simulator:
Collaboration graph

Public Types

using GlobalInformationPolicy = NoGlobalInformation
 
using LocalInformationPolicy = NoLocalInformation
 
using BeliefPolicy = NoBelief
 
using BehaviourPolicy = NoBehaviour< BeliefPolicy >
 
using PersonType = Person< BehaviourPolicy, BeliefPolicy >
 
using TravellerType = Traveller< PersonType >
 
- Public Types inherited from stride::util::Subject< Simulator >
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 PopulationgetPopulation () 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 CalendargetCalendar () 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
 
- Public Member Functions inherited from stride::util::Subject< Simulator >
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::TravellerTypem_trav_elsewhere
 
std::map< unsigned int, Simulator::TravellerTypem_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::Randomm_rng
 
LogMode m_log_level
 Specifies logging mode. More...
 
std::shared_ptr< Calendarm_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< Populationm_population
 Pointer to the Population. More...
 
std::vector< Clusterm_households
 Container with household Clusters. More...
 
std::vector< Clusterm_school_clusters
 Container with school Clusters. More...
 
std::vector< Clusterm_work_clusters
 Container with work Clusters. More...
 
std::vector< Clusterm_primary_community
 Container with primary community Clusters. More...
 
std::vector< Clusterm_secondary_community
 Container with secondary community Clusters. More...
 
std::vector< Districtm_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
 

Detailed Description

Main class that contains and direct the virtual world.

Definition at line 64 of file Simulator.h.

Member Typedef Documentation

Definition at line 69 of file Simulator.h.

Definition at line 74 of file Simulator.h.

Definition at line 163 of file Simulator.h.

Constructor & Destructor Documentation

stride::Simulator::Simulator ( )

Default constructor for empty Simulator.

Definition at line 43 of file Simulator.cpp.

References m_parallel, and m_rng.

Member Function Documentation

const shared_ptr< const Population > stride::Simulator::getPopulation ( ) const

Get the population.

Definition at line 56 of file Simulator.cpp.

References m_population.

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.

void stride::Simulator::setName ( string  name)
inline

Definition at line 85 of file Simulator.h.

string stride::Simulator::getName ( ) const
inline

Definition at line 87 of file Simulator.h.

Referenced by stride::run::Runner::initOutputs().

void stride::Simulator::setCommunicationMap ( const std::map< string, AsyncSimulator * > &  comm_map)
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().

const Calendar& stride::Simulator::getCalendar ( ) const
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

Retrieve the states of the rng's.

Definition at line 152 of file Simulator.cpp.

References m_rng.

void stride::Simulator::setRngStates ( std::vector< std::string >  states)

Set the states of the rng's.

Definition at line 160 of file Simulator.cpp.

References m_rng.

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().

const SimplePlanner<Traveller<Simulator::PersonType> >& stride::Simulator::getPlanner ( ) const
inline

Definition at line 134 of file Simulator.h.

const std::vector<Cluster>& stride::Simulator::getSchoolClusters ( ) const
inline
const std::vector<Cluster>& stride::Simulator::getWorkClusters ( ) const
inline
const std::vector<District>& stride::Simulator::getDistricts ( ) const
inline

Definition at line 147 of file Simulator.h.

Referenced by stride::ClusterSaver::saveTransportationFacilities().

template<LogMode log_level, bool track_index_case>
void stride::Simulator::updateClusters ( )
private

Friends And Related Function Documentation

friend class SimulatorBuilder
friend

Definition at line 201 of file Simulator.h.

friend class LocalSimulatorAdapter
friend

Definition at line 203 of file Simulator.h.

friend class Hdf5Saver
friend

Definition at line 205 of file Simulator.h.

friend class Hdf5Loader
friend

Definition at line 207 of file Simulator.h.

friend class run::Runner
friend

Definition at line 209 of file Simulator.h.

Member Data Documentation

std::map<unsigned int, Simulator::TravellerType> stride::Simulator::m_trav_elsewhere
private

Definition at line 151 of file Simulator.h.

std::map<unsigned int, Simulator::TravellerType> stride::Simulator::m_trav_hosting
private

Definition at line 152 of file Simulator.h.

unsigned int stride::Simulator::m_num_threads
private

The number of threads(as a hint)

Definition at line 160 of file Simulator.h.

decltype(Parallel().with<RandomRef>()) stride::Simulator::m_parallel
private

Definition at line 168 of file Simulator.h.

Referenced by Simulator(), and updateClusters().

std::shared_ptr<util::Random> stride::Simulator::m_rng
private

Definition at line 170 of file Simulator.h.

Referenced by chooseCluster(), getRngStates(), sendNewTravellers(), setRngStates(), and Simulator().

LogMode stride::Simulator::m_log_level
private

Specifies logging mode.

Definition at line 171 of file Simulator.h.

Referenced by timeStep().

std::shared_ptr<Calendar> stride::Simulator::m_calendar
private

Management of calendar.

Definition at line 172 of file Simulator.h.

Referenced by timeStep(), and updateClusters().

boost::property_tree::ptree stride::Simulator::m_config_pt
private

Configuration property tree.

Definition at line 175 of file Simulator.h.

Referenced by stride::run::Runner::initOutputs().

boost::property_tree::ptree stride::Simulator::m_config_pop
private

Definition at line 176 of file Simulator.h.

std::shared_ptr<spdlog::logger> stride::Simulator::m_logger
private

Definition at line 177 of file Simulator.h.

Referenced by stride::run::Runner::initOutputs(), and updateClusters().

std::shared_ptr<Population> stride::Simulator::m_population
private
std::vector<Cluster> stride::Simulator::m_households
private

Container with household Clusters.

Definition at line 180 of file Simulator.h.

Referenced by getClusters(), and updateClusters().

std::vector<Cluster> stride::Simulator::m_school_clusters
private

Container with school Clusters.

Definition at line 181 of file Simulator.h.

Referenced by getClusters(), and updateClusters().

std::vector<Cluster> stride::Simulator::m_work_clusters
private

Container with work Clusters.

Definition at line 182 of file Simulator.h.

Referenced by getClusters(), hostForeignTravellers(), returnForeignTravellers(), and updateClusters().

std::vector<Cluster> stride::Simulator::m_primary_community
private

Container with primary community Clusters.

Definition at line 183 of file Simulator.h.

Referenced by getClusters(), hostForeignTravellers(), returnForeignTravellers(), and updateClusters().

std::vector<Cluster> stride::Simulator::m_secondary_community
private

Container with secondary community Clusters.

Definition at line 184 of file Simulator.h.

Referenced by getClusters(), hostForeignTravellers(), returnForeignTravellers(), and updateClusters().

std::vector<District> stride::Simulator::m_districts
private

Container with districts (villages and cities).

Definition at line 186 of file Simulator.h.

Referenced by hostForeignTravellers(), and timeStep().

std::map<string, AsyncSimulator*> stride::Simulator::m_communication_map
private

Communication between the simulator and the senders.

Definition at line 188 of file Simulator.h.

Referenced by returnForeignTravellers(), and sendNewTravellers().

DiseaseProfile stride::Simulator::m_disease_profile
private

Profile of disease.

Definition at line 190 of file Simulator.h.

Referenced by updateClusters().

bool stride::Simulator::m_track_index_case
private

General simulation or tracking index case.

Definition at line 192 of file Simulator.h.

Referenced by setTrackIndexCase(), and timeStep().

uint stride::Simulator::m_next_id
private

The ID of the next traveller that arrives.

Definition at line 194 of file Simulator.h.

Referenced by hostForeignTravellers().

uint stride::Simulator::m_next_hh_id
private

The household ID of the next traveller that arrives.

Definition at line 195 of file Simulator.h.

Referenced by hostForeignTravellers().

string stride::Simulator::m_name
private

Name of the simulator (the region it simulates)

Definition at line 196 of file Simulator.h.

Referenced by sendNewTravellers().

SimplePlanner<Traveller<Simulator::PersonType> > stride::Simulator::m_planner
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().


The documentation for this class was generated from the following files: