## 4 System Model Implementation
### Automatic FIS Rule Base Generation  
The proposed system is evaluated with the help of fuzzy rules in order to determine the total energy consumption. As the input parameters of the FIS increase, the number of rules in the FIS rule base also increased. It is often observed that defining rules manually to the software is a very lengthy and tedious process. As the proposed technique in this paper is an extension of a worldwide adaptive thermostat model [28] by adding humidity as an input parameter, one can observe the increase in the number of rules, which is as follows:  
1. In worldwide adaptive thermostat [28], there were four variables with three membership functions and one variable with two membership functions. This resulted in a total of 162 rules to be defined in the rule base of Mamdani FIS and Sugeno FIS. 2. Adding humidity as a parameter to the system results in five variables with three membership functions and one variable with two membership functions. A total of 486 rules are required to be defined for the both Mamdani FIS and Sugeno FIS. As the number of rules to be defined in a system increases, the process of defining the rules will become cumbersome. Many approaches have been designed to lessen the burden of defining rules manually. In this paper, a technique for the automatic generation of rule base is proposed using the combinatorics and weightage method. Each membership function of a single input parameter is assigned a weightage that is used to calculate _Score_, and values of output parameters are going to be assigned according to the calculated _Score_ as shown in Algorithm 1. The major steps of FLC are as follows:  
1. The first step is the fuzzification process in which all the membership functions of the system parameters are initialized and defined. 2. The second step is defining the rules in the rule base by giving weightage to membership functions of input parameters and then assigning the suitable output fuzzy value. 3. The third step uses the Mamdani FIS and Sugeno FIS to evaluate the energy consumption. 4. After rule evaluation, defuzzification is performed to get the crisp value for the energy consumption. In the end, calculation of remaining performance measures is performed. In the second step, after assigning weights to the membership functions of the input parameters, to circumvent the combinatorial growth of IF-THEN rules, we introduce a parameter called _Score_, which is indicative of energy consumption. Low _Score_ means low energy consumption and vice versa. The _Score_ is calculated as the weighted sum of weights assigned to the membership function of variables involved. The weights are dependent on the membership function where membership function of low, medium, and high have the weights of 0, 1, and 2, respectively. The only exception is the variable of Occupancy with binary weights of 0 or 1 in reference to the absence and presence of occupants. The method used for the automatic rule generation utilizes the combination of the input parameters where order does not matter and they follow the commutative property when _Score_ is calculated by adding the weights of membership functions of input parameters. The _Score_ at any instant is as follows:  
\[Score=\sum_{i=1}^{6}W(v_{i}), \tag{9}\]where \(W\) is weight and variables \(v_{i}\) are renamed according to Table 3.  
Sample FIS rules defined using the automatic rule generation algorithm are presented in Table 4. Membership functions of the input provided to the proposed FIS and the resulting output are defined and abbreviated as follows:  
1. Temperature: Indoor temperature (\(T_{in}\)) and outdoor temperature (\(T_{out}\)) for both hot and cold cities have membership functions of (1) Low (L); (2) Medium (M); and (3) High (H) according to their cold and hot weather. 2. Electricity Pricing: Pricing tariff (_Rate_) is classified into the following membership functions: (1) Off-Peak (OP); (2) Mid-Peak (MP); and (3) High-Peak (HP). 3. Occupancy: The user can either be present in the residential building or not.