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

FuzzyModel.h

00001 // Copyright (C) 2000 Dominic Letourneau (dominic.letourneau@courrier.usherb.ca)
00002 
00003 // FuzzyModel.h: interface for the FuzzyModel class.
00004 //
00006 #ifndef _FUZZY_MODEL_H_
00007 #define _FUZZY_MODEL_H_
00008 
00009 
00010 #include "FuzzySet.h"
00011 #include "FuzzyRule.h"
00012 #include <list>
00013 #include <string>
00014 #include "BufferedNode.h"
00015 
00016 
00017 namespace FD {
00018 
00019 class FuzzyModel : public BufferedNode {
00020 
00021 public:
00022   
00023   //rules consistency verification
00024   void verify_rules();
00025   
00026   //print the rules
00027   void print_rules(std::ostream &out);
00028   
00029   //print the sets
00030   void print_sets(std::ostream &out);
00031   
00032   void reset();
00033   
00034   //add a fuzzy set (of type input or output)
00035   void add_fuzzy_set(ObjectRef set, int type);
00036   
00037   //add a fuzzy rule (rules must be inserted after sets
00038   void add_fuzzy_rule (ObjectRef rule);
00039   
00040   //default constructor
00041   FuzzyModel();
00042   
00043   FuzzyModel(const FuzzyModel &model);
00044   
00045   
00046   FuzzyModel(std::string nodeName, ParameterSet params);
00047   
00048   //destructor
00049   virtual ~FuzzyModel();
00050   
00051   //evaluate the model with the named input values (in rule order)
00052   virtual Vector<float> & evaluate(Vector<float> &input_values);
00053   
00054   //pure virtual function that must be implemented by the
00055   //real model (conjunction,disjunction,defuzzification)
00056   virtual float conjunction(Vector<float> &c_values) = 0;
00057   virtual float disjunction(Vector<float> &d_values) = 0;
00058   virtual Vector<float> & defuzzification() = 0;
00059   
00060   
00061   virtual void calculate(int output_id, int count, Buffer &out);
00062   
00063   //cloning capability
00064   //virtual ObjectRef clone() = 0;
00065   
00066   //constants representing input and output sets
00067   static const int FUZZY_INPUT_SET;
00068   static const int FUZZY_OUTPUT_SET;
00069   
00070   
00071  protected:
00072   
00073   int m_RuleID;
00074   
00075   int m_ASetID;
00076   
00077   int m_CSetID;
00078   
00079   int m_InputID;
00080   
00081   int m_OutputID;
00082   
00083   int m_ModelID;
00084   
00085   //vector of rules
00086   Vector<ObjectRef> m_rules;
00087   
00088   //vector of input sets
00089   Vector<ObjectRef> m_input_set;
00090   
00091   //vector of output sets
00092   Vector<ObjectRef> m_output_set;
00093   
00094   //vector of input functions to be evaluated for a rule
00095   std::vector<std::list<FuzzyFunction*> > m_input_functions;
00096   
00097   //vector of output functions to be evaluated for a rule
00098   std::vector<std::list<FuzzyFunction*> > m_output_functions;
00099   
00100   //internal function to get a named set
00101   FuzzySet* find_set_named(const std::string &name, int type);
00102   
00103   //defuzzification result
00104   Vector<float> m_defuzzification;
00105   
00106 };
00107 
00108 }//namespace FD
00109 
00110 #endif

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