# Adaptive HVAC System Based on Fuzzy Controller Approach
## 3 Problem Formulation
### Overview of the Proposed Fuzzy Controller  
Fuzzy logic systems (FLSs) have shown solid proficiency in decision-making research that deals with approximations rather than exact values. Additionally, their mathematical modeling requirements for practical implementation in a control system are not complex compared to conventional techniques [57]. For this reason, the study utilizes FLS for the design and implementation of the proposed controller presented in Figure 2. The fuzzy-based HVAC controller consists of four main components: fuzzification, inference engine, fuzzy rule base, and defuzzification. Figure 2 shows these elements as well as the overall FLC design. Each element influences the controller's efficiency and behavior. For instance, during the fuzzification process, the fuzzy component translates measurements of crisp input data into fuzzy data or membership functions (MFs) known as linguistic variables, which are analogous to human decision-making. The fuzzy inference method combines the MFs and the control rules (i.e., rule base) in the second stage to produce the control output. The basis of a fuzzy inference engine's operation is its rule base, and those rules have a strong affinity with human emotion and intuition. Specifically, it offers the knowledge required for the language control rules underlying fuzzification and defuzzification. The MATLAB Fuzzy Logic Toolbox offers tools to construct and update fuzzy inference systems in the design process of the FL controller for HVAC. The total flow process of the FLC-designed system is shown in Figure 2. Fuzzy logic controllers come in two varieties: Mamdani-based controllers and Takagi-Sugenos-based controllers. We used the Mamdani-type FIS methodology as a fuzzy inference method because the Sugeno FIS does not have an output membership function while the Mamdani-type FIS does. The input variables used in the proposed controller include temperature (T), humidity (H), occupancy (O), initialized setpoint (Is), and energy price (P). These inputs are fuzzified to generate fuzzy membership functions (MFs), which are part of fuzzy sets defined in a readable and understandable format. As shown in Figure 2, the FIS takes four crisp inputs and fuzzified them, generating fuzzy MFs using the fuzzy engine. It then applies fuzzy operators to fuzzy MFs to construct fuzzy rules that signify the fuzzy input relationship effect on the output variable through a fuzzifier. The fuzzy model proposed to manage the HVAC system is implemented using Mamdani FIS. The following rules and assumptions are followed for Mamdani FIS, and the conclusion using the linguistic variables is mathematically presented in Equation (1). For example, IF (OutdoorT) is (\"Warm\") AND (IndoorT) is (\"Warm\") AND (P-Rate) is (\"Low\") AND (Occ) is (\"Present\") AND (ISP) is (\"Low\") AND (Humidityrel) is \"Normal,\" THEN ventilation frequency is \"Normal.\"  
\[\mathrm{z}=\frac{\int\mathrm{\mu c(z).zdz}}{\int\mathrm{\mu c(z)dz}} \tag{1}\]  
For the energy consumption cost, the following formula (see Equation (2)) is used to calculate the total hourly energy consumption cost: where \(\mathrm{Cost(h)}\) represents hourly cost, \(\mathrm{EC(h)}\) represents energy consumption on an hourly interval, and P represents the electricity tariffs based on real-time price (RTP). \[\mathrm{Cost(h)}=\mathrm{EC(h)}\times\mathrm{P(h)} \tag{2}\]  
The peak-to-average (PAR) formula is used to obtain information on the peak load during a power imbalance (see Equation (3)). \[\mathrm{PAR}=\frac{\mathrm{Load_{maximum}}}{\mathrm{Load_{average}}} \tag{3}\]To determine the efficiency of the proposed approach, the following equation (see Equation (4)) is used to calculate the efficiency gain compared to previous approaches, where \(\text{Value}_{\text{pre}}\) represents the efficiency attained by an existing study and \(\text{Value}_{\text{pro}}\) represents the efficiency achieved by the proposed approach.