Fuzzy Logic Tools  v1.0.5.1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
FLT::Rule Class Reference

This class contains methods and attributes common to fuzzy Rules. More...

#include <rule.hpp>

Collaboration diagram for FLT::Rule:
Collaboration graph
[legend]

Public Member Functions

size_t n_inputs (void) const
 Extract the number of inputs of the Rule.
 
int test (void) const
 This function checks the parameters of all Membership functions in the Rule, and corrects them if possible. More...
 
int changeTSK (double value, size_t input)
 Changes a parameter in the TSK consequent. More...
 
void changeTSK (const double *const TSK)
 Changes the TSK consequent.
 
double readTSK (size_t input) const
 Reads a TSK parameter. More...
 
TNT::Array1D< double > readTSK (void) const
 Reads the TSK consequent.
 
MembershipreadFunction (size_t input)
 Extracts a pointer to a Membership function. More...
 
int changeFunction (const Membership &P, size_t input)
 Changes a Membership function of the Rule. More...
 
int changeFunction (TYPE_MF type, size_t input)
 Changes the type af a Membership function. More...
 
void initialize (size_t in)
 Initializes the Rule for in inputs. More...
 
size_t NumberOfAntecedents (void)
 Gets the number of parameters stored in the antecedents of the Rule. More...
 
int setAntecedents (const double *const parameters)
 Sets the parameters of the antecedents of the Rule. More...
 
TNT::Array1D< double > getAntecedents (void)
 Gets the parameters of the antecedents of the Rule.
 
void setConsequents (const double *const parameters)
 Sets the consequents of the Rule.
 
TNT::Array1D< double > getConsequents (void)
 Gets the consequents of the Rule.
 
double activation (const double *const point, double *dW=NULL) const
 Calculates the matching degree of the rule in point and, optionally, its derivative. More...
 
Ruleoperator= (const Rule &R)
 
 Rule (const Rule &R)
 
 Rule (size_t in)
 

Private Member Functions

void clean (void)
 Cleans the dynamic memory.
 

Private Attributes

size_t in
 Number of inputs of the Rule.
 
double * TSK
 TSK consequent of the Rule.
 
Membership ** membership
 Membership functions of the Rule.
 

Detailed Description

This class contains methods and attributes common to fuzzy Rules.

This class stores a completely general Takagi-Sugeno Rule.

See also
You can use the Anymf Membership function to remove a variable from the antecedent of a Rule.
For Template Numerical Toolkit (TNT) documentation see http://math.nist.gov/tnt
Examples:
matlab_utilities/fuz2mat.cpp, matlab_utilities/fuzcomb.cpp, and matlab_utilities/mat2fuz.cpp.

Member Function Documentation

double Rule::activation ( const double *const  point,
double *  dW = NULL 
) const

Calculates the matching degree of the rule in point and, optionally, its derivative.

Optionally, this function also calculates the derivative of the degree of activation of the rule with respect to the input at point.
dW represents $dW / dX$, and its length is equal to the number of entries in the rule.

The length of point must match the number of inputs in the rule.

int Rule::changeFunction ( const Membership P,
size_t  input 
)

Changes a Membership function of the Rule.

Returns
Returns 0 if no errors occurred.
An error means the input is greater than the number of Rule inputs.
Examples:
matlab_utilities/fuzcomb.cpp.
int Rule::changeFunction ( TYPE_MF  type,
size_t  input 
)

Changes the type af a Membership function.

Returns
Returns 0 if no errors occurred.
An error means the type of Membership function is not recognized (1) or input is greater than the number of Rule inputs (2).
Note
The parameters of the new Membership function are not assigned, you must do so by Membership::edit method.
int Rule::changeTSK ( double  value,
size_t  input 
)

Changes a parameter in the TSK consequent.

Returns
Returns 0 if no errors occurred.
An error means the input is greater than the number of parameter of the consequent.
Note
TSK(0) is the affine term, TSK(1) is the term associated to the 1st input variable, ...
Examples:
matlab_utilities/fuzcomb.cpp.
void Rule::initialize ( size_t  in)

Initializes the Rule for in inputs.

Empty membership functions are used. You can change them with changeFunction method or using the Membership class methods.

size_t Rule::NumberOfAntecedents ( void  )

Gets the number of parameters stored in the antecedents of the Rule.

Note
The function NumberOfConsequents(void) is not necessary because this value is in+1.
Examples:
matlab_utilities/mat2fuz.cpp.
Membership * Rule::readFunction ( size_t  input)

Extracts a pointer to a Membership function.

Returns
Returns NULL if the input is greater than the number of Rule inputs.
Examples:
matlab_utilities/fuzcomb.cpp.
double Rule::readTSK ( size_t  input) const

Reads a TSK parameter.

Returns
Returns the selected parameter. If input is greater than the number of Rule inputs, an error is sent to the standard error stream and return 0.
Examples:
matlab_utilities/fuzcomb.cpp.
int Rule::setAntecedents ( const double *const  parameters)

Sets the parameters of the antecedents of the Rule.

Returns
Returns the result of running the Rule::test() method.
Examples:
matlab_utilities/mat2fuz.cpp.
int Rule::test ( void  ) const

This function checks the parameters of all Membership functions in the Rule, and corrects them if possible.

Returns
Returns 0 if no errors, 1 if an error occurs, and -1 if the parameters were corrected.

The documentation for this class was generated from the following files: