Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

FuzzySet.h

00001 // Copyright (C) 2000 Dominic Letourneau (dominic.letourneau@courrier.usherb.ca)
00002 
00003 // FuzzySet.h: interface for the FuzzySet class.
00004 //
00006 #ifndef _FUZZY_SET_H_
00007 #define _FUZZY_SET_H_
00008 
00009 #include <string>
00010 #include <vector>
00011 #include <map>
00012 #include "FuzzyFunction.h"
00013 #include "TrapezoidalFunction.h"
00014 #include "TriangularFunction.h"
00015 #include "BufferedNode.h"
00016 
00017 namespace FD {
00018 
00019 class FuzzySet : public BufferedNode {
00020 
00021   friend class FuzzyModel;
00022 
00023 public:
00024         
00025   //returns the index of the function in the set
00026   int find_function_by_index(const std::string &name);
00027     
00028   //adds a triangular function to the set
00029   void add_triangular_function (const std::string &name, float a, float b, float c);
00030   
00031   //adds a trapezoidal function to the set
00032   void add_trapezoidal_function (const std::string &name, float a, float b, float c, float d);
00033   
00034   //constructor with a name
00035   FuzzySet(const std::string &name);
00036   
00037   FuzzySet(std::string nodeName, ParameterSet params);
00038   
00039   FuzzySet();
00040   
00041   FuzzySet(std::istream &in);
00042   
00043   //destructor
00044   virtual ~FuzzySet();
00045   
00046   //evaluation of all the membership function at once
00047   Vector<float> & get_all_membership_evaluation(float x);
00048   
00049   //get the evaluation of the membership function of a given name
00050   float get_membership_evaluation(const std::string &name, float x);
00051   
00052   //accessor for the name
00053   const std::string& get_name(){return m_name;}
00054   
00055   //reset all functions inference stacks
00056   void reset() {
00057     for (int i = 0 ; i < m_functions.size(); i++) {
00058       object_cast<FuzzyFunction>(m_functions[i]).reset_inference_values();
00059     }
00060   }
00061   
00062   //retuns the internal vector of fuzzy functions
00063   Vector<ObjectRef> & get_member_functions() {return m_functions;}
00064   
00065   //returns the number of function in the set
00066   int get_function_count() {return m_functions.size();}
00067   
00068   //print the membership functions
00069   void print_functions(std::ostream &out);
00070   
00071   virtual void calculate(int output_id, int count, Buffer &out);
00072   
00073   virtual ObjectRef clone();
00074   
00075   virtual void printOn(std::ostream &out) const;
00076   
00077   virtual void readFrom(std::istream &in=std::cin);
00078   
00079  private:
00080   
00081   //returns the pointer of the function of a given name
00082   FuzzyFunction * find_function_by_name (const std::string &name);
00083 
00084   //the set name
00085   std::string m_name;
00086   
00087   //the vector of fuzzy functions
00088   Vector<ObjectRef> m_functions;
00089   
00090   //the evaluation vector (results of the evaluation of functions)
00091   Vector<float> m_evaluation;
00092   
00093   //the inputID
00094   int m_functionID;
00095   
00096   //the outputID
00097   int m_setID;
00098 };
00099 
00100 }//namespace FD
00101 
00102 #endif

Generated on Wed Oct 5 14:28:55 2005 for FlowDesigner by  doxygen 1.4.4