An Optimized Fuzzy Logic Control Model Based on a Strategy for the Learning of Membership Functions in an Indoor Environment

: The Mamdani fuzzy inference method is one of the most important fuzzy logic control (FLC) techniques and has several applications in different ﬁelds. Despite its applications, the Mamdani fuzzy inference method has some core issues which still require solutions. The most critical issue is the selection of accurate shape and boundaries of membership functions (MFs) in the universe of discourse. In this work, we introduced a methodology called learning to control (LtC) to resolve the problem. The proposed methodology consisted of two main modules, namely, a control algorithm (CA) module and a learning algorithm (LA) module. In the CA module, the Mamdani FLC method has been used, whereas, in the LA module, we have used the artiﬁcial neural network (ANN) algorithm. Inputs into the ANN were the error difference between environmental temperature and the required temperature. The output of the ANN was the MF set to the FLC. Inputs into the fuzzy logic controller (FLC) were the error difference between environmental temperature and required temperature (D), and the output was the required power for the fan actuator. The purpose of the ANN was to tune the MFs of the FLC to improve its efﬁciency. The proposed learning-to-control method along with the conventional fuzzy logic controller method was applied to the data to evaluate the model’s performance. The results indicate that the proposed model’s performance is far better than that of conventional fuzzy logic techniques.


Introduction
Currently, user comfort in electric vehicles has grasped the attention of many researchers.The purpose is to provide passengers with a comfortable environment and a high-quality transportation service.Novel heating, ventilation, and air conditioning (HVAC) systems are needed to provide passengers with a comfortable environment in electric vehicles.With the help of a new artificial control method, passenger comfort in electric vehicles can be improved [1,2].
Fuzzy inference systems and artificial neural networks (ANNs) have drawn the attention of the researchers in different areas [3,4], such as consumer products [5], industrial process control [6], medical instrument control [7], information systems [8], decision-making systems, and many more.With time, applications of fuzzy logic systems and ANNs have increased, and it can solve the issue of tuning.The neural network (NN) has the potential to learn from given data.The fuzzy logic controller, on the other hand, can work with structural knowledge by using rules.The combination of an ANN and an FLC provides the possibility to solve the issue existing in the FLC [9].
Temperature is one of the critical parameters that contribute greatly to the passenger or occupant comfort in electric vehicles and buildings [10].Thermal comfort represents the satisfaction level of individuals in the environment.Temperature control inside an electric vehicle is not an easy task if a passenger wishes to maintain the thermal comfort conditions inside the vehicle.
Currently, the fuzzy logic (FL) method has been widely used in several areas for different purposes [11].Fuzzy logic and neural networks together have interested researchers in many areas of research [3,12].The applications of fuzzy logic and the neural network are increasing tremendously in different fields such as consumer products [5] and industrial process control [12], risk index assessment [11], energy optimization [1], and so forth.Mostly, fuzzy logic control systems have been used where the exact mathematical model for controlling applications is unknown, but the behavior of the application can be identified based on the experience [13].The ANN method is considered a regression technique which indicates a sophisticated nonlinearity between independent and dependent variables [14].Researchers have deployed NNs to analyze various types of prediction problems in a variety of conditions.There are many types of ANN models, such as a feed-forward neural network (FFNN), a feed-forward back propagation neural network (FFBPNN), a recurrent neural network.In this work, we have used the FFBPNN because it is an efficient and straightforward method used by many authors for prediction purposes [15,16].
Several solutions have been proposed for energy consumption management in smart homes [1].The energy optimization methodology comprises three main modules, namely, prediction, optimization, and control.Most of the research focuses on developing new prediction and optimization techniques to minimize energy consumption and maximize user comfort.However, control is the most critical part, and many researchers have ignored this aspect which can improve performance, ultimately contributing to system performance.The Mamdani fuzzy logic method has been used in most studies because it is a very simple, familiar, and effective method.The central problem in the Mamdani fuzzy logic method is that once the boundaries of the membership functions (MFs) have been defined, they remain fixed for the entire data.
In the proposed method, we introduced a new learning-to-control model based on the fuzzy logic controller (FLC) and neural networks.The determination of a membership function's boundaries is a somewhat trial and error type of exercise, and the membership function's boundaries play a critical role in the performance of the fuzzy logic controller.In the conventional fuzzy logic controller, the membership function has fixed boundaries which affect the performance of the fuzzy logic controller because, for a particular value, different membership functions provide different results.The proposed method has the capability of tuning the membership function boundaries with each value which improves the performance of the fuzzy logic controller regarding accuracy.The proposed model comprises a control algorithm (CA) module and a learning algorithm (LA) module.In the CA module, we used a Mamdani fuzzy logic controller (FLC) algorithm and, in LA module, we used the ANN.First, the ANN was trained using the historical data.Current environmental parameters were used as input into the LA module as well as into the CA module.
Similarly, the user-required set parameter values has been used as inputs into the LA module as well as into the CA module.We used different sensors in order to get the environmental parameter values.In the traditional fuzzy logic controller, there are no accurate mechanisms of membership function determination.The objectives of this study were to determine the MFs in the FLC accurately and to fulfill the passenger user comfort requirement in an indoor environment.The central problem in the conventional FLC is the accurate determination of the distribution of membership functions.In the conventional Mamdani FL, the determination of membership functions is carried out by experts, and once the membership function distribution has been determined, it remains fixed for the entire data.In this work, we used a neural network to recommend the best-suited membership function set to a Mamdani fuzzy logic controller.Another critical issue of the conventional Mamdani fuzzy logic controller (MFLC) is the accurate number of membership functions specification for a variable.To handle the problem of selecting the exact number of membership functions for a variable, we calculated the standard deviation (STD) of the data for the variables.
The rest of the paper is organized as follows: the related work is presented in Section 2, and the proposed learning-to-control model with a detailed explanation of its structure is presented in Section 3. In Section 4 and its subsections, the implementation, results, and discussion are elaborated.Finally, the conclusion is provided in Section 5.

