// =========================================================================== // method definitions // =========================================================================== void AGHousehold::generatePeople() { AGDataAndStatistics* ds = &(myCity->statData); //the first adult AGAdult pers(ds->getRandomPopDistributed(ds->limitAgeChildren, ds->limitEndAge)); adults.push_back(pers); //the second adult if (decisionProba(ds->secondPersProb)) { if (pers.getAge() < ds->limitAgeRetirement) { AGAdult pers2(ds->getRandomPopDistributed(ds->limitAgeChildren, ds->limitAgeRetirement)); adults.push_back(pers2); } else { AGAdult pers2(ds->getRandomPopDistributed(ds->limitAgeRetirement, ds->limitEndAge)); adults.push_back(pers2); } } //Children if (pers.getAge() < ds->limitAgeRetirement) { int numChild = ds->getPoissonsNumberOfChildren(ds->meanNbrChildren); while (numChild > 0) { AGChild chl(ds->getRandomPopDistributed(0, ds->limitAgeChildren)); children.push_back(chl); --numChild; } } }
// =========================================================================== // method definitions // =========================================================================== void AGHousehold::generatePeople(int numAdults, int numChilds, bool firstRetired) { AGDataAndStatistics* ds = &(myCity->statData); //the first adult AGAdult pers(ds->getRandomPopDistributed(ds->limitAgeChildren, ds->limitEndAge)); if (firstRetired) { pers = AGAdult(ds->getRandomPopDistributed(ds->limitAgeRetirement, ds->limitEndAge)); } myAdults.push_back(pers); //further adults while (static_cast<int>(myAdults.size()) < numAdults) { if (firstRetired) { AGAdult pers2(ds->getRandomPopDistributed(ds->limitAgeRetirement, ds->limitEndAge)); myAdults.push_back(pers2); } else { AGAdult pers2(ds->getRandomPopDistributed(ds->limitAgeChildren, ds->limitAgeRetirement)); myAdults.push_back(pers2); } } //Children while (static_cast<int>(myChildren.size()) < numChilds) { AGChild chl(ds->getRandomPopDistributed(0, ds->limitAgeChildren)); myChildren.push_back(chl); } }