Shark Machine Learning Library
  • About Shark
  • Sourceforge
    • Project Summary
    • Downloads
    • Subversion Repository
  • Getting Started
  • Tutorials
  • FAQ
  • Main Modules
    • ReClaM
    • EALib
    • MOO-EALib
    • Fuzzy
  • Tools
    • Mixture
    • Array
    • Rng
    • LinAlg
    • FileUtil
  • Main Page
  • Related Pages
  • Classes

RuleBase.h

Go to the documentation of this file.
00001 
00010 /* $log$ */
00011 
00012 
00013 #ifndef RULEBASE_H
00014 #define RULEBASE_H
00015 
00016 
00017 #include "Rule.h"
00018 #include <list>
00019 #include "LinguisticVariable.h"
00020 #include "RCPtr.h"
00021 #include "Rule.h"
00022 
00023 
00024 
00030 class RuleBase {
00031 
00032 public:
00033 
00034     RuleBase();
00035     ~RuleBase();
00036 
00037     typedef std::list < RCPtr<LinguisticVariable> > inputTemplate;
00038     typedef std::list < RCPtr<LinguisticVariable> > outputTemplate;
00039 
00040 // this method inserts a new rule into the base and returns it,
00041 // so that the user can set it.
00046     void addRule(const RCPtr<Rule> & rule);
00047     
00052     void removeRule(const RCPtr<Rule> & rule);
00053     
00058     inline int getNumberOfRules() {
00059         return(rules.size());
00060     };
00061     
00066     const std::string print() const;
00067     
00072     const RCPtr<Rule> getRule(int whichone);
00073 
00074 private:
00075     typedef std::list < RCPtr<Rule> > RuleSet;
00076     
00077     
00078 public:
00079     
00080     typedef RuleSet::const_iterator BaseIterator;
00081     
00082     inline BaseIterator getFirstIterator() const {
00083         return(rules.begin());
00084     };
00085     
00086     inline BaseIterator                    getLastIterator() const {
00087         return(rules.end());
00088     };
00089     
00090     typedef inputTemplate::const_iterator  FormatIterator;
00091     
00092     inline FormatIterator                  getFirstFormatIterator() const {
00093         return(inputFormat.begin());
00094     };
00095     
00096     inline FormatIterator                  getLastFormatIterator() const {
00097         return(inputFormat.end());
00098     };
00099     
00100     typedef outputTemplate::const_iterator ConclIt;
00101     
00102     inline FormatIterator                  getFirstConclIt() const {
00103         return(outputFormat.begin());
00104     };
00105     
00106     inline FormatIterator                  getLastConclIt() const {
00107         return(outputFormat.end());
00108     };
00109     
00110 // the Input Format describes how a vector like (1,2,4,3) given as an input
00111 // to the rule must be interpreted, i.e. to which Linguistic Variables the
00112 // values refer. Thus the input format consists of a list of Linguistic-Variables
00113 
00118      void setInputFormat(inputTemplate & in);
00119     
00128     void addToInputFormat( const RCPtr<LinguisticVariable>& lv );
00129     
00139     void addToInputFormat(const RCPtr<LinguisticVariable>& lv1,
00140                           const RCPtr<LinguisticVariable>& lv2);
00141                                                             
00152     void addToInputFormat( const RCPtr<LinguisticVariable>& lv1,
00153                            const RCPtr<LinguisticVariable>& lv2,
00154                            const RCPtr<LinguisticVariable>& lv3);
00155     
00167     void addToInputFormat(const RCPtr<LinguisticVariable>& lv1,
00168                           const RCPtr<LinguisticVariable>& lv2,
00169                           const RCPtr<LinguisticVariable>& lv3,
00170                           const RCPtr<LinguisticVariable>& lv4);
00171                                                             
00180     void addToOutputFormat(const RCPtr<LinguisticVariable>& lv);
00181     
00191     void addToOutputFormat( const RCPtr<LinguisticVariable>& lv1,
00192                             const RCPtr<LinguisticVariable>& lv2 );
00193                                                             
00199     void removeFromInputFormat(const RCPtr<LinguisticVariable>& lv);
00200     
00206     inline unsigned int getNumberOfInputs() const {
00207         return(inputFormat.size());
00208     };
00209 
00210 private:
00211     RuleSet                                rules;
00212     inputTemplate                          inputFormat;
00213     outputTemplate                         outputFormat;
00214     bool                                   destructorFlag;
00215 
00216 };
00217 
00218 #endif
00219 
00220 
00221 
00222