Related Work
Several techniques have been used in different areas for different purposes based on fuzzy logic and machine learning algorithms.However, appropriate literature on fuzzy logic and neural network coupling for comfort index measurement is rarely available.
A hybrid model for indoor thermal comfort in an HVAC system was explained by Homod et al. [17].They suggested a building model and a fuzzy logic configuration for achieving indoor thermal comfort in buildings.Collotta et al. [10] designed an approach consisting of fuzzy logic and a neural network.They used an ANN for temperature prediction and the predicted outputs as inputs into the fuzzy logic controller unit for HVAC management.Also, the optimization of the ANN was carried out by systematic computation of the embedding factors.The evaluation of the proposed technique was carried out using MATLAB.The FLC has been driven through the inside temperature predicted by the ANN, and it had the membership function dynamic adjustment capability.Gouda et al. [18] proposed a quasi-adaptive FLC for building control applications.They used an ANN for the prediction of inter-air temperature.They also designed the FLC which consisted of two inputs, the first being the difference between the user-set and indoor temperature and the second being the forecasted indoor temperature.Van Cleave and Rattan [12] proposed a method for the tuning of membership functions.The training of the learning module was carried out with training data, and the output of the proportional neuro-fuzzy controller was used for membership function adjustment.They used offline training.In the neuro-fuzzy controller, the ANN learning methods has been used for FLC membership function tuning.Solmaz et al. [19] suggested a technique based on an ANN for the hourly cooling prediction of vehicles.The calculation of cooling was carried out during the cool season in the southern region of Turkey.Many authors have used fuzzy logic and neural networks for thermal comfort prediction and optimization in electric vehicles.Beinarts [20] suggested a method based on FL for determining passenger comfort in electric vehicles.Ibrahim et al. [21] suggested a strategy for temperature and humidity control for the HVAC of electric vehicles.The proposed method was based on the FLC.Busl [2] designed a novel evolutionary algorithm and a simplified system model for increasing individual comfort and decreasing energy consumption in electric cars.The verification of the implementation was carried out on a thermal car interior simulation model.
Several researchers have proposed methods for membership function optimization.Zhang et al. [22] suggested a technique based on a genetic algorithm for automatic designing and tuning of MF factors of fuzzy logic.A comparison of the optimized FLC with the conventional FLC was carried out.The results showed that their proposed technique performed well as compared to the conventional FLC.Martínez-Marroquín et al. [23] proposed a model based on an ant colony algorithm (ACO) to optimize MF parameters of an FLC for finding the optimal intelligent controller for a wheeled mobile robot.Fang et al. [24] suggested a model based on particle swarm optimization (PSO) for MF tuning of a Mamdani FLC.A demonstration of the proposed model was carried out to show its effectiveness.
Different authors proposed different techniques for fuzzy logic controller optimization, energy consumption, and user comfort maximization.Membership functions play a crucial role in FLC performance, but there is no accurate method to determine appropriate membership functions.In this work, we used an ANN to determine accurate MFs for the FLC.The FLC tuned the MFs, which in turn helped to determine the perfect set of MFs.The accurate determination of membership function improved the system.

