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

FuzzyRule.h

00001 // Copyright (C) 2000 Dominic Letourneau (dominic.letourneau@courrier.usherb.ca)
00002 
00003 // FuzzyRule.h: interface for the FuzzyRule class.
00004 //
00006 #ifndef _FUZZYRULE_H_
00007 #define _FUZZYRULE_H_
00008 
00009 #include <string>
00010 #include <vector>
00011 #include "BufferedNode.h"
00012 #include "Object.h"
00013 #include "Vector.h"
00014 
00015 namespace FD {
00016 
00017 class FuzzyRule : public BufferedNode {
00018 
00019 public:
00020         
00021   friend std::istream& operator>> (std::istream &in, FuzzyRule &rule);
00022   friend std::ostream& operator<< (std::ostream &out, FuzzyRule &rule);
00023   
00024 
00025   //printing the rule IF ... AND ... THEN ...
00026   void print_rule (std::ostream &out);
00027 
00028   //add a consequent in the rule
00029   void add_consequent (const std::string &set_name, const std::string &funct_name);
00030   
00031   //add an antecedant in the rule
00032   void add_antecedant(const std::string& set_name, const std::string &funct_name);
00033   
00034   
00035   FuzzyRule();
00036   
00037   //the constructor needs a rule number
00038   FuzzyRule(int rule_number);
00039   
00040   FuzzyRule(const FuzzyRule& cpy);
00041   
00042   FuzzyRule(std::string nodeName, ParameterSet params);
00043 
00044   FuzzyRule(std::istream &in);
00045   
00046   //destructor
00047   virtual ~FuzzyRule();
00048   
00049   //accessor for the antecedant part of the rule 
00050   std::vector<std::pair<std::string,std::string> >& get_antecedant_part() {return m_antecedant;}
00051   
00052   //accessor for the consequent of the rule
00053   std::vector<std::pair<std::string,std::string> >& get_consequent_part() {return m_consequent;}
00054   
00055   //accessor for the rule number
00056   int get_rule_number() {return m_rule_number;}
00057 
00058   void set_rule_number(int rule_number) {m_rule_number = rule_number;}
00059   
00060   virtual void calculate(int output_id, int count, Buffer &out);
00061     
00062   virtual ObjectRef clone();
00063 
00064   virtual void printOn(std::ostream &out=std::cout) const;
00065 
00066   virtual void readFrom(std::istream &in=std::cin);
00067   
00068  private:
00069   
00070   //vector of antecedant of type (FUZZY_SET,VARIABLE)
00071   std::vector<std::pair<std::string,std::string> > m_antecedant;
00072   
00073   //vector of consequent of type (FUZZY_SET,VARIABLE)
00074   std::vector<std::pair<std::string,std::string> > m_consequent;
00075   
00076   //the rule number     
00077   int m_rule_number;
00078 
00079   int m_ruleID;
00080 };
00081 
00082 template<>
00083 inline void Vector<FuzzyRule*>::printOn(std::ostream &out) const {
00084   for (int i = 0; i < size(); i++) {
00085     operator[](i)->printOn(out);
00086   }
00087 }
00088 
00089 template<>
00090 inline void Vector<FuzzyRule*>::destroy() {
00091 
00092  for (Vector<FuzzyRule*>::iterator iter = this->begin();
00093       iter != this->end(); iter++) {
00094    delete (*iter);
00095  }
00096 
00097  delete this;
00098 }
00099 
00100 }//namespace FD
00101 
00102 #endif 

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