diff options
Diffstat (limited to 'fuzzylite/fl/rule/Consequent.h')
-rw-r--r-- | fuzzylite/fl/rule/Consequent.h | 116 |
1 files changed, 93 insertions, 23 deletions
diff --git a/fuzzylite/fl/rule/Consequent.h b/fuzzylite/fl/rule/Consequent.h index 5394dc0..275d1e7 100644 --- a/fuzzylite/fl/rule/Consequent.h +++ b/fuzzylite/fl/rule/Consequent.h @@ -1,25 +1,17 @@ /* - Author: Juan Rada-Vilela, Ph.D. - Copyright (C) 2010-2014 FuzzyLite Limited - All rights reserved + fuzzylite (R), a fuzzy logic control library in C++. + Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved. + Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com> This file is part of fuzzylite. fuzzylite is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. + the terms of the FuzzyLite License included with the software. - fuzzylite is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - - You should have received a copy of the GNU Lesser General Public License - along with fuzzylite. If not, see <http://www.gnu.org/licenses/>. - - fuzzyliteâ„¢ is a trademark of FuzzyLite Limited. + You should have received a copy of the FuzzyLite License along with + fuzzylite. If not, see <http://www.fuzzylite.com/license/>. + fuzzylite is a registered trademark of FuzzyLite Limited. */ #ifndef FL_CONSEQUENT_H @@ -27,6 +19,8 @@ #include "fl/fuzzylite.h" +#include "fl/Complexity.h" + #include <string> #include <vector> @@ -36,8 +30,26 @@ namespace fl { class Proposition; class TNorm; + /** + The Consequent class is a proposition set that represents and evaluates + the consequent of a Rule.. The structure of a rule is: `if (antecedent) + then (consequent)`. The structure of the consequent of a rule is: + + `then variable is [hedge]* term [and variable is [hedge]* term]* [with + w]?` + + where `*`-marked elements may appear zero or more times, elements in + brackets are optional, elements in parentheses are compulsory, and + `?`-marked elements may appear once or not at all. + + @author Juan Rada-Vilela, Ph.D. + @see Antecedent + @see Rule + @since 4.0 + */ + class FL_API Consequent { - protected: + private: std::string _text; std::vector<Proposition*> _conclusions; @@ -45,24 +57,82 @@ namespace fl { Consequent(); virtual ~Consequent(); + /** + Sets the text of the consequent + @param text is the text of the consequent + */ virtual void setText(const std::string& text); + /** + Gets the text of the consequent + @return the text of the consequent + */ virtual std::string getText() const; + /** + Computes the estimated complexity of modifying the consequents + @return the estimated complexity of modifying the consequents + */ + virtual Complexity complexity(const TNorm* implication) const; + /** + Returns an immutable vector of the propositions that represent the + Consequent of a Rule + @return an immutable vector of the set of propositions that represent + the Consequent of a Rule + */ virtual const std::vector<Proposition*>& conclusions() const; + /** + Returns the vector of propositions that represent the Consequent of a + Rule + @return the vector of propositions that represent the Consequent of a + Rule + */ + virtual std::vector<Proposition*>& conclusions(); + + /** + Indicates whether the consequent is loaded + @return whether the consequent is loaded + */ virtual bool isLoaded(); + /** + Unloads the consequent + */ virtual void unload(); - virtual void load(Rule* rule, const Engine* engine); - virtual void load(const std::string& consequent, Rule* rule, const Engine* engine); - - virtual void modify(scalar activationDegree, const TNorm* activation); - + /** + Loads the consequent with text given from Consequent::getText() and + uses the engine to identify and retrieve references to the input + variables and output variables as required + @param engine is the engine from which the rules are part of + */ + virtual void load(const Engine* engine); + /** + Loads the consequent with the given text and uses the engine to + identify and retrieve references to the input variables and output + variables as required + @param consequent is the consequent of the rule in text + @param engine is the engine from which the rules are part of + */ + virtual void load(const std::string& consequent, const Engine* engine); + + /** + Modifies the proposition set according to the activation degree + (computed in the Antecedent of the Rule) and the implication operator + (given in the RuleBlock) + @param activationDegree is the activation degree computed in the + Antecedent of the Rule + @param implication is the implication operator configured in the + RuleBlock + */ + virtual void modify(scalar activationDegree, const TNorm* implication); + + /** + Returns a string representation of the Consequent + @return a string representation of the Consequent + */ virtual std::string toString() const; private: FL_DISABLE_COPY(Consequent) }; - } - #endif /* FL_CONSEQUENT_H */ |