Proposed Model
The determination of a membership function's boundaries is a somewhat trial and error type of exercise, and there is no accurate mechanism to determine membership boundaries in conventional fuzzy logic models.In the traditional FLC, once the boundary determination of membership functions has been carried out, it remains fixed for the entire data.Hence, if the determination of MF boundaries is not accurate, it can drastically affect the performance of the FLC.Thus, techniques to tune the FLC are required.To tackle these issues, we proposed a learning-to-control model.The proposed method uses the learning methods for membership function tuning.Figure 1 contains the recommended learning-to-control (LtC) model.It consists of two main modules, namely a control algorithm (CA) module, and a learning algorithm (LA) module.Current environmental parameters were used as input into the learning algorithm module as well as into the control algorithm module.
Similarly, the user-required set parameter values have been used as inputs into the LA module as well as into the CA module.We used different sensors in order to get the environmental parameter values.

Proposed Model
The determination of a membership function's boundaries is a somewhat trial and error type of exercise, and there is no accurate mechanism to determine membership boundaries in conventional fuzzy logic models.In the traditional FLC, once the boundary determination of membership functions has been carried out, it remains fixed for the entire data.Hence, if the determination of MF boundaries is not accurate, it can drastically affect the performance of the FLC.Thus, techniques to tune the FLC are required.To tackle these issues, we proposed a learning-to-control model.The proposed method uses the learning methods for membership function tuning.Figure 1 contains the recommended learning-to-control (LtC) model.It consists of two main modules, namely a control algorithm (CA) module, and a learning algorithm (LA) module.Current environmental parameters were used as input into the learning algorithm module as well as into the control algorithm module.
Similarly, the user-required set parameter values have been used as inputs into the LA module as well as into the CA module.We used different sensors in order to get the environmental parameter values.A moderately detailed diagram of the proposed learning-to-control model is shown in Figure 2. The proposed model has been designed for temperature control in an indoor environment.First, we designed a learning-to-control model based on the Mamdani fuzzy logic method and an artificial neural network.The FLC module takes the error difference between environmental temperature and user-required temperature.The ANN takes the current temperature values from the environment, the required temperature values from the user, and the error difference between environmental temperature values and current temperature values as inputs.The ANN uses training data and selects the best membership functions for fuzzy logic.The environmental temperature values has been collected through a temperature sensor, and the user sets the required temperature value.The de-fuzzified output of the controller's inference machine is the required power for the fan.The coordinator takes the output power as an input and sets the fan speed accordingly.The fan speed changes the environmental temperature.After a specific interval of time, the proposed model gets the same parameter values and performs operations accordingly.A moderately detailed diagram of the proposed learning-to-control model is shown in Figure 2. The proposed model has been designed for temperature control in an indoor environment.First, we designed a learning-to-control model based on the Mamdani fuzzy logic method and an artificial neural network.The FLC module takes the error difference between environmental temperature and user-required temperature.The ANN takes the current temperature values from the environment, the required temperature values from the user, and the error difference between environmental temperature values and current temperature values as inputs.The ANN uses training data and selects the best membership functions for fuzzy logic.The environmental temperature values has been collected through a temperature sensor, and the user sets the required temperature value.The de-fuzzified output of the controller's inference machine is the required power for the fan.The coordinator takes the output power as an input and sets the fan speed accordingly.The fan speed changes the environmental temperature.After a specific interval of time, the proposed model gets the same parameter values and performs operations accordingly.Figure 3 contains a detailed description of the proposed generic model.In the proposed model, the ANN has been trained using historical data as discussed above.The error difference between the current temperature from the environment and the user-set temperature is the input of the fuzzy logic module.The fuzzy logic controller consists of three main modules: fuzzification, rules base, and defuzzification.The neural network module uses training data to provide the best-suited membership function set to the fuzzy logic module.According to the error difference values between environmental parameters and user-required parameters, the fuzzy logic module provides required power to the fan actuator.Next, after the actuators operate on the required environmental conditions, these parameter values are changed after a specific time, the environmental parameter and required parameter values have been entered into the fuzzy logic controller, the fuzzy logic takes the error difference between current parameter values and user-requested parameter values.The process repeats itself whenever specific changes in the environmental conditions occur.Researchers have extensively used ANN models for prediction and recommendation in several areas.The ANN can be used for regression purposes to signify erudite nonlinearity between variables [25,26].In the recent past, ANN methods have been used extensively to solve prediction problems in different fields.The ANN model used in this work is the feed forward neural network with error backpropagation; inputs into the neural network model are current temperature (Tk), required temperature (Tr), and the difference between environmental temperature and required temperature (D).The output of the ANN is the membership function (MF) set for the FLC module.The ANN algorithm has been trained on historical data where the inputs are previous temperature (Tp) from the environment, previous user-required temperature (Trp), and the difference of both (Dp), and their corresponding outputs are the MF sets.

