FuzzyRule.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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: FuzzyRule.h
  14. * Author: jcrada
  15. *
  16. * Created on November 5, 2009, 11:11 AM
  17. */
  18. #ifndef FL_FUZZYRULE_H
  19. #define FL_FUZZYRULE_H
  20. #include "FuzzyOperator.h"
  21. #include "FuzzyAntecedent.h"
  22. #include "FuzzyConsequent.h"
  23. #include <string>
  24. #include <vector>
  25. #include "flScalar.h"
  26. #include "FuzzyExceptions.h"
  27. namespace fl {
  28. class FuzzyRule {
  29. public:
  30. static const std::string FR_IF;
  31. static const std::string FR_IS;
  32. static const std::string FR_THEN;
  33. static const std::string FR_AND;
  34. static const std::string FR_OR;
  35. static const std::string FR_WITH;
  36. private:
  37. const FuzzyOperator* _fuzzy_operator;
  38. FuzzyAntecedent* _antecedent;
  39. std::vector<FuzzyConsequent*> _consequents;
  40. public:
  41. FuzzyRule();
  42. FuzzyRule(const FuzzyOperator& fuzzy_op);
  43. virtual ~FuzzyRule();
  44. virtual void setFuzzyOperator(const FuzzyOperator& fuzzy_op);
  45. virtual const FuzzyOperator& fuzzyOperator() const;
  46. virtual FuzzyAntecedent* antecedent() const;
  47. virtual void setAntecedent(FuzzyAntecedent* antecedent);
  48. virtual FuzzyConsequent* consequent(int index) const;
  49. virtual void addConsequent(FuzzyConsequent* consequent);
  50. virtual int numberOfConsequents() const;
  51. virtual bool isValid() const;
  52. virtual flScalar firingStrength() const;
  53. virtual void fire(flScalar strength);
  54. virtual std::string toString() const;
  55. virtual void parse(const std::string& rule, const FuzzyEngine& engine) = 0;
  56. static void ExtractFromRule(const std::string& rule, std::string& antecedent, std::string& consequent);
  57. };
  58. }
  59. #endif /* _FUZZYRULE_H */