2
0

FuzzyOperator.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* Copyright 2010 Juan Rada-Vilela
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. */
  12. /*
  13. * File: FuzzyOperator.h
  14. * Author: jcrada
  15. *
  16. * Created on November 1, 2009, 3:05 PM
  17. */
  18. #ifndef FL_FUZZYOPERATOR_H
  19. #define FL_FUZZYOPERATOR_H
  20. #include "defs.h"
  21. #include "flScalar.h"
  22. #include "FuzzyOperation.h"
  23. #include "FuzzyAnd.h"
  24. #include "FuzzyOr.h"
  25. #include "FuzzyModulation.h"
  26. #include "AreaCentroidAlgorithm.h"
  27. #include "FuzzyDefuzzifier.h"
  28. namespace fl {
  29. class LinguisticTerm;
  30. class FuzzyOperator {
  31. private:
  32. const FuzzyOperation* _tnorm;
  33. const FuzzyOperation* _snorm;
  34. const FuzzyOperation* _cmodulation;
  35. const FuzzyOperation* _aggregation;
  36. const FuzzyDefuzzifier* _defuzzifier;
  37. const AreaCentroidAlgorithm* _acalgorithm;
  38. int _number_of_samples;
  39. public:
  40. FuzzyOperator(const FuzzyOperation* tnorm = new FuzzyAndMin,
  41. const FuzzyOperation* snorm = new FuzzyOrMax,
  42. const FuzzyOperation* cmod = new FuzzyModClip,
  43. const FuzzyOperation* aggregation = new FuzzyOrMax,
  44. const FuzzyDefuzzifier* defuzzifier = new CoGDefuzzifier,
  45. const AreaCentroidAlgorithm* algorithm = new TriangulationAlgorithm, //bugfix
  46. int number_of_samples = FL_SAMPLE_SIZE);
  47. virtual ~FuzzyOperator();
  48. virtual void setTnorm(const FuzzyOperation* tnorm);
  49. virtual void setSnorm(const FuzzyOperation* snorm);
  50. virtual void setModulation(const FuzzyOperation* modulation);
  51. virtual void setAggregation(const FuzzyOperation* aggregation);
  52. virtual void setDefuzzifier(const FuzzyDefuzzifier* defuzzifier);
  53. virtual void setAreaCentroidAlgorithm(const AreaCentroidAlgorithm* algorithm);
  54. virtual void setNumberOfSamples(int samples);
  55. virtual const FuzzyOperation& tnorm() const;
  56. virtual const FuzzyOperation& snorm() const;
  57. virtual const FuzzyOperation& modulation() const;
  58. virtual const FuzzyOperation& aggregation() const;
  59. virtual const FuzzyDefuzzifier& defuzzifier() const;
  60. virtual const AreaCentroidAlgorithm& acAlgorithm() const;
  61. virtual int numberOfSamples() const;
  62. virtual flScalar defuzzify(const LinguisticTerm* term) const;
  63. virtual flScalar area(const LinguisticTerm* term) const;
  64. virtual void centroid(const LinguisticTerm* term, flScalar& x, flScalar& y) const;
  65. virtual flScalar areaAndCentroid(const LinguisticTerm* term, flScalar& x, flScalar& y) const;
  66. static FuzzyOperator& DefaultFuzzyOperator();
  67. };
  68. }
  69. #endif /* FL_FUZZYOPERATOR_H */