Learning
The output of the fuzzy inference method is the required power (Pr) for the fan actuator, and the required power is then inputted into the coordinator.The coordinator adjusts the fan speed (Sp) according to the required power.
The ANN model combined with the error propagation algorithm (FFBPNN) is a prevalent ANN model for estimation and prediction [27,28].It usually has three layers, namely, input, hidden, and output.In this work, three neurons in the input layer have been defined, one for each input.In the hidden layer, ten (10) neurons have been determined, and after using the trial and test method, it has been observed that ten (10) neurons in combination with the input and output layer neurons Researchers have extensively used ANN models for prediction and recommendation in several areas.The ANN can be used for regression purposes to signify erudite nonlinearity between variables [25,26].In the recent past, ANN methods have been used extensively to solve prediction problems in different fields.The ANN model used in this work is the feed forward neural network with error backpropagation; inputs into the neural network model are current temperature (T k ), required temperature (Tr), and the difference between environmental temperature and required temperature (D).The output of the ANN is the membership function (MF) set for the FLC module.The ANN algorithm has been trained on historical data where the inputs are previous temperature (T p ) from the environment, previous user-required temperature (Tr p ), and the difference of both (D p ), and their corresponding outputs are the MF sets.
The output of the fuzzy inference method is the required power (Pr) for the fan actuator, and the required power is then inputted into the coordinator.The coordinator adjusts the fan speed (Sp) according to the required power.
The ANN model combined with the error propagation algorithm (FFBPNN) is a prevalent ANN model for estimation and prediction [27,28].It usually has three layers, namely, input, hidden, and output.In this work, three neurons in the input layer have been defined, one for each input.In the hidden layer, ten (10) neurons have been determined, and after using the trial and test method, it has been observed that ten (10) neurons in combination with the input and output layer neurons were well suited Finally, in the output layer, one neuron was defined.The structure diagram of the ANN for this work is illustrated in Figure 4.
were well suited Finally, in the output layer, one neuron was defined.The structure diagram of the ANN for this work is illustrated in Figure 4.The value of the hidden layer can be computed using Equation ( 1): where v represents the jth neuron in the hidden layer, x represents the ith neuron in the input layer, and the weight between neurons is represented by wij.The output layer node value can be computed using Equation (2): where m represents the output layer node (in this research, only one output node was taken; later on, as per requirements, we can use multiple nodes as well).The error between actual and computed data has been calculated using Equation (3): where a represents the actual data propagation from the output and hidden layers, as expressed in Equations ( 4) and ( 5), respectively.
The weight adjustment between layers can be carried out using Equations ( 6) and ( 7): where α represents the learning rate and, additionally, momentum can be measured as Equations ( 8) and ( 9), respectively: The value of the hidden layer can be computed using Equation (1): where v j represents the jth neuron in the hidden layer, x i represents the ith neuron in the input layer, and the weight between neurons is represented by w ij .The output layer node value can be computed using Equation (2): where m represents the output layer node (in this research, only one output node was taken; later on, as per requirements, we can use multiple nodes as well).The error between actual and computed data has been calculated using Equation (3): where a represents the actual data propagation from the output and hidden layers, as expressed in Equations ( 4) and ( 5), respectively.
The weight adjustment between layers can be carried out using Equations ( 6) and ( 7): where α represents the learning rate and, additionally, momentum can be measured as Equations ( 8) and ( 9), respectively: where n indicates iterations of error backpropagation and β represents momentum constant.
The training process in the flat region of the error surface avoids variations in the weights and has been accelerated using this momentum method.Usually, three types of membership functions can be used in the hidden and output layers of a multi-layer perceptron, namely, the linear, tang-sigmoid, and logarithmic sigmoid functions as represented in Equations ( 10)-( 12), respectively.
The selection of the appropriate activation function in the hidden layer is usually carried out using the trial and error method; in the proposed method, different activation functions have been applied, such as tan-sigmoid, linear, and logarithmic, and so forth.The specification of the number of neurons in the hidden layer is also a somewhat trial and error type of exercise.To optimize the ANN structure, we used a different number of neurons in the hidden layer.
Table 1 illustrates the description of notations used in the formulation.There are many types of FLC systems, the most essential being Mamdani, Tsukamoto, Sugeno, and Larsen.The most extensively used and common fuzzy inference method is Mamdani fuzzy logic which was suggested by Mamdani as mentioned in Klir and Yuan [29] for the steam engine and boiler combination.The Mamdani fuzzy inference system can be divided into many modules, namely, fuzzy knowledge-base, fuzzifier, inference engine, and de-fuzzifier.The combination of rules base and the database is referred to as the knowledge base.A rules base has IF-THEN rules, and the database contains fuzzy sets.The fuzzifier uses the MFs stored in the fuzzy knowledge base to convert the crisp input into a linguistic variable.Several types of membership functions can be used in Mamdani fuzzy logic, such as trapezoidal, bell-shaped, and so forth.In the suggested work, the triangular MFs has been used because they were the most common, efficient and straightforward MFs.Equation (13) Electronics 2019, 8, 132 9 of 18 shows the formula of a triangular membership function, where x represents the actual difference value, a is the lower bound, c is the upper bound, and b is the mid-point: The inference engine takes fuzzy values as input and uses IF-THEN fuzzy rules to convert the fuzzy inputs into the fuzzy outputs.For combination and implication operations, the "MIN" operator has been used, and for aggregating fuzzy outputs, we have used the "MAX" operator in Mamdani fuzzy logic.The de-fuzzifier converts the fuzzy output of the inference engine to crisp values which use MFs analogous to the ones used by the fuzzifier.The centroid of area method was used for defuzzification processes in this work, as shown in Equation ( 14).The structure diagram of the Mamdani fuzzy logic [30,31] is shown in Figure 5.
Electronics 2019, 10, x FOR PEER REVIEW 9 of 18 MFs. Equation (13) shows the formula of a triangular membership function, where x represents the actual difference value, a is the lower bound, c is the upper bound, and b is the mid-point: The inference engine takes fuzzy values as input and uses IF-THEN fuzzy rules to convert the fuzzy inputs into the fuzzy outputs.For combination and implication operations, the "MIN" operator has been used, and for aggregating fuzzy outputs, we have used the "MAX" operator in Mamdani fuzzy logic.The de-fuzzifier converts the fuzzy output of the inference engine to crisp values which use MFs analogous to the ones used by the fuzzifier.The centroid of area method was used for defuzzification processes in this work, as shown in Equation ( 14).The structure diagram of the Mamdani fuzzy logic [30,31] is shown in Figure 5.In this work, the tuning of the MFs was carried out in order to get better results when compared to the conventional Mamdani FLC method where the MFs are fixed.The tuning of MFs is a very necessary step in order to improve the fuzzy logic controller's performance.Membership functions having different distributions are given in Table 2.In this work, the tuning of the MFs was carried out in order to get better results when compared to the conventional Mamdani FLC method where the MFs are fixed.The tuning of MFs is a very necessary step in order to improve the fuzzy logic controller's performance.Membership functions having different distributions are given in Table 2.In order to get the membership degree values of the same membership function having different distribution values, we put the above distribution in Equation ( 1) as given below.Hence, it is a very necessary step to determine appropriate membership function distribution values in order to get accurate results for a system.In this work, the ANN algorithm was used to tune the membership function boundaries of the FLC method.
Another critical issue of the conventional Mamdani fuzzy logic controller (MFLC) is the accurate number of membership functions specification for a variable.In order to handle this problem, we used the standard deviation (STD).First, the standard deviation [32] of the data of a variable has been calculated, and according to that standard deviation value, the number of membership functions for a variable has been specified.The formula for standard deviation is given in Equation ( 15): where x represents the observed values, x represents the arithmetic mean values, and N is the number of observations.In this work, the error between the environmental temperature and required temperature has been used as input into the Mamdani FLC.First, the standard deviation of the input variable difference has been calculated which is equal to 2.56988 ( • C).According to this variation, seven (7) membership functions for input variables were defined for the difference (error between user-set temperature and environmental temperature) as well as for the output variable power.The abbreviations EL, VL, L, M, H, VH, and EH were defined for the input variable difference as well as for the output variable power (P), which represented extremely low, very low, low, medium, high, very high, and extremely high, respectively.In this work, a full structure Mamdani fuzzy inference controller has been used, and to specify the number of rules in a fuzzy logic method, Equation ( 16) can be used [32]: where M indicates the number of membership functions and v represents the number of input variables.As in the proposed Mamdani fuzzy logic, there is only one input variable, and nine (9) membership functions have been defined for that input variable.Hence, the total number of rules in the proposed method is equal to 10 1 = 10.The rules used in the proposed LtC model are shown in Table 3.
Table 3. Fuzzy rules for the temperature fuzzy controller.

