Fuzzy Logic Tools
v1.0.5.1
|
Fuzzy Logic Tools (FLT) namespace. More...
Classes | |
class | Anymf |
Any Membership function. More... | |
class | Constmf |
Constant Membership function. More... | |
class | Gauss2mf |
Double gaussian Membership function. More... | |
class | Gaussmf |
Gaussian Membership function. More... | |
class | GBellmf |
Bell Membership function. More... | |
class | Membership |
This class contains methods and attributes common to all Membership functions. More... | |
class | Pimf |
Pi (S-Z) Membership function. More... | |
class | PSigmf |
Product of sigmoidals Membership function. More... | |
class | Rule |
This class contains methods and attributes common to fuzzy Rules. More... | |
class | Sig2mf |
Difference of sigmoidals Membership function. More... | |
class | Sigmf |
Sigmoidal Membership function. More... | |
class | Smf |
S Membership function. More... | |
class | System |
This class contains methods and attributes common to fuzzy Systems. More... | |
class | Trapmf |
Trapezoidal Membership function. More... | |
class | Trimf |
Triangular Membership function. More... | |
class | Zmf |
Z Membership function. More... | |
Enumerations | |
enum | TYPE_MF { ANYMF = 0, CONSTMF, GAUSSMF, GAUSS2MF, GBELLMF, PIMF, PSIGMF, SMF, SIGMF, SIG2MF, TRAPMF, TRIMF, ZMF } |
Enumeration with the implemented Membership functions. More... | |
Functions | |
TNT::Array2D< double > | jacobian (System &S, const double *const x, const double *const u, TNT::Array2D< double > &B, TNT::Array1D< double > &F) |
Computes the open-loop jacobian matrix in x for the Plant S . More... | |
TNT::Array2D< double > | jacobian (System &S, System &C, const double *const x) |
Computes the closed-loop jacobian matrix in x for the Plant S and the Controller C . More... | |
TNT::Array2D< double > | jacobianAprox (System &S, System &C, const double *const x, double h=0.001) |
Computes the approximation of the closed-loop jacobian matrix in x for the Plant S and the Controller C using finite differences with a step h . More... | |
TNT::Array2D< double > | jacobianAprox (System &S, const double *const x, const double *const u, TNT::Array2D< double > &B, TNT::Array1D< double > &F, double h=0.001) |
Computes the approximation of the open-loop jacobian matrix in x for the Plant S using finite differences with a step h . More... | |
double | derconseq (System &S, double *x, size_t output, size_t rule, size_t parameter, int &error) |
Obtains the derivative of a fuzzy model with respect to a consequent. More... | |
TNT::Array2D< double > | derconseq (System &S, double *x) |
Obtains the jacobian matrix of a fuzzy model with respect to its consequents. More... | |
TNT::Array2D< double > | deraffine (System &S, double *x) |
Obtains the jacobian matrix of a fuzzy model with respect to its affine consequents. More... | |
double | derantec (System &S, double *x, size_t input, size_t output, size_t rule, size_t parameter, int &error) |
Obtains the derivative of a fuzzy model with respect to a parameter of an antecedent. More... | |
TNT::Array2D< double > | derantec (System &S, double *x) |
Obtains the jacobian matrix of a fuzzy model with respect to its antecedents. More... | |
TNT::Array2D< double > | derfuzzy (System &S, double *x) |
Obtains the jacobian matrix of a fuzzy model with respect to all of its parameters. More... | |
TNT::Array2D< double > | derCLFSconseq (System &P, System &C, const double *const x) |
Obtains the jacobian matrix of a Closed Loop Fuzzy System (CLFS) with respect to the consequents of the fuzzy controller This implementation does not provide for the inclusion of the control signal in the antecedents of the plant. More... | |
TNT::Array1D< double > | KalmanAntec (System &Model, TNT::Array1D< double > &input, TNT::Array1D< double > &output, TNT::Array2D< double > &covariance, TNT::Array2D< double > &P, TNT::Array2D< double > &Phi) |
Computes antecedets adjust by the discrete extended Kalman filter. More... | |
TNT::Array1D< double > | KalmanAntec (System &Model, TNT::Array1D< double > &input, TNT::Array1D< double > &output, TNT::Array2D< double > &covariance, TNT::Array2D< double > &P) |
Computes antecedets adjust by the discrete extended Kalman filter where Phi is assumed to be the identity matrix. More... | |
TNT::Array1D< double > | KalmanConseq (System &Model, TNT::Array1D< double > &input, TNT::Array1D< double > &output, TNT::Array2D< double > &covariance, TNT::Array2D< double > &P, TNT::Array2D< double > &Phi) |
Computes consequents adjust by the discrete extended Kalman filter. More... | |
TNT::Array1D< double > | KalmanConseq (System &Model, TNT::Array1D< double > &input, TNT::Array1D< double > &output, TNT::Array2D< double > &covariance, TNT::Array2D< double > &P) |
Computes consequents adjust by the discrete extended Kalman filter where Phi is assumed to be the identity matrix. More... | |
TNT::Array1D< double > | KalmanFuz (System &Model, TNT::Array1D< double > &input, TNT::Array1D< double > &output, TNT::Array2D< double > &covariance, TNT::Array2D< double > &P, TNT::Array2D< double > &Phi) |
Computes the simultaneous adjustment of antecedets and consequents by the discrete extended Kalman filter. More... | |
TNT::Array1D< double > | KalmanFuz (System &Model, TNT::Array1D< double > &input, TNT::Array1D< double > &output, TNT::Array2D< double > &covariance, TNT::Array2D< double > &P) |
Computes the simultaneous adjustment of antecedets and consequents by the discrete extended Kalman filter where Phi is assumed to be the identity matrix. More... | |
int | sign (double x) |
Implementation of the sign function. More... | |
Membership * | createMF (TYPE_MF t) |
Virtual constructor for Membership functions. More... | |
int | System2TXT (System &S, const char *file) |
Saves the fuzzy System S in a text file. More... | |
System | TXT2System (const char *file) |
Reads a fuzzy System from a text file. More... | |
int | printSystem (const char *file, System &S, char *inputs[]=NULL, char *outputs[]=NULL, int accuracy=10) |
Writes a fuzzy system in its linguistic form. More... | |
TNT::Array1D< double > | evaluate (const double *const point, System &S, System &C) |
Evaluates a closed loop fuzzy system in the given point . More... | |
System | initialController (System &Plant) |
Creates a fuzzy Controller from a given plant. More... | |
System | subSystem (System &S, size_t nrules, size_t *outputs, size_t *rules) |
Extracts a subsystem from a fuzzy System. More... | |
TNT::Array2D< double > | extractPoints (System &S, unsigned int numMeshPoints=5, double precision=1E-3, bool addMesh=false, bool onlyStatePoints=true) |
Extracts the representative points of a fuzzy system. More... | |
void | col2row_major (const double *const colM, double *rowM, size_t num_rows, size_t num_cols) |
Converts a column-major matrix in a row-major one. More... | |
TNT::Array2D< double > | col2row_major (const double *const colM, size_t num_rows, size_t num_cols) |
Converts a column-major matrix in a row-major one. More... | |
void | row2col_major (const double *const rowM, double *colM, size_t num_rows, size_t num_cols) |
Converts a row-major matrix in a column-major one. More... | |
int | readModel (const mxArray *model, System &S) |
Reads a Fuzzy Model (TXT, FIS file or FIS variable) More... | |
int | FIS2System (const mxArray *FIS, System &S) |
Reads the Fuzzy Model from a FIS variable. More... | |
int | System2FIS (System &S, mxArray *FIS) |
Writes the Fuzzy Model in a FIS variable. More... | |
Variables | |
static const char * | MF_NAMES [] |
Names of the Membership functions. More... | |
static const size_t | MF_PARAM_NUMBER [] |
Initial number of parameters of each Membership function in FLT::TYPE_MF. More... | |
Fuzzy Logic Tools (FLT) namespace.
enum FLT::TYPE_MF |
Enumeration with the implemented Membership functions.
FLT::TYPE_MF is used to determinate the Membership function type, FLT::MF_NAMES are the names of the Membership functions, and FLT::MF_PARAM_NUMBER are the initial number of parameters of the Membership functions.
Enumerator | |
---|---|
ANYMF |
Any Membership function (FLT::Anymf). |
CONSTMF |
Constant Membership function (FLT::Constmf). |
GAUSSMF |
Gaussian Membership function (FLT::Gaussmf). |
GAUSS2MF |
Double gaussian Membership function (FLT::Gauss2mf). |
GBELLMF |
Bell Membership function (FLT::GBellmf). |
PIMF |
Pi (S-Z) Membership function (FLT::Pimf). |
PSIGMF |
Product of sigmoidals Membership function (FLT::PSigmf). |
SMF |
S Membership function (FLT::Smf). |
SIGMF |
Sigmoidal Membership function (FLT::Sigmf). |
SIG2MF |
Difference of sigmoidals Membership function (FLT::Sig2mf). |
TRAPMF |
Trapezoidal Membership function (FLT::Trapmf). |
TRIMF |
Triangular Membership function (FLT::Trimf). |
ZMF |
Z Membership function (FLT::Zmf). |
|
inline |
Converts a column-major matrix in a row-major one.
MATLAB© uses column-major matrices, but C uses row-major.
|
inline |
Converts a column-major matrix in a row-major one.
MATLAB© uses column-major matrices, but C uses row-major.
Membership * FLT::createMF | ( | TYPE_MF | t | ) |
Virtual constructor for Membership functions.
This function create and return a Membership function of the selected type.
TNT::Array2D< double > FLT::deraffine | ( | System & | S, |
double * | x | ||
) |
Obtains the jacobian matrix of a fuzzy model with respect to its affine consequents.
double FLT::derantec | ( | System & | S, |
double * | x, | ||
size_t | input, | ||
size_t | output, | ||
size_t | rule, | ||
size_t | parameter, | ||
int & | error | ||
) |
Obtains the derivative of a fuzzy model with respect to a parameter of an antecedent.
It is assumed that the output of the system is the same as the parameter, otherwise it should be considered derivative equal to 0.
output
, rule
or parameter
are out of System limits, the function returns 0 and error
= 1. TNT::Array2D< double > FLT::derantec | ( | System & | S, |
double * | x | ||
) |
Obtains the jacobian matrix of a fuzzy model with respect to its antecedents.
TNT::Array2D<double> FLT::derCLFSconseq | ( | System & | P, |
System & | C, | ||
const double *const | x | ||
) |
Obtains the jacobian matrix of a Closed Loop Fuzzy System (CLFS) with respect to the consequents of the fuzzy controller This implementation does not provide for the inclusion of the control signal in the antecedents of the plant.
double FLT::derconseq | ( | System & | S, |
double * | x, | ||
size_t | output, | ||
size_t | rule, | ||
size_t | parameter, | ||
int & | error | ||
) |
Obtains the derivative of a fuzzy model with respect to a consequent.
It is assumed that the output of the system is the same as the parameter, otherwise it should be considered derivative equal to 0.
output
, rule
or parameter
are out of System limits, the function returns 0 and error
= 1. TNT::Array2D< double > FLT::derconseq | ( | System & | S, |
double * | x | ||
) |
Obtains the jacobian matrix of a fuzzy model with respect to its consequents.
TNT::Array2D< double > FLT::derfuzzy | ( | System & | S, |
double * | x | ||
) |
Obtains the jacobian matrix of a fuzzy model with respect to all of its parameters.
Evaluates a closed loop fuzzy system in the given point
.
S
is the plant and C
is a fuzzy controller.
Array2D< double > FLT::extractPoints | ( | System & | S, |
unsigned int | numMeshPoints = 5 , |
||
double | precision = 1E-3 , |
||
bool | addMesh = false , |
||
bool | onlyStatePoints = true |
||
) |
Extracts the representative points of a fuzzy system.
S | Is a fuzzy System. |
numMeshPoints | Is used in Memberships functions without significative points, like ANYMF, CONSTMF, SMF, ... |
precision | Is used to remove similar points. |
addMesh | If addMesh is true, a mesh of numMeshPoints for each dimmension will be added to System points. |
onlyStatePoints | If onlyStatePoints is true, this function only extracts the state vector points, not the control vector points. |
int FLT::FIS2System | ( | const mxArray * | FIS, |
System & | S | ||
) |
Reads the Fuzzy Model from a FIS variable.
Returns 0 if no errors.
Creates a fuzzy Controller from a given plant.
The fuzzy controller will have all the rules that the plant owns in each of its outputs.
Consequents all initialized to 0.
Array2D< double > FLT::jacobian | ( | System & | S, |
const double *const | x, | ||
const double *const | u, | ||
TNT::Array2D< double > & | B, | ||
TNT::Array1D< double > & | F | ||
) |
Computes the open-loop jacobian matrix in x
for the Plant S
.
Obtains the linearization .
Computes the closed-loop jacobian matrix in x
for the Plant S
and the Controller C
.
TNT::Array2D< double > FLT::jacobianAprox | ( | System & | S, |
System & | C, | ||
const double *const | x, | ||
double | h = 0.001 |
||
) |
Computes the approximation of the closed-loop jacobian matrix in x
for the Plant S
and the Controller C
using finite differences with a step h
.
TNT::Array2D< double > FLT::jacobianAprox | ( | System & | S, |
const double *const | x, | ||
const double *const | u, | ||
TNT::Array2D< double > & | B, | ||
TNT::Array1D< double > & | F, | ||
double | h = 0.001 |
||
) |
Computes the approximation of the open-loop jacobian matrix in x
for the Plant S
using finite differences with a step h
.
Obtains the linearization .
TNT::Array1D< double > FLT::KalmanAntec | ( | System & | Model, |
TNT::Array1D< double > & | input, | ||
TNT::Array1D< double > & | output, | ||
TNT::Array2D< double > & | covariance, | ||
TNT::Array2D< double > & | P, | ||
TNT::Array2D< double > & | Phi | ||
) |
Computes antecedets adjust by the discrete extended Kalman filter.
Model | Is the fuzzy system whose antecedents will be adjusted. |
input | Is the input applied to the system in the current iteration. |
output | Is the real output of the system in the current iteration. |
covariance | Is the noise covariance matrix estimated from the hope operator. |
P | Is the covariance matrix of the filter. |
Phi | Is the Jacobian matrix that relates the parameters to be set with the following value of these parameters. Usually this will be an identity matrix of appropriate dimensions. |
Model and P will be changed according to the Kalman discrete filte algorithm.
TNT::Array1D< double > FLT::KalmanAntec | ( | System & | Model, |
TNT::Array1D< double > & | input, | ||
TNT::Array1D< double > & | output, | ||
TNT::Array2D< double > & | covariance, | ||
TNT::Array2D< double > & | P | ||
) |
Computes antecedets adjust by the discrete extended Kalman filter where Phi is assumed to be the identity matrix.
Model | Is the fuzzy system whose antecedents will be adjusted. |
input | Is the input applied to the system in the current iteration. |
output | Is the real output of the system in the current iteration. |
covariance | Is the noise covariance matrix estimated from the hope operator. |
P | Is the covariance matrix of the filter. |
Model and P will be changed according to the Kalman discrete filte algorithm.
TNT::Array1D< double > FLT::KalmanConseq | ( | System & | Model, |
TNT::Array1D< double > & | input, | ||
TNT::Array1D< double > & | output, | ||
TNT::Array2D< double > & | covariance, | ||
TNT::Array2D< double > & | P, | ||
TNT::Array2D< double > & | Phi | ||
) |
Computes consequents adjust by the discrete extended Kalman filter.
Model | Is the fuzzy system whose consequents will be adjusted. |
input | Is the input applied to the system in the current iteration (current State vector, x(k)). |
output | Is the real output of the system in the current iteration. |
covariance | Is the noise covariance matrix estimated from the hope operator. |
P | Is the covariance matrix of the filter. |
Phi | Is the Jacobian matrix that relates the parameters to be set with the following value of these parameters. Usually this will be an identity matrix of appropriate dimensions. |
Model and P will be changed according to the Kalman discrete filte algorithm.
TNT::Array1D< double > FLT::KalmanConseq | ( | System & | Model, |
TNT::Array1D< double > & | input, | ||
TNT::Array1D< double > & | output, | ||
TNT::Array2D< double > & | covariance, | ||
TNT::Array2D< double > & | P | ||
) |
Computes consequents adjust by the discrete extended Kalman filter where Phi is assumed to be the identity matrix.
Model | Is the fuzzy system whose consequents will be adjusted. |
input | Is the input applied to the system in the current iteration (current State vector, x(k)). |
output | Is the real output of the system in the current iteration. |
covariance | Is the noise covariance matrix estimated from the hope operator. |
P | Is the covariance matrix of the filter. |
Model and P will be changed according to the Kalman discrete filte algorithm.
TNT::Array1D< double > FLT::KalmanFuz | ( | System & | Model, |
TNT::Array1D< double > & | input, | ||
TNT::Array1D< double > & | output, | ||
TNT::Array2D< double > & | covariance, | ||
TNT::Array2D< double > & | P, | ||
TNT::Array2D< double > & | Phi | ||
) |
Computes the simultaneous adjustment of antecedets and consequents by the discrete extended Kalman filter.
Model | Is the fuzzy system whose parameters will be adjusted. |
input | Is the input applied to the system in the current iteration. |
output | Is the real output of the system in the current iteration. |
covariance | Is the noise covariance matrix estimated from the hope operator. |
P | Is the covariance matrix of the filter. |
Phi | Is the Jacobian matrix that relates the parameters to be set with the following value of these parameters. Usually this will be an identity matrix of appropriate dimensions. |
Model and P will be changed according to the Kalman discrete filte algorithm.
TNT::Array1D< double > FLT::KalmanFuz | ( | System & | Model, |
TNT::Array1D< double > & | input, | ||
TNT::Array1D< double > & | output, | ||
TNT::Array2D< double > & | covariance, | ||
TNT::Array2D< double > & | P | ||
) |
Computes the simultaneous adjustment of antecedets and consequents by the discrete extended Kalman filter where Phi is assumed to be the identity matrix.
Model | Is the fuzzy system whose parameters will be adjusted. |
input | Is the input applied to the system in the current iteration. |
output | Is the real output of the system in the current iteration. |
covariance | Is the noise covariance matrix estimated from the hope operator. |
P | Is the covariance matrix of the filter. |
Model and P will be changed according to the Kalman discrete filte algorithm.
int FLT::printSystem | ( | const char * | file, |
System & | S, | ||
char * | inputs[] = NULL , |
||
char * | outputs[] = NULL , |
||
int | accuracy = 10 |
||
) |
Writes a fuzzy system in its linguistic form.
"IF temperature is high and pressure is ... THEN valve is ..."
You can specify the name of the variables and the number of decimals that will be used to represent the system.
int FLT::readModel | ( | const mxArray * | model, |
System & | S | ||
) |
Reads a Fuzzy Model (TXT, FIS file or FIS variable)
Returns 0 if no errors.
|
inline |
Converts a row-major matrix in a column-major one.
MATLAB© uses column-major matrices, but C uses row-major.
|
inline |
Implementation of the sign function.
Extracts a subsystem from a fuzzy System.
int FLT::System2FIS | ( | System & | S, |
mxArray * | FIS | ||
) |
Writes the Fuzzy Model in a FIS variable.
Returns 0 if no errors.
int FLT::System2TXT | ( | System & | S, |
const char * | file | ||
) |
Saves the fuzzy System S
in a text file.
System FLT::TXT2System | ( | const char * | file | ) |
Reads a fuzzy System from a text file.
'Number of inputs' 'Number of outputs'
'Number of rules for the 1st ouput' 'Number of rules for the 2nd ouput'
...'Type membership function' 'Parameters separated by spaces'
'Affine term'
and for each input 'consequents terms separated by spaces'
'lower limit for input 1' 'upper limit for input 1'
'lower limit for input 2' 'upper limit for input 2'
'lower limit for output 1' 'upper limit for output 1'
'lower limit for output 2' 'upper limit for output 2'
|
static |
Names of the Membership functions.
|
static |
Initial number of parameters of each Membership function in FLT::TYPE_MF.
num_params
function from Membership class.