{'fraction_non_alphanumeric': 0.03343455226773485, 'fraction_numerical': 0.011435585993022355, 'mean_word_length': 4.8255551373729775, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Implementation of a Fuzzy Logic Controller for the Irrigation of Rose Cultivation in Mexico

: The design and implementation of a fuzzy logic controller (FLC) are presented, offering a solution to improve the irrigation of rose crops. The objective is to reduce the water consumption and operative costs, taking advantage of intelligent controllers and environmental characteristics in a speciﬁc region. Considering that the main controllable variables that affect the growth of plants are relative humidity (RH) and temperature (T), in this study, these variables are used to create a system whose aim is to provide an adequate amount of water for a rose crop in the State of Mexico. The Mamdani method was used for the FLC design and the membership functions, while the area centroid was considered as the defuzziﬁcation strategy. After implementing the FLC proposal using a ﬁeld-programmable gate array (FPGA) in a domestic greenhouse, integrated by an array of [5 × 3] rose plants under natural restrictions, a reduction of 0.2 L per week with respect to the traditional manual irrigation system was found. The proposed design highlights the technological advantages of using a fuzzy logic-controlled irrigation system over traditional methods.


Introduction
According to the Servicio de Información Agroalimentaria y Pesquera (SIAP) [1] of Mexico in its 2019 yearbook of statistical production, the country produced nearly nine million gross of roses, the State of Mexico, Puebla, and Morelos being the leading producing states, with approximately 7.0, 0.6, and 0.5 million gross produced, respectively. However, despite these three states being the primary producers, their cultivation yield per harvested area is not the same due to the cultivation techniques and conditions available in each region. The states with the most efficient production are the State of Mexico, Querétaro, and Jalisco.
The experience of farmers with better yield, for example, from the State of Mexico, is required to improve the conditions for growing roses. The understanding of the area allows the creation and adjustment of the knowledge base (KB) for an irrigation system that considers natural climatic conditions suitable for cultivation, which can be achieved by implementing intelligent controls.
A fuzzy logic controller (FLC) is part of the intelligent control systems that are based in classic control and artificial intelligence. The FLC area is of special interest because of its applications in multidisciplinary fields. It facilitates the implementation of experts' technological knowledge into logical processes, which could be improved through new technologies according to their requirements.
To design an FLC, it is necessary to integrate a database of scientific and technological knowledge with information that defines the parameters and variables to be controlled in a system. This information must be provided by experts since without their knowledge, the correct operating ranges of a controller could not be defined. For example, in the health area, the knowledge of a medical expert is required to prescribe and supply any medicine based on the characteristics of the disease and the patient. In the case of an irrigation system, it is necessary to know the type of plant and the soil properties to manipulate the opening of valves for supplying water, nutrients, etc.
There are two approaches for creating an FLC, the Mamdani approach and the Takagi-Sugeno-Kang approach. The first is intuitive for its use of linguistic variables, while the second is a mathematical analysis. However, both require the stages of fuzzification and defuzzification [2,3]. Taking into consideration that the Mamdani approach allows the representation of scientific and technological knowledge as concepts instead of numerical values, it is best suited for the purposes of this work.
The fuzzy sets used in the FLC operate from the creation of membership functions (MF), representing the process information in a distributed form [4]. An MF helps obtain a defined output from a measured input, making it easier to obtain outputs by considering intervals rather than particular values.
The FLC is a general case of the application of fuzzy inferences represented by classic logical if-then statements. The creation of these inferences is known as fuzzification, and the set of logical sentences integrates the fuzzy rules set. They are commonly represented through elements of a mathematical matrix, considering the relationships between inputs and their corresponding outputs so that there is an output for each input within the defined intervals [5].
One way to positively impact other sectors with this technology is by implementing it in the water supply for irrigation fields or hydroponic growing systems. It benefits farmers who use water excessively, saving losses through filtration and evaporation [6]. Using alternative and novel technology in agricultural activities improves the crop development conditions and results in a more adequate use of natural resources, especially in cases where the production requires highly specific conditions, such as rose farming [7,8].
Based on the above, this work presents the design and implementation of an intelligent control focused on improving the irrigation conditions for cultivating roses using an FLC [9]. The aim is to take advantage of the farmers' experience with regional crops and the Mamdani approach properties, which permit the representation of expert and empirical knowledge through a description similar to human understanding [7].

Conditions for Growing Roses
The necessary conditions or variables of the experiment for the cultivation of roses are as follows: 1.
In production, the environmental temperature (T) is approximately 17-25 • C, with a minimum vegetative temperature close to 15 • C and a maximum of 32 • C.
RH ranges between 70-75% demand a higher light intensity since higher intensity results in higher yields. In summer months, when brighter and longer days prevail, flower production is greater when compared to winter crop output.

4.
During winter, it is recommended to raise (T), irradiate with artificial lighting (implementation of lamps), and install thermal blankets to preserve heat at night.
The main factors affecting rose production are climate fluctuations in (T) and (RH). On the one hand, a high level of (RH) combined with a low level of light favors and promotes fungi, pests, or malformations, such as crown galls, causing a decrease in the number Agriculture 2021, 11, 576 3 of 12 of sprouts and, therefore, of flowers. Furthermore, under these conditions, the plant's vegetative stage is complex, and the flowers acquire a less bright color.
Concerning T fluctuations, measurements above 40 • C and below 8 • C are lethal. There is a negative effect on growth when (T) rises above 30 • C, with the resulting flowers being small with fewer petals and pale in color. In contrast, temperatures below the recommended ones produce flowers with an excess of petals that may or may not bloom and alterations in anthocyanin production, which affects the flower pigmentation, giving them a reddish tone. Flower buds are favored from 14 • C, and the vegetation stops growing at 1 • C [10-12].

Evapotranspiration
The importance of creating an intelligent irrigation system lies in optimizing water use, especially for communities where this resource is scarce in certain seasons of the year and cultivation must continue. Climate is one of the fundamental aspects to estimate the amount of water needed. Researchers and technologists in this field have produced water demand formulas based on climatic data. This demand for water is known as evapotranspiration (ET 0 ) and depends on both the soil and the plant, as well as the climate. The water volume in liters that a plantation requires, according to García Blanco (2019) [13], is obtained from a relationship that involves the type and number of plants and the maximum (ET 0 ), among other factors, and can be summarized by Expression (1): where (Ca) is the amount of water required in liters (L) per day per plant or in millimeters (mm) of water height per day, S represents the area in square meters (m 2 ) of the plant leaf crown, (ET 0 ) is the evapotranspiration measured in millimeters (mm) of water height per day, (F) is the correction factor applied according to the type of plant, and (η) is the irrigation efficiency with a maximum value of 0.9, considering that plants only use 90% of the water as indicated in [13,14]. Taking into account the cultivation conditions and the (ET 0 ) in the following sections, the proposed FLC model is depicted, beginning by describing the parameters, variables, and values of the intelligent controller operation intervals, then the design of the inference rules set, and, finally, the FLC implementation in a field-programmable gate arrangement (FPGA) [15][16][17].

FLC Modeling
In the presented proposal, it is considered that, for optimal rose growth, a given water consumption is required according to the (ET 0 ) and (RH). The application presented focuses on small-scale cultivation, where wind speed and solar radiation are negligible [18].
Thermal phenomena play a fundamental role in the evaporation and precipitation of water, acting together to complete the hydrological cycle and causing evapotranspiration (ET 0 ), which is the amount of water from the soil that returns to the atmosphere due to the environmental (T) and (RH) of the plants. The irrigation that each plant needs depends on these values and, when applied to our particular case, opens and closes any given valve for proper irrigation control [19].
Measuring the experimental variables of (T) and (RH) using standardized sensors, each measurement is assigned a value on a scale from 0 to 255 decimal places for 8-bit digital circuits, with 0 being the value assigned to the minimum and 255 for the maximum measurement possible. For the cultivation of roses, (T) must be between 18 and 25 • C, while (RH) must be between 70 and 80%. With these values, it is possible to control the valve's position to supply an irrigation of approximately 3 × 10 3 mm of water height per day. Table 1 summarizes this data, which represent the operating limits of the variables.
In a basic Mamdani structure (as shown in Figure 1), the FLC consists of two processes: fuzzification and defuzzification, both with scaling stages, the set of inference rules, and the KB necessary to perform the operations and deliver the output results. valve's position to supply an irrigation of approximately 3 × 10 3 mm of water height per day. Table 1 summarizes this data, which represent the operating limits of the variables. In a basic Mamdani structure (as shown in Figure 1), the FLC consists of two processes: fuzzification and defuzzification, both with scaling stages, the set of inference rules, and the KB necessary to perform the operations and deliver the output results. The scaling corresponds to the assignment of decimal values shown in Table 1. In the rules of inference, for the inputs, the variables are of a linguistic type and are represented through the MF and with bounded values between 0 and 255, where 0 and 255 are null and maximum membership, respectively.
The expressions presented in (2) and (3) are the MF defined by intervals involving the errors of T (ErT) and errors of RH (ERH). These represent the difference between the required values and the ones measured. Expression (4) defines the time of irrigation (TIr) to be used in the defuzzification, where values a, b, c, and d are the vertex values of the MF in triangular and trapezoidal functions: Fsig (TIr) = {a, a = TIr; b, b = TIr; c, c = TIr} (4) where Ftria (ErT, a, b, c) is the triangular function for the error of temperature (ErT) variable, Ftrap (her, a, b, c, d) is the trapezoidal function of the relative humidity error (EHR), and Fsig (TIr) is the singleton function or single instance function that depends on the time of irrigation (TIr). The scaling corresponds to the assignment of decimal values shown in Table 1. In the rules of inference, for the inputs, the variables are of a linguistic type and are represented through the MF and with bounded values between 0 and 255, where 0 and 255 are null and maximum membership, respectively.
The expressions presented in (2) and (3) are the MF defined by intervals involving the errors of T (ErT) and errors of RH (ERH). These represent the difference between the required values and the ones measured. Expression (4) defines the time of irrigation (TIr) to be used in the defuzzification, where values a, b, c, and d are the vertex values of the MF in triangular and trapezoidal functions: Fsig (TIr) = {a, a = TIr; b, b = TIr; c, c = TIr} (4) where Ftria (ErT, a, b, c) is the triangular function for the error of temperature (ErT) variable, Ftrap (her, a, b, c, d) is the trapezoidal function of the relative humidity error (EHR), and Fsig (TIr) is the singleton function or single instance function that depends on the time of irrigation (TIr). The descriptors for each linguistic variable are defined from the available KB and the MF. The associate values are summarized in Table 2 and represented in graphic form in Figure 2, where the membership level given by the MF is associated with different measured bit values [0, 255]. Table 2. Values associated with the parameters of environmental temperature, relative humidity, and irrigation time, which define the membership functions for the rose cultivation fuzzy logic controller.   In the defuzzification stage, the fuzzy inputs of (T) and (RH) are related, obtaining the corresponding fuzzy value of (TIr) derived from the MF, and its nonfuzzy equivalent value is determined using the centroid of area (CoA) method, which is the most common [14]. In the defuzzification stage, the fuzzy inputs of (T) and (RH) are related, obtaining the corresponding fuzzy value of (TIr) derived from the MF, and its nonfuzzy equivalent value is determined using the centroid of area (CoA) method, which is the most common [14].
To calculate the corresponding CoA, Expression (5) is used, where (TI 0 ) is the centroid of the output variable; C1', C2', and C3' are the results of the MF; and TIr1 = {01 = 0}, TIr2 = {p1 = 50}, and TIr3 = {q1 = 100} are the singleton functions for each output: As part of the Mamdani structure, a minimum (min) and maximum (max) aggregation inference method is applied to the inference rules following an if-then structure, which is defined by a matrix of size M [5 × 3] . This inference method links the input and output sets: max {min {(MF inputs), (MF outputs)}}. In the following sections, a description of how to implement this structure is detailed.

FLC Implementation
The FLC implementation is through modules with routines for each process block. The hardware description language selected for the implementation is Verilog ® , transforming the modules into digital circuits that represent the embedded control in an FPGA.
An FPGA of the EP4CE series is considered to control the irrigation time. It requires the Intel Quartus Prime version 17 platform [20,21], and with this, the four subroutines represented in the blocks in Figure 3 are generated: temp_fuz, fuz_dhl, min15, and max_defuz.
As part of the Mamdani structure, a minimum (min) and maximum (max) aggregation inference method is applied to the inference rules following an if-then structure, which is defined by a matrix of size M [5 × 3]. This inference method links the input and output sets: max {min {(MF inputs), (MF outputs)}}. In the following sections, a description of how to implement this structure is detailed.

FLC Implementation
The FLC implementation is through modules with routines for each process block. The hardware description language selected for the implementation is Verilog ® , transforming the modules into digital circuits that represent the embedded control in an FPGA.
An FPGA of the EP4CE series is considered to control the irrigation time. It requires the Intel Quartus Prime version 17 platform [20,21], and with this, the four subroutines represented in the blocks in Figure 3 are generated: temp_fuz, fuz_dhl, min15, and max_defuz. Next, the fuzzy algorithm for each of the four modules is presented, describing the variables and the fuzzy inference rules used in its implementation.

Module I: temp_fuz
This first module defines the values in bits of the system input temperature (temp_in). Considering the equivalences of Table 1 and the MF of Figure 2, Figure 4 shows the algorithm that represents the possible values obtained, in the interval 0-255, for each temperature linguistic variable: cold (t1), cool (t2), normal (t3), warm (t4), and hot (t5).

Module II: fuz_dhl
In the same way as the first module, the second represents the (RH): the second entry for the FLC. In this case, the outputs are three fuzzy variables labeled as dry (t1), moist (t2), and wet (t3). Its representative algorithm and the assigned variable values are shown in Figure 5.

Module III: min15
The third module, named min15, focuses on the membership outputs and considers the above fuzzy (T) and (RH) variables. This module uses the fuzzy function min (μ(T),μ(RH),μ(TIr)) to relate both variables through a point-to-point product and, from that, creates the matrix called min_sets of size M[5 x 3]. The resulting matrix, shown in Figure 6, consists of a total of fifteen fuzzy rules. Next, the fuzzy algorithm for each of the four modules is presented, describing the variables and the fuzzy inference rules used in its implementation.

Module I: temp_fuz
This first module defines the values in bits of the system input temperature (temp_in). Considering the equivalences of Table 1 and the MF of Figure 2, Figure 4 shows the algorithm that represents the possible values obtained, in the interval 0-255, for each temperature linguistic variable: cold (t1), cool (t2), normal (t3), warm (t4), and hot (t5).

Module II: fuz_dhl
In the same way as the first module, the second represents the (RH): the second entry for the FLC. In this case, the outputs are three fuzzy variables labeled as dry (t1), moist (t2), and wet (t3). Its representative algorithm and the assigned variable values are shown in Figure 5.    Figure 5. Representation of the algorithm for the fuz_dhl module corresponding to relative humidity (RH) fuzzification.

Module III: min15
The third module, named min15, focuses on the membership outputs and considers the above fuzzy (T) and (RH) variables. This module uses the fuzzy function min (µ(T),µ(RH),µ(TIr)) to relate both variables through a point-to-point product and, from that, creates the matrix called min_sets of size M [5 × 3] . The resulting matrix, shown in Figure 6, consists of a total of fifteen fuzzy rules.    Figure 6. Matrix representation of the membership functions that relate, point to point, the variables of temperature and relative humidity.

Module IV: max_def
The last module for the FLC is the max_defuz module, and it considers the maximum operator (max) on the results of the minimum matrix presented in Figure 6 to create the complete rule base. Additionally, it considers the union operator to obtain the complete composition shown in Figure 7.

Module IV: max_def
The last module for the FLC is the max_defuz module, and it considers the maximum operator (max) on the results of the minimum matrix presented in Figure 6 to create the complete rule base. Additionally, it considers the union operator to obtain the complete composition shown in Figure 7.

FLC Implementation into an FPGA
To illustrate the implementation, Figure 8 shows the four modules mentioned above, connected to integrate the FLC into an FPGA. T (temp_in) and RH (wet_in), which are the input variables, and the fuzzy inferences are shown. The data then enters the transformation module and ends inside the defuzzification, determining if it is necessary to supply water.

Module IV: max_def
The last module for the FLC is the max_defuz module, and it considers the maximum operator (max) on the results of the minimum matrix presented in Figure 6 to create the complete rule base. Additionally, it considers the union operator to obtain the complete composition shown in Figure 7.

•
It is adaptable for any given plant, adjusting the parameters to the specific conditions required.

•
It is immune to noise variations since it is implemented in a single integrated circuit.
• It uses a system of two sensors to measure the temperature and relative humidity of the air, thereby saving resources by going from more complex irrigation systems to a simple one.
The FLC implementation results in a simple model suitable to improve the irrigation process due to its portable size. Figure 9 schematically shows how to implement the FLC into an FPGA using 24 V solenoid valves for the water supply in the cultivation arrangement proposed of size M [5 × 3] .
Granted that intelligent irrigation can be adapted to improve traditional irrigation processes, once implemented, the following advantages are presented: • It is adaptable for any given plant, adjusting the parameters to the specific conditions required.

•
It is immune to noise variations since it is implemented in a single integrated circuit. • It uses a system of two sensors to measure the temperature and relative humidity of the air, thereby saving resources by going from more complex irrigation systems to a simple one. The FLC implementation results in a simple model suitable to improve the irrigation process due to its portable size. Figure 9 schematically shows how to implement the FLC into an FPGA using 24 V solenoid valves for the water supply in the cultivation arrangement proposed of size M [5 × 3]. Currently, this proposal is being implemented for indoor rose cultivation, with plants arranged in a M [5 × 3] matrix, equivalent to 4.8 m 2 with a separation between plantings of 0.5 m, a soil surface at the root of 0.20 m, and a micro sprinkler type irrigation system. The rose planting distribution is represented in Figure 10, while Figure 11 shows the sprinkler valves for roses and the physical distribution plant columns with the implemented irrigation system.  Currently, this proposal is being implemented for indoor rose cultivation, with plants arranged in a M [5 × 3] matrix, equivalent to 4.8 m 2 with a separation between plantings of 0.5 m, a soil surface at the root of 0.20 m, and a micro sprinkler type irrigation system. The rose planting distribution is represented in Figure 10, while Figure 11 shows the sprinkler valves for roses and the physical distribution plant columns with the implemented irrigation system.
Granted that intelligent irrigation can be adapted to improve traditional irrigation processes, once implemented, the following advantages are presented: • It is adaptable for any given plant, adjusting the parameters to the specific conditions required.

•
It is immune to noise variations since it is implemented in a single integrated circuit. • It uses a system of two sensors to measure the temperature and relative humidity of the air, thereby saving resources by going from more complex irrigation systems to a simple one. The FLC implementation results in a simple model suitable to improve the irrigation process due to its portable size. Figure 9 schematically shows how to implement the FLC into an FPGA using 24 V solenoid valves for the water supply in the cultivation arrangement proposed of size M [5 × 3]. Currently, this proposal is being implemented for indoor rose cultivation, with plants arranged in a M [5 × 3] matrix, equivalent to 4.8 m 2 with a separation between plantings of 0.5 m, a soil surface at the root of 0.20 m, and a micro sprinkler type irrigation system. The rose planting distribution is represented in Figure 10, while Figure 11 shows the sprinkler valves for roses and the physical distribution plant columns with the implemented irrigation system.  In the arrangement of plants from Figure 10, before the implementation of the FLC, the rose crop required a weekly water flow of 15.2 L in the months from June to October, this period being the one with the highest water consumption, while during November to May, the amount of water required was 7.7 L. This data corresponds to a water supply per week for the complete arrangement under weather conditions in the State of Mexico.
After embedding the proposed controller in an Altera generation V card and implementing it in rose cultivation, the water consumed during the months of highest consumption was reduced to 15 L, while for the rest of the year, the required water flow was 7.5 L, thus achieving, on average, a reduction in water consumption of 0.2 L each week. this period being the one with the highest water consumption, while during November to May, the amount of water required was 7.7 L. This data corresponds to a water supply per week for the complete arrangement under weather conditions in the State of Mexico.
After embedding the proposed controller in an Altera generation V card and implementing it in rose cultivation, the water consumed during the months of highest consumption was reduced to 15 L, while for the rest of the year, the required water flow was 7.5 L, thus achieving, on average, a reduction in water consumption of 0.2 L each week.
(a) (b) Figure 11. Implementation of an irrigation system: (a) Micro sprinkler irrigation system for a M[5 × 3] rose matrix module with 5 rows; (b) matrix module columns of the roses' distribution.

Discussion
In this article, an irrigation process was proposed to accompany traditional irrigation through an FLC implemented in an FPGA to optimize water consumption. This represents an advantage for floriculture in Mexico. However, it must be noted that the FLC developed in this work is a tool designed for a specific plant (roses) and a specific region (State of Mexico). Seeing as how each type of plant has different requirements depending on the geographical region and the prevailing climatic conditions throughout the year, the research presented is a specific case that cannot be generalized.
To implement the FLC, it must be reprogrammed according to the needs of each plantation. When making the adjustment for a different case, the fundamental variables of each region; the plant's optimal growth conditions, such as humidity and the minimum and maximum temperature ranges; and the irrigation surface should be considered. This information must be obtained from experts in the field. Adapting the FLC is a low complexity task, since for the design of the controller, variables that represent the type of land of each plantation, the use of fertilizers, or the combustion gases found in the air were not considered, which also facilitates the definition of the MF in the fuzzification stage, seeing as how the KB can be concentrated in a matrix of rules, obtaining an exact defuzzification in the output.
Until now, the FLC has been used in domestic-scale planting, where the water consumption has been reduced to save 0.2 L per week, which, per year, adds up to 10.4 L in the complete plant array described in Figure 10. Due to this, a short-term objective is its implementation in medium-scale farms, with three different species of plants and, therefore, a greater number of specimens. The purpose is to show that the proposal is versatile and can be adapted by modifying the operating characteristics for the controller, that is, the maximum and minimum values of temperature and humidity required for the plantation concerned.

Discussion
In this article, an irrigation process was proposed to accompany traditional irrigation through an FLC implemented in an FPGA to optimize water consumption. This represents an advantage for floriculture in Mexico. However, it must be noted that the FLC developed in this work is a tool designed for a specific plant (roses) and a specific region (State of Mexico). Seeing as how each type of plant has different requirements depending on the geographical region and the prevailing climatic conditions throughout the year, the research presented is a specific case that cannot be generalized.
To implement the FLC, it must be reprogrammed according to the needs of each plantation. When making the adjustment for a different case, the fundamental variables of each region; the plant's optimal growth conditions, such as humidity and the minimum and maximum temperature ranges; and the irrigation surface should be considered. This information must be obtained from experts in the field. Adapting the FLC is a low complexity task, since for the design of the controller, variables that represent the type of land of each plantation, the use of fertilizers, or the combustion gases found in the air were not considered, which also facilitates the definition of the MF in the fuzzification stage, seeing as how the KB can be concentrated in a matrix of rules, obtaining an exact defuzzification in the output.
Until now, the FLC has been used in domestic-scale planting, where the water consumption has been reduced to save 0.2 L per week, which, per year, adds up to 10.4 L in the complete plant array described in Figure 10. Due to this, a short-term objective is its implementation in medium-scale farms, with three different species of plants and, therefore, a greater number of specimens. The purpose is to show that the proposal is versatile and can be adapted by modifying the operating characteristics for the controller, that is, the maximum and minimum values of temperature and humidity required for the plantation concerned.

Conclusions
In this work, the design of an FLC was shown, along with its implementation in an Altera generation V electronic card, to regulate water irrigation for the growth of roses, factoring in the temperature and humidity of the air measurements in the State of Mexico.
The proposed technological tool based on fuzzy logic concepts models the irrigation process without using traditional mathematical methods that involve the transfer function, since the obtained KB is used to determine the ranges of T and RH, helping to eliminate the uncertainty in the measurements and increase the robustness of the model.
Finally, the FLC design improved traditional irrigation systems in domestic-scale planting by using digital tools that reduce water consumption since it provided precision in the opening of the valves, controlling the exact amount of water that each plant required.
In accordance with the plantation area, the savings could be greater in a larger crop volume, so it is necessary to carry out the implementation of the FLC on a bigger plot or an estate. Funding: The APC was funded by the Instituto Politécnico Nacional through the Comisión de Operación y Fomento de Actividades Académicas.