## 3 Collaborative Knowledge-Based WSN Proposal
### Fuzzy Rule-Based System Adapted to a Sensor Node  
The knowledge-based sensor is based on the structure of the Mandani FRBS, which consists of the following components [3]:  
* A KB, which stores knowledge about the problem. The KB is composed of a Data Base (DB), which contains the linguistic term sets considered in the linguistic rules, and a fuzzy control Rule Base (RB), which comprises the collection of linguistic rules representing expert knowledge in the following form: IF X\({}_{1}\) is A\({}_{1}\) and... and X\({}_{\text{n}}\) is A\({}_{\text{n}}\) THEN Y is B, where X\({}_{\text{i}}\) are input variables, A\({}_{\text{i}}\) are fuzzy sets related to the input variables, Y is the output variable and B is a fuzzy set related to the output variable. * A fuzzy inference engine is composed of the following:
* A fuzzification interface, which transfers the values of the input variables into fuzzy information, assigning grades of membership to each fuzzy set defined for that variable;
* An inference system, which infers fuzzy actions by means of fuzzy implications and the rules of inference of fuzzy logic;
* A defuzzification interface, which yields a non-fuzzy control action from an inferred fuzzy control action. This interface aggregates the information provided by the output fuzzy sets to obtain an output value from them. Due to sensor constrains, we introduced several modifications to the structure of Mandani FRBS, and utilized technologies requiring the least computational burden in order to minimize computational cost and battery consumption. To reduce the computational burden, we propose the following:  
* An approach in which sensor nodes execute a small, but complete, FRBS;
* Only triangular or trapezoidal fuzzy sets be made available, which decreases the number of operations executed in the inference process;
* The input and output interfaces only admit linear conversions;
* A First Infer Then Aggregate (FITA) inference approach be used;
* Experts define the knowledge by means of linguistic labels, variables and rules, editing a KB in the computer. The KB is then translated into appropriate numerical values that are transmitted to the sensors. * The inference engine work with numerical values of variables, fuzzy sets and rules instead of linguistic labels. The translation of linguistic labels is executed in the computer, so the sensor nodes do not have to do this task;
* The number of fuzzy sets defined in each variable be small. Although there is not a direct relationship between the number of fuzzy sets defined in each variable and the inference time, an excessive number of fuzzy sets would involve a large number of rules, and as a consequence, the inference time would increase. To reduce the battery consumption and prolong the battery lifetime, we propose that:  
1. Sensors operate in a work cycle in which they first infer the output, and then are configured in a sleep mode;
2. Sensors only transmit remarkable outputs to their neighbors (e.g., when an inferred alert surpasses a threshold). Figure 1 shows the structure of a FRBS sensor that consists of a communication module, input and output interfaces with scaling functions, fuzzification and defuzzification interfaces, a KB and an adapted inference engine. The communication module mainly allows the sensor to update its KB and communicate the results of its inferences to other sensors. Other functions are described in Section 3.3. The input and output interfaces obtain and translate crisp values into the interval [0,1] using a linear conversion, and the fuzzification and defuzzification interfaces establish the correspondence between the normalized values of the variables and fuzzy sets defined on the universe of discourse. The KB, composed of data and rule bases, includes variable definitions, fuzzy sets defined for each variable and rules. After the variables are defined, fuzzy sets are associated to each variable. Each fuzzy set is defined by means of only four real numbers, enabling the system to utilize triangular or trapezoidal shapes.