DescriptiveAntecedent.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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: DescriptiveAntecedent.h
  14. * Author: jcrada
  15. *
  16. * Created on March 3, 2010, 12:32 AM
  17. */
  18. #ifndef FL_DESCRIPTIVEANTECEDENT_H
  19. #define FL_DESCRIPTIVEANTECEDENT_H
  20. #include "FuzzyAntecedent.h"
  21. #include "FuzzyOperator.h"
  22. #include "InputLVar.h"
  23. #include "Hedge.h"
  24. #include "LinguisticTerm.h"
  25. #include <vector>
  26. #include <string>
  27. #include "FuzzyEngine.h"
  28. #include "FuzzyExceptions.h"
  29. namespace fl {
  30. class DescriptiveAntecedent : public FuzzyAntecedent {
  31. public:
  32. enum OPERATION {
  33. O_NONE = ' ', O_AND = '&', O_OR = '*',
  34. };
  35. private:
  36. DescriptiveAntecedent* _left;
  37. DescriptiveAntecedent* _right;
  38. OPERATION _operation;
  39. std::vector<Hedge*> _hedges; //very
  40. const LinguisticTerm* _term; //high
  41. public:
  42. DescriptiveAntecedent();
  43. DescriptiveAntecedent(const FuzzyOperator& fuzzy_op);
  44. virtual ~DescriptiveAntecedent();
  45. virtual flScalar degreeOfTruth() const;
  46. virtual std::string toString() const;
  47. virtual void parse(const std::string& antecedent,
  48. const FuzzyEngine& engine) throw (ParsingException);
  49. virtual void setLeft(DescriptiveAntecedent* l_antecedent);
  50. virtual DescriptiveAntecedent* left() const;
  51. virtual void setRight(DescriptiveAntecedent* r_antecedent);
  52. virtual DescriptiveAntecedent* right() const;
  53. virtual void setOperation(OPERATION operation);
  54. virtual OPERATION operation() const;
  55. virtual void addHedge(Hedge* hedge);
  56. virtual int numberOfHedges() const;
  57. virtual Hedge* hedge(int index) const;
  58. virtual void setTerm(const LinguisticTerm* term);
  59. virtual const LinguisticTerm* term() const;
  60. virtual bool isTerminal() const;
  61. // static bool IsValid(const std::string& rule, const FuzzyEngine& engine);
  62. std::string Preprocess(const std::string& infix);
  63. std::string InfixToPostfix(const std::string& infix);
  64. };
  65. }
  66. #endif /* FL_DESCRIPTIVEANTECEDENT_H */