Temperature Fuzzy Rules
If In this work, the difference between environmental temperature and required temperature was used to calculate the output power (P) for the fan using the proposed learning-to-control model.Therefore, the output of the fuzzy logic controller was power; however, because the fan speed had to be optimized, some mathematical work was done for the fan speed calculation using power.The mathematical formulas as shown in Equations ( 17)- (19) were used to calculate the speed from the power provided by fuzzy logic: where D i represents the difference between the current temperature and required temperature, F i represents fuzzy logic, and P i represents power generated through fuzzy logic.S pi represents the speed of the fan, T k represents current temperature, C 2 represents the difference between maximum P i value and maximum D i value, and EI i represents environmental impact which can be calculated as in Equation ( 20): where C 1 is any constant number, the C 1 is changing environmental impact when the fan rotates, and N is the number of observations.Similarly, for the summer season, Equations ( 17), ( 18) and ( 20) can be used, but for Equation ( 21) some modifications are required in Equation ( 19): For the performance evaluation of the proposed LtC model, we used mean absolute error (MAE), mean absolute percentage error (MAPE), and root mean square error (RMSE), which are represented in Equations ( 22)-( 24): where N indicates the number of observations, A is the actual value, and E is the estimated values.

Implementation
The implementation of the proposed learning-to-control model was carried out on an Intel(R) Core (TM) i5-3570 CPU @ 3.40 GHz with MATLAB 2010a installed on it.The fuzzy logic implementation of fuzzy rules, rule viewer, rules editor, and membership function was carried using the fuzzy logic toolbox.The neural network implementation was also carried out in MATLAB.The implementation process continued by specifying the number of neurons in the input layer, hidden layer, and output layer, respectively.In this work, we have used three inputs into the ANN, namely, the difference (D), current environmental temperature, and required temperature.Hence, three neurons have been defined for the input layer, one for each input.The number of neurons in the hidden layer was defined later, using a trial and error mechanism, and one neuron has been defined for the output layer.The configuration model for the ANN is shown in Figure 6.For the suitable ANN model, different hidden layer activation functions have been tried.Similarly, different training functions and output layer transfer functions were applied.To achieve the best combination of the number of hidden layers with an input layer, an output layer, and various activation, training, and transfer functions, we tried a different number of neurons in the hidden layer, starting from 5 to 40.After training the neural network, we then carried out the implementation of Mamdani fuzzy logic module in our proposed learning-to-control model.The input into the neural network was the difference between the current environmental temperature and the user-set temperature.In this work, nine (9) membership functions according to Equation ( 1) has been defined.The input/output membership functions are represented in Figure 7, where the x-axis indicates the universe of discourse and the y-axis indicates the membership degree in [0, 1] interval.In this work, triangular membership functions have been considered.The type of membership function depends on the number of MFs.In the proposed method, 10 MFs has been used, which is a considerable number.MFs with nonlinear borders (e.g., Gaussian, trapezoidal, sigmoidal) are suitable to be considered if the number of MFs is small, but we used triangular membership functions.After training the neural network, we then carried out the implementation of Mamdani fuzzy logic module in our proposed learning-to-control model.The input into the neural network was the difference between the current environmental temperature and the user-set temperature.In this work, nine (9) membership functions according to Equation ( 1) has been defined.The input/output membership functions are represented in Figure 7, where the x-axis indicates the universe of discourse and the y-axis indicates the membership degree in [0, 1] interval.In this work, triangular membership functions have been considered.The type of membership function depends on the number of MFs.In the proposed method, 10 MFs has been used, which is a considerable number.MFs with nonlinear borders (e.g., Gaussian, trapezoidal, sigmoidal) are suitable to be considered if the number of MFs is small, but we used triangular membership functions.After training the neural network, we then carried out the implementation of Mamdani fuzzy logic module in our proposed learning-to-control model.The input into the neural network was the difference between the current environmental temperature and the user-set temperature.In this work, nine (9) membership functions according to Equation ( 1) has been defined.The input/output membership functions are represented in Figure 7, where the x-axis indicates the universe of discourse and the y-axis indicates the membership degree in [0, 1] interval.In this work, triangular membership functions have been considered.The type of membership function depends on the number of MFs.In the proposed method, 10 MFs has been used, which is a considerable number.MFs with nonlinear borders (e.g., Gaussian, trapezoidal, sigmoidal) are suitable to be considered if the number of MFs is small, but we used triangular membership functions.

