diff options
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/fuzzyvar_8cpp-source.html | 474 |
1 files changed, 474 insertions, 0 deletions
diff --git a/docs/doxygen/nel/fuzzyvar_8cpp-source.html b/docs/doxygen/nel/fuzzyvar_8cpp-source.html new file mode 100644 index 00000000..6462c859 --- /dev/null +++ b/docs/doxygen/nel/fuzzyvar_8cpp-source.html @@ -0,0 +1,474 @@ +<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<HTML> +<HEAD> + <TITLE>nevrax.org : docs</TITLE> + <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css"> + <link href="doxygen.css" rel="stylesheet" type="text/css"> +</HEAD> +<BODY MARGINHEIGHT="0" MARGINWIDTH="0"> + +<!-- uplinks --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR> +</TABLE> + +<!-- main table --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + + <!------ Begin Box ------> + <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black> + <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF> + <TABLE cellspacing=0 cellpadding=1 border=0> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr> + </TABLE> + </TD></TR></TABLE></TD></TR></TABLE> + <!------ End Box ------> + + </TD> + <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + +<!-- title --> +<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td> +<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A> +</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT=""> +</td></tr></table> + + +<!-- block --> +<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD> + <TD><B>Documentation</B></TD> + <TD ALIGN=RIGHT> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center> +<hr><h1>fuzzyvar.cpp</h1><a href="fuzzyvar_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00007 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font> +00008 <font class="comment"> *</font> +00009 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00013 <font class="comment"> * any later version.</font> +00014 <font class="comment"></font> +00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00018 <font class="comment"> * General Public License for more details.</font> +00019 <font class="comment"></font> +00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00023 <font class="comment"> * MA 02111-1307, USA.</font> +00024 <font class="comment"> */</font> +00025 +00026 <font class="preprocessor">#include "<a class="code" href="fuzzyvar_8h.html">nel/ai/fuzzy/fuzzyvar.h</a>"</font> +00027 <font class="preprocessor">#include "<a class="code" href="compilateur_8h.html">nel/ai/script/compilateur.h</a>"</font> +00028 <font class="preprocessor">#include "<a class="code" href="constraint_8h.html">nel/ai/script/constraint.h</a>"</font> +00029 <font class="preprocessor">#include "<a class="code" href="type__def_8h.html">nel/ai/script/type_def.h</a>"</font> +00030 <font class="preprocessor">#include "<a class="code" href="agent_8h.html">nel/ai/agent/agent.h</a>"</font> +00031 <font class="preprocessor">#include "<a class="code" href="agent__digital_8h.html">nel/ai/agent/agent_digital.h</a>"</font> +00032 <font class="preprocessor">#include "<a class="code" href="fuzzycond_8h.html">nel/ai/fuzzy/fuzzycond.h</a>"</font> +00033 +00034 <font class="keyword">namespace </font>NLAIFUZZY +00035 { +00036 <font class="keyword">using</font> <font class="keyword">namespace </font>NLAIAGENT; +00037 +<a name="l00038"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a0">00038</a> CFuzzyVar::CFuzzyVar(<font class="keyword">const</font> <a class="code" href="classNLAIAGENT_1_1IVarName.html">NLAIAGENT::IVarName</a> &name, <font class="keywordtype">double</font> <a class="code" href="bit__set_8cpp.html#a0">min</a>, <font class="keywordtype">double</font> max, <a class="code" href="classNLAIAGENT_1_1IObjetOp.html">NLAIAGENT::IObjetOp</a> *value) : IBaseVar(name) +00039 { +00040 <font class="keywordflow">if</font> ( value ) +00041 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> = ((<a class="code" href="classNLAIAGENT_1_1INombre.html">NLAIAGENT::INombre<double></a> *)value)->getValue(); +00042 <font class="keywordflow">else</font> +00043 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> = 0; +00044 +00045 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o1">_Min</a> = <a class="code" href="bit__set_8cpp.html#a0">min</a>; +00046 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o2">_Max</a> = max; +00047 } +00048 +<a name="l00049"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a1">00049</a> CFuzzyVar::CFuzzyVar(<font class="keyword">const</font> <a class="code" href="classNLAIAGENT_1_1IVarName.html">NLAIAGENT::IVarName</a> &name, <font class="keywordtype">double</font> <a class="code" href="bit__set_8cpp.html#a0">min</a>, <font class="keywordtype">double</font> max, <font class="keywordtype">double</font> value) : IBaseVar(name) +00050 { +00051 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> = value; +00052 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o1">_Min</a> = <a class="code" href="bit__set_8cpp.html#a0">min</a>; +00053 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o2">_Max</a> = max; +00054 } +00055 +<a name="l00056"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a2">00056</a> CFuzzyVar::CFuzzyVar(<font class="keyword">const</font> CFuzzyVar &cp) : IBaseVar( cp ) +00057 { +00058 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> = cp._Value; +00059 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o1">_Min</a> = cp._Min; +00060 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o2">_Max</a> = cp._Max; +00061 } +00062 +<a name="l00063"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a3">00063</a> CFuzzyVar::~CFuzzyVar() +00064 { +00065 +00066 std::vector<IFuzzySet *>::const_iterator it_fs = <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>.begin(); +00067 <font class="keywordflow">while</font> ( it_fs != <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>.end() ) +00068 { +00069 ( *it_fs )->release(); +00070 it_fs++; +00071 } +00072 +00073 std::vector<CFuzzyFact *>::const_iterator it_f = <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o6">_facts</a>.begin(); +00074 <font class="keywordflow">while</font> ( it_f != <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o6">_facts</a>.end() ) +00075 { +00076 ( *it_f )->release(); +00077 it_f++; +00078 } +00079 +00080 std::vector<NLAIAGENT::CStringVarName *>::const_iterator it_q = <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o5">_qual</a>.begin(); +00081 <font class="keywordflow">while</font> ( it_q != <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o5">_qual</a>.end() ) +00082 { +00083 ( *it_q )->release(); +00084 it_q++; +00085 } +00086 } +00087 +<a name="l00088"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a4">00088</a> <font class="keywordtype">void</font> CFuzzyVar::addSet(IFuzzySet *my_set, <font class="keywordtype">char</font> *set_name) +00089 { +00090 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>.push_back(my_set); +00091 my_set->incRef(); +00092 <a class="code" href="classNLAIAGENT_1_1CStringVarName.html">NLAIAGENT::CStringVarName</a> *qual = <font class="keyword">new</font> <a class="code" href="classNLAIAGENT_1_1CStringVarName.html">NLAIAGENT::CStringVarName</a>( set_name ); +00093 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o5">_qual</a>.push_back( qual ); +00094 } +00095 +<a name="l00096"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a6">00096</a> <a class="code" href="classstd_1_1list.html">std::list<CFuzzyFact *></a> *CFuzzyVar::fuzzify(<font class="keywordtype">double</font> val) +00097 { +00098 <a class="code" href="classstd_1_1list.html">std::list<CFuzzyFact *></a> *result = <font class="keyword">new</font> <a class="code" href="classstd_1_1list.html">std::list<CFuzzyFact *></a>; +00099 <font class="keywordflow">for</font> ( <a class="code" href="types__nl_8h.html#a9">sint32</a> i = 0; i < (sint32) <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>.size(); i++ ) +00100 { +00101 <font class="keywordflow">if</font> ( <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>[i]->isIn( val ) ) +00102 { +00103 result->push_back( <font class="keyword">new</font> CFuzzyFact( <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>[i], <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>[i]-><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a11">membership</a>(val) ) ); +00104 } +00105 } +00106 <font class="keywordflow">return</font> result; +00107 } +00108 +<a name="l00109"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a7">00109</a> <font class="keywordtype">double</font> CFuzzyVar::unfuzify() +00110 { +00111 <font class="keywordtype">double</font> total_membership = 0.0; +00112 <font class="keywordtype">double</font> set_membership; +00113 <font class="keywordtype">double</font> set_center; +00114 +00115 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> = 0.0; +00116 <font class="keywordflow">for</font>( <a class="code" href="types__nl_8h.html#a9">sint32</a> i = 0; i < (sint32) <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>.size() ; i++ ) +00117 { +00118 set_membership = <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>[i]->agregate(); +00119 <font class="keywordflow">if</font> ( set_membership ) +00120 { +00121 set_center = <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>[i]->center(); +00122 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> = <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> + set_membership * set_center; +00123 total_membership = total_membership + set_membership; +00124 } +00125 } +00126 +00127 <font class="keywordflow">if</font> ( total_membership > 0 ) +00128 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> = <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> / total_membership; +00129 <font class="keywordflow">else</font> +00130 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> = 0; +00131 +00132 <font class="keywordflow">return</font> <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a>; +00133 } +00134 +<a name="l00135"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a8">00135</a> <font class="keywordtype">void</font> CFuzzyVar::addFact(CFuzzyFact *f) +00136 { +00137 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o6">_facts</a>.push_back(f); +00138 } +00139 +<a name="l00140"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a5">00140</a> IFuzzySet *CFuzzyVar::getSet(<font class="keywordtype">char</font> *name) +00141 { +00142 std::vector<IFuzzySet *>::iterator it_set = <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>.begin(); +00143 <font class="keywordflow">while</font> ( it_set != <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>.end() ) +00144 { +00145 <font class="keywordflow">if</font> ( !strcmp( (*it_set) ->getName(), name) ) +00146 <font class="keywordflow">return</font> *it_set; +00147 it_set++; +00148 } +00149 <font class="keywordflow">return</font> NULL; +00150 } +00151 +<a name="l00152"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a9">00152</a> <font class="keywordtype">void</font> CFuzzyVar::addFact(<font class="keywordtype">char</font> *set_name, <font class="keywordtype">double</font> membership) +00153 { +00154 IFuzzySet *set = <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a5">getSet</a>( set_name ); +00155 <font class="keywordflow">if</font> ( set ) +00156 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o6">_facts</a>.push_back( <font class="keyword">new</font> CFuzzyFact(set, <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a11">membership</a>) ); +00157 } +00158 +<a name="l00159"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a13">00159</a> <font class="keywordtype">void</font> CFuzzyVar::setValue(<a class="code" href="classNLAIAGENT_1_1IObjetOp.html">NLAIAGENT::IObjetOp</a> *obj) +00160 { +00161 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> = ((<a class="code" href="classNLAIAGENT_1_1INombre.html">NLAIAGENT::INombre<double></a> *)obj)->getValue(); +00162 } +00163 +<a name="l00164"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a14">00164</a> <font class="keywordtype">void</font> CFuzzyVar::setValue(<font class="keywordtype">float</font> value) +00165 { +00166 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> = value; +00167 } +00168 +<a name="l00169"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a15">00169</a> <a class="code" href="classNLAIAGENT_1_1IObjetOp.html">NLAIAGENT::IObjetOp</a> *CFuzzyVar::getValue()<font class="keyword"> const</font> +00170 <font class="keyword"> </font>{ +00171 <font class="keywordflow">return</font> <font class="keyword">new</font> <a class="code" href="classNLAIAGENT_1_1DigitalType.html">NLAIAGENT::DigitalType</a>( (<font class="keywordtype">float</font>) <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> ); +00172 } +00173 +<a name="l00174"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a16">00174</a> <font class="keyword">const</font> <a class="code" href="classNLAIC_1_1IBasicType.html">NLAIC::IBasicType</a> *CFuzzyVar::clone()<font class="keyword"> const</font> +00175 <font class="keyword"> </font>{ +00176 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a0">CFuzzyVar</a> *<a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a16">clone</a> = <font class="keyword">new</font> <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a0">CFuzzyVar</a>(*<font class="keyword">this</font>); +00177 <font class="keywordflow">return</font> <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a16">clone</a>; +00178 } +00179 +<a name="l00180"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a17">00180</a> <font class="keyword">const</font> <a class="code" href="classNLAIC_1_1IBasicType.html">NLAIC::IBasicType</a> *CFuzzyVar::newInstance()<font class="keyword"> const</font> +00181 <font class="keyword"> </font>{ +00182 <a class="code" href="classNLAIAGENT_1_1CStringVarName.html">NLAIAGENT::CStringVarName</a> <a class="code" href="driver__opengl__extension__def_8h.html#a242">x</a>(<font class="stringliteral">"Inst"</font>); +00183 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a0">CFuzzyVar</a> *instance = <font class="keyword">new</font> <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a0">CFuzzyVar</a>(x,0,0); +00184 <font class="keywordflow">return</font> instance; +00185 } +00186 +<a name="l00187"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a18">00187</a> <font class="keywordtype">void</font> CFuzzyVar::save(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &os) +00188 { +00189 IObjectIA::save(os); +00190 os.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( (<font class="keywordtype">double</font> &) <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> ); +00191 os.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( (<font class="keywordtype">double</font> &) <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o1">_Min</a> ); +00192 os.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( (<font class="keywordtype">double</font> &) <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o2">_Max</a> ); +00193 <a class="code" href="types__nl_8h.html#a9">sint32</a> size = <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>.size(); +00194 os.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( size ); +00195 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a9">sint32</a> i = 0; i < size; i++ ) +00196 { +00197 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>[i]->save(os); +00198 } +00199 } +00200 +<a name="l00201"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a19">00201</a> <font class="keywordtype">void</font> CFuzzyVar::load(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &is) +00202 { +00203 IObjectIA::load( is ); +00204 +00205 is.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> ); +00206 is.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o1">_Min</a> ); +00207 is.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o2">_Max</a> ); +00208 +00209 <a class="code" href="types__nl_8h.html#a9">sint32</a> nb_sets; +00210 is.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( nb_sets ); +00211 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a9">sint32</a> i = 0; i < nb_sets; i++ ) +00212 { +00213 <a class="code" href="classNLAIC_1_1CIdentTypeAlloc.html">NLAIC::CIdentTypeAlloc</a> <a class="code" href="driver__opengl__extension__def_8h.html#a234">id</a>; +00214 is.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( id ); +00215 IFuzzySet *tmp_val = (IFuzzySet *) id.<a class="code" href="classNLAIC_1_1CIdentTypeAlloc.html#a3">allocClass</a>(); +00216 tmp_val->load( is ); +00217 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>.push_back( tmp_val ); +00218 } +00219 } +00220 +<a name="l00221"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a20">00221</a> <font class="keywordtype">void</font> CFuzzyVar::getDebugString(std::string &txt)<font class="keyword"> const</font> +00222 <font class="keyword"> </font>{ +00223 txt += <a class="code" href="namespaceNLAIC.html#a5">NLAIC::stringGetBuild</a>(<font class="stringliteral">"CFuzzyVar<%s> = %f\n"</font>, <a class="code" href="classNLAILOGIC_1_1IBaseVar.html#a5">getName</a>().getString(), <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a>); +00224 <font class="keywordflow">for</font>(<a class="code" href="types__nl_8h.html#a9">sint32</a> i = 0; i < (sint32) <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>.size(); i++) +00225 { +00226 <font class="keywordflow">if</font> ( <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>[i]->isIn( <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> ) ) +00227 { +00228 std::string buf; +00229 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>[i]->getDebugString(buf); +00230 txt += <a class="code" href="namespaceNLAIC.html#a5">NLAIC::stringGetBuild</a>(<font class="stringliteral">" %s %f\n"</font>, buf.c_str(), <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o4">_sets</a>[i]->membership( <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> ) ); +00231 } +00232 } +00233 } +00234 +<a name="l00235"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a22">00235</a> <font class="keywordtype">bool</font> <a class="code" href="chain_8cpp.html#a2">CFuzzyVar::isEqual</a>(<font class="keyword">const</font> CFuzzyVar &a)<font class="keyword"> const</font> +00236 <font class="keyword"> </font>{ +00237 <font class="keywordflow">return</font> <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> == a._Value; +00238 } +00239 +<a name="l00240"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a23">00240</a> <font class="keywordtype">bool</font> <a class="code" href="chain_8cpp.html#a2">CFuzzyVar::isEqual</a>(<font class="keyword">const</font> <a class="code" href="classNLAIAGENT_1_1IBasicObjectIA.html">NLAIAGENT::IBasicObjectIA</a> &a)<font class="keyword"> const</font> +00241 <font class="keyword"> </font>{ +00242 <font class="keywordflow">return</font> <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a> == ((<a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a0">CFuzzyVar</a> &)a)._Value; +00243 } +00244 +<a name="l00245"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a24">00245</a> <font class="keywordtype">bool</font> CFuzzyVar::isTrue()<font class="keyword"> const</font> +00246 <font class="keyword"> </font>{ +00247 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00248 } +00249 +<a name="l00250"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a25">00250</a> <font class="keyword">const</font> <a class="code" href="classNLAIC_1_1CIdentType.html">NLAIC::CIdentType</a> &CFuzzyVar::getType()<font class="keyword"> const</font> +00251 <font class="keyword"> </font>{ +00252 <font class="keywordflow">return</font> <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#p0">IdFuzzyVar</a>; +00253 } +00254 +<a name="l00255"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a26">00255</a> <font class="keywordtype">bool</font> CFuzzyVar::operator==(<a class="code" href="classNLAILOGIC_1_1IBaseVar.html">NLAILOGIC::IBaseVar</a> *var) +00256 { +00257 <font class="keywordflow">return</font> <font class="keyword">false</font>;<font class="comment">// _Value = var->getValue()</font> +00258 } +00259 +<a name="l00260"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a27">00260</a> <font class="keywordtype">bool</font> CFuzzyVar::unify(<a class="code" href="classNLAILOGIC_1_1IBaseVar.html">NLAILOGIC::IBaseVar</a> *, <font class="keywordtype">bool</font> assign) +00261 { +00262 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00263 } +00264 +<a name="l00265"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a28">00265</a> <font class="keywordtype">bool</font> CFuzzyVar::unify(<a class="code" href="classNLAIAGENT_1_1IObjetOp.html">NLAIAGENT::IObjetOp</a> *, <font class="keywordtype">bool</font> assign) +00266 { +00267 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00268 } +00269 +<a name="l00270"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a29">00270</a> <a class="code" href="classNLAIAGENT_1_1IObjetOp.html">NLAIAGENT::IObjetOp</a> *CFuzzyVar::operator == (<a class="code" href="classNLAIAGENT_1_1IObjetOp.html">NLAIAGENT::IObjetOp</a> &a)<font class="keyword"> const</font> +00271 <font class="keyword"> </font>{ +00272 <font class="keywordflow">return</font> NULL; +00273 } +00274 +<a name="l00275"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a21">00275</a> <font class="keyword">const</font> <a class="code" href="structNLAIAGENT_1_1IObjectIA_1_1CProcessResult.html">NLAIAGENT::IObjectIA::CProcessResult</a> &CFuzzyVar::run() +00276 { +00277 <font class="keywordflow">return</font> IObjectIA::ProcessRun; +00278 } +00279 +<a name="l00280"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a10">00280</a> <font class="keywordtype">bool</font> CFuzzyVar::isIn(IFuzzySet *my_set) +00281 { +00282 <font class="keywordflow">return</font> my_set->isIn(<a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a>); +00283 } +00284 +<a name="l00285"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a11">00285</a> <font class="keywordtype">float</font> CFuzzyVar::membership(IFuzzySet *my_set) +00286 { +00287 <font class="keywordflow">return</font> (float) my_set->membership( <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a>); +00288 } +00289 +<a name="l00290"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a12">00290</a> CSimpleFuzzyCond *CFuzzyVar::getCond(<font class="keywordtype">char</font> *name) +00291 { +00292 IFuzzySet *my_set = <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a5">getSet</a>( name ); +00293 <font class="keywordflow">if</font> ( my_set ) +00294 { +00295 <font class="keywordflow">return</font> <font class="keyword">new</font> CSimpleFuzzyCond( <font class="keyword">this</font>, my_set ); +00296 } +00297 <font class="keywordflow">else</font> +00298 <font class="keywordflow">return</font> NULL; +00299 } +00300 +<a name="l00301"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a30">00301</a> <a class="code" href="types__nl_8h.html#a9">sint32</a> CFuzzyVar::getMethodIndexSize()<font class="keyword"> const</font> +00302 <font class="keyword"> </font>{ +00303 <font class="keywordflow">return</font> IObjetOp::getMethodIndexSize() + 2; +00304 } +00305 +00306 <font class="comment">// Executes a method from its index id and with its parameters</font> +<a name="l00307"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a32">00307</a> IObjectIA::CProcessResult CFuzzyVar::runMethodeMember(<a class="code" href="types__nl_8h.html#a9">sint32</a> <a class="code" href="driver__opengl__extension__def_8h.html#a234">id</a>, IObjectIA *<a class="code" href="driver__opengl__extension__def_8h.html#a235">params</a>) +00308 { +00309 <font class="keywordflow">if</font> ( <a class="code" href="driver__opengl__extension__def_8h.html#a234">id</a> <= IBaseVar::getMethodIndexSize() ) +00310 <font class="keywordflow">return</font> IBaseVar::runMethodeMember(<a class="code" href="driver__opengl__extension__def_8h.html#a234">id</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a235">params</a>); +00311 +00312 IObjectIA::CProcessResult <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a>; +00313 +00314 std::string buf; +00315 <a class="code" href="classNLAIAGENT_1_1IObjetOp.html">NLAIAGENT::IObjetOp</a> *<a class="code" href="driver__opengl__extension__def_8h.html#a242">x</a>= NULL; +00316 <font class="keywordflow">if</font> ( ( (<a class="code" href="classNLAIAGENT_1_1IBaseGroupType.html">NLAIAGENT::IBaseGroupType</a> *) <a class="code" href="driver__opengl__extension__def_8h.html#a235">params</a>)->size() ) +00317 { +00318 ( ((<a class="code" href="classNLAIAGENT_1_1IBaseGroupType.html">NLAIAGENT::IBaseGroupType</a> *)<a class="code" href="driver__opengl__extension__def_8h.html#a235">params</a>))->popFront(); +00319 +00320 <font class="preprocessor">#ifdef NL_DEBUG</font> +00321 <font class="preprocessor"></font> x-><a class="code" href="classNLAIC_1_1IBasicType.html#a5">getDebugString</a>(buf); +00322 <font class="preprocessor">#endif</font> +00323 <font class="preprocessor"></font> } +00324 <font class="preprocessor">#ifdef NL_DEBUG</font> +00325 <font class="preprocessor"></font> <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a20">getDebugString</a>(buf); +00326 <font class="preprocessor">#endif</font> +00327 <font class="preprocessor"></font> +00328 <a class="code" href="types__nl_8h.html#a9">sint32</a> base = IBaseVar::getMethodIndexSize(); +00329 <a class="code" href="types__nl_8h.html#a9">sint32</a> op_add_subset = base+1; +00330 <a class="code" href="types__nl_8h.html#a9">sint32</a> op_unfuzify = base+2; +00331 +00332 <font class="keywordflow">if</font> ( <a class="code" href="driver__opengl__extension__def_8h.html#a234">id</a> == op_add_subset ) +00333 { +00334 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a4">addSet</a>( (IFuzzySet *) x, ((IFuzzySet *)x)-><a class="code" href="classNLAILOGIC_1_1IBaseVar.html#a5">getName</a>()); +00335 <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a>.ResultState = NLAIAGENT::processIdle; +00336 <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a>.Result = NULL; +00337 } +00338 +00339 +00340 <font class="keywordflow">if</font> ( <a class="code" href="driver__opengl__extension__def_8h.html#a234">id</a> == op_unfuzify ) +00341 { +00342 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a7">unfuzify</a>(); +00343 IObjectIA::CProcessResult <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a>; +00344 <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a>.ResultState = NLAIAGENT::processIdle; +00345 <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a>.Result = <font class="keyword">new</font> <a class="code" href="classNLAIAGENT_1_1DigitalType.html">NLAIAGENT::DigitalType</a>( (<font class="keywordtype">float</font>) <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o0">_Value</a>); +00346 } +00347 +00348 <font class="comment">// TODO: throw exception....</font> +00349 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a>; +00350 } +00351 +<a name="l00352"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a33">00352</a> IObjectIA::CProcessResult CFuzzyVar::runMethodeMember(<a class="code" href="types__nl_8h.html#a9">sint32</a> inheritance, <a class="code" href="types__nl_8h.html#a9">sint32</a> <a class="code" href="driver__opengl__extension__def_8h.html#a234">id</a>, IObjectIA *<a class="code" href="driver__opengl__extension__def_8h.html#a235">params</a>) +00353 { +00354 <font class="keywordflow">return</font> <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a32">runMethodeMember</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a234">id</a>,<a class="code" href="driver__opengl__extension__def_8h.html#a235">params</a>); +00355 } +00356 +00357 +<a name="l00358"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a34">00358</a> <font class="keywordtype">void</font> CFuzzyVar::init(IObjectIA *p) +00359 { +00360 <a class="code" href="classNLAIAGENT_1_1IBaseGroupType.html">NLAIAGENT::IBaseGroupType</a> *<a class="code" href="driver__opengl__extension__def_8h.html#a235">params</a> = ((<a class="code" href="classNLAIAGENT_1_1IBaseGroupType.html">NLAIAGENT::IBaseGroupType</a> *)p); +00361 +00362 <font class="keywordflow">if</font> ( params-><a class="code" href="classNLAIAGENT_1_1IBaseGroupType.html#z130_12">size</a>() < 2 ) +00363 { +00364 <font class="comment">// throw Exc::</font> +00365 } +00366 +00367 <font class="comment">// Nom</font> +00368 <a class="code" href="classNLAIAGENT_1_1IObjectIA.html#b0">IObjectIA</a> * arg = (<a class="code" href="classNLAIAGENT_1_1IObjectIA.html#b0">IObjectIA</a> *) params-><a class="code" href="classNLAIAGENT_1_1IBaseGroupType.html#z130_9">popFront</a>(); +00369 strcpy(<a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#o3">_Name</a>, ((<a class="code" href="classNLAIAGENT_1_1IVarName.html">NLAIAGENT::IVarName</a> *) arg)->getString() ); +00370 +00371 <font class="comment">// Sous ensembles</font> +00372 <font class="keywordflow">while</font> ( params-><a class="code" href="classNLAIAGENT_1_1IBaseGroupType.html#z130_12">size</a>() ) +00373 { +00374 IFuzzySet *set = (IFuzzySet *) params-><a class="code" href="classNLAIAGENT_1_1IBaseGroupType.html#z130_11">getFront</a>()->clone(); +00375 <a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a4">addSet</a>( set, set->getName() ); +00376 params-><a class="code" href="classNLAIAGENT_1_1IBaseGroupType.html#z130_9">popFront</a>(); +00377 } +00378 } +00379 +00380 +<a name="l00381"></a><a class="code" href="classNLAIFUZZY_1_1CFuzzyVar.html#a31">00381</a> <a class="code" href="namespaceNLAIAGENT.html#a1">tQueue</a> CFuzzyVar::isMember(<font class="keyword">const</font> <a class="code" href="classNLAIAGENT_1_1IVarName.html">NLAIAGENT::IVarName</a> *className,<font class="keyword">const</font> <a class="code" href="classNLAIAGENT_1_1IVarName.html">NLAIAGENT::IVarName</a> *name,<font class="keyword">const</font> IObjectIA &param)<font class="keyword"> const</font> +00382 <font class="keyword"> </font>{ +00383 <a class="code" href="namespaceNLAIAGENT.html#a1">tQueue</a> result; +00384 +00385 result = IBaseVar::isMember(className, name, param); +00386 +00387 <font class="keywordflow">if</font> ( result.size() ) +00388 <font class="keywordflow">return</font> result; +00389 +00390 <font class="keywordflow">if</font>(className != NULL) +00391 { +00392 <font class="keywordflow">if</font> ( *name == CStringVarName( <a class="code" href="agent__method__def_8h.html#a29">_ADDSUBSET_</a> ) ) +00393 { +00394 <a class="code" href="classNLAIAGENT_1_1IObjectIA.html#b0">IObjectIA</a> *op_type = (<a class="code" href="classNLAIAGENT_1_1IObjectIA.html#b0">IObjectIA</a> *) <font class="keyword">new</font> <a class="code" href="classNLAISCRIPT_1_1COperandVoid.html">NLAISCRIPT::COperandVoid</a>(); +00395 result.push( <a class="code" href="structNLAIAGENT_1_1CIdMethod.html">NLAIAGENT::CIdMethod</a>(1 + IObjetOp::getMethodIndexSize(), 0.0,NULL, op_type ) ); +00396 } +00397 <font class="keywordflow">if</font> ( *name == CStringVarName(<a class="code" href="agent__method__def_8h.html#a30">_UNFUZIFY_</a>) ) +00398 { +00399 <a class="code" href="classNLAIAGENT_1_1IObjectIA.html#b0">IObjectIA</a> *op_type = (<a class="code" href="classNLAIAGENT_1_1IObjectIA.html#b0">IObjectIA</a> *) <font class="keyword">new</font> <a class="code" href="classNLAISCRIPT_1_1COperandSimple.html">NLAISCRIPT::COperandSimple</a>( <font class="keyword">new</font> <a class="code" href="classNLAIC_1_1CIdentType.html">NLAIC::CIdentType</a>( DigitalType::IdDigitalType) ); +00400 result.push( <a class="code" href="structNLAIAGENT_1_1CIdMethod.html">NLAIAGENT::CIdMethod</a>(2 + IObjetOp::getMethodIndexSize(), 0.0, NULL, op_type ) ); +00401 } +00402 } +00403 <font class="keywordflow">return</font> result; +00404 } +00405 } +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </FONT> +</TD> +<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD> +</TR> +</TABLE> +</BODY> +</HTML> |