From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02929.html | 1237 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1237 insertions(+) create mode 100644 docs/doxygen/nel/a02929.html (limited to 'docs/doxygen/nel/a02929.html') diff --git a/docs/doxygen/nel/a02929.html b/docs/doxygen/nel/a02929.html new file mode 100644 index 00000000..4d2d68dc --- /dev/null +++ b/docs/doxygen/nel/a02929.html @@ -0,0 +1,1237 @@ + + +NeL: NLAINIMAT::CMHiCSbase class Reference + + + +
+

NLAINIMAT::CMHiCSbase Class Reference

#include <mhics.h> +

+


Detailed Description

+A Modular Hierarchical Classifier System. This is the base component where all rules are stored.
Author:
Gabriel ROBERT

+Nevrax France

+
Date:
2002
+ +

+ +

+Definition at line 122 of file mhics.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

void addActionCS (const CActionClassifiers &action)
 Add a new action in the net.

void addVirtualActionCS (const CActionClassifiers &action)
 CMHiCSbase ()
void dbgPrintClassifierPriorityInFile (std::string fileName) const
void dividePriorityByTheMinPriorityPartInAMotivation (TMotivation motivationName)
TAction getActionPart (TMotivation motivationName, TClassifierNumber classifierNumber) const
void getDebugString (std::string &t) const
 Chaine de debug.