Results
The current temperature values are shown in Figure 8a, the required temperature values are shown in Figure 8b, and the error difference between the current temperature and the required temperature values is shown in Figure 8c.

Results
The current temperature values are shown in Figure 8a, the required temperature values are shown in Figure 8b, and the error difference between the current temperature and the required temperature values is shown in Figure 8c.The input data used in the proposed method, namely, the error difference between environmental temperature and the required temperature, the current temperature from the environment, and the required temperature from the user, are shown in Figure 8.
In this work, we needed to indicate a relationship between different parameters: the learning-to-control (LtC) model produced the power, but we had to adjust the fan speed (rpm) according to that power.The relationship between difference and power is illustrated in Figure 9a.The relationship between speed and power is illustrated in Figure 9b.The relationship between speed and environmental temperature is shown in Figure 9c.
Electronics 2019, 10, x FOR PEER REVIEW 14 of 18 The input data used in the proposed method, namely, the error difference between environmental temperature and the required temperature, the current temperature from the environment, and the required temperature from the user, are shown in Figure 8.
In this work, we needed to indicate a relationship between different parameters: the learning-to-control (LtC) model produced the power, but we had to adjust the fan speed (rpm) according to that power.The relationship between difference and power is illustrated in Figure 9a.The relationship between speed and power is illustrated in Figure 9b.The relationship between speed and environmental temperature is shown in Figure 9c.For the next step, the comparison between the current temperature and the required temperature was carried out.First, we compared the environmental temperature and required temperature after a 15-minute interval of the fan rotating as shown in Figure 10a.Figure 10b  For the next step, the comparison between the current temperature and the required temperature was carried out.First, we compared the environmental temperature and required temperature after a 15-minute interval of the fan rotating as shown in Figure 10a.Figure 10b  To measure the performance of the proposed algorithm, the RMSE, MAE, and MAPE have been used.The results of the proposed LtC model have been compared with the conventional FLC.The same data and same procedure have been used in the conventional FLC as for the LtC model.The RMSE value of the proposed model was 2.5852, while the conventional FLC's MAE value was 0.3850, MSE value was 0.2129, and MAPE value was 2.548.Similarly, for the conventional fuzzy logic control method, the MAE, MAPE, and RMSE values were 2.0008, 5.7077, and 2.2451, respectively.The results indicate that the proposed LtC model's performance is better when compared to the conventional FLC method.The mean square error's given value is far better than that of the conventional FLC.
The most important advantage of the proposed approach is that it enhanced the performance (regarding accuracy) of the conventional Mamdani fuzzy logic method by defining accurate membership function boundaries using a neural network.The proposed model is also generic and can be used in different areas for different purposes.The proposed learning-to-control model also has some disadvantages, such as the fact that it required historical data for training and that its To measure the performance of the proposed algorithm, the RMSE, MAE, and MAPE have been used.The results of the proposed LtC model have been compared with the conventional FLC.The same data and same procedure have been used in the conventional FLC as for the LtC model.The RMSE value of the proposed model was 2.5852, while the conventional FLC's MAE value was 0.3850, MSE value was 0.2129, and MAPE value was 2.548.Similarly, for the conventional fuzzy logic control method, the MAE, MAPE, and RMSE values were 2.0008, 5.7077, and 2.2451, respectively.The results indicate that the proposed LtC model's performance is better when compared to the conventional FLC method.The mean square error's given value is far better than that of the conventional FLC.
The most important advantage of the proposed approach is that it enhanced the performance (regarding accuracy) of the conventional Mamdani fuzzy logic method by defining accurate membership function boundaries using a neural network.The proposed model is also generic and can be used in different areas for different purposes.The proposed learning-to-control model also has some disadvantages, such as the fact that it required historical data for training and that its computation time was high than for the conventional Mamdani fuzzy logic method due to the learning module.

