本文整理汇总了C++中SharedContext::getAgent方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedContext::getAgent方法的具体用法?C++ SharedContext::getAgent怎么用?C++ SharedContext::getAgent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedContext
的用法示例。
在下文中一共展示了SharedContext::getAgent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeHhType
//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;
}
示例2:
//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;
}