67 double immunityLinkProbability)
70 const auto poolsSize =
static_cast<int>(pools.
size());
71 auto intGenerator = m_rn_man.GetUniformIntGenerator(0, poolsSize, 0U);
72 auto uniform01Generator = m_rn_man.GetUniform01Generator(0U);
75 vector<double> populationBrackets(100, 0.0);
78 for (
auto& c : pools) {
79 for (
const auto &p : c.GetPool()) {
80 populationBrackets[p->GetAge()]++;
85 unsigned int numImmune = 0;
86 for (
unsigned int age = 0; age < 100; age++) {
87 populationBrackets[age] = floor(populationBrackets[age] * immunityDistribution[age]);
88 numImmune +=
static_cast<unsigned int>(populationBrackets[age]);
92 while (numImmune > 0) {
95 const auto size =
static_cast<unsigned int>(p_pool.
GetPool().size());
98 vector<unsigned int> indices(size);
99 iota(indices.begin(), indices.end(), 0U);
100 m_rn_man.Shuffle(indices, 0U);
103 for (
unsigned int i_p = 0; i_p < size && numImmune > 0; i_p++) {
108 populationBrackets[p.
GetAge()]--;
113 if(uniform01Generator() < (1 - immunityLinkProbability)) {
124 const auto popSize =
static_cast<int>(pop->size());
125 auto intGenerator = m_rn_man.GetUniformIntGenerator(0, popSize, 0U);
126 auto uniform01Generator = m_rn_man.GetUniform01Generator(0U);
129 vector<double> populationBrackets(100, 0.0);
130 vector<double> immuneByAge(100, 0.0);
133 for (
auto person_it = pop->begin(); person_it < pop->end(); person_it++) {
134 const auto age = person_it->GetAge();
135 populationBrackets[age]++;
139 unsigned int numImmune = 0;
140 for (
unsigned int age = 0; age < 100; age++) {
141 populationBrackets[age] = floor(populationBrackets[age] * immunityDistribution[age]);
142 numImmune +=
static_cast<unsigned int>(populationBrackets[age]);
146 while (numImmune > 0) {
148 auto& p = (*pop)[intGenerator()];
149 if (p.GetHealth().IsSusceptible() && immuneByAge[p.GetAge()] < populationBrackets[p.GetAge()]) {
150 p.GetHealth().SetImmune();
151 immuneByAge[p.GetAge()]++;
154 if (uniform01Generator() < immunityLinkProbability) {
155 const auto poolId = p.GetPoolId(contactPoolType);
156 const auto& pool = pop->CRefPoolSys().CRefPools(contactPoolType)[poolId].GetPool();
157 for (
auto i_p = pool.begin(); i_p < pool.end() && numImmune > 0; i_p++) {
158 if ((immuneByAge[(*i_p)->GetAge()] < populationBrackets[(*i_p)->GetAge()] * 1.1) && ((*i_p)->GetHealth().IsSusceptible())) {
159 (*i_p)->GetHealth().SetImmune();
160 immuneByAge[(*i_p)->GetAge()]++;
Health & GetHealth()
Return person's health status.
Id
Enumerates the ContactPool types.
Header file for the Person class.
A group of Persons that potentially have contacts with one another.
void SetImmune()
Set health state to immune.
float GetAge() const
Get the age.
Container that stores objects "almost contiguously" (in a chain of blocks) and guarantees that pointe...
const std::vector< Person * > & GetPool() const
Get the entire pool of members.
void Cocoon(const util::SegmentedVector< ContactPool > &, std::vector< double > &, double)
Cocoon immunization.
void Random(const util::SegmentedVector< ContactPool > &pools, std::vector< double > &immunityDistribution, double immunityLinkProbability)
Random immunization.
std::size_t size() const
Returns the number of elements.
Store and handle person data.
Namespace for the simulator and related classes.
bool IsSusceptible() const
Is this person susceptible?
Header for the Immunizer class.