Conclusions and Future Work
In this work, we proposed a novel model called the learning-to-control (LtC) model.The idea of the LtC model has been developed because of certain bottlenecks in the conventional FLC.The determination of the suitable membership function distribution in conventional fuzzy logic is a critical issue which affects the system's performance.In the proposed model, a new module called the learning module has been added to the conventional FLC for membership function tuning.Hence, the suitable membership function distribution has been assigned to a value which brings a specific improvement to the system performance.The proposed model has been deployed on simulated data that have been taken from related papers.The proposed learning-to-control model is a generic model that can be applied to different areas for controlling purposes.The proposed model has been compared with the conventional Mamdani fuzzy inference method.The results indicate that the performance of the proposed LtC model is better when compared to the conventional FLC method.The mean square error's given the value is far better than that of the conventional FLC.
In future work, we would like to compare the proposed approach with other control methods.We also plan to deploy the proposed LtC method in our energy consumption minimization and user comfort maximization work for controlling purposes.

Figure 2 .
Figure 2. Learning to fuzzy logic control model for temperature control in an indoor environment.

Figure 2 .
Figure 2. Learning to fuzzy logic control model for temperature control in an indoor environment.

Figure 3 18 TemperatureFigure 3 .
Figure3contains a detailed description of the proposed generic model.In the proposed model, the ANN has been trained using historical data as discussed above.The error difference between the current temperature from the environment and the user-set temperature is the input of the fuzzy logic module.The fuzzy logic controller consists of three main modules: fuzzification, rules base, and defuzzification.The neural network module uses training data to provide the best-suited membership function set to the fuzzy logic module.According to the error difference values between environmental parameters and user-required parameters, the fuzzy logic module provides required power to the fan actuator.Next, after the actuators operate on the required environmental conditions, these parameter values are changed after a specific time, the environmental parameter and required parameter values have been entered into the fuzzy logic controller, the fuzzy logic takes the error difference between current parameter values and user-requested parameter values.The process repeats itself whenever specific changes in the environmental conditions occur.