CClassifierPriority getPriorityPart (TMotivation motivationName, TClassifierNumber classifierNumber) const
bool isAnAction (TAction behav) const
 To now if a behav selected by a CS is an action (if not, it's a common CS).

void learningUpdatePriorityValueClassifierTime (TMotivation motivationName, TClassifierNumber classifierNumber, uint32 time)
void learningUpdatePriorityValueTimeToSuccess (TMotivation motivationName, TClassifierNumber classifierNumber, uint32 timeToSuccess)
 Update a priority value in learning mode.

bool loadClassifierFromFile (std::string fileName)
 Load classifiers from a file. Return false if thereis a probleme.

void printDebugString () const
void selectBehavior (TMotivation motivationName, const CCSPerception *psensorMap, std::multimap< CClassifierPriority, std::pair< TClassifierNumber, TTargetId > > &mapActivableCS)
void setPriorityValue (TMotivation motivationName, TClassifierNumber classifierNumber, CClassifierPriority priority)
 Set a new value for a classifier priority.

virtual ~CMHiCSbase ()

Data Fields

CActionResourcespActionResources

Private Attributes

std::set< TAction_ActionSet
std::map< TMotivation, CClassifierSystem_MotivationClassifierSystems
std::map< TAction, CClassifierSystem_VirtualActionClassifierSystems
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NLAINIMAT::CMHiCSbase::CMHiCSbase  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 212 of file mhics.cpp. +

+References pActionResources. +

+

00213 {
+00214         pActionResources = new CActionResources();
+00215 }
+
+

+ + + + +
+ + + + + + + + + +
NLAINIMAT::CMHiCSbase::~CMHiCSbase  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Definition at line 217 of file mhics.cpp. +

+References pActionResources. +

+

00218 {
+00219         delete pActionResources;
+00220 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + +
void NLAINIMAT::CMHiCSbase::addActionCS const CActionClassifiers action  ) 
+
+ + + + + +
+   + + +

+Add a new action in the net. +

+ +

+Definition at line 249 of file mhics.cpp. +

+References _ActionSet, NLAINIMAT::Action_VIRTUAL_ACTIONS, addVirtualActionCS(), NLAINIMAT::CActionClassifiers::getName(), and nlassert. +

+Referenced by loadClassifierFromFile(). +

+

00250 {
+00251         nlassert ( action.getName() < Action_VIRTUAL_ACTIONS);
+00252         addVirtualActionCS(action);
+00253         _ActionSet.insert(action.getName());
+00254 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLAINIMAT::CMHiCSbase::addVirtualActionCS const CActionClassifiers action  ) 
+
+ + + + + +
+   + + +

+Add a new virtual action in the net. A virtual action is an action without operator wich is also a motivation. Exemple : Figthing is a virtual action. It may satisfy the anger motivation and is a motivation for guive a sword slash. +

+Definition at line 222 of file mhics.cpp. +

+References _MotivationClassifierSystems, _VirtualActionClassifierSystems, NLAINIMAT::CClassifierSystem::addClassifierSystem(), NLAINIMAT::CActionClassifiers::getClassifiersByMotivationMap(), NLAINIMAT::CActionClassifiers::getClassifiersByVirtualActionMap(), NLAINIMAT::TAction, and NLAINIMAT::TMotivation. +

+Referenced by addActionCS(), and loadClassifierFromFile(). +

+

00223 {
+00224         const std::map<TMotivation, CClassifierSystem> *mapActionByMotivation = action.getClassifiersByMotivationMap();
+00225         std::map<TMotivation, CClassifierSystem>::const_iterator ItMapActionByMotivation;
+00226         for (ItMapActionByMotivation = mapActionByMotivation->begin(); ItMapActionByMotivation != mapActionByMotivation->end(); ItMapActionByMotivation++)
+00227         {
+00228                 CClassifierSystem* pCS;
+00229                 TMotivation motivationName = (*ItMapActionByMotivation).first;
+00230                 const CClassifierSystem* pOtherCS = &((*ItMapActionByMotivation).second);
+00231 
+00232                 pCS = &(_MotivationClassifierSystems[motivationName]);
+00233                 pCS->addClassifierSystem(*pOtherCS);
+00234         }
+00235 
+00236         const std::map<TAction, CClassifierSystem> *mapActionByVirtualAction = action.getClassifiersByVirtualActionMap();
+00237         std::map<TAction, CClassifierSystem>::const_iterator ItMapActionByVirtualAction;
+00238         for (ItMapActionByVirtualAction = mapActionByVirtualAction->begin(); ItMapActionByVirtualAction != mapActionByVirtualAction->end(); ItMapActionByVirtualAction++)
+00239         {
+00240                 CClassifierSystem* pCS;
+00241                 TAction virtualActionName = (*ItMapActionByVirtualAction).first;
+00242                 const CClassifierSystem* pOtherCS = &((*ItMapActionByVirtualAction).second);
+00243 
+00244                 pCS = &(_VirtualActionClassifierSystems[virtualActionName]);
+00245                 pCS->addClassifierSystem(*pOtherCS);
+00246         }
+00247 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLAINIMAT::CMHiCSbase::dbgPrintClassifierPriorityInFile std::string  fileName  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 531 of file mhics.cpp. +

+References _MotivationClassifierSystems, NLMISC::COFile::close(), NLMISC::CIFile::close(), NLAINIMAT::CClassifierPriority::getClassifierTimer(), NLAINIMAT::CClassifierPriority::getPriority(), getPriorityPart(), NLAINIMAT::CClassifierPriority::getPriorityTimer(), len, NLMISC::COFile::open(), NLMISC::CIFile::open(), NLMISC::COFile::serialBuffer(), NLAINIMAT::TMotivation, NLMISC::toString(), uint, and uint8. +

+

00532 {
+00533         int i;
+00534         std::map<TMotivation, CClassifierSystem>::const_iterator itMotivationClassifierSystems;
+00535         std::string nomDuFichier = "D:\\jgab\\doc\\IA\\_These\\gnuplot\\TFC\\";
+00536         nomDuFichier += fileName;
+00537         
+00538         NLMISC::CIFile baltazar;
+00539         bool yaqqunauboutdufil = baltazar.open(nomDuFichier.c_str(), true);
+00540         baltazar.close();
+00541         
+00542         NLMISC::COFile melkior;
+00543         std::string ohlabellephrase = "";
+00544         
+00545         if (!yaqqunauboutdufil)
+00546         {
+00547                 melkior.open(nomDuFichier.c_str(), false, true);
+00548                 
+00549                 for(itMotivationClassifierSystems  = _MotivationClassifierSystems.begin();
+00550                         itMotivationClassifierSystems != _MotivationClassifierSystems.end();
+00551                         itMotivationClassifierSystems++)
+00552                 {
+00553                         TMotivation laMotive = (*itMotivationClassifierSystems).first;
+00554                         for (i= 0; i< (*itMotivationClassifierSystems).second.getClassifierNumber(); i++)
+00555                         {
+00556                                 ohlabellephrase += "MAX ";
+00557                                 ohlabellephrase += NLAINIMAT::conversionMotivation.toString(laMotive);
+00558                                 ohlabellephrase += " ";
+00559                                 (*itMotivationClassifierSystems).second.getDebugString(i,ohlabellephrase);
+00560                                 ohlabellephrase += ";T2S ";
+00561                                 ohlabellephrase += NLAINIMAT::conversionMotivation.toString(laMotive);
+00562                                 ohlabellephrase += " ";
+00563                                 (*itMotivationClassifierSystems).second.getDebugString(i,ohlabellephrase);
+00564                                 ohlabellephrase += ";ExT ";
+00565                                 ohlabellephrase += NLAINIMAT::conversionMotivation.toString(laMotive);
+00566                                 ohlabellephrase += " ";
+00567                                 (*itMotivationClassifierSystems).second.getDebugString(i,ohlabellephrase);
+00568                                 //                              ohlabellephrase += NLMISC::toString(i);
+00569                                 
+00570                                 ohlabellephrase += ";";
+00571                         }
+00572                 }
+00573                 ohlabellephrase += "\n";
+00574         }
+00575         else
+00576         {
+00577                 melkior.open(nomDuFichier.c_str(), true, true);
+00578         }
+00579 
+00580         for(itMotivationClassifierSystems  = _MotivationClassifierSystems.begin();
+00581                 itMotivationClassifierSystems != _MotivationClassifierSystems.end();
+00582                 itMotivationClassifierSystems++)
+00583         {
+00584                 TMotivation laMotive = (*itMotivationClassifierSystems).first;
+00585                 for (i= 0; i< (*itMotivationClassifierSystems).second.getClassifierNumber(); i++)
+00586                 {
+00587                         CClassifierPriority laSuperPrio = getPriorityPart(laMotive, i);
+00588                         ohlabellephrase += NLMISC::toString(laSuperPrio.getPriority());
+00589                         ohlabellephrase += ";";
+00590                         ohlabellephrase += NLMISC::toString(laSuperPrio.getPriorityTimer());
+00591                         ohlabellephrase += ";";
+00592                         ohlabellephrase += NLMISC::toString(laSuperPrio.getClassifierTimer());
+00593                         ohlabellephrase += ";";
+00594                 }
+00595         }
+00596         ohlabellephrase += "\n";
+00597         
+00598         
+00599         uint8 *buf = (uint8 *)ohlabellephrase.c_str();
+00600         uint len = ohlabellephrase.length();
+00601         melkior.serialBuffer(buf,len);
+00602         melkior.close();
+00603 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLAINIMAT::CMHiCSbase::dividePriorityByTheMinPriorityPartInAMotivation TMotivation  motivationName  ) 
+
+ + + + + +
+   + + +

+

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
TAction NLAINIMAT::CMHiCSbase::getActionPart TMotivation  motivationName,
TClassifierNumber  classifierNumber
const
+
+ + + + + +
+   + + +

+Give the action part of a given Classifier.

Parameters:
+ + + +
motivationName is the name of the CS
classifierNumber is the number of the classifier.
+
+
Returns:
is the condition part of the wanted Classifier.
+ +

+Definition at line 285 of file mhics.cpp. +

+References _MotivationClassifierSystems, NLAINIMAT::Action_DoNothing, nlassert, NLAINIMAT::TAction, and NLAINIMAT::TClassifierNumber. +

+Referenced by NLAINIMAT::CMHiCSagent::motivationCompute(). +

+

00286 {
+00287         if (classifierNumber == -1) return Action_DoNothing;
+00288 
+00289         std::map<TMotivation, CClassifierSystem>::const_iterator itMotivationClassifierSystems = _MotivationClassifierSystems.find(motivationName);
+00290         nlassert(itMotivationClassifierSystems != _MotivationClassifierSystems.end());
+00291         return (*itMotivationClassifierSystems).second.getActionPart(classifierNumber);
+00292 }
+
+

+ + + + +
+ + + + + + + + + + +
void NLAINIMAT::CMHiCSbase::getDebugString std::string &  t  )  const
+
+ + + + + +
+   + + +

+Chaine de debug. +

+ +

+Definition at line 334 of file mhics.cpp. +

+References _ActionSet, _MotivationClassifierSystems, _VirtualActionClassifierSystems, and t. +

+

00335 {
+00336         std::string ret = "\n---------------------------";
+00337         std::map<TMotivation, CClassifierSystem>::const_iterator itMotivationClassifierSystems;
+00338         for (itMotivationClassifierSystems = _MotivationClassifierSystems.begin(); itMotivationClassifierSystems != _MotivationClassifierSystems.end(); itMotivationClassifierSystems++)
+00339         {
+00340                 ret += "\nMotivation : " + conversionMotivation.toString((*itMotivationClassifierSystems).first);
+00341                 (*itMotivationClassifierSystems).second.getDebugString(ret);
+00342         }
+00343         std::map<TAction, CClassifierSystem>::const_iterator itVirtualActionClassifierSystems;
+00344         for (itVirtualActionClassifierSystems = _VirtualActionClassifierSystems.begin(); itVirtualActionClassifierSystems != _VirtualActionClassifierSystems.end(); itVirtualActionClassifierSystems++)
+00345         {
+00346                 ret += "\nVirtual Action : " + conversionAction.toString((*itVirtualActionClassifierSystems).first);
+00347                 (*itVirtualActionClassifierSystems).second.getDebugString(ret);
+00348         }
+00349         ret += "\nACTIONS :\n";
+00350         std::set<TAction>::const_iterator itActionSet;
+00351         for (itActionSet = _ActionSet.begin(); itActionSet != _ActionSet.end(); itActionSet++)
+00352         {
+00353                 ret += conversionAction.toString((*itActionSet)) + "\n";
+00354         }
+00355         t+=ret;
+00356 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
CClassifierPriority NLAINIMAT::CMHiCSbase::getPriorityPart TMotivation  motivationName,
TClassifierNumber  classifierNumber
const
+
+ + + + + +
+   + + +

+ +

+Definition at line 303 of file mhics.cpp. +

+References _MotivationClassifierSystems, nlassert, and NLAINIMAT::TClassifierNumber. +

+Referenced by NLAINIMAT::CMotivationEnergy::computeMotivationValue(), and dbgPrintClassifierPriorityInFile(). +

+

00304 {
+00305         if (classifierNumber == -1) return CClassifierPriority();
+00306         
+00307         std::map<TMotivation, CClassifierSystem>::const_iterator itMotivationClassifierSystems = _MotivationClassifierSystems.find(motivationName);
+00308         nlassert(itMotivationClassifierSystems != _MotivationClassifierSystems.end());
+00309         return (*itMotivationClassifierSystems).second.getPriorityPart(classifierNumber);
+00310 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NLAINIMAT::CMHiCSbase::isAnAction TAction  behav  )  const
+
+ + + + + +
+   + + +

+To now if a behav selected by a CS is an action (if not, it's a common CS). +

+ +

+Definition at line 327 of file mhics.cpp. +

+References _ActionSet. +

+

00328 {
+00329         std::set<TAction>::const_iterator itActionSet = _ActionSet.find(behav);
+00330         return (itActionSet != _ActionSet.end());
+00331 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NLAINIMAT::CMHiCSbase::learningUpdatePriorityValueClassifierTime TMotivation  motivationName,
TClassifierNumber  classifierNumber,
uint32  time
+
+ + + + + +
+   + + +

+ +

+Definition at line 634 of file mhics.cpp. +

+References _MotivationClassifierSystems, nlassert, NLAINIMAT::CClassifierPriority::SetClassifierTimer(), NLAINIMAT::CClassifierPriority::setPriorityTimer(), NLAINIMAT::TClassifierNumber, and uint32. +

+Referenced by NLAINIMAT::CMHiCSagent::learningComputation(). +

+

00635 {
+00636         // Le but est de faire une moyenne sur les valeurs de fitness. Pour ça on fait une moyenne sur les 10 pas de temps précédents.
+00637         std::map<TMotivation, CClassifierSystem>::iterator itMotivationClassifierSystems = _MotivationClassifierSystems.find(motivationName);
+00638         nlassert(itMotivationClassifierSystems != _MotivationClassifierSystems.end());
+00639         uint32 oldTime = (*itMotivationClassifierSystems).second.getPriorityPart(classifierNumber).getClassifierTimer();
+00640         uint32 newTime;
+00641         if (oldTime == 0)
+00642         {
+00643                 newTime = time;
+00644         }
+00645         else
+00646         {
+00647                 if (oldTime > time)
+00648                 {
+00649                         newTime = (time + oldTime*3)/4;
+00650                 }
+00651                 else
+00652                 {
+00653                         newTime = (time*3 + oldTime)/4;
+00654                 }
+00655         }
+00656         CClassifierPriority newPrio;
+00657         newPrio.setPriorityTimer((*itMotivationClassifierSystems).second.getPriorityPart(classifierNumber).getPriorityTimer());
+00658         newPrio.SetClassifierTimer(newTime);
+00659 //      newPrio.SetClassifierTimer(time);
+00660         (*itMotivationClassifierSystems).second.setPriorityPart(classifierNumber, newPrio);
+00661 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NLAINIMAT::CMHiCSbase::learningUpdatePriorityValueTimeToSuccess TMotivation  motivationName,
TClassifierNumber  classifierNumber,
uint32  timeToSuccess
+
+ + + + + +
+   + + +

+Update a priority value in learning mode. +

+ +

+Definition at line 605 of file mhics.cpp. +

+References _MotivationClassifierSystems, nlassert, NLAINIMAT::CClassifierPriority::SetClassifierTimer(), NLAINIMAT::CClassifierPriority::setPriorityTimer(), NLAINIMAT::TClassifierNumber, and uint32. +

+Referenced by NLAINIMAT::CMHiCSagent::learningComputation(). +

+

00606 {
+00607         // Le but est de faire une moyenne sur les valeurs de fitness. Pour ça on fait une moyenne sur les 4 pas de temps précédents.
+00608         std::map<TMotivation, CClassifierSystem>::iterator itMotivationClassifierSystems = _MotivationClassifierSystems.find(motivationName);
+00609         nlassert(itMotivationClassifierSystems != _MotivationClassifierSystems.end());
+00610         uint32 oldTime2Success = (*itMotivationClassifierSystems).second.getPriorityPart(classifierNumber).getPriorityTimer();
+00611         uint32 newTime2Success;
+00612         if (oldTime2Success == 0)
+00613         {
+00614                 newTime2Success = timeToSuccess;
+00615         }
+00616         else
+00617         {
+00618                 if (oldTime2Success > timeToSuccess)
+00619                 {
+00620                         newTime2Success = (timeToSuccess*3 + oldTime2Success)/4;
+00621                 }
+00622                 else
+00623                 {
+00624                         newTime2Success = (timeToSuccess + oldTime2Success*3)/4;
+00625                 }
+00626         }
+00627 //      nlassert (newTime2Success != 0);
+00628         CClassifierPriority newPrio;
+00629         newPrio.setPriorityTimer(newTime2Success);
+00630 //      newPrio.setPriorityTimer(timeToSuccess);
+00631         newPrio.SetClassifierTimer((*itMotivationClassifierSystems).second.getPriorityPart(classifierNumber).getClassifierTimer());
+00632         (*itMotivationClassifierSystems).second.setPriorityPart(classifierNumber, newPrio);
+00633 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NLAINIMAT::CMHiCSbase::loadClassifierFromFile std::string  fileName  ) 
+
+ + + + + +
+   + + +

+Load classifiers from a file. Return false if thereis a probleme. +

+ +

+Definition at line 391 of file mhics.cpp. +

+References NLAINIMAT::Action_Unknown, NLAINIMAT::Action_VIRTUAL_ACTIONS, addActionCS(), NLAINIMAT::CConditionMap::addIfNotSensorCondition(), NLAINIMAT::CConditionMap::addIfSensorCondition(), addVirtualActionCS(), NLAINIMAT::CConditionMap::clear(), NLMISC::CIFile::close(), NLMISC::CIFile::getline(), NLAINIMAT::Motivation_Unknown, nlassert, NLMISC::CIFile::open(), NLAINIMAT::Sensor_Unknown, NLAINIMAT::CClassifierPriority::SetClassifierTimer(), NLAINIMAT::TAction, NLAINIMAT::TMotivation, NLAINIMAT::TSensor, uint, and uint32. +

+

00392 {
+00393         bool                    ret;
+00394         const uint32    aboeufSize = 2048;
+00395         char                    aboeuf[aboeufSize];
+00396         std::string             laLigne, leMot;
+00397         uint                    lastPos = 0;
+00398         uint                    nextPos = 0;
+00399         NLMISC::CIFile  melkior;
+00400         CConditionMap   conditionsMap;
+00401         std::map<TAction, CActionClassifiers >  actionsMap;
+00402         std::vector<TSensor>                                    sensorVector;
+00403         ret = melkior.open(fileName, true);
+00404         if (!ret) return false;
+00405         // 1ère ligne : titre conditions
+00406         melkior.getline(aboeuf, aboeufSize);
+00407         // 2ème ligne : Motivations; [Condition]*; Actions; priority; blabla
+00408         melkior.getline(aboeuf, aboeufSize);
+00409         laLigne = aboeuf;
+00410         // on construit une map avec les conditions
+00411         nextPos = laLigne.find_first_of(";",lastPos);
+00412         leMot = laLigne.substr(lastPos,nextPos - lastPos);
+00413         nlassert(leMot == "Motivations");
+00414         lastPos = nextPos+1;
+00415         nextPos = laLigne.find_first_of(";", lastPos);
+00416         leMot = laLigne.substr(lastPos, nextPos-lastPos);
+00417         while (leMot != "Actions")
+00418         {
+00419                 // on regarde le type du senseur :
+00420                 TSensor titi = conversionSensor.fromString(leMot);
+00421                 nlassert (titi != Sensor_Unknown);
+00422                 sensorVector.push_back(titi);
+00423 
+00424                 lastPos = nextPos+1;
+00425                 nextPos = laLigne.find_first_of(";", lastPos);
+00426                 leMot = laLigne.substr(lastPos, nextPos-lastPos);
+00427         }
+00428         // on parse le reste
+00429         melkior.getline(aboeuf, aboeufSize);
+00430         laLigne = aboeuf;
+00431         lastPos = 0;
+00432         nextPos = 0;
+00433         while (laLigne.size() > 0)
+00434         {
+00435                 TMotivation laMotive;
+00436                 TAction         laVirtuelle;
+00437                 // On récupère le nom de la motivation
+00438                 nextPos = laLigne.find_first_of(";",lastPos);
+00439                 leMot = laLigne.substr(lastPos,nextPos - lastPos);
+00440                 if (leMot.size() == 0) break;
+00441                 laMotive = conversionMotivation.fromString(leMot);
+00442                 if (laMotive == Motivation_Unknown)
+00443                 {
+00444                         // Si c'est pas une motivation, c'est peut-être une action virtuelle.
+00445                         laVirtuelle = conversionAction.fromString(leMot);
+00446                         nlassert(laVirtuelle != Action_Unknown);
+00447                 }
+00448                 
+00449                 lastPos = nextPos+1;
+00450                 nextPos = laLigne.find_first_of(";",lastPos);
+00451                 leMot = laLigne.substr(lastPos,nextPos - lastPos);
+00452                 
+00453                 // On récupère la liste des conditions
+00454                 uint ii;
+00455                 for (ii = 0; ii < sensorVector.size(); ii++)
+00456                 {
+00457                         if (leMot.size() >0)
+00458                         {
+00459                                 TSensor sensorName = sensorVector[ii];
+00460                                 if (leMot[0] == '!')
+00461                                 {
+00462                                         conditionsMap.addIfNotSensorCondition(sensorName,leMot[1]);
+00463                                 }
+00464                                 else
+00465                                 {
+00466                                         conditionsMap.addIfSensorCondition(sensorName,leMot[0]);
+00467                                 }
+00468                         }
+00469 
+00470                         lastPos = nextPos+1;
+00471                         nextPos = laLigne.find_first_of(";",lastPos);
+00472                         leMot = laLigne.substr(lastPos,nextPos - lastPos);
+00473                 }
+00474                 // on récupère le nom de l'action
+00475                 TAction actionName = conversionAction.fromString(leMot);
+00476                 nlassert(actionName != Action_Unknown);
+00477 
+00478                 lastPos = nextPos+1;
+00479                 nextPos = laLigne.find_first_of(";",lastPos);
+00480                 leMot = laLigne.substr(lastPos,nextPos - lastPos);
+00481 
+00482                 // on récupère la force du classeur
+00483                 CClassifierPriority laforce;
+00484                 laforce.SetClassifierTimer( atof(leMot.c_str()) );
+00485 
+00486                 // on rajoute la règle dans les actions.
+00487                 std::map<TAction, CActionClassifiers >::iterator itActionsMap = actionsMap.find(actionName);
+00488                 if (itActionsMap == actionsMap.end())
+00489                 {
+00490                         CActionClassifiers bibu(actionName);
+00491                         actionsMap.insert(std::make_pair(actionName, bibu));
+00492                 }
+00493                 CActionClassifiers mon_action(actionName);
+00494                 // Si la motivation est inconnue, c'est que c'est une action virtuelle.
+00495                 if (laMotive == Motivation_Unknown)
+00496                 {
+00497                         actionsMap[actionName].addVirtualActionRule(laVirtuelle,conditionsMap, laforce);
+00498                 }
+00499                 else
+00500                 {
+00501                         actionsMap[actionName].addMotivationRule(laMotive,conditionsMap, laforce);
+00502                 }
+00503 
+00504                 conditionsMap.clear();
+00505                 melkior.getline(aboeuf, aboeufSize);
+00506                 laLigne = aboeuf;
+00507                 lastPos = 0;
+00508                 nextPos = 0;
+00509         }
+00510         melkior.close();
+00511 
+00512         std::map<TAction, CActionClassifiers >::iterator itActionsMap;
+00513         for (itActionsMap = actionsMap.begin(); itActionsMap != actionsMap.end(); itActionsMap++)
+00514         {
+00515                 //***G*** ajouter aussi la gestion des actions virtuels
+00516                 TAction testAction = (*itActionsMap).second.getName();
+00517                 nlassert (testAction != Action_Unknown);
+00518                 if (testAction > Action_VIRTUAL_ACTIONS)
+00519                 {
+00520                         addVirtualActionCS( (*itActionsMap).second );
+00521                 }
+00522                 else
+00523                 {
+00524                         addActionCS( (*itActionsMap).second );
+00525                 }
+00526         }
+00527 
+00528         return true;
+00529 }
+
+

+ + + + +
+ + + + + + + + + +
void NLAINIMAT::CMHiCSbase::printDebugString  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 359 of file mhics.cpp. +

+References _ActionSet, _MotivationClassifierSystems, _VirtualActionClassifierSystems, and nldebug. +

+

00360 {
+00361         std::string ret = "";
+00362         nldebug("\n---------------------------");
+00363         std::map<TMotivation, CClassifierSystem>::const_iterator itMotivationClassifierSystems;
+00364         for (itMotivationClassifierSystems = _MotivationClassifierSystems.begin(); itMotivationClassifierSystems != _MotivationClassifierSystems.end(); itMotivationClassifierSystems++)
+00365         {
+00366                 ret += (("\nMotivation : " + conversionMotivation.toString((*itMotivationClassifierSystems).first)).c_str());
+00367                 (*itMotivationClassifierSystems).second.getDebugString(ret);
+00368                 nldebug(ret.c_str());
+00369                 ret = "";
+00370         }
+00371         std::map<TAction, CClassifierSystem>::const_iterator itVirtualActionClassifierSystems;
+00372         for (itVirtualActionClassifierSystems = _VirtualActionClassifierSystems.begin(); itVirtualActionClassifierSystems != _VirtualActionClassifierSystems.end(); itVirtualActionClassifierSystems++)
+00373         {
+00374                 ret += (("\nVirtual Action : " + conversionAction.toString((*itVirtualActionClassifierSystems).first)).c_str());
+00375                 (*itVirtualActionClassifierSystems).second.getDebugString(ret);
+00376                 nldebug(ret.c_str());
+00377                 ret = "";
+00378         }
+00379         ret += ("\nACTIONS :\n");
+00380         std::set<TAction>::const_iterator itActionSet;
+00381         for (itActionSet = _ActionSet.begin(); itActionSet != _ActionSet.end(); itActionSet++)
+00382         {
+00383                 ret += ((conversionAction.toString((*itActionSet)) + "\n").c_str());
+00384                 nldebug(ret.c_str());
+00385                 ret = "";
+00386         }
+00387 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NLAINIMAT::CMHiCSbase::selectBehavior TMotivation  motivationName,
const CCSPerception psensorMap,
std::multimap< CClassifierPriority, std::pair< TClassifierNumber, TTargetId > > &  mapActivableCS
+
+ + + + + +
+   + + +

+Select a behavior according to the values in the sensorMap.

Parameters:
+ + + + + + +
motivationName is the name of the CS that must be activated
sensorMap is a map whose key is the sensor name and value the sensor value.
lastClassifierNumber is the number of the last classifier selected. Also used as a return value.
lastTarget is the ID of the last target associated with the last classifier. Also used as a return value.
lastSelectionMaxPriority is the Priority given to the last selected classifier (witch is the max of all the last activable classifier priority). Also used as a return value.
+
+ +

+Definition at line 256 of file mhics.cpp. +

+References _MotivationClassifierSystems. +

+Referenced by NLAINIMAT::CMHiCSagent::motivationCompute(). +

+

00259 {
+00260         std::map<TMotivation, CClassifierSystem>::iterator itMotivationClassifierSystems = _MotivationClassifierSystems.find(motivationName);
+00261         if (itMotivationClassifierSystems != _MotivationClassifierSystems.end())
+00262         {
+00263                 (*itMotivationClassifierSystems).second.selectBehavior(psensorMap, mapActivableCS);
+00264         }
+00265 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NLAINIMAT::CMHiCSbase::setPriorityValue TMotivation  motivationName,
TClassifierNumber  classifierNumber,
CClassifierPriority  priority
+
+ + + + + +
+   + + +

+Set a new value for a classifier priority. +

+ +

+Definition at line 320 of file mhics.cpp. +

+References _MotivationClassifierSystems, nlassert, and NLAINIMAT::TClassifierNumber. +

+

00321 {
+00322         std::map<TMotivation, CClassifierSystem>::iterator itMotivationClassifierSystems = _MotivationClassifierSystems.find(motivationName);
+00323         nlassert(itMotivationClassifierSystems != _MotivationClassifierSystems.end());
+00324         (*itMotivationClassifierSystems).second.setPriorityPart(classifierNumber, priority);
+00325 }
+
+


Field Documentation

+

+ + + + +
+ + +
std::set<TAction> NLAINIMAT::CMHiCSbase::_ActionSet [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 190 of file mhics.h. +

+Referenced by addActionCS(), getDebugString(), isAnAction(), and printDebugString().

+

+ + + + +
+ + +
std::map<TMotivation, CClassifierSystem> NLAINIMAT::CMHiCSbase::_MotivationClassifierSystems [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 188 of file mhics.h. +

+Referenced by addVirtualActionCS(), dbgPrintClassifierPriorityInFile(), getActionPart(), getDebugString(), getPriorityPart(), learningUpdatePriorityValueClassifierTime(), learningUpdatePriorityValueTimeToSuccess(), printDebugString(), selectBehavior(), and setPriorityValue().

+

+ + + + +
+ + +
std::map<TAction, CClassifierSystem> NLAINIMAT::CMHiCSbase::_VirtualActionClassifierSystems [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 189 of file mhics.h. +

+Referenced by addVirtualActionCS(), getDebugString(), and printDebugString().

+

+ + + + +
+ + +
CActionResources* NLAINIMAT::CMHiCSbase::pActionResources +
+
+ + + + + +
+   + + +

+ +

+Definition at line 185 of file mhics.h. +

+Referenced by CMHiCSbase(), NLAINIMAT::CMHiCSagent::selectBehavior(), and ~CMHiCSbase().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 11:10:34 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1