#include <classifier.h>
Nevrax France
Definition at line 165 of file classifier.h.
|
Definition at line 200 of file classifier.h. Referenced by selectBehavior(). |
|
Destructor.
Definition at line 79 of file classifier.cpp. References _ClassifierNumber.
00080 { 00081 _ClassifierNumber = 0; 00082 } |
|
Definition at line 84 of file classifier.cpp. References _Classifiers.
00085 { 00086 std::map<TClassifierNumber, CClassifier*>::iterator itClassifiers = _Classifiers.begin(); 00087 while (itClassifiers != _Classifiers.end()) 00088 { 00089 delete (*itClassifiers).second; 00090 itClassifiers++; 00091 } 00092 } |
|
Add a new classifier in the classifier system.
Definition at line 94 of file classifier.cpp. References _ClassifierNumber, _Classifiers, _Sensors, NLAINIMAT::CConditionMap::begin(), NLAINIMAT::CClassifierSystem::CClassifier::Behavior, NLAINIMAT::CClassifierSystem::CClassifier::ConditionWithoutTarget, NLAINIMAT::CClassifierSystem::CClassifier::ConditionWithTarget, NLAINIMAT::CConditionMap::end(), NLAINIMAT::CClassifierSystem::CClassifier::Priority, and NLAINIMAT::TSensor. Referenced by addClassifierSystem(), NLAINIMAT::CActionClassifiers::addMotivationRule(), and NLAINIMAT::CActionClassifiers::addVirtualActionRule().
00095 { 00096 // We build a new classifier. 00097 CClassifier* classifier = new CClassifier(); 00098 classifier->Behavior = behavior; 00099 classifier->Priority = priority; 00100 00101 CClassifierConditionCell* condCell; 00102 std::map<TSensor, CConditionMap::CSensor >::const_iterator itCondition; 00103 for (itCondition = conditionsMap.begin(); itCondition != conditionsMap.end(); itCondition++) 00104 { 00105 // We add the new sensor in the sensor map and init it with a joker value '#' 00106 TSensor bibu = (*itCondition).first; 00107 _Sensors[(*itCondition).first] = '#'; 00108 00109 // A new condition cell is added to the classifier condition. 00110 condCell = new CClassifierConditionCell(_Sensors.find((*itCondition).first), 00111 (*itCondition).second.SensorValue, 00112 (*itCondition).second.TruthValue); 00113 if ((*itCondition).second.NeedTarget) 00114 { 00115 classifier->ConditionWithTarget.push_back(condCell); 00116 } 00117 else 00118 { 00119 classifier->ConditionWithoutTarget.push_back(condCell); 00120 } 00121 } 00122 00123 // The new classifier is added to the classifier list. 00124 _Classifiers[_ClassifierNumber++] = classifier; 00125 } |
|
Merge two CS.
Definition at line 128 of file classifier.cpp. References _Classifiers, addClassifier(), NLAINIMAT::CConditionMap::addSensorCondition(), NLAINIMAT::CClassifierSystem::CClassifierConditionCell::getSensorIsTrue(), NLAINIMAT::CClassifierSystem::CClassifierConditionCell::getSensorName(), and NLAINIMAT::CClassifierSystem::CClassifierConditionCell::getValue(). Referenced by NLAINIMAT::CMHiCSbase::addVirtualActionCS().
00129 { 00130 std::map<TClassifierNumber, CClassifier*>::const_iterator itCSClassifiers; 00131 00132 // Pour chacun des classeurs de cs 00133 for (itCSClassifiers = cs._Classifiers.begin(); itCSClassifiers != cs._Classifiers.end(); itCSClassifiers++) 00134 { 00135 CConditionMap conditionsMap; 00136 std::list<CClassifierConditionCell*>::const_iterator itCondCell; 00137 00138 // Pour chacune des condition sans cible d'un de ces classeur 00139 for (itCondCell = (*itCSClassifiers).second->ConditionWithoutTarget.begin(); 00140 itCondCell !=(*itCSClassifiers).second->ConditionWithoutTarget.end(); 00141 itCondCell++) 00142 { 00143 CClassifierConditionCell* pCondCell = (*itCondCell); 00144 // Je construit une liste de condition 00145 conditionsMap.addSensorCondition(pCondCell->getSensorName(), pCondCell->getValue(),pCondCell->getSensorIsTrue()); 00146 } 00147 00148 // Pour chacune des condition avec cible d'un de ces classeur 00149 for (itCondCell = (*itCSClassifiers).second->ConditionWithTarget.begin(); 00150 itCondCell !=(*itCSClassifiers).second->ConditionWithTarget.end(); 00151 itCondCell++) 00152 { 00153 CClassifierConditionCell* pCondCell = (*itCondCell); 00154 // Je construit une liste de condition 00155 conditionsMap.addSensorCondition(pCondCell->getSensorName(), pCondCell->getValue(),pCondCell->getSensorIsTrue()); 00156 } 00157 00158 // je rajoute dans mon cs un nouveau classeur avec ces conditions, la priorité et le comportement du classeur 00159 addClassifier(conditionsMap, (*itCSClassifiers).second->Priority, (*itCSClassifiers).second->Behavior); 00160 } 00161 } |
|
|
|
Give the action part of a given Classifier.
Definition at line 413 of file classifier.cpp. References _Classifiers, nlassert, NLAINIMAT::TAction, and NLAINIMAT::TClassifierNumber.
00414 { 00415 std::map<TClassifierNumber, CClassifier*>::const_iterator itClassifiers = _Classifiers.find(classifierNumber); 00416 nlassert(itClassifiers != _Classifiers.end()); 00417 return (*itClassifiers).second->Behavior; 00418 } |
|
Return the number of classifiers.
Definition at line 262 of file classifier.h. References _ClassifierNumber, and NLAINIMAT::TClassifierNumber.
00262 {return _ClassifierNumber;} |
|
Definition at line 505 of file classifier.cpp. References _Classifiers, NLAINIMAT::CClassifierPriority::getPriority(), NLAINIMAT::CClassifierSystem::CClassifierConditionCell::getSensorIsTrue(), NLAINIMAT::CClassifierSystem::CClassifierConditionCell::getSensorName(), NLAINIMAT::CClassifierSystem::CClassifierConditionCell::getValue(), nlassert, t, NLAINIMAT::TClassifierNumber, and NLMISC::toString().
00506 { 00507 std::string dbg = ""; 00508 std::map<TClassifierNumber, CClassifier*>::const_iterator itClassifiers = _Classifiers.find(classifierNumber); 00509 nlassert (itClassifiers != _Classifiers.end()); 00510 00511 dbg += "<" + NLMISC::toString(classifierNumber) + "> "; 00512 std::list<CClassifierConditionCell*>::const_iterator itConditions; 00513 // On parcour la liste de sensor indépendant d'une cible 00514 for (itConditions = (*itClassifiers).second->ConditionWithoutTarget.begin(); 00515 itConditions != (*itClassifiers).second->ConditionWithoutTarget.end(); 00516 itConditions++) 00517 { 00518 CClassifierConditionCell* condCell = (*itConditions); 00519 if (condCell->getSensorIsTrue()) 00520 { 00521 dbg += " (" + conversionSensor.toString(condCell->getSensorName()) + "= " + condCell->getValue() + ") +"; 00522 } 00523 else 00524 { 00525 dbg += " (" + conversionSensor.toString(condCell->getSensorName()) + "=!" + condCell->getValue() + ") +"; 00526 } 00527 } 00528 // On parcour la liste de sensor dépendant d'une cible 00529 for (itConditions = (*itClassifiers).second->ConditionWithTarget.begin(); 00530 itConditions != (*itClassifiers).second->ConditionWithTarget.end(); 00531 itConditions++) 00532 { 00533 CClassifierConditionCell* condCell = (*itConditions); 00534 if (condCell->getSensorIsTrue()) 00535 { 00536 dbg += " (" + conversionSensor.toString(condCell->getSensorName()) + "(x)= " + condCell->getValue() + ") +"; 00537 } 00538 else 00539 { 00540 dbg += " (" + conversionSensor.toString(condCell->getSensorName()) + "(x)=!" + condCell->getValue() + ") +"; 00541 } 00542 } 00543 std::string actionName = conversionAction.toString((*itClassifiers).second->Behavior); 00544 CClassifierPriority prio = (*itClassifiers).second->Priority; 00545 dbg += "> " + actionName + " [" + NLMISC::toString(prio.getPriority()) + "]"; 00546 t += dbg; 00547 } |
|
Definition at line 459 of file classifier.cpp. References _Classifiers, NLAINIMAT::CClassifierPriority::getPriority(), NLAINIMAT::CClassifierSystem::CClassifierConditionCell::getSensorIsTrue(), NLAINIMAT::CClassifierSystem::CClassifierConditionCell::getSensorName(), NLAINIMAT::CClassifierSystem::CClassifierConditionCell::getValue(), t, and NLMISC::toString().
00460 { 00461 std::string dbg = "\n"; 00462 00463 std::map<TClassifierNumber, CClassifier*>::const_iterator itClassifiers; 00464 for (itClassifiers = _Classifiers.begin(); itClassifiers != _Classifiers.end(); itClassifiers++) 00465 { 00466 dbg += "<" + NLMISC::toString((*itClassifiers).first) + "> "; 00467 std::list<CClassifierConditionCell*>::const_iterator itConditions; 00468 // On parcour la liste de sensor indépendant d'une cible 00469 for (itConditions = (*itClassifiers).second->ConditionWithoutTarget.begin(); 00470 itConditions != (*itClassifiers).second->ConditionWithoutTarget.end(); 00471 itConditions++) 00472 { 00473 CClassifierConditionCell* condCell = (*itConditions); 00474 if (condCell->getSensorIsTrue()) 00475 { 00476 dbg += " (" + conversionSensor.toString(condCell->getSensorName()) + "= " + condCell->getValue() + ") +"; 00477 } 00478 else 00479 { 00480 dbg += " (" + conversionSensor.toString(condCell->getSensorName()) + "=!" + condCell->getValue() + ") +"; 00481 } 00482 } 00483 // On parcour la liste de sensor dépendant d'une cible 00484 for (itConditions = (*itClassifiers).second->ConditionWithTarget.begin(); 00485 itConditions != (*itClassifiers).second->ConditionWithTarget.end(); 00486 itConditions++) 00487 { 00488 CClassifierConditionCell* condCell = (*itConditions); 00489 if (condCell->getSensorIsTrue()) 00490 { 00491 dbg += " (" + conversionSensor.toString(condCell->getSensorName()) + "(x)= " + condCell->getValue() + ") +"; 00492 } 00493 else 00494 { 00495 dbg += " (" + conversionSensor.toString(condCell->getSensorName()) + "(x)=!" + condCell->getValue() + ") +"; 00496 } 00497 } 00498 std::string actionName = conversionAction.toString((*itClassifiers).second->Behavior); 00499 CClassifierPriority prio = (*itClassifiers).second->Priority; 00500 dbg += "> " + actionName + " [" + NLMISC::toString(prio.getPriority()) + "]\n"; 00501 } 00502 t += dbg; 00503 } |
|
Definition at line 420 of file classifier.cpp. References _Classifiers, nlassert, and NLAINIMAT::TClassifierNumber.
00421 { 00422 std::map<TClassifierNumber, CClassifier*>::const_iterator itClassifiers = _Classifiers.find(classifierNumber); 00423 nlassert(itClassifiers != _Classifiers.end()); 00424 return (*itClassifiers).second->Priority; 00425 } |
|
Definition at line 215 of file classifier.cpp. References _Sensors, and NLAINIMAT::Sensors_WITHTARGET. Referenced by selectBehavior().
|
|
Definition at line 204 of file classifier.cpp. References _Sensors, and NLAINIMAT::Sensors_WITHTARGET. Referenced by selectBehavior().
|
|
Select a behavior according to the values in the sensorMap.
Definition at line 357 of file classifier.cpp. References _Classifiers, RAZNoTargetSensors(), RAZTargetSensors(), NLAINIMAT::CCSPerception::TargetSensors, TitClassifiers, NLAINIMAT::TTargetId, updateNoTargetSensors(), and updateTargetSensors().
00359 { 00360 // We update the internal sensor values for the no target sensors 00361 updateNoTargetSensors(psensorMap); 00362 00363 TitClassifiers itClassifiers; 00364 00365 for (itClassifiers = _Classifiers.begin(); 00366 itClassifiers != _Classifiers.end(); 00367 itClassifiers++) 00368 { 00369 // S'il y a des conditions dépendantes d'une cible, ce n'est pas activable. 00370 if ((*itClassifiers).second->ConditionWithTarget.begin() == (*itClassifiers).second->ConditionWithTarget.end()) 00371 { 00372 if ( (*itClassifiers).second->isActivable()) 00373 { 00374 mapActivableCS.insert(std::make_pair((*itClassifiers).second->Priority, std::make_pair((*itClassifiers).first, NullTargetId))); 00375 } 00376 } 00377 } 00378 00379 // We now do the same, but with target sensors. 00380 std::map<TTargetId, TSensorMap>::const_iterator itTargetSensorMap; 00381 for (itTargetSensorMap = psensorMap->TargetSensors.begin(); itTargetSensorMap != psensorMap->TargetSensors.end(); itTargetSensorMap++) 00382 { 00383 TTargetId myTarget = (*itTargetSensorMap).first; 00384 // We update the internal sensor values for the target sensors 00385 updateTargetSensors(psensorMap, myTarget); 00386 00387 // We select the activables classifiers 00388 for (itClassifiers = _Classifiers.begin(); 00389 itClassifiers != _Classifiers.end(); 00390 itClassifiers++) 00391 { 00392 // S'il n'y a pas de conditions dépendantes d'une cible, ça a déjà été traité au dessus. 00393 if ((*itClassifiers).second->ConditionWithTarget.begin() != (*itClassifiers).second->ConditionWithTarget.end()) 00394 { 00395 if ( (*itClassifiers).second->isActivable()) 00396 { 00397 mapActivableCS.insert(std::make_pair((*itClassifiers).second->Priority, std::make_pair((*itClassifiers).first, myTarget))); 00398 } 00399 } 00400 } 00401 RAZTargetSensors(); 00402 } 00403 00404 // We set the sensors back to the default value. 00405 RAZNoTargetSensors(); 00406 00407 // // We set the return values. 00408 // lastClassifierNumber = selectionNumber; 00409 // lastTarget = myTarget; 00410 // lastSelectionMaxPriority = higherPriority; 00411 } |
|
Definition at line 427 of file classifier.cpp. References _Classifiers, nlassert, and NLAINIMAT::TClassifierNumber.
00428 { 00429 std::map<TClassifierNumber, CClassifier*>::iterator itClassifiers = _Classifiers.find(classifierNumber); 00430 nlassert(itClassifiers != _Classifiers.end()); 00431 (*itClassifiers).second->Priority = priority; 00432 } |
|
Definition at line 164 of file classifier.cpp. References _Sensors, NLAINIMAT::CCSPerception::NoTargetSensors, NLAINIMAT::TSensor, and NLAINIMAT::TSensorValue. Referenced by selectBehavior().
00165 { 00166 // We use an internal sensor map, because each condition cell is mapped to this intrenal map. 00167 TSensorMap::iterator itSensors; 00168 TSensorMap::const_iterator itNoTargetSensors; 00169 00170 for (itSensors = _Sensors.begin(); itSensors != _Sensors.end(); itSensors++) 00171 { 00172 TSensor sensName = (*itSensors).first; 00173 itNoTargetSensors = psensorMap->NoTargetSensors.find(sensName); 00174 if (itNoTargetSensors !=psensorMap->NoTargetSensors.end()) 00175 { 00176 TSensorValue c = (*itNoTargetSensors).second; 00177 (*itSensors).second = c; 00178 } 00179 } 00180 } |
|
Definition at line 183 of file classifier.cpp. References _Sensors, nlassert, NLAINIMAT::CCSPerception::TargetSensors, NLAINIMAT::TSensor, NLAINIMAT::TSensorValue, and NLAINIMAT::TTargetId. Referenced by selectBehavior().
00184 { 00185 // We update the internal sensor values for the target sensors 00186 TSensorMap::iterator itSensors; 00187 TSensorMap::const_iterator itTargetSensors; 00188 std::map<TTargetId, TSensorMap>::const_iterator itTargetSensorMap = psensorMap->TargetSensors.find(target); 00189 nlassert( itTargetSensorMap != psensorMap->TargetSensors.end() ); 00190 00191 for (itSensors = _Sensors.begin(); itSensors != _Sensors.end(); itSensors++) 00192 { 00193 TSensor sensName = (*itSensors).first; 00194 itTargetSensors = (*itTargetSensorMap).second.find(sensName); 00195 if (itTargetSensors != (*itTargetSensorMap).second.end()) 00196 { 00197 TSensorValue c = (*itTargetSensors).second; 00198 (*itSensors).second = c; 00199 } 00200 } 00201 } |
|
Definition at line 222 of file classifier.h. Referenced by addClassifier(), CClassifierSystem(), and getClassifierNumber(). |
|
Definition at line 221 of file classifier.h. Referenced by addClassifier(), addClassifierSystem(), getActionPart(), getDebugString(), getPriorityPart(), selectBehavior(), setPriorityPart(), and ~CClassifierSystem(). |
|
Definition at line 220 of file classifier.h. Referenced by addClassifier(), RAZNoTargetSensors(), RAZTargetSensors(), updateNoTargetSensors(), and updateTargetSensors(). |