Example #1
0
//calcul du type de menage (suite a la modification d'un menage. exemple : décès, mariage,etc.)
void Household::computeHhType(SharedContext<Individual> & agentsInd) {

  int n_mate = 0;
  int n_children = 0;
  int n_adults = 0;

  char head_gender;

  this->getIndividuals(agentsInd)[0]->setHhRelationship('H'); // TODO faire attention aux orphelins (et autres adultes)!
  agentsInd.getAgent(this->getListInd()[0])->setHhRelationship('H');

  for (unsigned int i = 1; i < this->getIndividuals(agentsInd).size(); i++) {

    switch (this->getIndividuals(agentsInd)[i]->getHhRelationship()) {
      case 'M':
        n_mate++;
        break;
      case 'C':
        n_children++;
        break;
      case 'A':
        n_adults++;
        break;
      default:
        break;
    }
  }

  head_gender = this->getIndividuals(agentsInd)[0]->getGender();

  if (n_mate == 0) {
    if (n_children == 0) {
      if (head_gender == 'M') {
        this->_type = "IH";
      } else {
        this->_type = "IF";
      }
    } else {
      if (head_gender == 'M') {
        this->_type = "M";
      } else {
        this->_type = "W";
      }
    }
  } else {
    if (n_children == 0) {
      this->_type = "C";
    } else {
      this->_type = "F";
    }
  }

  this->_n_children = n_children;
  this->_n_adults = n_adults;

}
Example #2
0
//retourne les individus du menage -> doit se faire sous forme de liste
//d'id d'agents! -> erreur ici!!!!!!!!!
vector<Individual *> Household::getIndividuals(SharedContext<Individual> & agentsInd) {

  vector<Individual *> individuals;

  for (unsigned int i = 0; i < this->_list_ind.size(); i++) {
    individuals.push_back(agentsInd.getAgent(_list_ind[i]));
  }

  return individuals;

}