29 #include <spdlog/spdlog.h> 43 template<
bool track_index_case = false>
53 class R0_POLICY<true> {
61 template<LogMode log_level = LogMode::None>
65 ClusterType cluster_type, shared_ptr<const Calendar> environ) {}
75 ClusterType cluster_type, shared_ptr<const Calendar> environ) {
76 logger.info(
"[TRAN] {} {} {} {}",
77 p1->getId(), p2->getId(),
toString(cluster_type), environ->getSimulationDay());
88 ClusterType cluster_type, shared_ptr<const Calendar> calendar) {
95 logger.info(
"[CONT] {} {} {} {} {} {} {} {} {}",
96 p1->getId(), p1->getAge(), p2->getAge(), home, school, work, primary_community,
98 calendar->getSimulationDay());
108 template<LogMode log_level,
bool track_index_case,
typename local_information_policy>
111 util::Random& contact_handler, shared_ptr<const Calendar> calendar, spdlog::logger& logger) {
116 const auto& c_members = cluster.
m_members;
120 for (
size_t i_person1 = 0; i_person1 < c_members.size(); i_person1++) {
122 if (c_members[i_person1].second) {
123 auto p1 = c_members[i_person1].first;
128 for (
size_t i_person2 = i_person1 + 1; i_person2 < c_members.size(); i_person2++) {
130 if (c_members[i_person2].second) {
131 auto p2 = c_members[i_person2].first;
134 if (contact_handler.
hasContact(contact_rate)) {
136 local_information_policy::update(p1, p2);
138 bool transmission = contact_handler.
hasTransmission(transmission_rate);
140 if (p1->getHealth().isInfectious() && p2->getHealth().isSusceptible()) {
141 LOG_POLICY<log_level>::execute(logger, p1, p2, c_type, calendar);
142 p2->getHealth().startInfection();
143 R0_POLICY<track_index_case>::execute(p2);
144 }
else if (p2->getHealth().isInfectious() && p1->getHealth().isSusceptible()) {
145 LOG_POLICY<log_level>::execute(logger, p2, p1, c_type, calendar);
146 p1->getHealth().startInfection();
147 R0_POLICY<track_index_case>::execute(p1);
161 template<LogMode log_level,
bool track_index_case>
164 util::Random& contact_handler, shared_ptr<const Calendar> calendar, spdlog::logger& logger) {
167 bool infectious_cases;
169 tie(infectious_cases, num_cases) = cluster.
sortMembers();
171 if (infectious_cases) {
177 const auto& c_members = cluster.
m_members;
181 for (
size_t i_infected = 0; i_infected < num_cases; i_infected++) {
183 if (c_members[i_infected].second) {
184 const auto p1 = c_members[i_infected].first;
186 if (p1->getHealth().isInfectious()) {
189 for (
size_t i_contact = num_cases; i_contact < c_immune; i_contact++) {
191 if (c_members[i_contact].second) {
192 auto p2 = c_members[i_contact].first;
194 LOG_POLICY<log_level>::execute(logger, p1, p2, c_type, calendar);
195 p2->getHealth().startInfection();
196 R0_POLICY<track_index_case>::execute(p2);
210 template<
bool track_index_case>
213 util::Random& contact_handler, shared_ptr<const Calendar> calendar, spdlog::logger& logger) {
219 const auto& c_members = cluster.
m_members;
223 for (
size_t i_person1 = 0; i_person1 < c_members.size(); i_person1++) {
225 if (c_members[i_person1].second && c_members[i_person1].first->isParticipatingInSurvey()) {
226 auto p1 = c_members[i_person1].first;
229 for (
size_t i_person2 = i_person1 + 1; i_person2 < c_members.size(); i_person2++) {
231 if (c_members[i_person2].second) {
232 auto p2 = c_members[i_person2].first;
234 if (contact_handler.
hasContact(contact_rate)) {
235 bool transmission = contact_handler.
hasTransmission(transmission_rate);
237 if (p1->getHealth().isInfectious() && p2->getHealth().isSusceptible()) {
238 p2->getHealth().startInfection();
239 R0_POLICY<track_index_case>::execute(p2);
240 }
else if (p2->getHealth().isInfectious() && p1->getHealth().isSusceptible()) {
241 p1->getHealth().startInfection();
242 R0_POLICY<track_index_case>::execute(p1);
246 LOG_POLICY<LogMode::Contacts>::execute(logger, p1, p2, c_type, calendar);
void updateMemberPresence()
Calculate which members are present in the cluster on the current day.
Person< BehaviourPolicy, BeliefPolicy > PersonType
string toString(ClusterType c)
Converts a ClusterType value to corresponding name.
double getContactRate(const Simulator::PersonType *p) const
Get basic contact rate in this cluster.
Header for the Infector class.
Header file for the Calendar class.
std::vector< std::pair< Simulator::PersonType *, bool > > m_members
Container with pointers to Cluster members.
Time Dependent Person DataType.
bool hasContact(double contact_rate)
Check if two individuals have contact.
static void execute(Cluster &cluster, DiseaseProfile disease_profile, util::Random &contact_handler, std::shared_ptr< const Calendar > calendar, spdlog::logger &logger)
Header file for the Person class.
bool hasContactAndTransmission(double contact_rate, double transmission_rate)
bool hasTransmission(double transmission_rate)
Check if two individuals have transmission.
Header for the Random Number Generator class.
std::tuple< bool, size_t > sortMembers()
Sort members w.r.t. health status (order: exposed/infected/recovered, susceptible, immune).
Actual contacts and transmission in cluster (primary template).
LogMode
Enum specifiying the level of logging required:
std::size_t m_index_immune
Index of the first immune member in the Cluster.
Header for the LogMode class.
Represents a location for social contacts, an group of people.
ClusterType
Enumerates the cluster types.
Header for the core Cluster class.
ClusterType m_cluster_type
The type of the Cluster (for logging purposes).
The random number generator.
double getTransmissionRate()
Return transmission rate.