Fuzzy Logic Tools  v1.0.5.1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
rule.hpp
Go to the documentation of this file.
1 /* Copyright (C) 2004-2015
2  ANTONIO JAVIER BARRAGAN, antonio.barragan@diesia.uhu.es
3  http://uhu.es/antonio.barragan
4 
5  Collaborators:
6  JOSE MANUEL ANDUJAR, andujar@diesia.uhu.es
7 
8  DPTO. DE ING. ELECTRONICA, DE SISTEMAS INFORMATICOS Y AUTOMATICA
9  ETSI, UNIVERSITY OF HUELVA (SPAIN)
10 
11  For more information, please contact with authors.
12 
13  This software is free software: you can redistribute it and/or modify
14  it under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  This software is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  GNU General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with this program. If not, see <http://www.gnu.org/licenses/>.
25 */
26 
27 #ifndef _RULE_HPP_
28 #define _RULE_HPP_
29 
37 #include <stdio.h>
38 
39 #include <flt/membership.hpp>
40 
41 namespace FLT // Use the FTL (Fuzzy Logic Tools) namespace
42 {
43 
53  class Rule
54  {
55  size_t in;
56  double *TSK;
58  inline void clean(void);
59  public:
60  size_t n_inputs(void) const;
61 
68  int test(void) const;
69 
78  int changeTSK(double value,
79  size_t input);
80 
84  void changeTSK(const double* const TSK);
85 
92  double readTSK(size_t input) const;
93 
97  TNT::Array1D<double> readTSK(void) const;
98 
104  Membership *readFunction(size_t input);
105 
112  int changeFunction(const Membership &P,
113  size_t input);
114 
125  int changeFunction(TYPE_MF type,
126  size_t input);
127 
134  void initialize(size_t in);
135 
141  size_t NumberOfAntecedents(void);
142 
148  int setAntecedents(const double *const parameters);
149 
153  TNT::Array1D<double> getAntecedents(void);
154 
158  void setConsequents(const double *const parameters);
159 
163  TNT::Array1D<double> getConsequents(void);
164 
174  double activation(const double * const point,
175  double *dW = NULL) const;
176 
177  Rule &operator=(const Rule &R);
178  Rule();
179  Rule(const Rule &R);
180  Rule(size_t in);
181  ~Rule();
182  };
183 } // FLT namespace
184 
185 #endif
int changeFunction(const Membership &P, size_t input)
Changes a Membership function of the Rule.
Definition: rule.cpp:88
TYPE_MF
Enumeration with the implemented Membership functions.
Definition: membership.hpp:117
size_t NumberOfAntecedents(void)
Gets the number of parameters stored in the antecedents of the Rule.
Definition: rule.cpp:121
Membership ** membership
Membership functions of the Rule.
Definition: rule.hpp:57
This class contains methods and attributes common to fuzzy Rules.
Definition: rule.hpp:53
TNT::Array1D< double > readTSK(void) const
Reads the TSK consequent.
Definition: rule.cpp:75
Membership * readFunction(size_t input)
Extracts a pointer to a Membership function.
Definition: rule.cpp:81
double activation(const double *const point, double *dW=NULL) const
Calculates the matching degree of the rule in point and, optionally, its derivative.
Definition: rule.cpp:180
Fuzzy Logic Tools (FLT) namespace.
Definition: derivatives.hpp:41
size_t n_inputs(void) const
Extract the number of inputs of the Rule.
Definition: rule.cpp:31
double * TSK
TSK consequent of the Rule.
Definition: rule.hpp:56
void clean(void)
Cleans the dynamic memory.
Definition: rule.cpp:9
int setAntecedents(const double *const parameters)
Sets the parameters of the antecedents of the Rule.
Definition: rule.cpp:131
Defines Membership functions.
int test(void) const
This function checks the parameters of all Membership functions in the Rule, and corrects them if pos...
Definition: rule.cpp:36
void initialize(size_t in)
Initializes the Rule for in inputs.
Definition: rule.cpp:110
TNT::Array1D< double > getConsequents(void)
Gets the consequents of the Rule.
Definition: rule.cpp:170
TNT::Array1D< double > getAntecedents(void)
Gets the parameters of the antecedents of the Rule.
Definition: rule.cpp:146
This class contains methods and attributes common to all Membership functions.
Definition: membership.hpp:198
size_t in
Number of inputs of the Rule.
Definition: rule.hpp:55
int changeTSK(double value, size_t input)
Changes a parameter in the TSK consequent.
Definition: rule.cpp:54
void setConsequents(const double *const parameters)
Sets the consequents of the Rule.
Definition: rule.cpp:162