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

FuzzyFunction.h

00001 // Copyright (C) 2000 Dominic Letourneau (dominic.letourneau@courrier.usherb.ca)
00002 
00003 // FuzzyFunction.h: interface for the FuzzyFunction class.
00004 //
00006 #ifndef _FUZZY_FUNCTION_H_
00007 #define _FUZZY_FUNCTION_H_
00008 
00009 #include <string>
00010 #include <vector>
00011 #include "BufferedNode.h"
00012 #include "Vector.h"
00013 
00014 namespace FD {
00015 
00016 
00017 class FuzzyFunction : public BufferedNode {
00018 
00019 public:
00020 
00021   //friend std::istream& operator>> (std::istream &in, FuzzyFunction &function);
00022 
00023   //friend std::ostream& operator<< (std::ostream &out, FuzzyFunction &function);
00024   
00025   //accessor for the function name
00026   const std::string & get_name();
00027   
00028   virtual std::string get_type()=0;
00029   
00030   //virtual destructor
00031   virtual ~FuzzyFunction();
00032   
00033   //pure virtual function
00034   virtual float evaluate(float x) = 0;
00035   
00036   //the constructor with a function name
00037   FuzzyFunction(const std::string &name);
00038   
00039   FuzzyFunction(std::string nodeName, ParameterSet params);
00040   
00041   
00042   //reset the inference vector
00043   void reset_inference_values() {m_inference_values.resize(0);}
00044   
00045   //return the inference vector
00046   Vector<float> & get_inference_values() {return m_inference_values;}
00047   
00048   //push a value in the vector
00049   void push_inference_value(float value) {m_inference_values.push_back(value);}
00050   
00051   //computes the area (pure virtual function)
00052   virtual float get_area() = 0;
00053   
00054   //computes the center of gravity (pure virtual function)
00055   virtual float get_center_of_gravity() = 0;
00056   
00057   //higher limits of the function
00058   virtual float get_upper_bound() = 0;
00059   
00060   //lower limit of the functions
00061   virtual float get_lower_bound() = 0;
00062 
00063   //get all bounds of the function
00064   virtual Vector<float> get_bounds() = 0;
00065 
00066   //cloning capability
00067   //virtual ObjectRef clone() = 0;
00068   
00069   virtual void calculate(int output_id, int count, Buffer &out);
00070   
00071  protected:
00072   
00073   //the function name (linguistic term)
00074   std::string m_name;
00075   
00076   //the vector used for inference (temporary)
00077   Vector<float> m_inference_values;
00078   
00079   int m_functionID;
00080   
00081   //we shouldn't use this default constructor
00082   FuzzyFunction();
00083   
00084 };
00085 
00086 /*
00087 
00088 inline void Vector<FuzzyFunction*>::printOn(std::ostream &out) const {
00089 
00090   std::cerr<<"PrintOn called Vector<FuzzyFunction*>"<<endl;
00091   
00092   for (int i = 0; i < size(); i++) {
00093     std::cerr<<"calling printon"<<endl;
00094     operator[](i)->printOn(out);
00095   }
00096 }
00097 
00098 inline void Vector<FuzzyFunction*>::readFrom(std::istream &in) {
00099 
00100 }
00101 
00102 
00103 inline void Vector<FuzzyFunction*>::destroy() {
00104 
00105  for (Vector<FuzzyFunction*>::iterator iter = this->begin();
00106       iter != this->end(); iter++) {
00107    delete (*iter);
00108  }
00109 
00110  delete this;
00111 }
00112 */
00113 
00114 
00115 }//namespace FD
00116 
00117 #endif

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