Figure 3 .
Figure 3. Detailed processing diagram of the learning-to-control model.

Figure 4 .
Figure 4. Structure diagram of the artificial neural network (ANN) in our proposed learning-to-control model.

Figure 4 .
Figure 4.Structure diagram of the artificial neural network (ANN) in our proposed learning-to-control model.

Figure 5 .
Figure 5. Structure diagram of Mamdani fuzzy logic used in this work.

Figure 5 .
Figure 5. Structure diagram of Mamdani fuzzy logic used in this work.

Figure 6 .
Figure 6.ANN configuration model for this work.

Figure 6 .
Figure 6.ANN configuration model for this work.

Figure 8 .
Figure 8.(a) Current temperature, (b) required temperature, and (c) the error difference between the current temperature and the required temperature.

Figure 8 .
Figure 8.(a) Current temperature, (b) required temperature, and (c) the error difference between the current temperature and the required temperature.

Figure 9 .
Figure 9. Relationship: difference between (a) current temperature and required temperature, (b) speed and power, and (c) speed and next temperature.

Figure 9 .
Figure 9. Relationship: difference between (a) current temperature and required temperature, (b) speed and power, and (c) speed and next temperature.
shows the required temperature and environmental temperature after a one-hour interval of the fan rotating.The blue line indicates the required temperature from user and the green line indicates the environmental temperature in Figures 10a and 10b respectively for 15-minutes interval and one-hour interval.Electronics 2019, 10, x FOR PEER REVIEW 15 of 18

Figure 10 .
Figure 10.Proposed model results for the environmental temperature and the required temperature.

Figure 10 .
Figure 10.Proposed model results for the environmental temperature and the required temperature.

Table 1 .
Description of notations used in the formulation.

Table 2 .
Membership functions with different distributions.

Table 2 .
Membership functions with different distributions.