63 double pop = 0, work = 0;
64 std::vector<AGStreet*>::iterator it;
67 pop += (*it)->getPopulation();
68 work += (*it)->getWorkplaceNumber();
89 std::vector<AGStreet*>::iterator itS;
91 if (*itS == itE.second) {
96 if (itS ==
streets.end() && !itE.second->isInternal()) {
97 streets.push_back(static_cast<AGStreet*>(itE.second));
104 std::vector<AGStreet*>::iterator it;
105 int workPositionCounter = 0;
110 for (
int i = 0; i < (*it)->getWorkplaceNumber(); ++i) {
112 ++workPositionCounter;
115 }
catch (
const std::bad_alloc& e) {
116 std::cout <<
"Number of work positions at bad_alloc exception: " << workPositionCounter << std::endl;
123 std::cout <<
"--> work position: " << std::endl;
124 std::cout <<
" |-> in city: " << workPositionCounter << std::endl;
133 if (nbrWorkers <= 0) {
146 for (
int i = 0; i < nbrOutWorkPositions; ++i) {
159 std::list<AGBusLine>::iterator it;
168 std::vector<AGStreet*>::iterator it;
171 int idHouseholds = 0;
180 numAdults[i] = -numAdults[i];
181 }
else if (totalChildrenLeft > 0) {
183 totalChildrenLeft -= numChilds[i];
188 for (
int i = 0; i < numSecondPers; i++) {
189 int index = i % numAdults.size();
190 if (numAdults[index] >= 0) {
191 numAdults[index] += 1;
193 numAdults[index] -= 1;
197 people += (*it)->getPopulation();
198 while (people > 0 && idHouseholds < (
int)numAdults.size()) {
202 households.back().generatePeople(abs(numAdults[i]), numChilds[i], numAdults[i] < 0);
205 numAdults[i] = numAdults[numAdults.size() - idHouseholds];
206 numChilds[i] = numChilds[numAdults.size() - idHouseholds];
219 std::list<AGHousehold>::iterator itt;
221 if (itt->getAdultNbr() == 1) {
223 if (itt->getAdults().front().isWorking()) {
227 if (itt->getAdultNbr() == 2) {
229 if (itt->getAdults().front().isWorking()) {
232 if (itt->getAdults().back().isWorking()) {
236 nbrChild += itt->getPeopleNbr() - itt->getAdultNbr();
248 std::cout <<
"--> population: " << std::endl;
249 std::cout <<
" |-> city households: " << nbrHH << std::endl;
250 std::cout <<
" |-> city people: " << nbrSingle + nbrCouple + nbrChild << std::endl;
251 std::cout <<
" |-> city single: " << nbrSingle <<
" / (in) couple: " << nbrCouple << std::endl;
252 std::cout <<
" |-> city adults: " << nbrSingle + nbrCouple << std::endl;
255 std::cout <<
" |-> city children: " << nbrChild << std::endl;
270 std::list<AGHousehold>::iterator it;
273 shortage = !it->allocateChildrenSchool();
297 std::list<AGHousehold>::iterator it;
305 if (it->retiredHouseholders()) {
308 shortage = !it->allocateAdultsWork();
310 std::cout <<
"===> ERROR: Not enough work positions in the city for all working people..." << std::endl;
321 std::list<AGAdult>::iterator itA;
327 std::cout <<
"not enough work for incoming people..." << std::endl;
333 std::list<AGHousehold>::iterator itt;
335 if (itt->getAdultNbr() == 1) {
336 if (itt->getAdults().front().isWorking()) {
340 if (itt->getAdultNbr() == 2) {
341 if (itt->getAdults().front().isWorking()) {
344 if (itt->getAdults().back().isWorking()) {
349 std::cout <<
" |-> working people: " <<
peopleIncoming.size() + workingP << std::endl;
350 std::cout <<
" |-> working people in city: " << workingP << std::endl;
351 std::cout <<
" |-> working people from outside: " <<
peopleIncoming.size() << std::endl;
359 std::list<AGHousehold>::iterator it;
377 if (newRate < 0 || newRate >= 1) {
384 it->generateCars(newRate);
386 nbrAdults += it->getAdultNbr();
410 std::cout <<
"first completed in getStreet() of City: Consolidation of data not needed in ActivityGen any more" << std::endl;
413 std::vector<AGStreet*>::iterator it =
streets.begin();
415 if ((*it)->getID() == edge) {
420 std::cout <<
"===> ERROR: WRONG STREET EDGE (" << edge <<
") given and not found in street set." << std::endl;
421 throw (std::runtime_error(
"Street not found with edge id " + edge));
427 throw (std::runtime_error(
"No street found in this city"));
int getPeopleOlderThan(int age)
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
AGDataAndStatistics & statData
int getRandomCityGateByOutgoing()
A model of the street in the city.
void generatePopulation()
int getRandomPopDistributed(int n, int m)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const AGStreet & getStreet(const std::string &edge)
static OptionsCont & getOptions()
Retrieves the options.
std::list< AGBusLine > busLines
An adult person who can have a job.
const AGStreet & getRandomStreet()
void generateOutgoingWP()
void generateWorkPositions()
int getPeopleYoungerThan(int age)
double factorWorkPositions
std::list< AGHousehold > households
std::vector< AGStreet * > streets
std::list< AGAdult > peopleIncoming
int getPoissonsNumberOfChildren(double mean)
const NamedObjectCont< ROEdge * > & getEdgeMap() const
static const T & getRandomFrom(const std::vector< T > &v, std::mt19937 *rng=0)
Returns a random element from the given vector.
void generateIncomingPopulation()
std::vector< AGPosition > cityGates
std::map< int, AGPosition > busStations
std::vector< AGWorkPosition > workPositions