aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a06032.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--docs/doxygen/nel/a06032.html1607
1 files changed, 1607 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a06032.html b/docs/doxygen/nel/a06032.html
new file mode 100644
index 00000000..7f2dac74
--- /dev/null
+++ b/docs/doxygen/nel/a06032.html
@@ -0,0 +1,1607 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+<title>NeL: mhics.cpp Source File</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+</head><body>
+<!-- Generated by Doxygen 1.3.6 -->
+<div class="qindex"> <form class="search" action="search.php" method="get">
+<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a> | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
+<h1>mhics.cpp</h1><a href="a04609.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <span class="comment">/* Copyright, 2003 Nevrax Ltd.</span>
+00008 <span class="comment"> *</span>
+00009 <span class="comment"> * This file is part of NEVRAX NEL.</span>
+00010 <span class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</span>
+00011 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
+00012 <span class="comment"> * the Free Software Foundation; either version 2, or (at your option)</span>
+00013 <span class="comment"> * any later version.</span>
+00014 <span class="comment"></span>
+00015 <span class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</span>
+00016 <span class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</span>
+00017 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
+00018 <span class="comment"> * General Public License for more details.</span>
+00019 <span class="comment"></span>
+00020 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
+00021 <span class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</span>
+00022 <span class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</span>
+00023 <span class="comment"> * MA 02111-1307, USA.</span>
+00024 <span class="comment"> */</span>
+00025
+00026 <span class="preprocessor">#include "<a class="code" href="a04610.html">nel/ai/nimat/mhics.h</a>"</span>
+00027 <span class="preprocessor">#include "<a class="code" href="a04286.html">nel/misc/file.h</a>"</span>
+00028
+00029 <span class="keyword">namespace </span>NLAINIMAT
+00030 {
+00031 <span class="keyword">using</span> <span class="keyword">namespace </span>NLMISC;
+00032
+<a name="l00033"></a><a class="code" href="a05371.html#a0">00033</a> <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="a05371.html#a13">TTargetId</a> <a class="code" href="a05371.html#a0">NullTargetId</a> = 0;
+00034
+00036 <span class="comment">// CMotivationEnergy</span>
+<a name="l00038"></a><a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergya1">00038</a> <span class="comment"></span>CMotivationEnergy::CMotivationEnergy()
+00039 {
+00040 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr4">_SumValue</a> = 0;
+00041 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr1">_MHiCSagent</a> = NULL;
+00042 <span class="comment">// _WasPreviouslyActived = false;</span>
+00043 }
+00044
+<a name="l00045"></a><a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergya11">00045</a> CMotivationEnergy::~CMotivationEnergy()
+00046 {
+00047 }
+00048
+<a name="l00049"></a><a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergya6">00049</a> <span class="keywordtype">double</span> CMotivationEnergy::getSumValue()<span class="keyword"> const</span>
+00050 <span class="keyword"></span>{
+00051 <span class="keywordflow">return</span> <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr4">_SumValue</a>;
+00052 }
+00053
+<a name="l00054"></a><a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergya7">00054</a> <span class="keywordtype">void</span> CMotivationEnergy::removeProvider(TMotivation providerName)
+00055 {
+00056 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr2">_MotivationProviders</a>.erase(providerName);
+00057 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyd0">computeMotivationValue</a>();
+00058 }
+00059
+00060 <span class="comment">//void CMotivationEnergy::removeProvider(TAction providerName)</span>
+00061 <span class="comment">//{</span>
+00062 <span class="comment">// _VirtualActionProviders.erase(providerName);</span>
+00063 <span class="comment">// computeMotivationValue();</span>
+00064 <span class="comment">//}</span>
+00065
+<a name="l00066"></a><a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergya0">00066</a> <span class="keywordtype">void</span> CMotivationEnergy::addProvider(TMotivation providerName, <a class="code" href="a05371.html#a7">TClassifierNumber</a> classifierNumber)
+00067 {
+00068 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr2">_MotivationProviders</a>[providerName].insert(classifierNumber);
+00069 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyd0">computeMotivationValue</a>();
+00070 }
+00071
+00072 <span class="comment">//void CMotivationEnergy::addProvider(TAction providerName, const CMotivationEnergy&amp; providerMotivation)</span>
+00073 <span class="comment">//{</span>
+00074 <span class="comment">// _VirtualActionProviders[providerName] = providerMotivation._EnergyByMotivation ;</span>
+00075 <span class="comment">// computeMotivationValue();</span>
+00076 <span class="comment">//}</span>
+00077
+00078 <span class="comment">//void CMotivationEnergy::updateProvider(TMotivation providerName, const CMotivationEnergy&amp; providerMotivation)</span>
+00079 <span class="comment">//{</span>
+00080 <span class="comment">// _MotivationProviders[providerName] = providerMotivation._EnergyByMotivation ;</span>
+00081 <span class="comment">// computeMotivationValue();</span>
+00082 <span class="comment">//}</span>
+00083
+00084 <span class="comment">//void CMotivationEnergy::updateProvider(TAction providerName, const CMotivationEnergy&amp; providerMotivation)</span>
+00085 <span class="comment">//{</span>
+00086 <span class="comment">// _VirtualActionProviders[providerName] = providerMotivation._EnergyByMotivation ;</span>
+00087 <span class="comment">// computeMotivationValue();</span>
+00088 <span class="comment">//}</span>
+00089 <span class="comment">//void CMotivationEnergy::setWasPreviouslyActived(bool yesOrNo)</span>
+00090 <span class="comment">//{</span>
+00091 <span class="comment">// _WasPreviouslyActived = yesOrNo;</span>
+00092 <span class="comment">//}</span>
+00093
+00094
+<a name="l00095"></a><a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyd0">00095</a> <span class="keywordtype">void</span> CMotivationEnergy::computeMotivationValue()
+00096 {
+00097 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr0">_EnergyByMotivation</a>.clear();
+00098
+00099 <a class="code" href="a05371.html#a99">TMotivation</a> lastMotivationName = <a class="code" href="a05371.html#a99a21">Motivation_Unknown</a>;
+00100 <span class="comment">// We look for motivation values comming directly from Motivations</span>
+00101 std::multimap&lt;TMotivation, std::set&lt;TClassifierNumber&gt; &gt;::iterator itMotivationProviders;
+00102 <span class="keywordflow">for</span> (itMotivationProviders = <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr2">_MotivationProviders</a>.begin();
+00103 itMotivationProviders != <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr2">_MotivationProviders</a>.end();
+00104 itMotivationProviders++)
+00105 {
+00106 <a class="code" href="a04558.html#a11">uint32</a> lastMaxMotiveValue = 0;
+00107 <a class="code" href="a05371.html#a99">TMotivation</a> motivationName = (*itMotivationProviders).first;
+00108 std::set&lt;TClassifierNumber&gt;::iterator itClassifierNumber;
+00109 <span class="keywordflow">for</span> (itClassifierNumber = (*itMotivationProviders).second.begin(); itClassifierNumber != (*itMotivationProviders).second.end(); itClassifierNumber++)
+00110 {
+00111 <a class="code" href="a05371.html#a7">TClassifierNumber</a> classierNumber = (*itClassifierNumber);
+00112 <a class="code" href="a04558.html#a11">uint32</a> classifierTimer = <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr1">_MHiCSagent</a>-&gt;<a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta3">getMHiCSbase</a>()-&gt;<a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea7">getPriorityPart</a>(motivationName, classierNumber).<a class="code" href="a02342.html#NLAINIMAT_1_1CClassifierPrioritya1">getClassifierTimer</a>();;
+00113 <span class="keywordtype">bool</span> wasPreviouslyActived = <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr1">_MHiCSagent</a>-&gt;<a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta13">wasClassifierPreviouslyActive</a>(motivationName,classierNumber);
+00114 <span class="keywordflow">if</span> (wasPreviouslyActived)
+00115 {
+00116 <a class="code" href="a04558.html#a11">uint32</a> temporaryClassifierPriorityTime = <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr1">_MHiCSagent</a>-&gt;<a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta6">getTemporaryClassifierPriorityTime</a>(motivationName, classierNumber);
+00117 <span class="comment">// on donne une marge de 15 secondes à l'action activée.</span>
+00118 <span class="keywordflow">if</span> (temporaryClassifierPriorityTime &gt; classifierTimer + 15)
+00119 {
+00120 classifierTimer = temporaryClassifierPriorityTime;
+00121 }
+00122 <span class="keywordflow">else</span>
+00123 {
+00124 classifierTimer -=1; <span class="comment">// Pour lui donner un avantage en cas d'égalité</span>
+00125 }
+00126 }
+00127 <span class="keywordtype">double</span> motiveValue = <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr1">_MHiCSagent</a>-&gt;<a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta5">getMotivationValue</a>(motivationName);
+00128 <span class="keywordtype">double</span> motivePP = <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr1">_MHiCSagent</a>-&gt;<a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta4">getMotivationPP</a>(motivationName);
+00129 <a class="code" href="a04558.html#a11">uint32</a> priorityTimer = <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr1">_MHiCSagent</a>-&gt;<a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta3">getMHiCSbase</a>()-&gt;<a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea7">getPriorityPart</a>(motivationName, classierNumber).<a class="code" href="a02342.html#NLAINIMAT_1_1CClassifierPrioritya3">getPriorityTimer</a>();
+00130 priorityTimer = std::max(priorityTimer, classifierTimer);
+00131
+00132
+00133 <a class="code" href="a04558.html#a11">uint32</a> combinedValue = (motiveValue * 10000.0) - priorityTimer;
+00134 <span class="keywordflow">if</span> (combinedValue &gt; lastMaxMotiveValue)
+00135 {
+00136 lastMaxMotiveValue = combinedValue;
+00137 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr0">_EnergyByMotivation</a>[motivationName].Value = combinedValue;
+00138 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr0">_EnergyByMotivation</a>[motivationName].PP = motivePP;
+00139 }
+00140 }
+00141 }
+00142
+00143 TEnergyByMotivation::const_iterator itEnergyByMotivation;
+00144 <span class="keywordtype">double</span> sum = 0;
+00145 <span class="keywordflow">for</span> (itEnergyByMotivation = <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr0">_EnergyByMotivation</a>.begin(); itEnergyByMotivation != <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr0">_EnergyByMotivation</a>.end(); itEnergyByMotivation++)
+00146 {
+00147 sum += (*itEnergyByMotivation).second.Value * (*itEnergyByMotivation).second.PP;
+00148 }
+00149 sum += <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr3">_MyMotivationValue</a>.<a class="code" href="a02939.html#NLAINIMAT_1_1CMotivationEnergy_1_1CMotivationValueo0">PP</a> * <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr3">_MyMotivationValue</a>.<a class="code" href="a02939.html#NLAINIMAT_1_1CMotivationEnergy_1_1CMotivationValueo1">Value</a>;
+00150
+00151 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr4">_SumValue</a> = sum;
+00152 <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr4">_SumValue</a> &gt;= 0);
+00153 }
+00154
+<a name="l00156"></a><a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergya9">00156</a> <span class="keywordtype">void</span> CMotivationEnergy::setMotivationPP(TMotivation motivationName, <span class="keywordtype">double</span> PP)
+00157 {
+00158 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr4">_SumValue</a> -= <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr3">_MyMotivationValue</a>.<a class="code" href="a02939.html#NLAINIMAT_1_1CMotivationEnergy_1_1CMotivationValueo1">Value</a> * <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr3">_MyMotivationValue</a>.<a class="code" href="a02939.html#NLAINIMAT_1_1CMotivationEnergy_1_1CMotivationValueo0">PP</a>;
+00159 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr4">_SumValue</a> += <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr3">_MyMotivationValue</a>.<a class="code" href="a02939.html#NLAINIMAT_1_1CMotivationEnergy_1_1CMotivationValueo1">Value</a> * PP;
+00160 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr0">_EnergyByMotivation</a>[motivationName].PP = PP;
+00161 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr3">_MyMotivationValue</a>.<a class="code" href="a02939.html#NLAINIMAT_1_1CMotivationEnergy_1_1CMotivationValueo0">PP</a> = PP;
+00162 <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr4">_SumValue</a> &gt;= 0);
+00163 }
+00164
+<a name="l00166"></a><a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergya3">00166</a> <span class="keywordtype">double</span> CMotivationEnergy::getMotivationPP(TMotivation motivationName)<span class="keyword"> const</span>
+00167 <span class="keyword"></span>{
+00168 <span class="keywordflow">return</span> <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr3">_MyMotivationValue</a>.<a class="code" href="a02939.html#NLAINIMAT_1_1CMotivationEnergy_1_1CMotivationValueo0">PP</a>;
+00169 }
+00170
+<a name="l00172"></a><a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergya10">00172</a> <span class="keywordtype">void</span> CMotivationEnergy::setMotivationValue(TMotivation motivationName, <span class="keywordtype">double</span> <a class="code" href="a04223.html#a658">value</a>)
+00173 {
+00174 <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a04223.html#a658">value</a> &gt;= 0);
+00175 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr4">_SumValue</a> -= <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr3">_MyMotivationValue</a>.<a class="code" href="a02939.html#NLAINIMAT_1_1CMotivationEnergy_1_1CMotivationValueo1">Value</a> * <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr3">_MyMotivationValue</a>.<a class="code" href="a02939.html#NLAINIMAT_1_1CMotivationEnergy_1_1CMotivationValueo0">PP</a>;
+00176 <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr4">_SumValue</a> &gt;= 0);
+00177 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr4">_SumValue</a> += <a class="code" href="a04223.html#a658">value</a> * <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr3">_MyMotivationValue</a>.<a class="code" href="a02939.html#NLAINIMAT_1_1CMotivationEnergy_1_1CMotivationValueo0">PP</a>;
+00178 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr0">_EnergyByMotivation</a>[motivationName].Value = <a class="code" href="a04223.html#a658">value</a>;
+00179 <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr3">_MyMotivationValue</a>.<a class="code" href="a02939.html#NLAINIMAT_1_1CMotivationEnergy_1_1CMotivationValueo1">Value</a> = <a class="code" href="a04223.html#a658">value</a>;
+00180
+00181 <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr4">_SumValue</a> &gt;= 0);
+00182 }
+00183
+<a name="l00185"></a><a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergya4">00185</a> <span class="keywordtype">double</span> CMotivationEnergy::getMotivationValue(TMotivation motivationName)<span class="keyword"> const</span>
+00186 <span class="keyword"></span>{
+00187 <span class="keywordflow">return</span> <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr3">_MyMotivationValue</a>.<a class="code" href="a02939.html#NLAINIMAT_1_1CMotivationEnergy_1_1CMotivationValueo1">Value</a>;
+00188 }
+00189
+<a name="l00190"></a><a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergya5">00190</a> <span class="keyword">const</span> std::map&lt;TMotivation, std::set&lt;TClassifierNumber&gt; &gt;* CMotivationEnergy::getProviders()<span class="keyword"> const</span>
+00191 <span class="keyword"></span>{
+00192 <span class="keywordflow">return</span> &amp;<a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr2">_MotivationProviders</a>;
+00193 }
+00194
+<a name="l00196"></a><a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergya2">00196</a> <span class="keywordtype">void</span> CMotivationEnergy::getDebugString(std::string &amp;<a class="code" href="a04223.html#a627">t</a>)<span class="keyword"> const</span>
+00197 <span class="keyword"></span>{
+00198 std::string ret;
+00199 TEnergyByMotivation::const_iterator itEnergyByMotivation;
+00200
+00201 <span class="keywordflow">for</span> (itEnergyByMotivation = <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr0">_EnergyByMotivation</a>.begin(); itEnergyByMotivation!= <a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergyr0">_EnergyByMotivation</a>.end(); itEnergyByMotivation++)
+00202 {
+00203 ret += <span class="stringliteral">" "</span> + conversionMotivation.toString((*itEnergyByMotivation).first) + <span class="stringliteral">" ("</span> + <a class="code" href="a05378.html#a244">NLMISC::toString</a>((*itEnergyByMotivation).second.Value * (*itEnergyByMotivation).second.PP) + <span class="stringliteral">") "</span>;
+00204 }
+00205 <a class="code" href="a04223.html#a627">t</a>+=ret;
+00206 }
+00207
+00209 <span class="comment">// CMHiCSbase</span>
+00211 <span class="comment"></span>
+<a name="l00212"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea2">00212</a> CMHiCSbase::CMHiCSbase()
+00213 {
+00214 <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaseo0">pActionResources</a> = <span class="keyword">new</span> <a class="code" href="a02159.html">CActionResources</a>();
+00215 }
+00216
+<a name="l00217"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea15">00217</a> CMHiCSbase::~CMHiCSbase()
+00218 {
+00219 <span class="keyword">delete</span> <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaseo0">pActionResources</a>;
+00220 }
+00221
+<a name="l00222"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea1">00222</a> <span class="keywordtype">void</span> CMHiCSbase::addVirtualActionCS(<span class="keyword">const</span> <a class="code" href="a02158.html">CActionClassifiers</a> &amp;action)
+00223 {
+00224 <span class="keyword">const</span> std::map&lt;TMotivation, CClassifierSystem&gt; *mapActionByMotivation = action.<a class="code" href="a02158.html#NLAINIMAT_1_1CActionClassifiersa4">getClassifiersByMotivationMap</a>();
+00225 std::map&lt;TMotivation, CClassifierSystem&gt;::const_iterator ItMapActionByMotivation;
+00226 <span class="keywordflow">for</span> (ItMapActionByMotivation = mapActionByMotivation-&gt;begin(); ItMapActionByMotivation != mapActionByMotivation-&gt;end(); ItMapActionByMotivation++)
+00227 {
+00228 <a class="code" href="a02343.html">CClassifierSystem</a>* pCS;
+00229 <a class="code" href="a05371.html#a99">TMotivation</a> motivationName = (*ItMapActionByMotivation).first;
+00230 <span class="keyword">const</span> <a class="code" href="a02343.html">CClassifierSystem</a>* pOtherCS = &amp;((*ItMapActionByMotivation).second);
+00231
+00232 pCS = &amp;(<a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>[motivationName]);
+00233 pCS-&gt;<a class="code" href="a02343.html#NLAINIMAT_1_1CClassifierSystema1">addClassifierSystem</a>(*pOtherCS);
+00234 }
+00235
+00236 <span class="keyword">const</span> std::map&lt;TAction, CClassifierSystem&gt; *mapActionByVirtualAction = action.<a class="code" href="a02158.html#NLAINIMAT_1_1CActionClassifiersa5">getClassifiersByVirtualActionMap</a>();
+00237 std::map&lt;TAction, CClassifierSystem&gt;::const_iterator ItMapActionByVirtualAction;
+00238 <span class="keywordflow">for</span> (ItMapActionByVirtualAction = mapActionByVirtualAction-&gt;begin(); ItMapActionByVirtualAction != mapActionByVirtualAction-&gt;end(); ItMapActionByVirtualAction++)
+00239 {
+00240 <a class="code" href="a02343.html">CClassifierSystem</a>* pCS;
+00241 <a class="code" href="a05371.html#a101">TAction</a> virtualActionName = (*ItMapActionByVirtualAction).first;
+00242 <span class="keyword">const</span> <a class="code" href="a02343.html">CClassifierSystem</a>* pOtherCS = &amp;((*ItMapActionByVirtualAction).second);
+00243
+00244 pCS = &amp;(<a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser2">_VirtualActionClassifierSystems</a>[virtualActionName]);
+00245 pCS-&gt;<a class="code" href="a02343.html#NLAINIMAT_1_1CClassifierSystema1">addClassifierSystem</a>(*pOtherCS);
+00246 }
+00247 }
+00248
+<a name="l00249"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea0">00249</a> <span class="keywordtype">void</span> CMHiCSbase::addActionCS(<span class="keyword">const</span> <a class="code" href="a02158.html">CActionClassifiers</a>&amp; action)
+00250 {
+00251 <a class="code" href="a04199.html#a6">nlassert</a> ( action.<a class="code" href="a02158.html#NLAINIMAT_1_1CActionClassifiersa7">getName</a>() &lt; <a class="code" href="a05371.html#a101a75">Action_VIRTUAL_ACTIONS</a>);
+00252 <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea1">addVirtualActionCS</a>(action);
+00253 <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser0">_ActionSet</a>.insert(action.<a class="code" href="a02158.html#NLAINIMAT_1_1CActionClassifiersa7">getName</a>());
+00254 }
+00255
+<a name="l00256"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea13">00256</a> <span class="keywordtype">void</span> CMHiCSbase::selectBehavior(TMotivation motivationName,
+00257 <span class="keyword">const</span> <a class="code" href="a02422.html">CCSPerception</a>* psensorMap,
+00258 std::multimap&lt;<a class="code" href="a02342.html">CClassifierPriority</a>, std::pair&lt;TClassifierNumber, TTargetId&gt; &gt; &amp;mapActivableCS)
+00259 {
+00260 std::map&lt;TMotivation, CClassifierSystem&gt;::iterator itMotivationClassifierSystems = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.find(motivationName);
+00261 <span class="keywordflow">if</span> (itMotivationClassifierSystems != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.end())
+00262 {
+00263 (*itMotivationClassifierSystems).second.selectBehavior(psensorMap, mapActivableCS);
+00264 }
+00265 }
+00266
+00267 <span class="comment">//void CMHiCSbase::selectBehavior(TAction VirtualActionName,</span>
+00268 <span class="comment">// const CCSPerception* psensorMap,</span>
+00269 <span class="comment">// std::multimap&lt;double, std::pair&lt;TClassifierNumber, TTargetId&gt; &gt; &amp;mapActivableCS,</span>
+00270 <span class="comment">// TTargetId &amp;target)</span>
+00271 <span class="comment">//{</span>
+00272 <span class="comment">// std::map&lt;TAction, CClassifierSystem&gt;::iterator itVirtualActionClassifierSystems = _VirtualActionClassifierSystems.find(VirtualActionName);</span>
+00273 <span class="comment">// nlassert(itVirtualActionClassifierSystems != _VirtualActionClassifierSystems.end());</span>
+00274 <span class="comment">// // When we select an high level action, we limit the perception to the target associated with this action.</span>
+00275 <span class="comment">// CCSPerception neoPerception;</span>
+00276 <span class="comment">// neoPerception.NoTargetSensors = psensorMap-&gt;NoTargetSensors;</span>
+00277 <span class="comment">// std::map&lt;TTargetId, TSensorMap&gt;::const_iterator itSensorMap = psensorMap-&gt;TargetSensors.find(target);</span>
+00278 <span class="comment">// if(itSensorMap != psensorMap-&gt;TargetSensors.end())</span>
+00279 <span class="comment">// {</span>
+00280 <span class="comment">// neoPerception.TargetSensors[target] = (*itSensorMap).second;</span>
+00281 <span class="comment">// }</span>
+00282 <span class="comment">// (*itVirtualActionClassifierSystems).second.selectBehavior(&amp;neoPerception, mapActivableCS);</span>
+00283 <span class="comment">//}</span>
+00284
+<a name="l00285"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea5">00285</a> <a class="code" href="a05371.html#a101">TAction</a> CMHiCSbase::getActionPart(TMotivation motivationName, <a class="code" href="a05371.html#a7">TClassifierNumber</a> classifierNumber)<span class="keyword"> const</span>
+00286 <span class="keyword"></span>{
+00287 <span class="keywordflow">if</span> (classifierNumber == -1) <span class="keywordflow">return</span> <a class="code" href="a05371.html#a101a56">Action_DoNothing</a>;
+00288
+00289 std::map&lt;TMotivation, CClassifierSystem&gt;::const_iterator itMotivationClassifierSystems = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.find(motivationName);
+00290 <a class="code" href="a04199.html#a6">nlassert</a>(itMotivationClassifierSystems != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.end());
+00291 <span class="keywordflow">return</span> (*itMotivationClassifierSystems).second.getActionPart(classifierNumber);
+00292 }
+00293
+00294 <span class="comment">//TAction CMHiCSbase::getActionPart(TAction motivationName, TClassifierNumber classifierNumber)</span>
+00295 <span class="comment">//{</span>
+00296 <span class="comment">// if (classifierNumber == -1) return Action_DoNothing;</span>
+00297 <span class="comment">// </span>
+00298 <span class="comment">// std::map&lt;TAction, CClassifierSystem&gt;::iterator itVirtualActionClassifierSystems = _VirtualActionClassifierSystems.find(motivationName);</span>
+00299 <span class="comment">// nlassert(itVirtualActionClassifierSystems != _VirtualActionClassifierSystems.end());</span>
+00300 <span class="comment">// return (*itVirtualActionClassifierSystems).second.getActionPart(classifierNumber);</span>
+00301 <span class="comment">//}</span>
+00302
+<a name="l00303"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea7">00303</a> <a class="code" href="a02342.html">CClassifierPriority</a> CMHiCSbase::getPriorityPart(TMotivation motivationName, <a class="code" href="a05371.html#a7">TClassifierNumber</a> classifierNumber)<span class="keyword"> const</span>
+00304 <span class="keyword"></span>{
+00305 <span class="keywordflow">if</span> (classifierNumber == -1) <span class="keywordflow">return</span> <a class="code" href="a02342.html">CClassifierPriority</a>();
+00306
+00307 std::map&lt;TMotivation, CClassifierSystem&gt;::const_iterator itMotivationClassifierSystems = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.find(motivationName);
+00308 <a class="code" href="a04199.html#a6">nlassert</a>(itMotivationClassifierSystems != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.end());
+00309 <span class="keywordflow">return</span> (*itMotivationClassifierSystems).second.getPriorityPart(classifierNumber);
+00310 }
+00311
+00312 <span class="comment">//void CMHiCSbase::dividePriorityByTheMinPriorityPartInAMotivation(TMotivation motivationName)</span>
+00313 <span class="comment">//{</span>
+00314 <span class="comment">// std::map&lt;TMotivation, CClassifierSystem&gt;::iterator itMotivationClassifierSystems = _MotivationClassifierSystems.find(motivationName);</span>
+00315 <span class="comment">// nlassert(itMotivationClassifierSystems != _MotivationClassifierSystems.end());</span>
+00316 <span class="comment">// (*itMotivationClassifierSystems).second.dividePriorityByTheMinPriorityPart();</span>
+00317 <span class="comment">//}</span>
+00318
+00319
+<a name="l00320"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea14">00320</a> <span class="keywordtype">void</span> CMHiCSbase::setPriorityValue(TMotivation motivationName, <a class="code" href="a05371.html#a7">TClassifierNumber</a> classifierNumber, <a class="code" href="a02342.html">CClassifierPriority</a> priority)
+00321 {
+00322 std::map&lt;TMotivation, CClassifierSystem&gt;::iterator itMotivationClassifierSystems = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.find(motivationName);
+00323 <a class="code" href="a04199.html#a6">nlassert</a>(itMotivationClassifierSystems != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.end());
+00324 (*itMotivationClassifierSystems).second.setPriorityPart(classifierNumber, priority);
+00325 }
+00326
+<a name="l00327"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea8">00327</a> <span class="keywordtype">bool</span> CMHiCSbase::isAnAction(TAction behav)<span class="keyword"> const</span>
+00328 <span class="keyword"></span>{
+00329 std::set&lt;TAction&gt;::const_iterator itActionSet = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser0">_ActionSet</a>.find(behav);
+00330 <span class="keywordflow">return</span> (itActionSet != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser0">_ActionSet</a>.end());
+00331 }
+00332
+<a name="l00334"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea6">00334</a> <span class="keywordtype">void</span> CMHiCSbase::getDebugString(std::string &amp;<a class="code" href="a04223.html#a627">t</a>)<span class="keyword"> const</span>
+00335 <span class="keyword"></span>{
+00336 std::string ret = <span class="stringliteral">"\n---------------------------"</span>;
+00337 std::map&lt;TMotivation, CClassifierSystem&gt;::const_iterator itMotivationClassifierSystems;
+00338 <span class="keywordflow">for</span> (itMotivationClassifierSystems = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.begin(); itMotivationClassifierSystems != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.end(); itMotivationClassifierSystems++)
+00339 {
+00340 ret += <span class="stringliteral">"\nMotivation : "</span> + conversionMotivation.toString((*itMotivationClassifierSystems).first);
+00341 (*itMotivationClassifierSystems).second.getDebugString(ret);
+00342 }
+00343 std::map&lt;TAction, CClassifierSystem&gt;::const_iterator itVirtualActionClassifierSystems;
+00344 <span class="keywordflow">for</span> (itVirtualActionClassifierSystems = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser2">_VirtualActionClassifierSystems</a>.begin(); itVirtualActionClassifierSystems != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser2">_VirtualActionClassifierSystems</a>.end(); itVirtualActionClassifierSystems++)
+00345 {
+00346 ret += <span class="stringliteral">"\nVirtual Action : "</span> + conversionAction.toString((*itVirtualActionClassifierSystems).first);
+00347 (*itVirtualActionClassifierSystems).second.getDebugString(ret);
+00348 }
+00349 ret += <span class="stringliteral">"\nACTIONS :\n"</span>;
+00350 std::set&lt;TAction&gt;::const_iterator itActionSet;
+00351 <span class="keywordflow">for</span> (itActionSet = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser0">_ActionSet</a>.begin(); itActionSet != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser0">_ActionSet</a>.end(); itActionSet++)
+00352 {
+00353 ret += conversionAction.toString((*itActionSet)) + <span class="stringliteral">"\n"</span>;
+00354 }
+00355 <a class="code" href="a04223.html#a627">t</a>+=ret;
+00356 }
+00357
+00358
+<a name="l00359"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea12">00359</a> <span class="keywordtype">void</span> CMHiCSbase::printDebugString()<span class="keyword"> const</span>
+00360 <span class="keyword"></span>{
+00361 std::string ret = <span class="stringliteral">""</span>;
+00362 <a class="code" href="a04199.html#a0">nldebug</a>(<span class="stringliteral">"\n---------------------------"</span>);
+00363 std::map&lt;TMotivation, CClassifierSystem&gt;::const_iterator itMotivationClassifierSystems;
+00364 <span class="keywordflow">for</span> (itMotivationClassifierSystems = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.begin(); itMotivationClassifierSystems != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.end(); itMotivationClassifierSystems++)
+00365 {
+00366 ret += ((<span class="stringliteral">"\nMotivation : "</span> + conversionMotivation.toString((*itMotivationClassifierSystems).first)).c_str());
+00367 (*itMotivationClassifierSystems).second.getDebugString(ret);
+00368 <a class="code" href="a04199.html#a0">nldebug</a>(ret.c_str());
+00369 ret = <span class="stringliteral">""</span>;
+00370 }
+00371 std::map&lt;TAction, CClassifierSystem&gt;::const_iterator itVirtualActionClassifierSystems;
+00372 <span class="keywordflow">for</span> (itVirtualActionClassifierSystems = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser2">_VirtualActionClassifierSystems</a>.begin(); itVirtualActionClassifierSystems != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser2">_VirtualActionClassifierSystems</a>.end(); itVirtualActionClassifierSystems++)
+00373 {
+00374 ret += ((<span class="stringliteral">"\nVirtual Action : "</span> + conversionAction.toString((*itVirtualActionClassifierSystems).first)).c_str());
+00375 (*itVirtualActionClassifierSystems).second.getDebugString(ret);
+00376 <a class="code" href="a04199.html#a0">nldebug</a>(ret.c_str());
+00377 ret = <span class="stringliteral">""</span>;
+00378 }
+00379 ret += (<span class="stringliteral">"\nACTIONS :\n"</span>);
+00380 std::set&lt;TAction&gt;::const_iterator itActionSet;
+00381 <span class="keywordflow">for</span> (itActionSet = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser0">_ActionSet</a>.begin(); itActionSet != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser0">_ActionSet</a>.end(); itActionSet++)
+00382 {
+00383 ret += ((conversionAction.toString((*itActionSet)) + <span class="stringliteral">"\n"</span>).c_str());
+00384 <a class="code" href="a04199.html#a0">nldebug</a>(ret.c_str());
+00385 ret = <span class="stringliteral">""</span>;
+00386 }
+00387 }
+00388
+00389
+<a name="l00391"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea11">00391</a> <span class="keywordtype">bool</span> CMHiCSbase::loadClassifierFromFile(std::string fileName)
+00392 {
+00393 <span class="keywordtype">bool</span> ret;
+00394 <span class="keyword">const</span> <a class="code" href="a04558.html#a11">uint32</a> aboeufSize = 2048;
+00395 <span class="keywordtype">char</span> aboeuf[aboeufSize];
+00396 std::string laLigne, leMot;
+00397 <a class="code" href="a04558.html#a15">uint</a> lastPos = 0;
+00398 <a class="code" href="a04558.html#a15">uint</a> nextPos = 0;
+00399 <a class="code" href="a02653.html">NLMISC::CIFile</a> melkior;
+00400 <a class="code" href="a02399.html">CConditionMap</a> conditionsMap;
+00401 std::map&lt;TAction, CActionClassifiers &gt; actionsMap;
+00402 std::vector&lt;TSensor&gt; sensorVector;
+00403 ret = melkior.<a class="code" href="a02653.html#NLMISC_1_1CIFilea12">open</a>(fileName, <span class="keyword">true</span>);
+00404 <span class="keywordflow">if</span> (!ret) <span class="keywordflow">return</span> <span class="keyword">false</span>;
+00405 <span class="comment">// 1ère ligne : titre conditions</span>
+00406 melkior.<a class="code" href="a02653.html#NLMISC_1_1CIFilea7">getline</a>(aboeuf, aboeufSize);
+00407 <span class="comment">// 2ème ligne : Motivations; [Condition]*; Actions; priority; blabla</span>
+00408 melkior.<a class="code" href="a02653.html#NLMISC_1_1CIFilea7">getline</a>(aboeuf, aboeufSize);
+00409 laLigne = aboeuf;
+00410 <span class="comment">// on construit une map avec les conditions</span>
+00411 nextPos = laLigne.find_first_of(<span class="stringliteral">";"</span>,lastPos);
+00412 leMot = laLigne.substr(lastPos,nextPos - lastPos);
+00413 <a class="code" href="a04199.html#a6">nlassert</a>(leMot == <span class="stringliteral">"Motivations"</span>);
+00414 lastPos = nextPos+1;
+00415 nextPos = laLigne.find_first_of(<span class="stringliteral">";"</span>, lastPos);
+00416 leMot = laLigne.substr(lastPos, nextPos-lastPos);
+00417 <span class="keywordflow">while</span> (leMot != <span class="stringliteral">"Actions"</span>)
+00418 {
+00419 <span class="comment">// on regarde le type du senseur :</span>
+00420 <a class="code" href="a05371.html#a100">TSensor</a> titi = conversionSensor.fromString(leMot);
+00421 <a class="code" href="a04199.html#a6">nlassert</a> (titi != <a class="code" href="a05371.html#a100a55">Sensor_Unknown</a>);
+00422 sensorVector.push_back(titi);
+00423
+00424 lastPos = nextPos+1;
+00425 nextPos = laLigne.find_first_of(<span class="stringliteral">";"</span>, lastPos);
+00426 leMot = laLigne.substr(lastPos, nextPos-lastPos);
+00427 }
+00428 <span class="comment">// on parse le reste</span>
+00429 melkior.<a class="code" href="a02653.html#NLMISC_1_1CIFilea7">getline</a>(aboeuf, aboeufSize);
+00430 laLigne = aboeuf;
+00431 lastPos = 0;
+00432 nextPos = 0;
+00433 <span class="keywordflow">while</span> (laLigne.size() &gt; 0)
+00434 {
+00435 <a class="code" href="a05371.html#a99">TMotivation</a> laMotive;
+00436 <a class="code" href="a05371.html#a101">TAction</a> laVirtuelle;
+00437 <span class="comment">// On récupère le nom de la motivation</span>
+00438 nextPos = laLigne.find_first_of(<span class="stringliteral">";"</span>,lastPos);
+00439 leMot = laLigne.substr(lastPos,nextPos - lastPos);
+00440 <span class="keywordflow">if</span> (leMot.size() == 0) <span class="keywordflow">break</span>;
+00441 laMotive = conversionMotivation.fromString(leMot);
+00442 <span class="keywordflow">if</span> (laMotive == <a class="code" href="a05371.html#a99a21">Motivation_Unknown</a>)
+00443 {
+00444 <span class="comment">// Si c'est pas une motivation, c'est peut-être une action virtuelle.</span>
+00445 laVirtuelle = conversionAction.fromString(leMot);
+00446 <a class="code" href="a04199.html#a6">nlassert</a>(laVirtuelle != <a class="code" href="a05371.html#a101a76">Action_Unknown</a>);
+00447 }
+00448
+00449 lastPos = nextPos+1;
+00450 nextPos = laLigne.find_first_of(<span class="stringliteral">";"</span>,lastPos);
+00451 leMot = laLigne.substr(lastPos,nextPos - lastPos);
+00452
+00453 <span class="comment">// On récupère la liste des conditions</span>
+00454 <a class="code" href="a04558.html#a15">uint</a> ii;
+00455 <span class="keywordflow">for</span> (ii = 0; ii &lt; sensorVector.size(); ii++)
+00456 {
+00457 <span class="keywordflow">if</span> (leMot.size() &gt;0)
+00458 {
+00459 <a class="code" href="a05371.html#a100">TSensor</a> sensorName = sensorVector[ii];
+00460 <span class="keywordflow">if</span> (leMot[0] == <span class="charliteral">'!'</span>)
+00461 {
+00462 conditionsMap.<a class="code" href="a02399.html#NLAINIMAT_1_1CConditionMapa0">addIfNotSensorCondition</a>(sensorName,leMot[1]);
+00463 }
+00464 <span class="keywordflow">else</span>
+00465 {
+00466 conditionsMap.<a class="code" href="a02399.html#NLAINIMAT_1_1CConditionMapa1">addIfSensorCondition</a>(sensorName,leMot[0]);
+00467 }
+00468 }
+00469
+00470 lastPos = nextPos+1;
+00471 nextPos = laLigne.find_first_of(<span class="stringliteral">";"</span>,lastPos);
+00472 leMot = laLigne.substr(lastPos,nextPos - lastPos);
+00473 }
+00474 <span class="comment">// on récupère le nom de l'action</span>
+00475 <a class="code" href="a05371.html#a101">TAction</a> actionName = conversionAction.fromString(leMot);
+00476 <a class="code" href="a04199.html#a6">nlassert</a>(actionName != <a class="code" href="a05371.html#a101a76">Action_Unknown</a>);
+00477
+00478 lastPos = nextPos+1;
+00479 nextPos = laLigne.find_first_of(<span class="stringliteral">";"</span>,lastPos);
+00480 leMot = laLigne.substr(lastPos,nextPos - lastPos);
+00481
+00482 <span class="comment">// on récupère la force du classeur</span>
+00483 <a class="code" href="a02342.html">CClassifierPriority</a> laforce;
+00484 laforce.<a class="code" href="a02342.html#NLAINIMAT_1_1CClassifierPrioritya5">SetClassifierTimer</a>( atof(leMot.c_str()) );
+00485
+00486 <span class="comment">// on rajoute la règle dans les actions.</span>
+00487 std::map&lt;TAction, CActionClassifiers &gt;::iterator itActionsMap = actionsMap.find(actionName);
+00488 <span class="keywordflow">if</span> (itActionsMap == actionsMap.end())
+00489 {
+00490 <a class="code" href="a02158.html">CActionClassifiers</a> bibu(actionName);
+00491 actionsMap.insert(std::make_pair(actionName, bibu));
+00492 }
+00493 <a class="code" href="a02158.html">CActionClassifiers</a> mon_action(actionName);
+00494 <span class="comment">// Si la motivation est inconnue, c'est que c'est une action virtuelle.</span>
+00495 <span class="keywordflow">if</span> (laMotive == <a class="code" href="a05371.html#a99a21">Motivation_Unknown</a>)
+00496 {
+00497 actionsMap[actionName].addVirtualActionRule(laVirtuelle,conditionsMap, laforce);
+00498 }
+00499 <span class="keywordflow">else</span>
+00500 {
+00501 actionsMap[actionName].addMotivationRule(laMotive,conditionsMap, laforce);
+00502 }
+00503
+00504 conditionsMap.<a class="code" href="a02399.html#NLAINIMAT_1_1CConditionMapa4">clear</a>();
+00505 melkior.<a class="code" href="a02653.html#NLMISC_1_1CIFilea7">getline</a>(aboeuf, aboeufSize);
+00506 laLigne = aboeuf;
+00507 lastPos = 0;
+00508 nextPos = 0;
+00509 }
+00510 melkior.<a class="code" href="a02653.html#NLMISC_1_1CIFilea3">close</a>();
+00511
+00512 std::map&lt;TAction, CActionClassifiers &gt;::iterator itActionsMap;
+00513 <span class="keywordflow">for</span> (itActionsMap = actionsMap.begin(); itActionsMap != actionsMap.end(); itActionsMap++)
+00514 {
+00515 <span class="comment">//***G*** ajouter aussi la gestion des actions virtuels</span>
+00516 <a class="code" href="a05371.html#a101">TAction</a> testAction = (*itActionsMap).second.getName();
+00517 <a class="code" href="a04199.html#a6">nlassert</a> (testAction != <a class="code" href="a05371.html#a101a76">Action_Unknown</a>);
+00518 <span class="keywordflow">if</span> (testAction &gt; <a class="code" href="a05371.html#a101a75">Action_VIRTUAL_ACTIONS</a>)
+00519 {
+00520 <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea1">addVirtualActionCS</a>( (*itActionsMap).second );
+00521 }
+00522 <span class="keywordflow">else</span>
+00523 {
+00524 <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea0">addActionCS</a>( (*itActionsMap).second );
+00525 }
+00526 }
+00527
+00528 <span class="keywordflow">return</span> <span class="keyword">true</span>;
+00529 }
+00530
+<a name="l00531"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea3">00531</a> <span class="keywordtype">void</span> CMHiCSbase::dbgPrintClassifierPriorityInFile(std::string fileName)<span class="keyword"> const</span>
+00532 <span class="keyword"></span>{
+00533 <span class="keywordtype">int</span> i;
+00534 std::map&lt;TMotivation, CClassifierSystem&gt;::const_iterator itMotivationClassifierSystems;
+00535 std::string nomDuFichier = <span class="stringliteral">"D:\\jgab\\doc\\IA\\_These\\gnuplot\\TFC\\"</span>;
+00536 nomDuFichier += fileName;
+00537
+00538 <a class="code" href="a02653.html">NLMISC::CIFile</a> baltazar;
+00539 <span class="keywordtype">bool</span> yaqqunauboutdufil = baltazar.<a class="code" href="a02653.html#NLMISC_1_1CIFilea12">open</a>(nomDuFichier.c_str(), <span class="keyword">true</span>);
+00540 baltazar.<a class="code" href="a02653.html#NLMISC_1_1CIFilea3">close</a>();
+00541
+00542 <a class="code" href="a03011.html">NLMISC::COFile</a> melkior;
+00543 std::string ohlabellephrase = <span class="stringliteral">""</span>;
+00544
+00545 <span class="keywordflow">if</span> (!yaqqunauboutdufil)
+00546 {
+00547 melkior.<a class="code" href="a03011.html#NLMISC_1_1COFilea9">open</a>(nomDuFichier.c_str(), <span class="keyword">false</span>, <span class="keyword">true</span>);
+00548
+00549 <span class="keywordflow">for</span>(itMotivationClassifierSystems = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.begin();
+00550 itMotivationClassifierSystems != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.end();
+00551 itMotivationClassifierSystems++)
+00552 {
+00553 <a class="code" href="a05371.html#a99">TMotivation</a> laMotive = (*itMotivationClassifierSystems).first;
+00554 <span class="keywordflow">for</span> (i= 0; i&lt; (*itMotivationClassifierSystems).second.getClassifierNumber(); i++)
+00555 {
+00556 ohlabellephrase += <span class="stringliteral">"MAX "</span>;
+00557 ohlabellephrase += NLAINIMAT::conversionMotivation.toString(laMotive);
+00558 ohlabellephrase += <span class="stringliteral">" "</span>;
+00559 (*itMotivationClassifierSystems).second.getDebugString(i,ohlabellephrase);
+00560 ohlabellephrase += <span class="stringliteral">";T2S "</span>;
+00561 ohlabellephrase += NLAINIMAT::conversionMotivation.toString(laMotive);
+00562 ohlabellephrase += <span class="stringliteral">" "</span>;
+00563 (*itMotivationClassifierSystems).second.getDebugString(i,ohlabellephrase);
+00564 ohlabellephrase += <span class="stringliteral">";ExT "</span>;
+00565 ohlabellephrase += NLAINIMAT::conversionMotivation.toString(laMotive);
+00566 ohlabellephrase += <span class="stringliteral">" "</span>;
+00567 (*itMotivationClassifierSystems).second.getDebugString(i,ohlabellephrase);
+00568 <span class="comment">// ohlabellephrase += NLMISC::toString(i);</span>
+00569
+00570 ohlabellephrase += <span class="stringliteral">";"</span>;
+00571 }
+00572 }
+00573 ohlabellephrase += <span class="stringliteral">"\n"</span>;
+00574 }
+00575 <span class="keywordflow">else</span>
+00576 {
+00577 melkior.<a class="code" href="a03011.html#NLMISC_1_1COFilea9">open</a>(nomDuFichier.c_str(), <span class="keyword">true</span>, <span class="keyword">true</span>);
+00578 }
+00579
+00580 <span class="keywordflow">for</span>(itMotivationClassifierSystems = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.begin();
+00581 itMotivationClassifierSystems != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.end();
+00582 itMotivationClassifierSystems++)
+00583 {
+00584 <a class="code" href="a05371.html#a99">TMotivation</a> laMotive = (*itMotivationClassifierSystems).first;
+00585 <span class="keywordflow">for</span> (i= 0; i&lt; (*itMotivationClassifierSystems).second.getClassifierNumber(); i++)
+00586 {
+00587 <a class="code" href="a02342.html">CClassifierPriority</a> laSuperPrio = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea7">getPriorityPart</a>(laMotive, i);
+00588 ohlabellephrase += <a class="code" href="a05378.html#a244">NLMISC::toString</a>(laSuperPrio.<a class="code" href="a02342.html#NLAINIMAT_1_1CClassifierPrioritya2">getPriority</a>());
+00589 ohlabellephrase += <span class="stringliteral">";"</span>;
+00590 ohlabellephrase += <a class="code" href="a05378.html#a244">NLMISC::toString</a>(laSuperPrio.<a class="code" href="a02342.html#NLAINIMAT_1_1CClassifierPrioritya3">getPriorityTimer</a>());
+00591 ohlabellephrase += <span class="stringliteral">";"</span>;
+00592 ohlabellephrase += <a class="code" href="a05378.html#a244">NLMISC::toString</a>(laSuperPrio.<a class="code" href="a02342.html#NLAINIMAT_1_1CClassifierPrioritya1">getClassifierTimer</a>());
+00593 ohlabellephrase += <span class="stringliteral">";"</span>;
+00594 }
+00595 }
+00596 ohlabellephrase += <span class="stringliteral">"\n"</span>;
+00597
+00598
+00599 <a class="code" href="a04558.html#a7">uint8</a> *buf = (<a class="code" href="a04558.html#a7">uint8</a> *)ohlabellephrase.c_str();
+00600 <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a571">len</a> = ohlabellephrase.length();
+00601 melkior.<a class="code" href="a03011.html#NLMISC_1_1COFilea12">serialBuffer</a>(buf,<a class="code" href="a04223.html#a571">len</a>);
+00602 melkior.<a class="code" href="a03011.html#NLMISC_1_1COFilea0">close</a>();
+00603 }
+00604
+<a name="l00605"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea10">00605</a> <span class="keywordtype">void</span> CMHiCSbase::learningUpdatePriorityValueTimeToSuccess(TMotivation motivationName, <a class="code" href="a05371.html#a7">TClassifierNumber</a> classifierNumber, <a class="code" href="a04558.html#a11">uint32</a> timeToSuccess)
+00606 {
+00607 <span class="comment">// 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.</span>
+00608 std::map&lt;TMotivation, CClassifierSystem&gt;::iterator itMotivationClassifierSystems = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.find(motivationName);
+00609 <a class="code" href="a04199.html#a6">nlassert</a>(itMotivationClassifierSystems != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.end());
+00610 <a class="code" href="a04558.html#a11">uint32</a> oldTime2Success = (*itMotivationClassifierSystems).second.getPriorityPart(classifierNumber).getPriorityTimer();
+00611 <a class="code" href="a04558.html#a11">uint32</a> newTime2Success;
+00612 <span class="keywordflow">if</span> (oldTime2Success == 0)
+00613 {
+00614 newTime2Success = timeToSuccess;
+00615 }
+00616 <span class="keywordflow">else</span>
+00617 {
+00618 <span class="keywordflow">if</span> (oldTime2Success &gt; timeToSuccess)
+00619 {
+00620 newTime2Success = (timeToSuccess*3 + oldTime2Success)/4;
+00621 }
+00622 <span class="keywordflow">else</span>
+00623 {
+00624 newTime2Success = (timeToSuccess + oldTime2Success*3)/4;
+00625 }
+00626 }
+00627 <span class="comment">// nlassert (newTime2Success != 0);</span>
+00628 <a class="code" href="a02342.html">CClassifierPriority</a> newPrio;
+00629 newPrio.<a class="code" href="a02342.html#NLAINIMAT_1_1CClassifierPrioritya6">setPriorityTimer</a>(newTime2Success);
+00630 <span class="comment">// newPrio.setPriorityTimer(timeToSuccess);</span>
+00631 newPrio.<a class="code" href="a02342.html#NLAINIMAT_1_1CClassifierPrioritya5">SetClassifierTimer</a>((*itMotivationClassifierSystems).second.getPriorityPart(classifierNumber).getClassifierTimer());
+00632 (*itMotivationClassifierSystems).second.setPriorityPart(classifierNumber, newPrio);
+00633 }
+<a name="l00634"></a><a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea9">00634</a> <span class="keywordtype">void</span> CMHiCSbase::learningUpdatePriorityValueClassifierTime(TMotivation motivationName, <a class="code" href="a05371.html#a7">TClassifierNumber</a> classifierNumber, <a class="code" href="a04558.html#a11">uint32</a> time)
+00635 {
+00636 <span class="comment">// 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.</span>
+00637 std::map&lt;TMotivation, CClassifierSystem&gt;::iterator itMotivationClassifierSystems = <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.find(motivationName);
+00638 <a class="code" href="a04199.html#a6">nlassert</a>(itMotivationClassifierSystems != <a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaser1">_MotivationClassifierSystems</a>.end());
+00639 <a class="code" href="a04558.html#a11">uint32</a> oldTime = (*itMotivationClassifierSystems).second.getPriorityPart(classifierNumber).getClassifierTimer();
+00640 <a class="code" href="a04558.html#a11">uint32</a> newTime;
+00641 <span class="keywordflow">if</span> (oldTime == 0)
+00642 {
+00643 newTime = time;
+00644 }
+00645 <span class="keywordflow">else</span>
+00646 {
+00647 <span class="keywordflow">if</span> (oldTime &gt; time)
+00648 {
+00649 newTime = (time + oldTime*3)/4;
+00650 }
+00651 <span class="keywordflow">else</span>
+00652 {
+00653 newTime = (time*3 + oldTime)/4;
+00654 }
+00655 }
+00656 <a class="code" href="a02342.html">CClassifierPriority</a> newPrio;
+00657 newPrio.<a class="code" href="a02342.html#NLAINIMAT_1_1CClassifierPrioritya6">setPriorityTimer</a>((*itMotivationClassifierSystems).second.getPriorityPart(classifierNumber).getPriorityTimer());
+00658 newPrio.<a class="code" href="a02342.html#NLAINIMAT_1_1CClassifierPrioritya5">SetClassifierTimer</a>(newTime);
+00659 <span class="comment">// newPrio.SetClassifierTimer(time);</span>
+00660 (*itMotivationClassifierSystems).second.setPriorityPart(classifierNumber, newPrio);
+00661 }
+00662
+00663
+00665 <span class="comment">// CMHiCSagent</span>
+00667 <span class="comment"></span>
+<a name="l00668"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta0">00668</a> CMHiCSagent::CMHiCSagent(<a class="code" href="a02929.html">CMHiCSbase</a>* pMHiCSbase)
+00669 {
+00670 <a class="code" href="a04199.html#a6">nlassert</a> (pMHiCSbase != NULL);
+00671 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr5">_pMHiCSbase</a> = pMHiCSbase;
+00672 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a> = <span class="keyword">new</span> std::map&lt;TTargetId, std::map&lt;TAction, CMotivationEnergy&gt; &gt;();
+00673 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr6">_pOldActionsExecutionIntensityByTarget</a> = <span class="keyword">new</span> std::map&lt;TTargetId, std::map&lt;TAction, CMotivationEnergy&gt; &gt;();
+00674 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr1">_Learning</a> = <span class="keyword">true</span>;
+00675 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr4">_pInfoClassifierActivity</a> = <span class="keyword">new</span> std::map&lt;TMotivation, std::map&lt;TClassifierNumber, CClassifierActivityInfo&gt; &gt;();
+00676 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr7">_pOldInfoClassifierActivity</a> = <span class="keyword">new</span> std::map&lt;TMotivation, std::map&lt;TClassifierNumber, CClassifierActivityInfo&gt; &gt;();
+00677 <span class="comment">// _ActionsExecutionIntensity[Action_DoNothing] = CMotivationEnergy();</span>
+00678 <span class="comment">// _IdByActions[Action_DoNothing] = NullTargetId;</span>
+00679 <span class="comment">// _ItCurrentAction = _IdByActions.find(Action_DoNothing);</span>
+00680 }
+00681
+<a name="l00682"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta14">00682</a> CMHiCSagent::~CMHiCSagent()
+00683 {
+00684 <span class="keyword">delete</span> <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr6">_pOldActionsExecutionIntensityByTarget</a>;
+00685 <span class="keyword">delete</span> <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a>;
+00686 <span class="keyword">delete</span> <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr4">_pInfoClassifierActivity</a>;
+00687 <span class="keyword">delete</span> <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr7">_pOldInfoClassifierActivity</a>;
+00688 }
+00689
+<a name="l00691"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentd2">00691</a> std::string CMHiCSagent::targetId2String(<a class="code" href="a05371.html#a13">TTargetId</a> <span class="keywordtype">id</span>)<span class="keyword"> const</span>
+00692 <span class="keyword"></span>{
+00693 <span class="comment">/* // Le format est celui pour afficher en debug le Nb comme dans Ryzom.</span>
+00694 <span class="comment"> uint32 aiBoteId = id;</span>
+00695 <span class="comment"> uint32 managerID = (aiBoteId&gt;&gt;(8+12))&amp;( (1&lt;&lt;10)-1 );</span>
+00696 <span class="comment"> uint32 groupeID = (aiBoteId&gt;&gt;8)&amp;( (1&lt;&lt;12)-1 );</span>
+00697 <span class="comment"> uint32 boteID = aiBoteId&amp;( (1&lt;&lt;8)-1 );</span>
+00698 <span class="comment"> char result[30];</span>
+00699 <span class="comment"> sprintf(result,"AI:%04x:BOT:%04x:%04x:%04x",aiBoteId,managerID,groupeID,boteID);</span>
+00700 <span class="comment"> return result;</span>
+00701 <span class="comment">*/</span>
+00702 std::string ret = <a class="code" href="a05378.html#a244">NLMISC::toString</a>(<span class="keywordtype">id</span>);
+00703 <span class="keywordflow">return</span> ret;
+00704 }
+00705
+<a name="l00707"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta1">00707</a> <span class="keywordtype">void</span> CMHiCSagent::getDebugString(std::string &amp;<a class="code" href="a04223.html#a627">t</a>)<span class="keyword"> const</span>
+00708 <span class="keyword"></span>{
+00709 std::string ret = <span class="stringliteral">"\n\n---------------------------\n"</span>;
+00710 ret += <span class="stringliteral">"\nPerceptions :"</span>;
+00711 ret += <span class="stringliteral">"\n Without target"</span>;
+00712 NLAINIMAT::TSensorMap::const_iterator itNoTargetSensors;
+00713 <span class="keywordflow">for</span> (itNoTargetSensors = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr8">_pSensorsValues</a>-&gt;<a class="code" href="a02422.html#NLAINIMAT_1_1CCSPerceptiono0">NoTargetSensors</a>.begin();
+00714 itNoTargetSensors != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr8">_pSensorsValues</a>-&gt;<a class="code" href="a02422.html#NLAINIMAT_1_1CCSPerceptiono0">NoTargetSensors</a>.end();
+00715 itNoTargetSensors++)
+00716 {
+00717 ret += <span class="stringliteral">"\n "</span> + conversionSensor.toString((*itNoTargetSensors).first) + <span class="stringliteral">"("</span> + (*itNoTargetSensors).second + <span class="stringliteral">")"</span>;
+00718 }
+00719 std::map&lt;TTargetId, TSensorMap&gt;::const_iterator itTargetSensors;
+00720 <span class="keywordflow">for</span> (itTargetSensors = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr8">_pSensorsValues</a>-&gt;<a class="code" href="a02422.html#NLAINIMAT_1_1CCSPerceptiono1">TargetSensors</a>.begin();
+00721 itTargetSensors != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr8">_pSensorsValues</a>-&gt;<a class="code" href="a02422.html#NLAINIMAT_1_1CCSPerceptiono1">TargetSensors</a>.end();
+00722 itTargetSensors++)
+00723 {
+00724 ret += <span class="stringliteral">"\n On target n#"</span> + <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentd2">targetId2String</a>((*itTargetSensors).first);
+00725 <span class="keywordflow">for</span> (itNoTargetSensors = (*itTargetSensors).second.begin();
+00726 itNoTargetSensors != (*itTargetSensors).second.end();
+00727 itNoTargetSensors++)
+00728 {
+00729 ret += <span class="stringliteral">"\n "</span> + conversionSensor.toString((*itNoTargetSensors).first) + <span class="stringliteral">"("</span> + (*itNoTargetSensors).second + <span class="stringliteral">")"</span>;
+00730 }
+00731 }
+00732 ret += <span class="stringliteral">"\n\nMotivations :"</span>;
+00733 std::map&lt;TMotivation, CMotivationEnergy&gt;::const_iterator itClassifiersAndMotivationIntensity;
+00734 <span class="keywordflow">for</span> (itClassifiersAndMotivationIntensity = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.begin();
+00735 itClassifiersAndMotivationIntensity != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.end();
+00736 itClassifiersAndMotivationIntensity++)
+00737 {
+00738 ret += <span class="stringliteral">"\n &lt;"</span> + conversionMotivation.toString((*itClassifiersAndMotivationIntensity).first) + <span class="stringliteral">"&gt; "</span>;
+00739 ret += <span class="stringliteral">"[MI="</span> + <a class="code" href="a05378.html#a244">NLMISC::toString</a>((*itClassifiersAndMotivationIntensity).second.getSumValue()) + <span class="stringliteral">"] :"</span>;
+00740 (*itClassifiersAndMotivationIntensity).second.getDebugString(ret);
+00741 <span class="comment">// ret += "\n -&gt; Classifier number " + NLMISC::toString((*itClassifiersAndMotivationIntensity).second.ClassifierNumber); </span>
+00742 ret += <span class="stringliteral">"\n"</span>;
+00743 }
+00744 <span class="comment">// ret += "\nVirtual Actions :";</span>
+00745 <span class="comment">// std::map&lt;TAction, CMotivationEnergy&gt;::const_iterator itClassifiersAndVirtualActionIntensity;</span>
+00746 <span class="comment">// for (itClassifiersAndVirtualActionIntensity = _ClassifiersAndVirtualActionIntensity.begin();</span>
+00747 <span class="comment">// itClassifiersAndVirtualActionIntensity != _ClassifiersAndVirtualActionIntensity.end();</span>
+00748 <span class="comment">// itClassifiersAndVirtualActionIntensity++)</span>
+00749 <span class="comment">// {</span>
+00750 <span class="comment">// ret += "\n &lt;" + conversionAction.toString((*itClassifiersAndVirtualActionIntensity).first) + "&gt; ";</span>
+00751 <span class="comment">// ret += "[MI=" + NLMISC::toString((*itClassifiersAndVirtualActionIntensity).second.getSumValue()) + "] :";</span>
+00752 <span class="comment">// (*itClassifiersAndVirtualActionIntensity).second.getDebugString(ret);</span>
+00757 <span class="comment"></span><span class="comment">// ret += "\n -&gt; Classifier number " + NLMISC::toString((*itClassifiersAndVirtualActionIntensity).second.ClassifierNumber); </span>
+00758 <span class="comment">// ret += "\n";</span>
+00759 <span class="comment">// }</span>
+00760 ret += <span class="stringliteral">"\nACTIONS :"</span>;
+00761 std::map&lt;TAction, CMotivationEnergy&gt;::const_iterator itActionsExecutionIntensity;
+00762 <span class="comment">// for (itActionsExecutionIntensity = _ActionsExecutionIntensity.begin(); itActionsExecutionIntensity != _ActionsExecutionIntensity.end(); itActionsExecutionIntensity++)</span>
+00763 <span class="comment">// {</span>
+00764 <span class="comment">// ret += "\n &lt;" + conversionAction.toString((* itActionsExecutionIntensity).first) + "&gt; [EI=" + NLMISC::toString((*itActionsExecutionIntensity).second.getSumValue()) + "] : ";</span>
+00765 <span class="comment">// (*itActionsExecutionIntensity).second.getDebugString(ret);</span>
+00766 <span class="comment">// std::map&lt;TAction, TTargetId&gt;::const_iterator itIdByActions = _IdByActions.find((*itActionsExecutionIntensity).first);</span>
+00767 <span class="comment">// nlassert (itIdByActions != _IdByActions.end());</span>
+00769 <span class="comment"></span><span class="comment">// ret += " on target n#" + targetId2String((*itIdByActions).second);</span>
+00770 <span class="comment">// }</span>
+00771 <span class="comment">// if (_ItCurrentAction != _IdByActions.end())</span>
+00772 <span class="comment">// {</span>
+00774 <span class="comment"></span><span class="comment">// ret += "\nACTION ACTIVE : " + NLAINIMAT::conversionAction.toString((*_ItCurrentAction).first) + " on " + targetId2String((*_ItCurrentAction).second);</span>
+00775 <span class="comment">// }</span>
+00776 <a class="code" href="a04223.html#a627">t</a>+=ret;
+00777 }
+00778
+<a name="l00780"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta10">00780</a> <span class="keywordtype">void</span> CMHiCSagent::setMotivationPP(TMotivation motivationName, <span class="keywordtype">double</span> PP)
+00781 {
+00782 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>[motivationName].setMHiCSagent(<span class="keyword">this</span>);
+00783 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>[motivationName].setMotivationPP(motivationName, PP);
+00784 <span class="comment">// spreadMotivationReckon(motivationName);</span>
+00785 }
+00786
+<a name="l00788"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta4">00788</a> <span class="keywordtype">double</span> CMHiCSagent::getMotivationPP(TMotivation motivationName)<span class="keyword"> const</span>
+00789 <span class="keyword"></span>{
+00790 std::map&lt;TMotivation, CMotivationEnergy&gt;::const_iterator itClassifiersAndMotivationIntensity = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.find(motivationName);
+00791 <span class="keywordflow">if</span> (itClassifiersAndMotivationIntensity != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.end())
+00792 {
+00793 <span class="keywordflow">return</span> (*itClassifiersAndMotivationIntensity).second.getMotivationPP(motivationName);
+00794 }
+00795 <span class="keywordflow">else</span>
+00796 {
+00797 <span class="keywordflow">return</span> -1;
+00798 }
+00799 }
+00800
+<a name="l00802"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta11">00802</a> <span class="keywordtype">void</span> CMHiCSagent::setMotivationValue(TMotivation motivationName, <span class="keywordtype">double</span> <a class="code" href="a04223.html#a658">value</a>)
+00803 {
+00804 <span class="comment">// if (_Learning)</span>
+00805 <span class="comment">// {</span>
+00806 <span class="comment">// double lastMotiveValue = _ClassifiersAndMotivationIntensity[motivationName].getMotivationValue(motivationName);</span>
+00807 <span class="comment">// // Si la valeur de motivation a diminuée, il est temps d'apprendre</span>
+00808 <span class="comment">// if (lastMotiveValue &gt; value)</span>
+00809 <span class="comment">// {</span>
+00810 <span class="comment">// learningComputationMotivationDecrease(motivationName);</span>
+00811 <span class="comment">// }</span>
+00812 <span class="comment">// }</span>
+00813
+00814 std::map&lt;TMotivation, CMotivationEnergy&gt;::iterator itClassifiersAndMotivationIntensity = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.find(motivationName);
+00815 <span class="keywordflow">if</span> (itClassifiersAndMotivationIntensity == <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.end())
+00816 {
+00817 itClassifiersAndMotivationIntensity = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.insert(std::make_pair(motivationName,<a class="code" href="a02938.html">CMotivationEnergy</a>())).first;
+00818
+00819 <span class="comment">// On en profite pour mettre à zero la date de la première réponse positive d'une motivation</span>
+00820 <span class="comment">// _TimeOfLastMotivationValueDecrease[motivationName] = NLMISC::CTime::getSecondsSince1970();</span>
+00821 }
+00822 (*itClassifiersAndMotivationIntensity).second.setMHiCSagent(<span class="keyword">this</span>);
+00823 (*itClassifiersAndMotivationIntensity).second.setMotivationValue(motivationName, <a class="code" href="a04223.html#a658">value</a>);
+00824 <span class="comment">// spreadMotivationReckon(motivationName);</span>
+00825 }
+00826
+<a name="l00827"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta5">00827</a> <span class="keywordtype">double</span> CMHiCSagent::getMotivationValue(TMotivation motivationName)<span class="keyword"> const</span>
+00828 <span class="keyword"></span>{
+00829 std::map&lt;TMotivation, CMotivationEnergy&gt;::const_iterator itClassifiersAndMotivationIntensity = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.find(motivationName);
+00830 <span class="keywordflow">if</span> (itClassifiersAndMotivationIntensity != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.end())
+00831 {
+00832 <span class="keywordflow">return</span> (*itClassifiersAndMotivationIntensity).second.getMotivationValue(motivationName);
+00833 }
+00834 <span class="keywordflow">else</span>
+00835 {
+00836 <span class="keywordflow">return</span> -1;
+00837 }
+00838 }
+00839
+00841 <span class="comment">//double CMHiCSagent::getMotivationIntensity(TAction virtualAction) const</span>
+00842 <span class="comment">//{</span>
+00843 <span class="comment">// std::map&lt;TAction, CMotivationEnergy&gt;::const_iterator itClassifiersAndVirtualActionIntensity = _ClassifiersAndVirtualActionIntensity.find(virtualAction);</span>
+00844 <span class="comment">// if (itClassifiersAndVirtualActionIntensity != _ClassifiersAndVirtualActionIntensity.end()) </span>
+00845 <span class="comment">// {</span>
+00846 <span class="comment">// return (*itClassifiersAndVirtualActionIntensity).second.getSumValue();</span>
+00847 <span class="comment">// }</span>
+00848 <span class="comment">// else</span>
+00849 <span class="comment">// {</span>
+00850 <span class="comment">// return -1;</span>
+00851 <span class="comment">// }</span>
+00852 <span class="comment">//}</span>
+00853
+<a name="l00855"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta2">00855</a> <span class="keywordtype">double</span> CMHiCSagent::getExecutionIntensity(TAction action, <a class="code" href="a05371.html#a13">TTargetId</a> target)<span class="keyword"> const</span>
+00856 <span class="keyword"></span>{
+00857 std::map&lt;TTargetId, std::map&lt;TAction, CMotivationEnergy&gt; &gt;::const_iterator itActionsExecutionIntensityByTarget;
+00858 itActionsExecutionIntensityByTarget = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a>-&gt;find(target);
+00859 <span class="keywordflow">if</span> (itActionsExecutionIntensityByTarget == <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a>-&gt;end())
+00860 {
+00861 <span class="keywordflow">return</span> -1;
+00862 }
+00863 std::map&lt;TAction, CMotivationEnergy&gt;::const_iterator itActionsExecutionIntensity = (*itActionsExecutionIntensityByTarget).second.find(action);
+00864 <span class="keywordflow">if</span> (itActionsExecutionIntensity != (*itActionsExecutionIntensityByTarget).second.end())
+00865 {
+00866 <span class="keywordflow">return</span> (*itActionsExecutionIntensity).second.getSumValue();
+00867 }
+00868 <span class="keywordflow">else</span>
+00869 {
+00870 <span class="keywordflow">return</span> -1;
+00871 }
+00872 }
+00873
+00874
+00875 <span class="comment">//void CMHiCSagent::spreadMotivationReckon(TMotivation CS)</span>
+00876 <span class="comment">//{</span>
+00877 <span class="comment">// std::map&lt;TMotivation, CMotivationEnergy&gt;::iterator itClassifiersAndMotivationIntensity = _ClassifiersAndMotivationIntensity.find(CS);</span>
+00878 <span class="comment">// nlassert(itClassifiersAndMotivationIntensity != _ClassifiersAndMotivationIntensity.end());</span>
+00879 <span class="comment">// TClassifierNumber lastClassifierNumber = (*itClassifiersAndMotivationIntensity).second.ClassifierNumber;</span>
+00880 <span class="comment">// if (lastClassifierNumber &gt;=0 )</span>
+00881 <span class="comment">// {</span>
+00882 <span class="comment">// TAction lastActionName = _pMHiCSbase-&gt;getActionPart(CS, lastClassifierNumber);</span>
+00883 <span class="comment">// if (_pMHiCSbase-&gt;isAnAction(lastActionName))</span>
+00884 <span class="comment">// {</span>
+00885 <span class="comment">// std::map&lt;TAction, CMotivationEnergy&gt;::iterator itActionsExecutionIntensity =</span>
+00886 <span class="comment">// _ActionsExecutionIntensity.find(lastActionName);</span>
+00887 <span class="comment">// // Test if the action selected hasn't been removed.</span>
+00888 <span class="comment">// if (itActionsExecutionIntensity == _ActionsExecutionIntensity.end()) return;</span>
+00889 <span class="comment">//</span>
+00890 <span class="comment">// // Update the motivation provider for the action execution intensity.</span>
+00891 <span class="comment">// (*itActionsExecutionIntensity).second.updateProvider(CS,</span>
+00892 <span class="comment">// (*itClassifiersAndMotivationIntensity).second.MotivationIntensity);</span>
+00893 <span class="comment">// // If the action doesn't receive motivation any more, we remove it.</span>
+00894 <span class="comment">// double energy = (*itActionsExecutionIntensity).second.getSumValue();</span>
+00895 <span class="comment">// if (energy &lt;= 0)</span>
+00896 <span class="comment">// {</span>
+00897 <span class="comment">// _ActionsExecutionIntensity.erase(lastActionName);</span>
+00898 <span class="comment">// _IdByActions.erase(lastActionName);</span>
+00899 <span class="comment">// // we check if it was the current action</span>
+00900 <span class="comment">// if ((*_ItCurrentAction).first == lastActionName)</span>
+00901 <span class="comment">// {</span>
+00902 <span class="comment">// _ItCurrentAction = _IdByActions.find(Action_DoNothing);</span>
+00903 <span class="comment">// nlassert (_ItCurrentAction != _IdByActions.end());</span>
+00904 <span class="comment">// }</span>
+00905 <span class="comment">// }</span>
+00906 <span class="comment">// }</span>
+00907 <span class="comment">// else</span>
+00908 <span class="comment">// {</span>
+00909 <span class="comment">// std::map&lt;TAction, CMotivationEnergy&gt;::iterator itClassifiersAndVirtualActionIntensity = </span>
+00910 <span class="comment">// _ClassifiersAndVirtualActionIntensity.find(lastActionName);</span>
+00911 <span class="comment">// // Test if the virtual action selected hasn't been removed.</span>
+00912 <span class="comment">// if (itClassifiersAndVirtualActionIntensity == _ClassifiersAndVirtualActionIntensity.end()) return;</span>
+00913 <span class="comment">// </span>
+00914 <span class="comment">// // Update the motivation provider for the virtual action execution intensity.</span>
+00915 <span class="comment">// (*itClassifiersAndVirtualActionIntensity).second.updateProvider(CS,</span>
+00916 <span class="comment">// (*itClassifiersAndMotivationIntensity).second.MotivationIntensity);</span>
+00917 <span class="comment">// spreadMotivationReckon(lastActionName);</span>
+00918 <span class="comment">// // If the CS doesn't receive motivation any more, we remove it.</span>
+00919 <span class="comment">// double energy = (*itClassifiersAndVirtualActionIntensity).second.getSumValue();</span>
+00920 <span class="comment">// if (energy &lt;= 0)</span>
+00921 <span class="comment">// {</span>
+00922 <span class="comment">// _ClassifiersAndVirtualActionIntensity.erase(lastActionName);</span>
+00923 <span class="comment">// }</span>
+00924 <span class="comment">// }</span>
+00925 <span class="comment">// }</span>
+00926 <span class="comment">//}</span>
+00927 <span class="comment">//</span>
+00928 <span class="comment">//void CMHiCSagent::spreadMotivationReckon(TAction CS)</span>
+00929 <span class="comment">//{</span>
+00930 <span class="comment">// std::map&lt;TAction, CMotivationEnergy&gt;::iterator itClassifiersAndVirtualActionIntensityORIGIN = </span>
+00931 <span class="comment">// _ClassifiersAndVirtualActionIntensity.find(CS);</span>
+00932 <span class="comment">// nlassert(itClassifiersAndVirtualActionIntensityORIGIN != _ClassifiersAndVirtualActionIntensity.end());</span>
+00933 <span class="comment">// TClassifierNumber lastClassifierNumber = (*itClassifiersAndVirtualActionIntensityORIGIN).second.ClassifierNumber;</span>
+00934 <span class="comment">// if (lastClassifierNumber &gt;=0 )</span>
+00935 <span class="comment">// {</span>
+00936 <span class="comment">// TAction lastActionName = _pMHiCSbase-&gt;getActionPart(CS, lastClassifierNumber);</span>
+00937 <span class="comment">// if (_pMHiCSbase-&gt;isAnAction(lastActionName))</span>
+00938 <span class="comment">// {</span>
+00939 <span class="comment">// std::map&lt;TAction, CMotivationEnergy&gt;::iterator itActionsExecutionIntensity =</span>
+00940 <span class="comment">// _ActionsExecutionIntensity.find(lastActionName);</span>
+00941 <span class="comment">// // Test if the action selected hasn't been removed.</span>
+00942 <span class="comment">// if (itActionsExecutionIntensity == _ActionsExecutionIntensity.end()) return;</span>
+00943 <span class="comment">// </span>
+00944 <span class="comment">// // Update the motivation provider for the action execution intensity.</span>
+00945 <span class="comment">// (*itActionsExecutionIntensity).second.updateProvider(CS,</span>
+00946 <span class="comment">// (*itClassifiersAndVirtualActionIntensityORIGIN).second.MotivationIntensity);</span>
+00947 <span class="comment">// // If the action doesn't receive motivation any more, we remove it.</span>
+00948 <span class="comment">// double energy = (*itActionsExecutionIntensity).second.getSumValue();</span>
+00949 <span class="comment">// if (energy &lt;= 0)</span>
+00950 <span class="comment">// {</span>
+00951 <span class="comment">// _ActionsExecutionIntensity.erase(lastActionName);</span>
+00952 <span class="comment">// _IdByActions.erase(lastActionName);</span>
+00953 <span class="comment">// // we check if it was the current action</span>
+00954 <span class="comment">// if ((*_ItCurrentAction).first == lastActionName)</span>
+00955 <span class="comment">// {</span>
+00956 <span class="comment">// _ItCurrentAction = _IdByActions.find(Action_DoNothing);</span>
+00957 <span class="comment">// nlassert (_ItCurrentAction != _IdByActions.end());</span>
+00958 <span class="comment">// }</span>
+00959 <span class="comment">// }</span>
+00960 <span class="comment">// }</span>
+00961 <span class="comment">// else</span>
+00962 <span class="comment">// {</span>
+00963 <span class="comment">// std::map&lt;TAction, CMotivationEnergy&gt;::iterator itClassifiersAndVirtualActionIntensity = </span>
+00964 <span class="comment">// _ClassifiersAndVirtualActionIntensity.find(lastActionName);</span>
+00965 <span class="comment">// // Test if the virtual action selected hasn't been removed.</span>
+00966 <span class="comment">// if (itClassifiersAndVirtualActionIntensity == _ClassifiersAndVirtualActionIntensity.end()) return;</span>
+00967 <span class="comment">// </span>
+00968 <span class="comment">// // Update the motivation provider for the virtual action execution intensity.</span>
+00969 <span class="comment">// (*itClassifiersAndVirtualActionIntensity).second.updateProvider(CS,</span>
+00970 <span class="comment">// (*itClassifiersAndVirtualActionIntensityORIGIN).second.MotivationIntensity);</span>
+00971 <span class="comment">// spreadMotivationReckon(lastActionName);</span>
+00972 <span class="comment">// // If the CS doesn't receive motivation any more, we remove it.</span>
+00973 <span class="comment">// double energy = (*itClassifiersAndVirtualActionIntensity).second.getSumValue();</span>
+00974 <span class="comment">// if (energy &lt;= 0)</span>
+00975 <span class="comment">// {</span>
+00976 <span class="comment">// _ClassifiersAndVirtualActionIntensity.erase(lastActionName);</span>
+00977 <span class="comment">// }</span>
+00978 <span class="comment">// }</span>
+00979 <span class="comment">// }</span>
+00980 <span class="comment">//}</span>
+00981
+<a name="l00982"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentd1">00982</a> <span class="keywordtype">void</span> CMHiCSagent::motivationCompute()
+00983 {
+00984 <a class="code" href="a05371.html#a101">TAction</a> behav;
+00985
+00986 std::map&lt;TMotivation, CMotivationEnergy&gt;::iterator itClassifiersAndMotivationIntensity;
+00987
+00988 <span class="comment">// On parcour toutes les motivations.</span>
+00989 <span class="keywordflow">for</span> (itClassifiersAndMotivationIntensity = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.begin();
+00990 itClassifiersAndMotivationIntensity != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.end();
+00991 itClassifiersAndMotivationIntensity++)
+00992 {
+00993 <a class="code" href="a02938.html">CMotivationEnergy</a>* pCSselection = &amp;((*itClassifiersAndMotivationIntensity).second);
+00994 <a class="code" href="a05371.html#a99">TMotivation</a> selectionName = (*itClassifiersAndMotivationIntensity).first;
+00995 <span class="keywordtype">double</span> energy = pCSselection-&gt;<a class="code" href="a02938.html#NLAINIMAT_1_1CMotivationEnergya6">getSumValue</a>();
+00996 <span class="comment">// Si une motivation est active (une energie &gt;0 ) on actionne ses règles.</span>
+00997 <span class="keywordflow">if</span> (energy &gt; 0)
+00998 {
+00999 <span class="comment">// On fait calculer le CS</span>
+01000 std::multimap&lt;CClassifierPriority, std::pair&lt;TClassifierNumber, TTargetId&gt; &gt; mapActivableCS;
+01001 std::multimap&lt;CClassifierPriority, std::pair&lt;TClassifierNumber, TTargetId&gt; &gt;::iterator itMapActivableCS;
+01002
+01003 <span class="comment">// On fait la liste des classeurs activables.</span>
+01004 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr5">_pMHiCSbase</a>-&gt;<a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea13">selectBehavior</a>(selectionName,<a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr8">_pSensorsValues</a>, mapActivableCS);
+01005
+01006 <span class="comment">// Pour chaque classeur activable, on transmet la valeur de motivation à l'action selectionnée.</span>
+01007 <span class="keywordflow">for</span> (itMapActivableCS = mapActivableCS.begin(); itMapActivableCS != mapActivableCS.end(); itMapActivableCS++)
+01008 {
+01009 <a class="code" href="a05371.html#a7">TClassifierNumber</a> selectedClassifierNumber = (*itMapActivableCS).second.first;
+01010 <a class="code" href="a05371.html#a13">TTargetId</a> currentTargetId = (*itMapActivableCS).second.second;
+01011 behav = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr5">_pMHiCSbase</a>-&gt;<a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea5">getActionPart</a>(selectionName, selectedClassifierNumber);
+01012
+01013 (*_pInfoClassifierActivity)[selectionName][selectedClassifierNumber].IsActivable = <span class="keyword">true</span>;
+01014
+01015 <span class="comment">// We add the current motivation energy to the selected action.</span>
+01016 <span class="keywordflow">if</span> (behav != <a class="code" href="a05371.html#a101a56">Action_DoNothing</a>)
+01017 {
+01018 <span class="comment">// std::map&lt;TTargetId, std::map&lt;TAction, CMotivationEnergy&gt; &gt;::const_iterator itOldActionsExecutionIntensityByTarget = (*_pOldActionsExecutionIntensityByTarget).find(currentTargetId);</span>
+01019 <span class="comment">// if (itOldActionsExecutionIntensityByTarget != (*_pOldActionsExecutionIntensityByTarget).end() )</span>
+01020 <span class="comment">// {</span>
+01021 <span class="comment">// std::map&lt;TAction, CMotivationEnergy&gt;::const_iterator itIntensityByTarget = (*itOldActionsExecutionIntensityByTarget).second.find(behav);</span>
+01022 <span class="comment">// if (itIntensityByTarget != (*itOldActionsExecutionIntensityByTarget).second.end())</span>
+01023 <span class="comment">// {</span>
+01024 <span class="comment">// (*_pActionsExecutionIntensityByTarget)[currentTargetId][behav].setWasPreviouslyActived(true);</span>
+01025 <span class="comment">// }</span>
+01026 <span class="comment">// }</span>
+01027 (*_pActionsExecutionIntensityByTarget)[currentTargetId][behav].setMHiCSagent(<span class="keyword">this</span>);
+01028 (*_pActionsExecutionIntensityByTarget)[currentTargetId][behav].addProvider(selectionName, selectedClassifierNumber);
+01029 }
+01030 }
+01031 }
+01032 }
+01033 }
+01034
+01035
+01036
+01037 <span class="comment">//void CMHiCSagent::virtualActionCompute()</span>
+01038 <span class="comment">//{</span>
+01039 <span class="comment">// /*</span>
+01040 <span class="comment">// Je sélectionne par roulette weel l'action virtuel que je vais gérer</span>
+01041 <span class="comment">// Je met à jour l'énergie du vainqueur</span>
+01042 <span class="comment">// */</span>
+01043 <span class="comment">// double somme = 0;</span>
+01044 <span class="comment">// typedef std::map&lt;TAction, CMotivationEnergy&gt;::iterator TitNameAndVirtualAction;</span>
+01045 <span class="comment">// std::map&lt;double, TitNameAndVirtualAction &gt; mapCSweel;</span>
+01046 <span class="comment">// std::map&lt;TAction, CMotivationEnergy&gt;::iterator itClassifiersAndVirtualActionIntensity;</span>
+01047 <span class="comment">// // On calcule la somme</span>
+01048 <span class="comment">// for (itClassifiersAndVirtualActionIntensity = _ClassifiersAndVirtualActionIntensity.begin();</span>
+01049 <span class="comment">// itClassifiersAndVirtualActionIntensity != _ClassifiersAndVirtualActionIntensity.end();</span>
+01050 <span class="comment">// itClassifiersAndVirtualActionIntensity++)</span>
+01051 <span class="comment">// {</span>
+01052 <span class="comment">// CMotivationEnergy* pCMotivationEnergy = &amp;((*itClassifiersAndVirtualActionIntensity).second);</span>
+01053 <span class="comment">// double energy = pCMotivationEnergy-&gt;getSumValue();</span>
+01054 <span class="comment">// if (energy &gt; 0)</span>
+01055 <span class="comment">// {</span>
+01056 <span class="comment">// somme += energy;</span>
+01057 <span class="comment">// mapCSweel[somme] = itClassifiersAndVirtualActionIntensity;</span>
+01058 <span class="comment">// }</span>
+01059 <span class="comment">// }</span>
+01060 <span class="comment">// if (somme&gt;0)</span>
+01061 <span class="comment">// {</span>
+01062 <span class="comment">// // on selectionne le classeur;</span>
+01063 <span class="comment">// double randomeNumber = (rand()%(int(somme*100)))/100.0;</span>
+01064 <span class="comment">// std::map&lt;double, TitNameAndVirtualAction&gt;::iterator itMapCSweel = mapCSweel.upper_bound(randomeNumber);</span>
+01065 <span class="comment">// CMotivationEnergy* pCSselection = &amp;((*((*itMapCSweel).second)).second);</span>
+01066 <span class="comment">// TAction selectionName = (*((*itMapCSweel).second)).first;</span>
+01067 <span class="comment">//</span>
+01068 <span class="comment">// // Get the target Id for this Virtual Action</span>
+01069 <span class="comment">// std::map&lt;TAction, TTargetId&gt;::const_iterator itIdByActions = _IdByActions.find(selectionName);</span>
+01070 <span class="comment">// nlassert (itIdByActions != _IdByActions.end());</span>
+01071 <span class="comment">// TTargetId myTarget = (*itIdByActions).second;</span>
+01072 <span class="comment">//</span>
+01073 <span class="comment">// // On fait calculer le CS</span>
+01074 <span class="comment">// TClassifierNumber lastClassifierNumber = _ClassifiersAndVirtualActionIntensity[selectionName].ClassifierNumber;</span>
+01075 <span class="comment">// TClassifierNumber selectedClassifierNumber = lastClassifierNumber;</span>
+01076 <span class="comment">// TTargetId currentTargetId = myTarget;</span>
+01077 <span class="comment">// double lastSelectionMaxPriority = _ClassifiersAndVirtualActionIntensity[selectionName].LastSelectionMaxPriority;</span>
+01078 <span class="comment">// std::multimap&lt;double, std::pair&lt;TClassifierNumber, TTargetId&gt; &gt; mapActivableCS;</span>
+01079 <span class="comment">// </span>
+01080 <span class="comment">// _pMHiCSbase-&gt;selectBehavior(selectionName,_pSensorsValues, mapActivableCS, currentTargetId);</span>
+01081 <span class="comment">//</span>
+01083 <span class="comment"></span><span class="comment">// {</span>
+01084 <span class="comment">// // ***G*** Ici on décide de rien faire si on sait pas quoi faire. En fait il faudrait créer un règle.</span>
+01085 <span class="comment">// _ClassifiersAndVirtualActionIntensity[selectionName].ClassifierNumber = selectedClassifierNumber;</span>
+01086 <span class="comment">// _ClassifiersAndVirtualActionIntensity[selectionName].TargetId = currentTargetId;</span>
+01087 <span class="comment">// _ClassifiersAndVirtualActionIntensity[selectionName].LastSelectionMaxPriority = lastSelectionMaxPriority;</span>
+01088 <span class="comment">// return; </span>
+01089 <span class="comment">// }</span>
+01090 <span class="comment">//*/ </span>
+01091 <span class="comment">// TAction behav = _pMHiCSbase-&gt;getActionPart(selectionName, selectedClassifierNumber);</span>
+01092 <span class="comment">//</span>
+01093 <span class="comment">// // We check the last action selected by the current motivation to remove the motivation influence on this action.</span>
+01094 <span class="comment">// if (lastClassifierNumber &gt;= 0)</span>
+01095 <span class="comment">// {</span>
+01096 <span class="comment">// TAction lastActionName = _pMHiCSbase-&gt;getActionPart(selectionName, lastClassifierNumber);</span>
+01097 <span class="comment">//</span>
+01098 <span class="comment">// // We check if we have selected the same behavior.</span>
+01099 <span class="comment">// if (lastActionName != behav)</span>
+01100 <span class="comment">// {</span>
+01101 <span class="comment">// if (_pMHiCSbase-&gt;isAnAction(lastActionName))</span>
+01102 <span class="comment">// {</span>
+01103 <span class="comment">// _ActionsExecutionIntensity[lastActionName].removeProvider(selectionName);</span>
+01104 <span class="comment">// // If the action doesn't receive motivation any more, we remove it.</span>
+01105 <span class="comment">// double energy = _ActionsExecutionIntensity[lastActionName].getSumValue();</span>
+01106 <span class="comment">// if (energy &lt;= 0)</span>
+01107 <span class="comment">// {</span>
+01108 <span class="comment">// _ActionsExecutionIntensity.erase(lastActionName);</span>
+01109 <span class="comment">// _IdByActions.erase(lastActionName);</span>
+01110 <span class="comment">// // we check if it was the current action</span>
+01111 <span class="comment">// if ((*_ItCurrentAction).first == lastActionName)</span>
+01112 <span class="comment">// {</span>
+01113 <span class="comment">// _ItCurrentAction = _IdByActions.find(Action_DoNothing);</span>
+01114 <span class="comment">// nlassert (_ItCurrentAction != _IdByActions.end());</span>
+01115 <span class="comment">// }</span>
+01116 <span class="comment">// }</span>
+01117 <span class="comment">// }</span>
+01118 <span class="comment">// else</span>
+01119 <span class="comment">// {</span>
+01120 <span class="comment">// _ClassifiersAndVirtualActionIntensity[lastActionName].removeProvider(selectionName);</span>
+01121 <span class="comment">// spreadMotivationReckon(lastActionName);</span>
+01122 <span class="comment">// // If the CS doesn't receive motivation any more, we remove it.</span>
+01123 <span class="comment">// double energy = _ClassifiersAndVirtualActionIntensity[lastActionName].getSumValue();</span>
+01124 <span class="comment">// if (energy &lt;= 0)</span>
+01125 <span class="comment">// {</span>
+01126 <span class="comment">// _ClassifiersAndVirtualActionIntensity.erase(lastActionName);</span>
+01127 <span class="comment">// }</span>
+01128 <span class="comment">// }</span>
+01129 <span class="comment">// }</span>
+01130 <span class="comment">// }</span>
+01131 <span class="comment">//</span>
+01132 <span class="comment">// // We store the number of the new classifier actived by this motivation.</span>
+01133 <span class="comment">// _ClassifiersAndVirtualActionIntensity[selectionName].ClassifierNumber = selectedClassifierNumber;</span>
+01134 <span class="comment">// _ClassifiersAndVirtualActionIntensity[selectionName].TargetId = currentTargetId;</span>
+01135 <span class="comment">// _ClassifiersAndVirtualActionIntensity[selectionName].LastSelectionMaxPriority = lastSelectionMaxPriority;</span>
+01136 <span class="comment">// </span>
+01137 <span class="comment">// if (selectedClassifierNumber &gt;= 0)</span>
+01138 <span class="comment">// {</span>
+01139 <span class="comment">// // We add the current motivation energy to the selected action.</span>
+01140 <span class="comment">// if (_pMHiCSbase-&gt;isAnAction(behav))</span>
+01141 <span class="comment">// {</span>
+01142 <span class="comment">// _ActionsExecutionIntensity[behav].addProvider(selectionName, pCSselection-&gt;MotivationIntensity);</span>
+01143 <span class="comment">// }</span>
+01144 <span class="comment">// else</span>
+01145 <span class="comment">// {</span>
+01146 <span class="comment">// // Else it must be a virtual action (common CS)</span>
+01147 <span class="comment">// _ClassifiersAndVirtualActionIntensity[behav].addProvider(selectionName, pCSselection-&gt;MotivationIntensity);</span>
+01148 <span class="comment">// spreadMotivationReckon(behav);</span>
+01149 <span class="comment">// }</span>
+01150 <span class="comment">//</span>
+01151 <span class="comment">// // We set the Id of this action.</span>
+01152 <span class="comment">// // For moment there's no test to see if it is the same target or not. In the futur it can be usefull to make this test</span>
+01153 <span class="comment">// // to avoid unwilled target switch.</span>
+01154 <span class="comment">// _IdByActions[behav] = currentTargetId;</span>
+01155 <span class="comment">// }</span>
+01156 <span class="comment">// }</span>
+01157 <span class="comment">//}</span>
+01158
+<a name="l01159"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta7">01159</a> <span class="keywordtype">void</span> CMHiCSagent::run()
+01160 {
+01161 std::map&lt;TTargetId, std::map&lt;TAction, CMotivationEnergy&gt; &gt; *bibu = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr6">_pOldActionsExecutionIntensityByTarget</a>;
+01162 _pOldActionsExecutionIntensityByTarget = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a>;
+01163 _pActionsExecutionIntensityByTarget = bibu;
+01164 _pActionsExecutionIntensityByTarget-&gt;clear();
+01165
+01166 std::map&lt;TMotivation, std::map&lt;TClassifierNumber, CClassifierActivityInfo&gt; &gt; *biba = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr7">_pOldInfoClassifierActivity</a>;
+01167 _pOldInfoClassifierActivity = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr4">_pInfoClassifierActivity</a>;
+01168 _pInfoClassifierActivity = biba;
+01169 _pInfoClassifierActivity-&gt;clear();
+01170
+01171 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentd1">motivationCompute</a>();
+01172 <span class="comment">// virtualActionCompute();</span>
+01173 }
+01174
+01175
+<a name="l01176"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta12">01176</a> <span class="keywordtype">void</span> CMHiCSagent::setSensors(<a class="code" href="a02422.html">CCSPerception</a>* psensorMap)
+01177 {
+01178 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr8">_pSensorsValues</a> = psensorMap;
+01179 }
+01180
+<a name="l01181"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta9">01181</a> <span class="keywordtype">void</span> CMHiCSagent::setLearning(<span class="keywordtype">bool</span> active)
+01182 {
+01183 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr1">_Learning</a> = active;
+01184 }
+01185
+01186 <span class="comment">//void CMHiCSagent::learningComputationMotivationDecrease(TMotivation motivationName)</span>
+01187 <span class="comment">//{</span>
+01188 <span class="comment">// // On calcule le temps en seconde depuis la dernière récompense</span>
+01189 <span class="comment">// uint32 previousLastTime = 0;</span>
+01190 <span class="comment">// uint32 newTime = NLMISC::CTime::getSecondsSince1970();</span>
+01191 <span class="comment">//</span>
+01192 <span class="comment">// std::map&lt;TMotivation, uint32&gt;::const_iterator itTimeOfLastMotivationValueDecrease = _TimeOfLastMotivationValueDecrease.find(motivationName);</span>
+01193 <span class="comment">// if (itTimeOfLastMotivationValueDecrease != _TimeOfLastMotivationValueDecrease.end())</span>
+01194 <span class="comment">// {</span>
+01195 <span class="comment">// previousLastTime = (*itTimeOfLastMotivationValueDecrease).second;</span>
+01196 <span class="comment">// }</span>
+01197 <span class="comment">//</span>
+01198 <span class="comment">// _TimeOfLastMotivationValueDecrease[motivationName] = newTime;</span>
+01199 <span class="comment">// TClassifierPriority diffTime = newTime - previousLastTime;</span>
+01200 <span class="comment">// nlassert (diffTime &gt; 0);</span>
+01201 <span class="comment">//</span>
+01202 <span class="comment">// // Pour tous les classeurs actifs de la motivation, je met à jour la fitness avec cette nouvelle valeur de temps (et je met à jour le temps).</span>
+01203 <span class="comment">// std::multimap&lt;TMotivation, std::pair &lt;TClassifierNumber, uint32&gt; &gt;::iterator itActiveClassifiersByMotivation = _ActiveClassifiersByMotivation.find(motivationName);</span>
+01204 <span class="comment">// if (itActiveClassifiersByMotivation != _ActiveClassifiersByMotivation.end() )</span>
+01205 <span class="comment">// {</span>
+01206 <span class="comment">// uint i;</span>
+01207 <span class="comment">// for (i = 0; i &lt; _ActiveClassifiersByMotivation.count(motivationName); i++ )</span>
+01208 <span class="comment">// {</span>
+01209 <span class="comment">// TClassifierNumber leNumeroDuClasseur = (*itActiveClassifiersByMotivation).second.first;</span>
+01210 <span class="comment">// _ActiveClassifiersByMotivation.insert(std::make_pair(motivationName, std::make_pair(leNumeroDuClasseur, newTime)));</span>
+01211 <span class="comment">//</span>
+01212 <span class="comment">// //***G*** TODO : Faire qqchose avec leNumeroDuClasseur</span>
+01213 <span class="comment">// _pMHiCSbase-&gt;learningUpdatePriorityValue(motivationName, leNumeroDuClasseur, diffTime);</span>
+01214 <span class="comment">// }</span>
+01215 <span class="comment">// }</span>
+01216 <span class="comment">//}</span>
+01217
+01218
+<a name="l01219"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentd0">01219</a> <span class="keywordtype">void</span> CMHiCSagent::learningComputation()
+01220 {
+01221 <span class="comment">/*</span>
+01222 <span class="comment"> * Le but de l'apprentissage par ajustement des valeurs de priorité :</span>
+01223 <span class="comment"> * La valeur de priorité est utilisé pour choisir un classeur lorsque plusieurs classeurs sont activable simultanement</span>
+01224 <span class="comment"> * et partagent une même ressource d'action.</span>
+01225 <span class="comment"> * On veut la faire évoluer afin que dans une situation donnée, c'est le classeur le plus apte à satisfaire la motivation </span>
+01226 <span class="comment"> * qui soit sélectionné.</span>
+01227 <span class="comment"> * Celon le principe de bucket brigade, un classeur qui mène à satisfaire une motivation est un bon classeur.</span>
+01228 <span class="comment"> * Ensuite un classeur qui a défaut de satisfaire la motivation mène à un classeur pouvant la satisfaire est bon mais un peut moins, etc.</span>
+01229 <span class="comment"> */</span>
+01230
+01231
+01232 <span class="comment">// std::map&lt;TMotivation, std::set&lt;TClassifierNumber&gt; &gt; oldClassifierByMotivation; // Liste des classeurs actifs au pas précédent.</span>
+01233 <span class="comment">// std::map&lt;TMotivation, std::set&lt;TClassifierNumber&gt; &gt; classifierByMotivation; // Liste des classeurs activés</span>
+01234
+01235 <span class="comment">// On note les descentes de motivations</span>
+01236 <a class="code" href="a04558.html#a11">uint32</a> newTime = <a class="code" href="a02142.html#NLMISC_1_1CTimee2">NLMISC::CTime::getSecondsSince1970</a>();
+01237 std::set&lt;TMotivation&gt; decreasingMotivations;
+01238 std::map&lt;TMotivation, CMotivationEnergy&gt;::iterator itOldClassifiersAndMotivationIntensity, itClassifiersAndMotivationIntensity;
+01239 <span class="keywordflow">for</span>(itOldClassifiersAndMotivationIntensity = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr2">_OldClassifiersAndMotivationIntensity</a>.begin();
+01240 itOldClassifiersAndMotivationIntensity != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr2">_OldClassifiersAndMotivationIntensity</a>.end();
+01241 itOldClassifiersAndMotivationIntensity++)
+01242 {
+01243 <a class="code" href="a05371.html#a99">TMotivation</a> motivationName = (*itOldClassifiersAndMotivationIntensity).first;
+01244 <span class="keywordtype">double</span> oldMV = (*itOldClassifiersAndMotivationIntensity).second.getMotivationValue(motivationName);
+01245 itClassifiersAndMotivationIntensity = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.find(motivationName);
+01246 <a class="code" href="a04199.html#a6">nlassert</a>(itClassifiersAndMotivationIntensity != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>.end());
+01247 <span class="keywordtype">double</span> newMV = (*itClassifiersAndMotivationIntensity).second.getMotivationValue(motivationName);
+01248 <span class="keywordflow">if</span> (newMV &lt; oldMV)
+01249 {
+01250 decreasingMotivations.insert(motivationName);
+01251 }
+01252 }
+01253
+01254 <span class="comment">// // On établit la liste des classeurs utilisés précédemment</span>
+01255 <span class="comment">// std::map&lt;TMotivation, std::set&lt;TClassifierNumber&gt; &gt;::iterator itOldClassifierByMotivation;</span>
+01256 <span class="comment">// std::map&lt;TTargetId, std::map&lt;TAction, CMotivationEnergy&gt; &gt;::iterator itOldActionsExecutionIntensityByTarget;</span>
+01257 <span class="comment">// std::map&lt;TAction, CMotivationEnergy&gt;::iterator itOldActionsExecutionIntensity;</span>
+01258 <span class="comment">// for(itOldActionsExecutionIntensityByTarget = _pOldActionsExecutionIntensityByTarget-&gt;begin();</span>
+01259 <span class="comment">// itOldActionsExecutionIntensityByTarget != _pOldActionsExecutionIntensityByTarget-&gt;end();</span>
+01260 <span class="comment">// itOldActionsExecutionIntensityByTarget++)</span>
+01261 <span class="comment">// {</span>
+01262 <span class="comment">// for(itOldActionsExecutionIntensity = (*itOldActionsExecutionIntensityByTarget).second.begin();</span>
+01263 <span class="comment">// itOldActionsExecutionIntensity != (*itOldActionsExecutionIntensityByTarget).second.end();</span>
+01264 <span class="comment">// itOldActionsExecutionIntensity++)</span>
+01265 <span class="comment">// {</span>
+01266 <span class="comment">// const std::map&lt;TMotivation, std::set&lt;TClassifierNumber&gt; &gt;* provounet = (*itOldActionsExecutionIntensity).second.getProviders();</span>
+01267 <span class="comment">// std::map&lt;TMotivation, std::set&lt;TClassifierNumber&gt; &gt;::const_iterator itProvounet;</span>
+01268 <span class="comment">// for(itProvounet = provounet-&gt;begin();</span>
+01269 <span class="comment">// itProvounet != provounet-&gt;end();</span>
+01270 <span class="comment">// itProvounet++)</span>
+01271 <span class="comment">// {</span>
+01272 <span class="comment">// TMotivation motivationName = (*itProvounet).first;</span>
+01273 <span class="comment">// std::set&lt;TClassifierNumber&gt;::const_iterator itClassifierNumber;</span>
+01274 <span class="comment">// for (itClassifierNumber = (*itProvounet).second.begin(); itClassifierNumber != (*itProvounet).second.end(); itClassifierNumber++)</span>
+01275 <span class="comment">// {</span>
+01276 <span class="comment">// TClassifierNumber classifierNumber = (*itClassifierNumber);</span>
+01277 <span class="comment">// // On établit une liste des classeurs ayant été actifs.</span>
+01278 <span class="comment">// oldClassifierByMotivation[motivationName].insert(classifierNumber);</span>
+01279 <span class="comment">// }</span>
+01280 <span class="comment">// }</span>
+01281 <span class="comment">// }</span>
+01282 <span class="comment">// }</span>
+01283
+01284 <span class="comment">// On remet à zero les compteurs de temps pour les actions qui on satisfait une motivation</span>
+01285 std::set&lt;TMotivation&gt;::iterator itDecreasingMotivations;
+01286 <span class="keywordflow">for</span> (itDecreasingMotivations = decreasingMotivations.begin(); itDecreasingMotivations != decreasingMotivations.end(); itDecreasingMotivations++)
+01287 {
+01288 <a class="code" href="a05371.html#a99">TMotivation</a> motivationName = (*itDecreasingMotivations);
+01289 std::map&lt;TMotivation, std::map&lt;TClassifierNumber, CTemporaryPriority&gt; &gt;::iterator itTemporaryPriority = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr9">_TemporaryPriority</a>.find(motivationName);
+01290 <span class="keywordflow">if</span> (itTemporaryPriority != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr9">_TemporaryPriority</a>.end())
+01291 {
+01292 std::map&lt;TClassifierNumber, CTemporaryPriority&gt;::iterator itPrioByCl;
+01293 <span class="keywordflow">for</span> (itPrioByCl = (*itTemporaryPriority).second.begin(); itPrioByCl != (*itTemporaryPriority).second.end(); itPrioByCl++ )
+01294 {
+01295 <span class="comment">// Si le temps a été fixé</span>
+01296 <span class="comment">// bool aUnFixedStartTime = (*itPrioByCl).second.FixedStartTime;</span>
+01297 <span class="comment">// if (aUnFixedStartTime)</span>
+01298 <span class="comment">// {</span>
+01299 <a class="code" href="a04558.html#a11">uint32</a> startTime = (*itPrioByCl).second.StartTime;
+01300 <span class="keywordflow">if</span> (startTime &gt; newTime)
+01301 {
+01302 newTime = startTime;
+01303 }
+01304 <a class="code" href="a04558.html#a11">uint32</a> timeToSatisfaction = newTime - startTime;
+01305 <a class="code" href="a05371.html#a7">TClassifierNumber</a> classifierNumber = (*itPrioByCl).first;
+01306 <span class="comment">// On met à jour la fitness des classeurs ayant été activés.</span>
+01307 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr5">_pMHiCSbase</a>-&gt;<a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea10">learningUpdatePriorityValueTimeToSuccess</a>(motivationName, classifierNumber, timeToSatisfaction);
+01308 <span class="comment">// }</span>
+01309 }
+01310 }
+01311 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr9">_TemporaryPriority</a>.erase(motivationName);
+01312 }
+01313
+01314 <span class="comment">// On établit la liste des classeurs nouveaux utilisés à ce pas ci</span>
+01315 std::map&lt;TTargetId, std::map&lt;TAction, CMotivationEnergy&gt; &gt;::iterator itActionsExecutionIntensityByTarget;
+01316 std::map&lt;TAction, CMotivationEnergy&gt;::iterator itActionsExecutionIntensity;
+01317 <span class="keywordflow">for</span>(itActionsExecutionIntensityByTarget = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a>-&gt;begin();
+01318 itActionsExecutionIntensityByTarget != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a>-&gt;end();
+01319 itActionsExecutionIntensityByTarget++)
+01320 {
+01321 <span class="keywordflow">for</span>(itActionsExecutionIntensity = (*itActionsExecutionIntensityByTarget).second.begin();
+01322 itActionsExecutionIntensity != (*itActionsExecutionIntensityByTarget).second.end();
+01323 itActionsExecutionIntensity++)
+01324 {
+01325 <span class="keyword">const</span> std::map&lt;TMotivation, std::set&lt;TClassifierNumber&gt; &gt;* provounet = (*itActionsExecutionIntensity).second.getProviders();
+01326 std::map&lt;TMotivation, std::set&lt;TClassifierNumber&gt; &gt;::const_iterator itProvounet;
+01327 <span class="keywordflow">for</span>(itProvounet = provounet-&gt;begin();
+01328 itProvounet != provounet-&gt;end();
+01329 itProvounet++)
+01330 {
+01331 <a class="code" href="a05371.html#a99">TMotivation</a> motivationName = (*itProvounet).first;
+01332 std::set&lt;TClassifierNumber&gt;::const_iterator itClassifierNumber;
+01333 <span class="keywordflow">for</span> (itClassifierNumber = (*itProvounet).second.begin(); itClassifierNumber != (*itProvounet).second.end(); itClassifierNumber++)
+01334 {
+01335 <a class="code" href="a05371.html#a7">TClassifierNumber</a> classifierNumber = (*itClassifierNumber);
+01336 <span class="comment">// itOldClassifierByMotivation = oldClassifierByMotivation.find(motivationName);</span>
+01337 <span class="comment">// if (itOldClassifierByMotivation != oldClassifierByMotivation.end() )</span>
+01338 <span class="comment">// {</span>
+01339 <span class="comment">// ajout du classeur dans la liste des classeurs activés</span>
+01340 (*_pInfoClassifierActivity)[motivationName][classifierNumber].IsActive = <span class="keyword">true</span>;
+01341 <span class="comment">// classifierByMotivation[motivationName].insert(classifierNumber);</span>
+01342 <span class="comment">// }</span>
+01343 }
+01344 }
+01345 }
+01346 }
+01347
+01348 <span class="comment">// on établit la liste des classeurs qui étaient activables et qui ne le sont plus</span>
+01349 std::map&lt;TMotivation, std::map&lt;TClassifierNumber, CClassifierActivityInfo&gt; &gt;::iterator itOldInfoClassifierActivity;
+01350 std::map&lt;TMotivation, std::map&lt;TClassifierNumber, CClassifierActivityInfo&gt; &gt;::iterator itInfoClassifierActivity;
+01351 <span class="keywordflow">for</span>(itOldInfoClassifierActivity = (*_pOldInfoClassifierActivity).begin();
+01352 itOldInfoClassifierActivity != (*_pOldInfoClassifierActivity).end();
+01353 itOldInfoClassifierActivity++ )
+01354 {
+01355 <a class="code" href="a05371.html#a99">TMotivation</a> motivationName = (*itOldInfoClassifierActivity).first;
+01356 std::map&lt;TClassifierNumber, CClassifierActivityInfo&gt;::iterator itClassifiers, itClassifiersBis;
+01357 <span class="keywordflow">for</span> (itClassifiers = (*itOldInfoClassifierActivity).second.begin(); itClassifiers != (*itOldInfoClassifierActivity).second.end(); itClassifiers++)
+01358 {
+01359 <span class="comment">// std::set&lt;TClassifierNumber&gt;::iterator itClassifiersBisBis;</span>
+01360 <span class="comment">// bool isStillActivable = false;</span>
+01361 <a class="code" href="a05371.html#a7">TClassifierNumber</a> classifierNumber = (*itClassifiers).first;
+01362 <span class="keywordtype">bool</span> wasActive = (*itClassifiers).second.IsActive;
+01363 <span class="keywordtype">bool</span> isActive = (*_pInfoClassifierActivity)[motivationName][classifierNumber].IsActive;
+01364 <span class="keywordflow">if</span> (wasActive &amp;&amp; !isActive)
+01365 {
+01366 <span class="comment">// Le classeur vient de finir son activité, je calcule sa nouvelle priorité.</span>
+01367 <a class="code" href="a04558.html#a11">uint32</a> diffTime = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr9">_TemporaryPriority</a>[motivationName][classifierNumber].TemporaryClassifierPriorityTime;
+01368 <span class="keywordflow">if</span> (diffTime &gt;0)
+01369 {
+01370 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr5">_pMHiCSbase</a>-&gt;<a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbasea9">learningUpdatePriorityValueClassifierTime</a>(motivationName, classifierNumber, diffTime);
+01371 <span class="comment">// _TemporaryPriority[motivationName][classifierNumber].FixedStartTime = false;</span>
+01372 }
+01373 }
+01374
+01375 <span class="comment">// bool wasActivable = (*itClassifiers).second.IsActivable;</span>
+01376 <span class="comment">// if (wasActivable)</span>
+01377 <span class="comment">// {</span>
+01378 <span class="comment">// itInfoClassifierActivity = (*_pInfoClassifierActivity).find(motivationName);</span>
+01379 <span class="comment">// if (itInfoClassifierActivity != (*_pInfoClassifierActivity).end())</span>
+01380 <span class="comment">// {</span>
+01381 <span class="comment">// itClassifiersBis = (*itInfoClassifierActivity).second.find(classifierNumber);</span>
+01382 <span class="comment">// if ( itClassifiersBis != (*itInfoClassifierActivity).second.end() )</span>
+01383 <span class="comment">// {</span>
+01384 <span class="comment">// isStillActivable = true;</span>
+01385 <span class="comment">// }</span>
+01386 <span class="comment">// }</span>
+01387 <span class="comment">// if (isStillActivable)</span>
+01388 <span class="comment">// {</span>
+01389 <span class="comment">// // s'il est activable mais plus activé alors on met à jour son compteur de temps d'execution</span>
+01390 <span class="comment">// bool estActif = (*_pInfoClassifierActivity)[motivationName][classifierNumber].IsActive;</span>
+01400 <span class="comment"></span><span class="comment">// if (!estActif)</span>
+01401 <span class="comment">// {</span>
+01402 <span class="comment">// std::map&lt;TMotivation, std::set&lt;TClassifierNumber&gt; &gt;::iterator itOldClassifierByMotivation = oldClassifierByMotivation.find(motivationName);</span>
+01403 <span class="comment">// if (itOldClassifierByMotivation != oldClassifierByMotivation.end())</span>
+01404 <span class="comment">// {</span>
+01405 <span class="comment">// itClassifiersBisBis = (*itOldClassifierByMotivation).second.find(classifierNumber);</span>
+01406 <span class="comment">// if ( itClassifiersBisBis != (*itOldClassifierByMotivation).second.end() )</span>
+01407 <span class="comment">// {</span>
+01408 <span class="comment">// // Le classeur vient de finir son activité, je calcule sa nouvelle priorité.</span>
+01409 <span class="comment">// uint32 diffTime = _TemporaryPriority[motivationName][classifierNumber].TemporaryClassifierPriorityTime;</span>
+01410 <span class="comment">// if (diffTime &gt;0)</span>
+01411 <span class="comment">// {</span>
+01412 <span class="comment">// _pMHiCSbase-&gt;learningUpdatePriorityValueClassifierTime(motivationName, classifierNumber, diffTime);</span>
+01413 <span class="comment">// _TemporaryPriority[motivationName][classifierNumber].FixedStartTime = false;</span>
+01414 <span class="comment">// }</span>
+01415 <span class="comment">// }</span>
+01416 <span class="comment">// }</span>
+01417 <span class="comment">// }</span>
+01418 <span class="comment">// }</span>
+01419 <span class="comment">// else</span>
+01420 <span class="comment">// {</span>
+01421 <span class="comment">// // Dans tous les cas on met à jour son temps d'activation s'il a été activé par le passé.</span>
+01422 <span class="comment">// std::map&lt;TMotivation, std::map&lt;TClassifierNumber, CTemporaryPriority&gt; &gt;::iterator itTemporaryPriority = _TemporaryPriority.find(motivationName);</span>
+01423 <span class="comment">// if (itTemporaryPriority != _TemporaryPriority.end())</span>
+01424 <span class="comment">// {</span>
+01425 <span class="comment">// std::map&lt;TClassifierNumber, CTemporaryPriority&gt;::iterator itClassifiersTerce = (*itTemporaryPriority).second.find(classifierNumber);</span>
+01426 <span class="comment">// if (itClassifiersTerce != (*itTemporaryPriority).second.end() )</span>
+01427 <span class="comment">// {</span>
+01428 <span class="comment">// // Le classeur vient de finir son activité, je calcule sa nouvelle priorité.</span>
+01429 <span class="comment">// uint32 diffTime = _TemporaryPriority[motivationName][classifierNumber].TemporaryClassifierPriorityTime;</span>
+01430 <span class="comment">// if (diffTime &gt;0)</span>
+01431 <span class="comment">// {</span>
+01432 <span class="comment">// _pMHiCSbase-&gt;learningUpdatePriorityValueClassifierTime(motivationName, classifierNumber, diffTime);</span>
+01433 <span class="comment">// _TemporaryPriority[motivationName][classifierNumber].FixedStartTime = false;</span>
+01434 <span class="comment">// }</span>
+01435 <span class="comment">// }</span>
+01436 <span class="comment">// }</span>
+01437 <span class="comment">// </span>
+01438 <span class="comment">// // S'il n'était pas activé (avant de n'être plus activable), on le retire de la liste des éligibles au T2S</span>
+01451 <span class="comment"></span><span class="comment">// _TemporaryPriority[motivationName][classifierNumber].FixedStartTime = false;</span>
+01453 <span class="comment"></span><span class="comment">// }</span>
+01454 <span class="comment">// }</span>
+01455 }
+01456 }
+01457
+01458 std::map&lt;TClassifierNumber, CClassifierActivityInfo&gt;::iterator itUnChtitClassifierNumberInfo;
+01459 <span class="comment">// On regarde quelles sont les nouveaux classeurs activés</span>
+01460 <span class="keywordflow">for</span>(itInfoClassifierActivity = (*_pInfoClassifierActivity).begin();
+01461 itInfoClassifierActivity != (*_pInfoClassifierActivity).end();
+01462 itInfoClassifierActivity++)
+01463 {
+01464 <a class="code" href="a05371.html#a99">TMotivation</a> motivationName = (*itInfoClassifierActivity).first;
+01465
+01466 <span class="keywordflow">for</span>(itUnChtitClassifierNumberInfo = (*itInfoClassifierActivity).second.begin();
+01467 itUnChtitClassifierNumberInfo != (*itInfoClassifierActivity).second.end();
+01468 itUnChtitClassifierNumberInfo++)
+01469 {
+01470 <a class="code" href="a05371.html#a7">TClassifierNumber</a> leNumberDuClasseur = (*itUnChtitClassifierNumberInfo).first;
+01471 <span class="keywordtype">bool</span> wasActive = (*_pOldInfoClassifierActivity)[motivationName][leNumberDuClasseur].IsActive;
+01472 <span class="keywordtype">bool</span> isActive = (*itUnChtitClassifierNumberInfo).second.IsActive;
+01473 <span class="keywordflow">if</span> (isActive)
+01474 {
+01475 <span class="keywordflow">if</span> (!wasActive)
+01476 {
+01477 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr9">_TemporaryPriority</a>[motivationName][leNumberDuClasseur].StartTime = newTime;
+01478 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr9">_TemporaryPriority</a>[motivationName][leNumberDuClasseur].LastTime = newTime;
+01479 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr9">_TemporaryPriority</a>[motivationName][leNumberDuClasseur].FixedStartTime = <span class="keyword">true</span>;
+01480 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr9">_TemporaryPriority</a>[motivationName][leNumberDuClasseur].TemporaryClassifierPriorityTime = 0;
+01481 }
+01482 <span class="comment">// Je fais progresser le timer</span>
+01483 <a class="code" href="a04558.html#a11">uint32</a> lastTime = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr9">_TemporaryPriority</a>[motivationName][leNumberDuClasseur].LastTime;
+01484 <span class="keywordflow">if</span> (lastTime &gt; newTime)
+01485 {
+01486 newTime = lastTime;
+01487 }
+01488 <a class="code" href="a04558.html#a11">uint32</a> diffTime = newTime - lastTime;
+01489 _TemporaryPriority[motivationName][leNumberDuClasseur].LastTime = newTime;
+01490 _TemporaryPriority[motivationName][leNumberDuClasseur].TemporaryClassifierPriorityTime += diffTime;
+01491 }
+01492
+01493 <span class="comment">// if (isActive)</span>
+01494 <span class="comment">// {</span>
+01495 <span class="comment">// // Si l'action n'avait pas de startTime fixé, on lui en donne un.</span>
+01496 <span class="comment">// bool avaitUnFixedStartTime = false;</span>
+01497 <span class="comment">// std::map&lt;TMotivation, std::map&lt;TClassifierNumber, CTemporaryPriority&gt; &gt;::iterator itTemporaryPriority = _TemporaryPriority.find(motivationName);</span>
+01498 <span class="comment">// if (itTemporaryPriority != _TemporaryPriority.end() )</span>
+01499 <span class="comment">// {</span>
+01500 <span class="comment">// std::map&lt;TClassifierNumber, CTemporaryPriority&gt;::iterator itClassifierAndPrio = (*itTemporaryPriority).second.find(leNumberDuClasseur);</span>
+01501 <span class="comment">// if (itClassifierAndPrio != (*itTemporaryPriority).second.end() )</span>
+01502 <span class="comment">// {</span>
+01503 <span class="comment">// avaitUnFixedStartTime = (*itClassifierAndPrio).second.FixedStartTime;</span>
+01504 <span class="comment">// }</span>
+01505 <span class="comment">// }</span>
+01506 <span class="comment">// if (!avaitUnFixedStartTime)</span>
+01507 <span class="comment">// {</span>
+01508 <span class="comment">// _TemporaryPriority[motivationName][leNumberDuClasseur].StartTime = newTime;</span>
+01509 <span class="comment">// _TemporaryPriority[motivationName][leNumberDuClasseur].FixedStartTime = true;</span>
+01510 <span class="comment">// _TemporaryPriority[motivationName][leNumberDuClasseur].TemporaryClassifierPriorityTime = 0;</span>
+01511 <span class="comment">// }</span>
+01512 <span class="comment">// else</span>
+01513 <span class="comment">// {</span>
+01514 <span class="comment">// // Si elle avait un startime, on regarde si elle était active au tour précédent.</span>
+01515 <span class="comment">// bool etaitActifJusteAvant = false;</span>
+01516 <span class="comment">// std::map&lt;TMotivation, std::set&lt;TClassifierNumber&gt; &gt;::iterator itOldClassifierByMotivation = oldClassifierByMotivation.find(motivationName);</span>
+01517 <span class="comment">// if (itOldClassifierByMotivation != oldClassifierByMotivation.end())</span>
+01518 <span class="comment">// {</span>
+01519 <span class="comment">// std::set&lt;TClassifierNumber&gt;::iterator itClassifier = (*itOldClassifierByMotivation).second.find(leNumberDuClasseur);</span>
+01520 <span class="comment">// if (itClassifier != (*itOldClassifierByMotivation).second.end() )</span>
+01521 <span class="comment">// {</span>
+01522 <span class="comment">// etaitActifJusteAvant = true;</span>
+01523 <span class="comment">// }</span>
+01524 <span class="comment">// }</span>
+01525 <span class="comment">// if (!etaitActifJusteAvant)</span>
+01526 <span class="comment">// {</span>
+01527 <span class="comment">// _TemporaryPriority[motivationName][leNumberDuClasseur].LastTime = newTime;</span>
+01529 <span class="comment"></span><span class="comment">// }</span>
+01530 <span class="comment">// }</span>
+01531 <span class="comment">// </span>
+01532 <span class="comment">// // Je fais progresser le timer</span>
+01533 <span class="comment">// uint32 lastTime = _TemporaryPriority[motivationName][leNumberDuClasseur].LastTime;</span>
+01534 <span class="comment">// if (lastTime &gt; newTime)</span>
+01535 <span class="comment">// {</span>
+01536 <span class="comment">// newTime = lastTime;</span>
+01537 <span class="comment">// }</span>
+01538 <span class="comment">// uint32 diffTime = newTime - lastTime;</span>
+01539 <span class="comment">// _TemporaryPriority[motivationName][leNumberDuClasseur].LastTime = newTime;</span>
+01540 <span class="comment">// _TemporaryPriority[motivationName][leNumberDuClasseur].TemporaryClassifierPriorityTime += diffTime;</span>
+01541 <span class="comment">// }</span>
+01542
+01543 }
+01544 }
+01545 }
+01546
+01547
+<a name="l01548"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta8">01548</a> <span class="keyword">const</span> std::map&lt;TTargetId, std::map&lt;TAction, CMotivationEnergy&gt; &gt;* CMHiCSagent::selectBehavior()
+01549 {
+01550 <span class="comment">//We sort actions by priority</span>
+01551 <span class="keywordtype">double</span> priority;
+01552 <a class="code" href="a05371.html#a101">TAction</a> action;
+01553 <a class="code" href="a05371.html#a13">TTargetId</a> target;
+01554 std::multimap&lt;double, std::pair&lt;TTargetId,TAction&gt; &gt; actionsToRemove;
+01555
+01556 std::map&lt;TTargetId, std::map&lt;TAction, CMotivationEnergy&gt; &gt;::iterator itActionsExecutionIntensityByTarget;
+01557 std::map&lt;TAction, CMotivationEnergy&gt;::const_iterator itMotiveByAction;
+01558 <span class="keywordflow">for</span> (itActionsExecutionIntensityByTarget = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a>-&gt;begin();
+01559 itActionsExecutionIntensityByTarget != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a>-&gt;end();
+01560 itActionsExecutionIntensityByTarget++)
+01561 {
+01562 <span class="keywordflow">for</span> (itMotiveByAction = (*itActionsExecutionIntensityByTarget).second.begin();
+01563 itMotiveByAction != (*itActionsExecutionIntensityByTarget).second.end();
+01564 itMotiveByAction++)
+01565 {
+01566 priority = (*itMotiveByAction).second.getSumValue();
+01567 action = (*itMotiveByAction).first;
+01568 target = (*itActionsExecutionIntensityByTarget).first;
+01569
+01570 <span class="comment">// on rajoute du bruit sur les priorité afin d'avoir une diversité si des priorités sont proches</span>
+01571 <span class="comment">// double randomeNumber = ((rand()%5)*priority)/100;</span>
+01572 <span class="comment">// priority += randomeNumber;</span>
+01573
+01574 actionsToRemove.insert(std::make_pair(priority, std::make_pair(target,action)));
+01575 }
+01576 }
+01577
+01578 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr5">_pMHiCSbase</a>-&gt;<a class="code" href="a02929.html#NLAINIMAT_1_1CMHiCSbaseo0">pActionResources</a>-&gt;<a class="code" href="a02159.html#NLAINIMAT_1_1CActionResourcesa1">filterMyActions</a>(actionsToRemove);
+01579
+01580 std::multimap&lt;double, std::pair&lt;TTargetId,TAction&gt; &gt;::iterator itActionsToRemove;
+01581 <span class="keywordflow">for</span> (itActionsToRemove = actionsToRemove.begin();
+01582 itActionsToRemove != actionsToRemove.end();
+01583 itActionsToRemove++)
+01584 {
+01585 target = (*itActionsToRemove).second.first;
+01586 action = (*itActionsToRemove).second.second;
+01587 itActionsExecutionIntensityByTarget = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a>-&gt;find(target);
+01588 <a class="code" href="a04199.html#a6">nlassert</a> (itActionsExecutionIntensityByTarget != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a>-&gt;end());
+01589 itMotiveByAction = (*itActionsExecutionIntensityByTarget).second.find(action);
+01590 <a class="code" href="a04199.html#a6">nlassert</a> (itMotiveByAction != (*itActionsExecutionIntensityByTarget).second.end());
+01591 (*itActionsExecutionIntensityByTarget).second.erase(action);
+01592 <span class="keywordflow">if</span> ( (*itActionsExecutionIntensityByTarget).second.begin() == (*itActionsExecutionIntensityByTarget).second.end() )
+01593 {
+01594 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a>-&gt;erase(target);
+01595 }
+01596 }
+01597
+01598 <span class="keywordflow">if</span> (<a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr1">_Learning</a>)
+01599 {
+01600 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentd0">learningComputation</a>();
+01601
+01602 <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr2">_OldClassifiersAndMotivationIntensity</a> = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr0">_ClassifiersAndMotivationIntensity</a>;
+01603 }
+01604
+01605 <span class="keywordflow">return</span> <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr3">_pActionsExecutionIntensityByTarget</a>;
+01606 }
+01607
+<a name="l01608"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta6">01608</a> <a class="code" href="a04558.html#a11">uint32</a> CMHiCSagent::getTemporaryClassifierPriorityTime(TMotivation motivationName, <a class="code" href="a05371.html#a7">TClassifierNumber</a> classifierNumber)<span class="keyword"> const</span>
+01609 <span class="keyword"></span>{
+01610 std::map&lt;TMotivation, std::map&lt;TClassifierNumber, CTemporaryPriority&gt; &gt;::const_iterator itTemporaryPriority = <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr9">_TemporaryPriority</a>.find(motivationName);
+01611 <span class="keywordflow">if</span> (itTemporaryPriority == <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr9">_TemporaryPriority</a>.end())
+01612 {
+01613 <span class="keywordflow">return</span> 0;
+01614 }
+01615 std::map&lt;TClassifierNumber, CTemporaryPriority&gt;::const_iterator itIteratorBis = (*itTemporaryPriority).second.find(classifierNumber);
+01616 <span class="keywordflow">if</span> (itIteratorBis == (*itTemporaryPriority).second.end())
+01617 {
+01618 <span class="keywordflow">return</span> 0;
+01619 }
+01620 <a class="code" href="a04558.html#a11">uint32</a> bibureturn = (*itIteratorBis).second.TemporaryClassifierPriorityTime;
+01621 <span class="keywordflow">return</span> bibureturn;
+01622 }
+01623
+<a name="l01624"></a><a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagenta13">01624</a> <span class="keywordtype">bool</span> CMHiCSagent::wasClassifierPreviouslyActive (TMotivation motivationName, <a class="code" href="a05371.html#a7">TClassifierNumber</a> classifierNumber)<span class="keyword"> const</span>
+01625 <span class="keyword"></span>{
+01626 <span class="keywordtype">bool</span> wasPreviouslyActived = <span class="keyword">false</span>;
+01627
+01628 std::map&lt;TMotivation, std::map&lt;TClassifierNumber, CClassifierActivityInfo&gt; &gt;::const_iterator itOldInfoClassifierActivity;
+01629 itOldInfoClassifierActivity = (*_pOldInfoClassifierActivity).find(motivationName);
+01630 <span class="keywordflow">if</span> (itOldInfoClassifierActivity != <a class="code" href="a02926.html#NLAINIMAT_1_1CMHiCSagentr7">_pOldInfoClassifierActivity</a>-&gt;end())
+01631 {
+01632 std::map&lt;TClassifierNumber, CClassifierActivityInfo&gt;::const_iterator itClassifierInfo = (*itOldInfoClassifierActivity).second.find(classifierNumber);
+01633 <span class="keywordflow">if</span> (itClassifierInfo != (*itOldInfoClassifierActivity).second.end() )
+01634 {
+01635 wasPreviouslyActived = (*itClassifierInfo).second.IsActive;
+01636 }
+01637 }
+01638 <span class="keywordflow">return</span> wasPreviouslyActived;
+01639 }
+01640
+01641
+01643 <span class="comment">//void CMHiCSagent::behaviorTerminate(TAction action, TTargetId target, TBehaviorTerminate how_does_it_terminate)</span>
+01644 <span class="comment">//{</span>
+01645 <span class="comment">// (*_pActionsExecutionIntensityByTarget)[target].erase(action);</span>
+01646 <span class="comment">//}</span>
+01647
+01648 } <span class="comment">// NLAINIMAT</span>
+01649
+</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 06:28:45 2004 for NeL by
+<a href="http://www.doxygen.org/index.html">
+<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
+</a>1.3.6 </small></address>
+</body>
+</html>