# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

fuzzyset.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_FUZZYSET_H
00027 #define NL_FUZZYSET_H
00028 
00029 #include "nel/ai/agent/agent.h"
00030 #include "nel/ai/agent/agent_digital.h"
00031 #include "nel/ai/agent/object_type.h"
00032 
00033 namespace NLAIFUZZY {
00034 
00035         class IFuzzySet : public NLAIAGENT::IObjectIA {
00036                 protected:                      
00037                         char *_Name;
00038                         std::list<double> _Facts;
00039                         double _Value;
00040 
00041                 public:
00042                         IFuzzySet(char *name)
00043                         {
00044                                 _Name = new char[strlen(name) + 1];
00045                                 strcpy(_Name, name);
00046                         }
00047 
00048                         virtual ~IFuzzySet()
00049                         {
00050                                 delete[] _Name;
00051                         }
00052 
00053                         char *getName()
00054                         {
00055                                 return _Name;
00056                         }
00057 
00058                         virtual double membership(double) = 0;
00059                         virtual double surface() = 0;
00060                         virtual bool isIn(double) = 0;
00061                         virtual double center() = 0;
00062                         virtual void addFact(double);
00063                         virtual double agregate();
00064                         virtual double getValue();
00065 
00066                         virtual NLAIAGENT::tQueue isMember(const NLAIAGENT::IVarName *, const NLAIAGENT::IVarName *, const NLAIAGENT::IObjectIA &) const;
00067                         virtual NLAIAGENT::IObjectIA::CProcessResult runMethodeMember(sint32, NLAIAGENT::IObjectIA *);
00068         };
00069 
00070         class CFuzzyInterval : public IFuzzySet
00071         {
00072                 private:
00073                         double _Min;
00074                         double _Max;
00075                 public:
00076                         CFuzzyInterval(char *,double min, double max);
00077                         CFuzzyInterval(const CFuzzyInterval &cp);
00078                         virtual double membership(double val);
00079                         virtual bool isIn(double val);
00080                         virtual double surface();
00081                         virtual double center();
00082 
00083                         virtual const NLAIC::IBasicType *clone() const;
00084                         virtual const NLAIC::IBasicType *newInstance() const;
00085                         virtual const NLAIC::CIdentType &getType() const;
00086                         virtual void save(NLMISC::IStream &os);
00087                         virtual void load(NLMISC::IStream &is);
00088                         virtual void getDebugString(std::string &) const;
00089                         virtual bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const;
00090                         virtual const CProcessResult &run();
00091 
00092                         static const NLAIC::CIdentType IdFuzzyInterval;
00093                         virtual void init(NLAIAGENT::IObjectIA *);
00094         };
00095 
00096         class CRightFuzzySet : public IFuzzySet {
00097                 private:
00098                         double _X1;
00099                         double _X2;
00100                         double _X3;
00101 
00102                 public:
00103                         CRightFuzzySet(char *, double, double, double);
00104                         CRightFuzzySet(const CRightFuzzySet &);
00105                         virtual double membership(double val);
00106                         virtual bool isIn(double val);
00107                         virtual double surface();
00108                         virtual double center();
00109 
00110                         static const NLAIC::CIdentType IdRightFuzzySet;
00111 
00112                         virtual const NLAIC::IBasicType *clone() const;
00113                         virtual const NLAIC::IBasicType *newInstance() const;
00114                         virtual const NLAIC::CIdentType &getType() const;
00115                         virtual void save(NLMISC::IStream &os);
00116                         virtual void load(NLMISC::IStream &is);
00117                         virtual void getDebugString(std::string &) const;
00118                         virtual bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const;
00119                         virtual const CProcessResult &run();
00120                         virtual void init(NLAIAGENT::IObjectIA *);
00121         };
00122 
00123         class CTriangleFuzzySet : public IFuzzySet {
00124                 private:
00125                         double _X1;
00126                         double _X2;
00127                         double _X3;
00128 
00129                 public:
00130                         CTriangleFuzzySet(char *,double, double, double);
00131                         CTriangleFuzzySet(const CTriangleFuzzySet &);
00132 
00133                         virtual double membership(double);
00134                         virtual bool isIn(double);
00135                         virtual double surface();
00136                         virtual double center();
00137 
00138                         static const NLAIC::CIdentType IdTriangleFuzzySet;
00139                         virtual const NLAIC::IBasicType *clone() const;
00140                         virtual const NLAIC::IBasicType *newInstance() const;
00141                         virtual const NLAIC::CIdentType &getType() const;
00142                         virtual void save(NLMISC::IStream &os);
00143                         virtual void load(NLMISC::IStream &is);
00144                         virtual void getDebugString(std::string &) const;
00145                         virtual bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const;
00146                         virtual const CProcessResult &run();
00147 
00148                         virtual void init(NLAIAGENT::IObjectIA *);
00149         };
00150 
00151         class CTrapezeFuzzySet : public IFuzzySet {
00152                 private:
00153                         double _X1;
00154                         double _X2;
00155                         double _X3;
00156                         double _X4;
00157 
00158                 public:
00159                         static const NLAIC::CIdentType IdTrapezeFuzzySet;
00160 
00161                         CTrapezeFuzzySet(char *,double p1,double p2,double p3, double p4);
00162                         CTrapezeFuzzySet(const CTrapezeFuzzySet &);
00163                         ~CTrapezeFuzzySet();
00164                         virtual double membership(double val);
00165                         virtual bool isIn(double val);
00166                         virtual double surface();
00167                         virtual double center();
00168 
00169                         virtual const NLAIC::IBasicType *clone() const;
00170                         virtual const NLAIC::IBasicType *newInstance() const;
00171                         virtual const NLAIC::CIdentType &getType() const;
00172                         virtual void save(NLMISC::IStream &os);
00173                         virtual void load(NLMISC::IStream &is);
00174                         virtual void getDebugString(std::string &) const;
00175                         virtual bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const;
00176                         virtual const CProcessResult &run();
00177 
00178                         virtual void init(NLAIAGENT::IObjectIA *);
00179         };
00180 
00181         class CLeftFuzzySet : public IFuzzySet {
00182                 private:
00183                         double _X1;
00184                         double _X2;
00185                         double _X3;
00186 
00187                 public:
00188                         CLeftFuzzySet(char *,double p1,double p2,double p3);
00189                         CLeftFuzzySet(const CLeftFuzzySet &);
00190                         ~CLeftFuzzySet();
00191                         virtual double membership(double val);
00192                         virtual bool isIn(double val);
00193                         virtual double surface();
00194                         virtual double center();
00195 
00196                         static const NLAIC::CIdentType IdLeftFuzzySet;
00197 
00198                         virtual const NLAIC::IBasicType *clone() const;
00199                         virtual const NLAIC::IBasicType *newInstance() const;
00200                         virtual const NLAIC::CIdentType &getType() const;
00201                         virtual void save(NLMISC::IStream &os);
00202                         virtual void load(NLMISC::IStream &is);
00203                         virtual void getDebugString(std::string &) const;
00204                         virtual bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const;
00205                         virtual const CProcessResult &run();
00206 
00207                         virtual void init(NLAIAGENT::IObjectIA *);
00208         };
00209 
00210 /*
00211         class CompositeFuzzySet : public IFuzzySet {
00212                 private:
00213                         std::list<Filter *> _filters;
00214                 public:
00215                         CompositeFuzzySet();
00216                         CompositeFuzzySet(const CompositeFilter &cp);
00217                         void addFilter(Filter *f);
00218                         virtual double membership(double val);
00219                         virtual bool isIn(double val );
00220                         virtual double surface();
00221                         virtual double center();
00222 
00223                         virtual const CProcessResult &run();
00224                         static const NLAIC::CIdentType idCompositeFilter;
00225                         virtual const NLAIC::IBasicType *clone() const;
00226                         virtual const NLAIC::IBasicType *newInstance() const;
00227                         virtual const NLAIC::CIdentType &getType() const;
00228                         virtual void save(NLMISC::IStream &os);
00229                         virtual void load(NLMISC::IStream &is);
00230                         virtual void getDebugString(char *) const;
00231                         virtual bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const;
00232         };
00233 */
00234 
00235 }
00236 #endif
00237 
00238