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

Operators.cpp

Go to the documentation of this file.
00001 
00010 /* $log$ */
00011 
00012 #include "Fuzzy/Operators.h"
00013 
00014 RCPtr<ComposedFS> Operators::max(const RCPtr<FuzzySet>& l ,const RCPtr<FuzzySet>& r) {
00015     RCPtr<ComposedFS> cfs(new ComposedFS(ComposedFS::MAX,l,r));
00016     return(cfs);
00017 };
00018 
00019 /* RCPtr<SingletonFS> Operators::min(const RCPtr<FuzzySet>& fs,const RCPtr<SingletonFS>& s) */
00020 /*  {  RCPtr<SingletonFS> sfs(new SingletonFS(s->defuzzify(),(*fs)(s->defuzzify()))); */
00021 /*    // cout<<"Spezieller Konstruktor"<<endl; */
00022 /*    return(sfs); */
00023 /*  }; */
00024 
00025 /* RCPtr<SingletonFS> Operators::min(const RCPtr<SingletonFS>& s,const RCPtr<FuzzySet>& fs) */
00026 /* {  RCPtr<SingletonFS> sfs(new SingletonFS(s->defuzzify(),(*fs)(s->defuzzify()))); */
00027 /*    return(sfs); */
00028 /* };    */
00029 
00030 RCPtr<SingletonFS> Operators::minLFS(const RCPtr<FuzzySet>&  s,const RCPtr<FuzzySet>& fs) {
00031     RCPtr<SingletonFS> sfs(new SingletonFS(s->defuzzify(),(*fs)(s->defuzzify())));
00032     return(sfs);
00033 };
00034 
00035 RCPtr<FuzzySet> Operators::min(const RCPtr<FuzzySet>& l, const RCPtr<FuzzySet>& r) {
00036     RCPtr<FuzzySet> result;
00037     if (fabs(l->getMin()-l->getMax())<1E-8)
00038         // is the left operand a singleton?
00039         // this simplification restricts numbers to numbers
00040         // whose significant digits begin before 1E-8
00041     {
00042         result = minLFS(l,r);
00043         return result;
00044     };
00045     if (fabs(r->getMin()-r->getMax())<1E-8)
00046         // is the right operand a singleton
00047     {
00048         result = minLFS(r,l);
00049         return result;
00050     };
00051     ComposedFS* cfs = new ComposedFS(ComposedFS::MIN,l,r);
00052     return(cfs);
00053 };
00054 
00055 RCPtr< ComposedNDimFS > Operators::supMinComp(const std::vector<double>  & d, Implication* imp) {
00056     // cf Bothe p126: mu(y)=sup_x min(mu_a(x),mu_m(x,y)
00057     // where mu_m(x,y) is the implication function
00058     // and mu_a is the current input, in our case a
00059     // vector of singletons, which simplifies this to
00060     // mu(y)=mu_m(singleton_input,y)
00061     // where our lambda feature yields a convenient solution
00062     RCPtr<ComposedNDimFS> ndfs = (*imp)(d,Implication::Y);
00063     return(ndfs);
00064 };