The Engine class is the core class of the library as it groups the necessary components of a fuzzy logic controller. More...
#include <Engine.h>
Public Types | |
enum | Type { Mamdani, Larsen, TakagiSugeno, Tsukamoto, InverseTsukamoto, Hybrid, Unknown } |
Public Member Functions | |
Engine (const std::string &name="") | |
Engine (const Engine &other) | |
Engine & | operator= (const Engine &other) |
virtual | ~Engine () |
virtual void | configure (const std::string &conjunction, const std::string &disjunction, const std::string &implication, const std::string &aggregation, const std::string &defuzzifier, const std::string &activation) |
Configures the engine with the given operators. More... | |
virtual void | configure (TNorm *conjunction, SNorm *disjunction, TNorm *implication, SNorm *aggregation, Defuzzifier *defuzzifier, Activation *activation) |
Configures the engine with clones of the given object operators, taking ownership of the objects. More... | |
virtual bool | isReady (std::string *status=fl::null) const |
Indicates whether the engine has been configured correctly and is ready for operation. More... | |
virtual Complexity | complexity () const |
Computes the estimated complexity of operation of the engine. More... | |
virtual void | process () |
Processes the engine in its current state as follows: (a) Clears the aggregated fuzzy output variables, (b) Activates the rule blocks, and (c) Defuzzifies the output variables. More... | |
virtual void | restart () |
Restarts the engine by setting the values of the input variables to fl::nan and clearing the output variables. More... | |
virtual void | setName (const std::string &name) |
Sets the name of the engine. More... | |
virtual std::string | getName () const |
Gets the name of the engine. More... | |
virtual void | setDescription (const std::string &description) |
Sets the description of the engine. More... | |
virtual std::string | getDescription () const |
Gets the description of the engine. More... | |
virtual void | setInputValue (const std::string &name, scalar value) |
Sets the value of the given input variable. More... | |
virtual scalar | getOutputValue (const std::string &name) |
Gets the value of the given output variable. More... | |
virtual std::string | toString () const |
Returns a string representation of the engine in the FuzzyLite Language. More... | |
virtual Type | type (std::string *name=fl::null, std::string *reason=fl::null) const |
Infers the type of the engine based on its current configuration. More... | |
virtual Engine * | clone () const |
Creates a clone of the engine. More... | |
virtual std::vector< Variable * > | variables () const |
Returns a vector that contains the input variables followed by the output variables in the order of insertion. More... | |
virtual void | addInputVariable (InputVariable *inputVariable) |
Adds the input variable. More... | |
virtual InputVariable * | setInputVariable (InputVariable *inputVariable, std::size_t index) |
Sets the input variable at the given index. More... | |
virtual void | insertInputVariable (InputVariable *inputVariable, std::size_t index) |
Inserts the input variable at the given index, shifting other variables one position to the right. More... | |
virtual InputVariable * | getInputVariable (std::size_t index) const |
Gets the input variable at the given index. More... | |
virtual InputVariable * | getInputVariable (const std::string &name) const |
Gets the input variable of the given name after iterating the input variables. More... | |
virtual InputVariable * | removeInputVariable (std::size_t index) |
Removes the input variable at the given index (without deleting it) and shifts the remaining input variables one position to the left. More... | |
virtual InputVariable * | removeInputVariable (const std::string &name) |
Removes the input variable of the given name (without deleting it) and shifts the remaining input variables one position to the left. More... | |
virtual bool | hasInputVariable (const std::string &name) const |
Indicates whether an input variable of the given name is in the input variables. More... | |
virtual std::size_t | numberOfInputVariables () const |
Returns the number of input variables added to the engine. More... | |
virtual const std::vector< InputVariable * > & | inputVariables () const |
Returns an immutable vector of input variables. More... | |
virtual void | setInputVariables (const std::vector< InputVariable *> &inputVariables) |
Sets the vector of input variables. More... | |
virtual std::vector< InputVariable * > & | inputVariables () |
Returns a mutable vector of input variables. More... | |
virtual void | addOutputVariable (OutputVariable *outputVariable) |
Adds the output variable. More... | |
virtual OutputVariable * | setOutputVariable (OutputVariable *outputVariable, std::size_t index) |
Sets the output variable at the given index. More... | |
virtual void | insertOutputVariable (OutputVariable *outputVariable, std::size_t index) |
Inserts the output variable at the given index, shifting other variables one position to the right. More... | |
virtual OutputVariable * | getOutputVariable (std::size_t index) const |
Gets the output variable at the given index. More... | |
virtual OutputVariable * | getOutputVariable (const std::string &name) const |
Gets the output variable of the given name after iterating the output variables. More... | |
virtual bool | hasOutputVariable (const std::string &name) const |
Indicates whether an output variable of the given name is in the output variables. More... | |
virtual OutputVariable * | removeOutputVariable (std::size_t index) |
Removes the output variable at the given index (without deleting it) and shifts the remaining output variables one position to the left. More... | |
virtual OutputVariable * | removeOutputVariable (const std::string &name) |
Removes the output variable of the given name (without deleting it) and shifts the remaining output variables one position to the left. More... | |
virtual std::size_t | numberOfOutputVariables () const |
Returns the number of output variables added to the engine. More... | |
virtual const std::vector< OutputVariable * > & | outputVariables () const |
Returns an immutable vector of output variables. More... | |
virtual void | setOutputVariables (const std::vector< OutputVariable *> &outputVariables) |
Sets the vector of output variables. More... | |
virtual std::vector< OutputVariable * > & | outputVariables () |
Returns a mutable vector of output variables. More... | |
virtual void | addRuleBlock (RuleBlock *ruleBlock) |
Adds the rule block. More... | |
virtual RuleBlock * | setRuleBlock (RuleBlock *ruleBlock, std::size_t index) |
Sets the rule block at the given index. More... | |
virtual void | insertRuleBlock (RuleBlock *ruleBlock, std::size_t index) |
Inserts the rule block at the given index, shifting other blocks one position to the right. More... | |
virtual RuleBlock * | getRuleBlock (std::size_t index) const |
Gets the rule block at the given index. More... | |
virtual RuleBlock * | getRuleBlock (const std::string &name) const |
Gets the rule block of the given name after iterating the rule blocks. More... | |
virtual bool | hasRuleBlock (const std::string &name) const |
Indicates whether an rule block of the given name is in the rule blocks. More... | |
virtual RuleBlock * | removeRuleBlock (std::size_t index) |
Removes the rule block at the given index (without deleting it) and shifts the remaining rule blocks one position to the left. More... | |
virtual RuleBlock * | removeRuleBlock (const std::string &name) |
Removes the rule block of the given name (without deleting it) and shifts the remaining rule blocks one position to the left. More... | |
virtual std::size_t | numberOfRuleBlocks () const |
Returns the number of rule blocks added to the engine. More... | |
virtual const std::vector< RuleBlock * > & | ruleBlocks () const |
Returns an immutable vector of rule blocks. More... | |
virtual void | setRuleBlocks (const std::vector< RuleBlock *> &ruleBlocks) |
Sets the vector of rule blocks. More... | |
virtual std::vector< RuleBlock * > & | ruleBlocks () |
Returns a mutable vector of rule blocks. More... | |
Protected Member Functions | |
void | updateReferences () const |
The Engine class is the core class of the library as it groups the necessary components of a fuzzy logic controller.
enum fl::Engine::Type |
Enumerator | |
---|---|
Mamdani | Mamdani: When the output variables have IntegralDefuzzifiers. |
Larsen | Larsen: When Mamdani and AlgebraicProduct is the implication operator of the rule blocks. |
TakagiSugeno | TakagiSugeno: When output variables have WeightedDefuzzifiers of type TakagiSugeno and the output variables have Constant, Linear, or Function terms. |
Tsukamoto | Tsukamoto: When output variables have WeightedDefuzzifiers of type Tsukamoto and the output variables only have monotonic terms (Concave, Ramp, Sigmoid, SShape, and ZShape) |
InverseTsukamoto | InverseTsukamoto: When output variables have WeightedDefuzzifiers of type TakagiSugeno and the output variables do not only have Constant, Linear or Function terms. |
Hybrid | Hybrid: When output variables have different defuzzifiers. |
Unknown | Unknown: When output variables have no defuzzifiers. |
|
explicit |
fl::Engine::Engine | ( | const Engine & | other | ) |
|
virtual |
|
virtual |
Adds the input variable.
inputVariable | is the input variable |
|
virtual |
Adds the output variable.
outputVariable | is the output variable |
|
virtual |
Adds the rule block.
ruleBlock | is the rule block |
|
virtual |
Creates a clone of the engine.
|
virtual |
Computes the estimated complexity of operation of the engine.
|
virtual |
Configures the engine with the given operators.
conjunction | is a TNorm registered in the TNormFactory |
disjunction | is an SNorm registered in the SNormFactory |
implication | is an TNorm registered in the TNormFactory |
aggregation | is an SNorm registered in the SNormFactory |
defuzzifier | is a defuzzifier registered in the DefuzzifierFactory |
activation | is an activation method registered in the ActivationFactory |
|
virtual |
Configures the engine with clones of the given object operators, taking ownership of the objects.
conjunction | is the operator to process the propositions joined by and in the antecedent of the rules |
disjunction | is the operator to process the propositions joined by or in the antecedent of the rules |
implication | is the operator to modify the consequents of the rules based on the activation degree of the antecedents of the rules |
aggregation | is the operator to aggregate the resulting implications of the rules |
defuzzifier | is the operator to transform the aggregated implications into a single scalar value |
activation | is the activation method to activate and fire the rule blocks |
|
virtual |
Gets the description of the engine.
|
virtual |
Gets the input variable at the given index.
index | is the given index |
|
virtual |
Gets the input variable of the given name after iterating the input variables.
The cost of this method is O(n), where n is the number of input variables in the engine. For performance, please get the variables by index.
name | is the name of the input variable |
fl::Exception | if there is no variable with the given name |
|
virtual |
Gets the name of the engine.
|
virtual |
Gets the value of the given output variable.
The cost of this method is O(n), where n is the number of output variables in the engine. For performance, please get the variables by index.
name | is the name of the output variable |
|
virtual |
Gets the output variable at the given index.
index | is the given index |
|
virtual |
Gets the output variable of the given name after iterating the output variables.
The cost of this method is O(n), where n is the number of output variables in the engine. For performance, please get the variables by index.
name | is the name of the output variable |
fl::Exception | if there is no variable with the given name |
|
virtual |
Gets the rule block at the given index.
index | is the given index |
|
virtual |
Gets the rule block of the given name after iterating the rule blocks.
The cost of this method is O(n), where n is the number of rule blocks in the engine. For performance, please get the rule blocks by index.
name | is the name of the rule block |
fl::Exception | if there is no block with the given name |
|
virtual |
Indicates whether an input variable of the given name is in the input variables.
name | is the name of the input variable |
|
virtual |
Indicates whether an output variable of the given name is in the output variables.
name | is the name of the output variable |
|
virtual |
Indicates whether an rule block of the given name is in the rule blocks.
name | is the name of the rule block |
|
virtual |
Returns an immutable vector of input variables.
|
virtual |
Returns a mutable vector of input variables.
|
virtual |
Inserts the input variable at the given index, shifting other variables one position to the right.
inputVariable | is the input variable to insert |
index | is the index at which the input variable is to be inserted |
|
virtual |
Inserts the output variable at the given index, shifting other variables one position to the right.
outputVariable | is the output variable to insert |
index | is the index at which the output variable is to be inserted |
|
virtual |
Inserts the rule block at the given index, shifting other blocks one position to the right.
ruleBlock | is the rule block to insert |
index | is the index at which the rule block is to be inserted |
|
virtual |
Indicates whether the engine has been configured correctly and is ready for operation.
In more advanced engines, the result of this method should be taken as a suggestion and not as a prerequisite to operate the engine.
status | (if not null) contains the configuration errors of the engine |
|
virtual |
Returns the number of input variables added to the engine.
|
virtual |
Returns the number of output variables added to the engine.
|
virtual |
Returns the number of rule blocks added to the engine.
|
virtual |
Returns an immutable vector of output variables.
|
virtual |
Returns a mutable vector of output variables.
|
virtual |
Processes the engine in its current state as follows: (a) Clears the aggregated fuzzy output variables, (b) Activates the rule blocks, and (c) Defuzzifies the output variables.
|
virtual |
Removes the input variable at the given index (without deleting it) and shifts the remaining input variables one position to the left.
index | is the given index |
|
virtual |
Removes the input variable of the given name (without deleting it) and shifts the remaining input variables one position to the left.
name | is the name of the input variable |
fl::Exception | if there is no variable with the given name |
|
virtual |
Removes the output variable at the given index (without deleting it) and shifts the remaining output variables one position to the left.
index | is the given index |
|
virtual |
Removes the output variable of the given name (without deleting it) and shifts the remaining output variables one position to the left.
name | is the name of the output variable |
fl::Exception | if there is no variable with the given name |
|
virtual |
Removes the rule block at the given index (without deleting it) and shifts the remaining rule blocks one position to the left.
index | is the given index |
|
virtual |
Removes the rule block of the given name (without deleting it) and shifts the remaining rule blocks one position to the left.
name | is the name of the rule block |
fl::Exception | if there is no rule block with the given name |
|
virtual |
Restarts the engine by setting the values of the input variables to fl::nan and clearing the output variables.
|
virtual |
Returns an immutable vector of rule blocks.
|
virtual |
Returns a mutable vector of rule blocks.
|
virtual |
Sets the description of the engine.
description | is the description of the engine |
|
virtual |
Sets the value of the given input variable.
The cost of this method is O(n), where n is the number of input variables in the engine. For performance, please get the variables by index.
name | is the name of the input variable |
value | is the value for the input variable |
|
virtual |
Sets the input variable at the given index.
inputVariable | is the input variable to set |
index | is the index at which the input variable is to be stored |
|
virtual |
Sets the vector of input variables.
inputVariables | is the vector of input variables |
|
virtual |
Sets the name of the engine.
name | is the name of the engine |
|
virtual |
Sets the output variable at the given index.
outputVariable | is the output variable to set |
index | is the index at which the output variable is to be stored |
|
virtual |
Sets the vector of output variables.
outputVariables | is the vector of output variables |
Sets the rule block at the given index.
ruleBlock | is the rule block to set |
index | is the index at which the rule block is to be stored |
|
virtual |
Sets the vector of rule blocks.
ruleBlocks | is the vector of rule blocks |
|
virtual |
Returns a string representation of the engine in the FuzzyLite Language.
|
virtual |
Infers the type of the engine based on its current configuration.
name | stores a string representation of the engine type (if the pointer passed is not fl::null ) |
reason | stores a string representation explaining the reasons for the inferred type (if the pointer passed is not fl::null ) |
|
protected |
|
virtual |
Returns a vector that contains the input variables followed by the output variables in the order of insertion.