Accumulated.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. Author: Juan Rada-Vilela, Ph.D.
  3. Copyright (C) 2010-2014 FuzzyLite Limited
  4. All rights reserved
  5. This file is part of fuzzylite.
  6. fuzzylite is free software: you can redistribute it and/or modify it under
  7. the terms of the GNU Lesser General Public License as published by the Free
  8. Software Foundation, either version 3 of the License, or (at your option)
  9. any later version.
  10. fuzzylite is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
  13. for more details.
  14. You should have received a copy of the GNU Lesser General Public License
  15. along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
  16. fuzzylite™ is a trademark of FuzzyLite Limited.
  17. */
  18. #ifndef FL_ACCUMULATED_H
  19. #define FL_ACCUMULATED_H
  20. #include "fl/term/Term.h"
  21. #include <vector>
  22. namespace fl {
  23. class Activated;
  24. class SNorm;
  25. class TNorm;
  26. class FL_API Accumulated : public Term {
  27. private:
  28. void copyFrom(const Accumulated& source);
  29. protected:
  30. std::vector<Activated*> _terms;
  31. scalar _minimum, _maximum;
  32. FL_unique_ptr<SNorm> _accumulation;
  33. public:
  34. Accumulated(const std::string& name = "",
  35. scalar minimum = fl::nan,
  36. scalar maximum = fl::nan,
  37. SNorm* accumulation = fl::null);
  38. Accumulated(const Accumulated& other);
  39. Accumulated& operator=(const Accumulated& other);
  40. virtual ~Accumulated() FL_IOVERRIDE;
  41. FL_DEFAULT_MOVE(Accumulated)
  42. virtual std::string className() const FL_IOVERRIDE;
  43. virtual std::string parameters() const FL_IOVERRIDE;
  44. virtual void configure(const std::string& parameters) FL_IOVERRIDE;
  45. virtual Accumulated* clone() const FL_IOVERRIDE;
  46. virtual scalar membership(scalar x) const FL_IOVERRIDE;
  47. virtual scalar activationDegree(const Term* forTerm) const;
  48. virtual std::string toString() const FL_IOVERRIDE;
  49. virtual void setMinimum(scalar minimum);
  50. virtual scalar getMinimum() const;
  51. virtual void setMaximum(scalar maximum);
  52. virtual scalar getMaximum() const;
  53. virtual void setRange(scalar minimum, scalar maximum);
  54. virtual scalar range() const;
  55. virtual void setAccumulation(SNorm* accumulation);
  56. virtual SNorm* getAccumulation() const;
  57. /**
  58. * Operations for std::vector _terms
  59. */
  60. virtual void addTerm(const Term* term, scalar degree, const TNorm* activation);
  61. virtual void addTerm(Activated* term);
  62. virtual Activated* getTerm(int index) const;
  63. virtual Activated* removeTerm(int index);
  64. virtual int numberOfTerms() const;
  65. virtual const std::vector<Activated*>& terms() const;
  66. virtual std::vector<Activated*>& terms();
  67. virtual bool isEmpty() const;
  68. virtual void clear();
  69. };
  70. }
  71. #endif /* FL_ACCUMULATED_H */