An Improved Optimization Function to Integrate the User’s Comfort Perception into a Smart Home Controller Based on Particle Swarm Optimization and Fuzzy Logic

Scheduling residential loads for financial savings and user comfort may be performed by smart home controllers (SHCs). For this purpose, the electricity utility’s tariff variation costs, the lowest tariff cost schedules, the user’s preferences, and the level of comfort that each load may add to the household user are examined. However, the user’s comfort modeling, found in the literature, does not take into account the user’s comfort perceptions, and only uses the user-defined preferences for load on-time when it is registered in the SHC. The user’s comfort perceptions are dynamic and fluctuating, while the comfort preferences are fixed. Therefore, this paper proposes the modeling of a comfort function that takes into account the user’s perceptions using fuzzy logic. The proposed function is integrated into an SHC that uses PSO for scheduling residential loads, and aims at economy and user comfort as multiple objectives. The analysis and validation of the proposed function includes different scenarios related to economy–comfort, load shifting, consideration of energy tariffs, user preferences, and user perceptions. The results show that it is more beneficial to use the proposed comfort function method only when the user requires SHC to prioritize comfort at the expense of financial savings. Otherwise, it is more beneficial to use a comfort function that only considers the user’s comfort preferences and not their perceptions.


Introduction
In the context of demand response (DR), measures to improve the energy chain unfold in two areas: supply-side management (SSM) and demand-side management (DSM). The first area aims to improve the generation, transmission, and distribution of electricity, while the second area aims to influence the consumption profile of households through flexible tariffs or energy bonuses [1,2]. In this scenario, residential consumers can use smart home controllers (SHCs) to take advantage of benefits offered by the utility [3]. These controllers may incorporate residential comfort functions [4][5][6], residential load modeling, the ability to manage distributed generation (DG) associated with energy storage systems (ESSs) and electric vehicles (EVs), and a collaborative/non-collaborative relationship between prosumers [7].
Specifically in the context of DSM, residential load modeling and user comfort modeling are presented as one of the important measures that fulfill the above idea. The modeling • Introduction of a novel residential comfort function capable of integrating parameters associated with the human perceptions of temperature and humidity. • Proposal of a multi-objective SHC model that relies on PSO for scheduling the residential loads and integrates the proposed comfort function by means of fuzzy logic. • Improvement of thermal comfort indices, the computational burden of the SHC, the efficiency of the particle swarm optimization (PSO) algorithm, and economic savings when compared with [5,6]. • Supplemental materials are available at GitHub ® through https://github.com/ jonathacosta/SmartGrid/tree/main/SCC-SHC accessed on 15 February 2023, including our source codes, allowing prompt reproduction of our results.
The remainder of this paper is organized as follows. Section 2 presents a brief overview of the theoretical foundations. Section 3 presents the PSO and fuzzy principles along with mathematical definitions. Section 4 describes the methodology used to obtain the new comfort function and incorporate it into the SHC. Section 5 presents the results obtained under different scenarios. A discussion of the results is presented in Section 6 and our final considerations are provided in Section 7.

Demand-Side Management (DSM)
Among the main programs, DSM stands out for the response to tariff signals offered by the concessionaire to end users, namely, time of use (time-of-use (ToU)), critical peak pricing (CPP), and real-time price (RTP) [17].
In the Brazilian market, the "white-rate tariff" is a term for the ToU [18] tariff, as mentioned above. In this scenario, low-voltage consumers, called group B, are informed of energy costs based on the day and time of consumption. Such a program provides significant benefits by shifting consumption from peak periods to times when the power distribution system has spare capacity. Table 1 shows that as more loads are shifted to off-peak hours and the difference between the conventional tariff (CT) and ToU tariffs increases, the savings for consumers increase as well [18]. Otherwise, high energy costs may be incurred, which is why the use of SHCs is of great importance in this scenario.

Smart Home Controllers (SHCs)
The basic definition of an SHC is based on the search for the best control strategy, considering the aim of scheduling household loads while minimizing cost and maximizing user comfort. In this sense, residential loads have a certain degree of flexibility in terms of duty cycle, power, and on/off times. These loads are part of the smart homes (SHs), which can exchange information with the utility in response to DSM programs. At this point, it should be emphasized that SHs can include DG units with or without ESSs and EVs to support the optimization goal of SHCs.
In this context, in [19] the authors proposed a simulation tool for residential load scheduling that uses binary particle swarm optimization (BPSO) and allows the proper selection of DG units. However, the mathematical model proposed in the tool does not have a function to evaluate the comfort level of the user. In [3], an event-based controller using integer linear programming (ILP) was proposed to minimize residential energy consumption while considering the variation in the electricity tariff and the average consumption of scheduled loads. However, the authors did not present user comfort metrics, and the proposed approach does not minimize consumption peaks, although it uses a restriction to avoid network overloads.
The authors of [20,21] employed a mixed ILP to optimize the operation of residential loads based on consumer preferences, which were modeled in a load schedule sliding window (LSSW) of heating, ventilation, and air conditioning (HVAC) equipment. The assessed scenarios combined DG, ESSs, and EVs. In [21], a thermodynamic comfort model for thermostatic loads was incorporated using linear programming (LP), where the index predicted mean vote (PMV) was used to measure the thermal comfort. However, this work did not consider users' overall comfort level.
The authors of [22,23] proposed a dynamic parameter selection process to improve the performance of an HVAC controller designed for load balancing within one hour. However, comfort and consumption optimization functions were not included. In [24], mixed integer nonlinear programming (MINLP) is used while taking into account changes in the intraday energy price and user preferences for thermal comfort in order to minimize daily energy demand. The authors did not examine overall user comfort and did not consider perceived user comfort.
A linear aggregation function with weights in the range [0, 1] was incorporated into the load controller by [4] to correlate the consumption and comfort functions; however, the authors did not address the perceived comfort of users. In [25], the authors introduced an equilibrium parameter and a comfort model using the Taguchi loss function. Their proposal relied on convex optimization, and they studied the rate scenarios day-ahead price (DAP) and flat price (FP). The authors did not investigate the users' perceptions of comfort, and only considered pre-configured devices registered in the SHC. The controller evaluated in [26] used genetic algorithm (GA), teacher learning-based optimization (TLBO) and LP for load scheduling, and the authors proposed a novel optimization technique based on the combination of GA and TLBO called teacher learning genetic optimization (TLGO). The proposed technique presents a satisfaction cost index depending on the time and the type of device, where the user can use more electrical devices or use the same device for a longer period of time. The studies reported in [27] present a home interactive interface (HIC) based on the ubiquity concept to enable SHs users to monitor residential loads and comfort metrics, as well as consumption and operational status related to fault alerts. The multi-objective controller described in [5] includes a global comfort function, while the work in [4] evaluated multiple fare scenarios associated with DG. The authors considered the user's comfort level based on the relevance of each load to that comfort level. In these proposals, however, the relevance of loads was fixed and the user's perceived comfort was not examined. The method introduced in [5] was reformulated in [28] by implementing an GA-based approach. This approach applies Pareto front approximation for the automatic definition of load activation, and provides users with options that take into account both energy consumption and residential comfort. According to [6], it is possible to associate PSO with the mathematical formulation of comfort and loads presented in [5], where it is possible to obtain a maximum consumption threshold modeled by an inverted Gaussian. Similarly, the authors did not address the users' perception of comfort.
In [29], the authors presented a residential controller that optimizes the charge/discharge scheduling of local ESSs in SHs with DG. It aims to it aims to minimize the cost of local energy consumption and to enable the negotiation of excess energy between prosumers and between prosumers and the utility. The authors used an objective function based on multi-objective grey wolf optimization (MOGWO) and compared the results with PSO. The authors did not, however, examine users' perceptions of comfort A coordination model involving a central controller, local controllers, and residential consumers was proposed in [30]. The hierarchical structure aims to reduce demand through competitive bidding. The authors modeled the consumption of air conditioners and water heaters using an optimization function based on mixed integer linear programming (MILP) to minimize the total reward at each bid.
Lyapunov optimization based on virtual queue stability was used in [31]. This work aimed to study energy optimization in an SH with HVAC loads, DG, and an ESS. The proposed algorithm creates and controls four queues for indoor temperature, EV charging, and ESS. System implementation is conducted by convex programming. The authors of [32] employed fuzzy logic to determine the estimated comfort and cost-benefit ratio in the near future, and used simulated anneling (SA) to determine the set point for battery bank operation. Their focus was on maximizing the monthly profit from energy sales. In turn, the study of [33] presented an algorithm that reduces the consumption of HVAC loads. The resulting energy surplus enables the adjustment of the illuminance set point in the range of 0-500 lux to maximize the user's visual comfort. Both of the aforementioned controls are based on fuzzy logic. Finally, in [34], a controller was proposed that considers DG and ESS to minimize the energy cost. The load schedule results from the proposed algorithm based on ant colony optimization (ACO) and TLBO. The authors studied comfort in terms of thermal and lighting preferences, though they did not consider the user's perception of comfort.

Comfort Analysis Strategy
Based on the above, residential comfort can be classified into three categories: (a) Conceptual Comfort, which refers to the wellbeing of the user and the perception of less effort. An example is communication and automatic configuration between internet of things (IoT) devices in a SH that does not require specific knowledge of the user, as in [27].
This type of convenience, by its nature, does not include quantitative metrics. (b) Individual Comfort, which refers to the individual measurement of variables associated with user comfort, that is, temperature, humidity, lighting, noise, and CO 2 levels, among others. Each variable can be analyzed under a specific metric, as in [31,33]. (c) Global Comfort, which refers to a numerical index representing the sum of the individual values associated with each residential load enabled according to user preferences, as in [5,6,25]. In this category, each residential load (x i ) is assigned a value representing its relevance level (w i ), which can be expressed as the sum of the products x i × w i . Therefore, in the above research, it can be seen that while SHC algorithms and current strategies consider user preferences in comfort modeling, they do not consider user perceptions. The user's comfort preferences have been considered when registering household loads in the SHC. On the other hand, the user's comfort perception varies throughout the day and has not been considered in SHC modeling in the aforementioned studies. It is worth noting that the present work focuses on global comfort and aims at optimizing residential comfort by incorporating user-perceived variables, as presented in Section 1.

Computer Algorithms
The strategy presented in this paper to minimize energy costs and maximize user comfort consists of a combination of fuzzy logic and PSO. Below, we present the mathematical bases of PSO and fuzzy logic.

Principles of Fuzzy Sets and Logic
In classical (binary) logic, sets of elements are called crisp sets, in which it is defined that an element x belongs to a set A and not to a set B, as there is a well-defined boundary to decide whether or not element x belongs to a set, expressed in the following form: x ∈ A and x / ∈ B. In fuzzy logic, sets of elements are called fuzzy sets, in which an element x has degrees of membership in set A and in set B, as the above boundary decision is not present. The degree of membership of an element x in a set A is expressed by µ A (x), which takes continuous values in the closed interval [0,1]. Thus, an element x can be described by its degrees of membership in the sets A and B, which can be expressed, for example, in the form µ A (x) = 0.4 and µ B (x) = 0.6.
Furthermore, a linguistic variable is defined as a variable with values that are fuzzy set names (U), as in: U = {"cold", "warm", "very warm"}. Such variables refer to the diffuse human perception of measurable quantities, and may contain sets of logical connectives (negation: no, connectives: and/or), modifiers (much, little), and delimiters (such as parentheses). Otherwise, a function that establishes a relationship between crisp values and linguistic variables is defined as a membership function (u A (x)) in fuzzy logic. This function expresses a priori knowledge about the behavior of the analyzed variable, and can be modeled by a profile: triangular, trapezoidal, Gaussian, generalized bell, sigmoidal, and others.
That said, mapping an input with a precise value (not fuzzy through membership functions (u A (x)) is called the fuzzy step of a fuzzy inference system. This step processes rules in the linguistic variables to derive the output values, for which it uses the Mamdani or Takagi-Sugeno method. The first method returns a fuzzy set, while the second method returns a real number. The last step of a fuzzy inference system is called defuzzification, and can use one of several well-known methods for it: centroid, first-of-maximum, maximum criterion, angle bisector, and others.

Formalization
Formally, a fuzzy set A in X is expressed as a set of ordered pairs, as shown in Equation (1): where u A (x) is the membership function of element x in the set A, which can be represented as in Equation (2) where: a, b, c, d represent the limits of functions on the Cartesian axis.

Application
Fuzzy inference systems are commonly used in many areas, for example, in the development of control systems for air conditioners, washing machines and vehicles. In the context of this paper, Figure 1 illustrates human perception of temperature in a residential environment. The fuzzy degrees of membership in the "cold" and "warm" groups are represented by the hatching in the Gaussian lines in the center of the figure.
Note that the values corresponding to a temperature of ≈ 30 • C (a value of crisp on the ordinate axis) have a membership degree of µ mild (temp) ≈ 0.26, µ hot (temp) ≈ 0.49, and µ very_hot (temp) ≈ 0.15 on the vertical axis ('membership degree'). Direct application of fuzzy logic (FL) and a link to the implemented source codes are provided for those involved in related research. In addition, modeling and control of systems with fuzzy logic are available in [35,36], and introductory concepts and a methodology for applying fuzzy logic in the context of DSM are presented in [37][38][39].

Principles of Particle Swarm Optimization (PSO)
PSO is a stochastic population optimization method based on the collective behavior of animals, such as schooling or flocking [40]. The algorithm attempts to find the best solution using a population of particles, and is based on the concept of collective cooperation.

Formalization
In the PSO algorithm, a particle i is defined by the vectors of position ( x i ), velocity ( v i ), and best individual position ( pbest). A vector with the best global position of the swarm ( gbest) is the result of the individual positions of n particles in this cluster. The elements of the algorithm are:

A
The population of particles x i The position vector of particle i in the solution space f The evaluation function (fitness) v i The velocity vector of particle i pbest i The vector of the best individual position of particle i, corresponding to the position in the search space where particle i has the best value of the evaluation function f . gbest i The vector of the best global position of the particle, corresponding to the position that provides the best value among all pbest i .

Updating Individual and Global Best Positions
Equations (6) and (7) specify how pbest i and gbest i are updated with time t. The swarm is said to have n particles in a minimization problem of a function f such that: where pbest ∈ { pbest 0 , pbest 1 , · · · , pbest n }.

Updating the Velocity and Position of a Particle
In addition, the velocity ( v) for a particle i is defined by the inertia parameter, the cognitive parameter, and the social parameter. The first (inertia parameter) is the previous velocity of the swarm, which causes the particle to continue to move in the same direction as it already is. The second (cognitive parameter) expresses the particle's individual experience of where the solution lies, and influences the particle to move to a better position than its current one. The third parameter (social parameter) represents the experience of the swarm, and influences the particle to follow in the direction of its best neighbors. Equations (8) and (9) respectively describe how the velocity and position of the ith particle are updated: where c 1 and c 2 are positive constants representing the cognitive and social parameters, respectively, the variables r 1 and r 2 are random numbers ∈ [0, 1], and w is the inertia weight.

Application
General aspects regarding the development of the PSO algorithm, along with discussion of the constraint factors, inertia weights, dynamic tracking systems, adaptive parameter adjustments, and more, are available in [41,42]. In addition, [16,[43][44][45] provide examples of the use of PSO and fuzzy strategies in other applications. Note the first decision block of the flowchart; after loading the user's preference and perception values, PSO can achieve a tradeoff between savings and comfort using the comfort conventional concept according to user preferences or the new comfort concept according to user perception.  Note the first decision block of the flowchart; after loading the user's preference and perception values, PSO can achieve a tradeoff between savings and comfort using the comfort conventional concept according to user preferences or the new comfort concept according to user perception. The SHC receives information about utility billing (T), residential loads (L m ), residential load activation preferences (L m best ), and comfort level (C L m ). The residential loads considered here (L m ) include: (a) schedulable loads that can be directly activated by smart outlets at a specified time interval, such as air conditioners, heaters, and pool filter pumps, among others; and (b) non-schedulable loads that cannot be directly controlled, such as multimedia equipment, microwave ovens, toasters, vacuum cleaners, etc. The PSO algorithm is used for multi-objective optimization of schedulable loads. For this purpose, the data comprising the residential loads, consumption profile ( f 1 ), and residential comfort profile ( f 2 ) are modeled, leading to an appreciation of consumption (a), savings (b), and comfort (c) by a day-ahead load schedule (d) considering both asynchronous operation and synchronous operation throughout the same day.  The SHC receives information about utility billing (T), residential loads (L m ), residential load activation preferences (L m best ), and comfort level (C L m ). The residential loads considered here (L m ) include: (a) schedulable loads that can be directly activated by smart outlets at a specified time interval, such as air conditioners, heaters, and pool filter pumps, among others; and (b) non-schedulable loads that cannot be directly controlled, such as multimedia equipment, microwave ovens, toasters, vacuum cleaners, etc. The PSO algorithm is used for multi-objective optimization of schedulable loads. For this purpose, the data comprising the residential loads, consumption profile ( f 1 ), and residential comfort profile ( f 2 ) are modeled, leading to an appreciation of consumption (a), savings (b), and comfort (c) by a day-ahead load schedule (d) considering both asynchronous operation and synchronous operation throughout the same day.

Energy tariff
Residential loads

Mathematical Modeling
The mathematical model of the SHC is represented as a discrete-time system operating at a sampling rate T s that allows the management of controllable and non-controllable loads according to the residential consumption profile. In the proposed approach, the cost function ( f 1 ) and the comfort function ( f 2 ) define the financial savings and the comfort relevance level, respectively, according to Figure 3. Table 2 defines the variables used in the modeling.  This paper uses the mathematical definitions of residential load at the grid level, as presented in [3]. The mathematical model of residential loads corresponds to Equation (10), considering the following premises: m schedulable loads, N daily samples, and a sampling rate T s , as well as the notation described in Table 2, as follows: subject to the following constraints: The constraints in Equation (11) state that the schedule for activation of the m-th load must be within the minimum and maximum flexibility intervals defined by the user, while the loads must not exceed the threshold demand at the k-th time of activation according to the constraints of Equation (12).
The cost function ( f 1 ) defines the economic savings due to SHC. The first and second terms in Equation (13) correspond to the costs resulting from the user preference profile and the SHC scheduling, respectively: where f 1 ≥ 0, meaning that the schedule proposed by the SHC is accepted by the algorithm as a valid solution for the user.

Comfort Model-f 2
The comfort model proposed in [5] considers the comfort relevance level of a load m as a fixed value and defines user preferences. It takes into account the user's perception of comfort, for example, in terms of temperature and humidity. Such parameters may change the relevance that the user assigns to a given load m when registering it through the SHC. Considering the above, the second objective function ( f 2 ) defines the relevance of comfort (C Lm ) using fuzzy logic.
For this purpose, the user should register the residential loads that can be scheduled in SHC, as well as the comfort relevance values (0 ≤ C Lm ≤ 1) and the load onset times in terms of minimum (I Sm ), maximum (I Em ), and preferred (I Bm ) values. The C Lm value of each load is updated using fuzzy logic taking into account the user's perception of comfort.
Equation (14) represents the comfort function. The first term corresponds to the activation window of a load m with respect to the user's preferences; thus, this value is used as a reference for calculating the comfort. The second term defines the distance between the time instant (I Cm ) selected by SHC and the time preferred by the user (I Bm ), which is weighted by the comfort relevance of the m-th load.
For a given load m with a comfort relevance of C Lm = 1, this parameter takes the maximum value when the SHC's scheduled time converges with the user's preferred time (I Cm ≈ I Bm ). Otherwise, if I Cm ≈ I Sm (or I Cm ≈ I Em at the other end of the load activation window), the comfort is minimal, as the operation cycle starts at the time farthest from the one the user has specified as their preferred time. Figure 4 represents the fuzzification process of the comfort relevance level (C Lm ) considering user perception.

Fuzzification of Comfort Relevance Level
The values denoting the user's perception of temperature and humidity are the inputs of the fuzzy system by means of the linguistic variables τ and υ, respectively. The fuzzy system uses rules to calculate a new relevance value (ω) for a load m, then updates the value of C Lm from Equation (14). The values of τ and υ can be loaded automatically or passed to the SHC by the user. In the first case, the proposed algorithm accesses the weather data available at https://pt.weatherspark.com/ and https://tempo.inmet.gov.br/TabelaEstacoes/82397, accessed on 15 February 2023, to load the temperature and humidity values associated with τ and υ, respectively. In the second case, SHC interacts with the user through voice commands to collect information about the user's temperature and humidity perceptions, then assigns values to the respective variables. The user's perceptions are fuzzy variables that can be handled with the linguistic variables defined in Table 3. When the user starts interacting with the SHC, a timer is activated to ensure that the first mode of operation is loaded in the event that the process is not completed because the user gives up or times out. The comfort relevance stage update phase (ω) is the first stage to be executed by the SHC algorithm. The update from C Lm to ω is performed according to the criterion defined by Equation (15), meaning that only the registered loads with priorities close to the maximum relevance value (C Lm = 1.0) are activated.
where C Lm 0 is the initial value of the relevance comfort level of the m-th load registered by the user and ω is the value of the relevance comfort level comprising the fuzzy sets of the user's perception.

Comfort Fuzzification Model
The values of C Lm obtained from Equation (14) are updated considering fuzzy sets for the perception of thermal comfort (τ) and humidity (υ), the linguistic variables of which are defined by the corresponding notation and normalized range shown in Table 3. The linguistic variables of the fuzzy sets were quantitatively distributed using the intuitive method to investigate different combinations between them while considering the following definitions: τ = {t 1 , t 2 , t 3 , t 4 , t 5 }, υ = {υ 1 , υ 2 , υ 3 }. The ranges of linguistic variables for each fuzzy set (τ, υ, ω) were determined using Gaussian, trapezoidal, and triangular membership functions such that the thresholds converge with those defined by the corresponding standards of the Brazilian Association of Technical Standards (ABNT) (NBR 16401-2/2008) and the American Society of Heating, Refrigerating, and Air Conditioning Engineers (ASHRAE) [46]. The adjustment of the membership functions and the choice of generators for each membership function were accomplished by considering successive simulations using the exhaustive search method for each function and domain.
The fuzzy rules were created both by directly combining the two input variables and combinations between them. Thus, comfort relevance, that is, the output variable ω, always takes into account the influence of the input variables. Next, we incorporate the following rules.
If τ = t 5 and ∀υ, or if τ = t 4 and υ = u 3 , then ω = c 3 It can be observed that the output of the "low" (c 1 ) comfort level (ω) in (1) is when the user considers the ambient temperature as "cold" or "very cold" (τ ≤ t 2 ), regardless of the perceived humidity ( ). In this way, the rule establishes a relationship between user-perceived temperature and humidity, meaning that it provides the SHC with the flexibility to schedule loads by reducing them (ω). The remaining rules follow the same reasoning for creating the inference system. Figure 5 shows a surface map based on the relationship between user perception and the comfort adjustments made in the SHC. The user's comfort level is determined by defuzzification of the temperature and humidity variables perceived by the user. Following the fuzzification rules presented in this section, the surface map in Figure 5 is obtained. It is worth noting that the axes represent temperature, humidity, and comfort. In addition, user perception allows the comfort level to be adjusted even in fuzzy modeling, providing the SHC with the flexibility to reduce energy consumption in residential energy usage contexts. Figure 6 shows the behavior of the fuzzy set representing the temperature. The domain corresponds to the range between 0 and 40 • C, while the membership function is between 0.0 and 1.0. The fuzzy input 'very cold' is modeled by a trapezoidal function starting at 0 • C and decreasing from 10 to 18 • C. The fuzzy input 'cold' is modeled by a Gaussian function centered at 18 • C with a deviation of 3 • C. The fuzzy input 'mild' is modeled by a Gaussian function centered at 25 • C and deviating by 3 • C. The fuzzy input 'hot' is modeled by a Gaussian function centered at 35 • C and differing by 4 • C. The fuzzy input 'very hot' is modeled by a Gaussian function centered at 38 • C and differing by 4 • C. The shaded areas represent the sets of membership corresponding to the crisp input of 38 • C. This input is represented by the vertical bar on the abscissa axis, for which the projection on the ordinate axis represents its membership in the sets that contain it, that is, µ hot (τ) ≈ 0.75 and µ veryhot (τ) ≈ 1.0. Figure 7 shows the behavior of the fuzzy set named 'humidity'. The domain corresponds to the range between 0 and 100% of the relative humidity (RH), while the amplitude includes the membership values between 0 and 1. The 'low' input is modeled by a trapezoidal function that starts at 0 and decreases between 40 and 50% RH. The 'medium' input is modeled by a triangular function centered at 55% RH and bounded between 40 and 70% RH. The 'high' input is modeled by a trapezoidal function that starts at 60, increases to 70% RH, and remains constant at 75% RH. The shaded area represents the membership set defining the crisp input of 60% RH. This input corresponds to the vertical bar on the abscissa axis, and its projection on the ordinate axis represents the membership of the sets containing it, that is, µ medium (υ) ≈ 0.65. Figure 8 displays the behavior of the fuzzy set called 'comfort'. Both the domains and the amplitude range between 0.0 and 1.0. The 'low' input is modeled by a trapezoidal function that starts at 0 and decreases between 0.2 and 0.4. The 'medium' input is modeled by a trapezoidal function that starts at 0.2, increases to 0.4, remains constant at 0.6, and decreases to 0.8. The 'high' input is modeled by a trapezoidal function that starts at 0.6, increases to 0.8, and remains constant at 1.0. Unlike the previous graphs, the shaded area represents the membership sets corresponding to the crisp output of 0.83. This value is represented by the vertical bar on the abscissa axis, and its projection on the ordinate axis represents the membership of the sets containing it, that is, µ com f ort (ω) = 1.0.
The proposed fuzzy modeling relies on an object-oriented programming (OOP) approach. The source code was written in the Python ® language using the Scikit-Fuzzy, numpy, and random modules. The developed classes and methods are appropriately commented in the code for proper understanding of the programming logic, which includes a simulation field for new values of the fuzzy variables. The source code is available at https://raw.githubusercontent.com/jonathacosta/SmartGrid/main/SCC-SHC/Codes/ ModConfFz.py, accessed on 15 February 2023.
The following definitions identify each of the scenarios assessed in the simulations described in Section 5: • fz-comf: employs fuzzy variables to assign a new value to the comfort relevance level according to Equation (15)-user's perceptions. • nfz-comf: a fixed value for the comfort relevance level is used, which is specified by the user when registering the loads in the SHC-user's preferences. • PSO & nfz-comf: the algorithm proposed in [6], which relies on PSO and the comfort function proposed in [5], which uses nfz-comf. • PSO & fz-comf: the algorithm introduced in this paper, combining PSO and the comfort function proposed. • PSO & nfz-tag-comf: the algorithm proposed in [6], which relies on PSO and the comfort function proposed in [25], which uses nfz-comf. • PSO & fz-tag-comf: the algorithm presented in this paper combining PSO and the comfort function proposed in [25], with the addition of fuzzy comfort (fz-comf).

Multi-Objective SHC Function
The evaluation function of the solutions obtained with the SHC consists of the functions f 1 and f 2 . The first defines the resulting financial savings, while the second represents the user's comfort level. Equation (16) represents a total cost function F that consolidates f 1 and f 2 , corresponding respectively to Equations (13) and (14).
where α ∈ [0, 1]. The values adopted for α are directly related to the relationship between consumption and user comfort. Comfort is maximal for the maximum threshold α = 0.0, resulting in minimal or no savings. Conversely, comfort is minimal for α = 1.0, while savings are maximal. The pseudocode of SHC which applies the proposed comfort function is shown in Algorithm 1. To ensure performance, note that the convergence criterion is 20% of the maximum iterations, with the population restarted if no improvement in the solution is achieved after 10% of the iterations.

Simulation Scenarios and Analysis Criteria
The characteristics common to all simulation scenarios are: (a) sampling rate (T s ) 5.0 min; (b) daily demand threshold 4.0 kW, represented by an inverted Gaussian centered at 18:30 h with an amplitude of 1.0 kW to simulate a decrease in the demand threshold; (c) the ToU tariffs; and (d) the household loads described in Table 4 and detailed in [5].

Simulation Parameters
Reference loads are identified by the operating cycle, time per cycle (∆t) in minutes, average power (P) in kW, maximum power (P) in kW, best start time, minimum time, maximum time, and comfort relevance level (C Lm ). In addition, certain loads have two values for the best start time. Our simulations were performed with the same parameters presented in [6] to allow for a more fair comparison, considering the following aspects: (a) swarm size of ten particles, with each particle representing one possible solution of the algorithm, i.e., the total number of loads; (b) the weight change technique (w) and inertial weight (DIW); (c) the cognitive and social parameters (c 1 = 2 and c 2 = 2, respectively); (d) a maximum number of iterations of 10,000. Each solution in each scenario was executed 30 times.

Analysis Criteria
Each solution was evaluated based on the results of the simulated scenarios. The same simulation parameters were used for each scenario, with a single variable being changed each time to allow for fair comparison of the results. For this purpose, the fitness function, financial savings, relative comfort, expected consumption, total consumption of household loads, execution time, and standard deviation were analyzed for each solution. The scenarios were evaluated against the above metrics using load scheduling diagrams and exploratory data analysis according to the model developed by the authors. The corresponding source code is available at https://raw.githubusercontent.com/jonathacosta/ SmartGrid/main/SCC-SHC/Codes/ModEDA.py, accessed on 15 February 2023.

Analysis of Comfort Relevance Level
From Table 4, it is apparent that air conditioners have a relevant comfort level of (C Lm ) 1.0. This means that the SHC must prioritize the activation of these loads at the time chosen by the user in order to satisfy the user's comfort preferences. However, the user's comfort perception may vary over the course of days due to both climatic and psychological aspects. This means that the previously established comfort preferences may not match the individual's actual comfort perception at a given time. For example, the relevance of air conditioning must be adjusted to the user's comfort perception. Table 5 shows the variation in the relevance of user comfort level (C Lm ) for an air conditioner along with the fuzzy variables involved. It can be observed that the temperature (τ) and humidity (υ) perceptions were chosen under extreme conditions of the domain ranges. In addition, all loads are scheduled to ensure comfort. However, because C Lm is assigned with the value of ω, the load scheduling algorithm has the flexibility to shift loads to times close to peak hours, maximizing user comfort while simultaneously allowing for improvement of the cost-comfort ratio.

Analysis of Residential Scenarios
The simulations in this scenario consider the most critical tariff costs published by a regulatory agency in northeastern Brazil, namely, USD 0.3047 for green flag tariffs, USD 0.3073 for yellow flag tariffs, and USD 0.3230 for red flag tariffs [47].
It is useful to note that the use of the white tariff (ToU) allows an additional adjustment of the cost-comfort ratio by α according to Equation (16). This parameter was used in this simulation as [0.25, 0.50, 0.75] to highlight different SHC configuration conditions between two houses with the same loads and the same fuzzy parameters. With the parameter α = 0.25, according to Equation (16), the user sets SHC to 0.25 for cost savings and 0.75 for comfort. Therefore, the user configures the system to prioritize user comfort over savings in load scheduling. The reverse is true for α = 0.75, and for α = 0.5 there is an even threshold. 5.3.1. ToU Scenario com α = 0. 25 With the parameter α = 0.25, the user sets the SHC to 0.25 for cost savings and 0.75 for comfort. This configures the system to favor comfort over cost savings when scheduling loads. Table 6 shows the results of the simulations with the above parameters.  Table 6 shows the values and compares two different comfort functions, the first originally proposed by [5] and the second proposed by [25]. Note that the average user's comfort level is higher when the SHC uses the fz-comf comfort function instead of the nfz-comf comfort function. Even when the ω parameter tends to 0.0, the user continues to gain comfort. The same relationship is observed when the SHC sets fz-tag-comf instead of nfz-tag-comf. In this scenario, it can be seen that the use of the proposed comfort function provides further benefits, as it takes into account the user's perception of comfort in load scheduling instead only the user's preferences.

ToU Scenario com α = 0.50
Otherwise, using the parameter α = 0.50, the user sets the SHC to 0.50 for cost savings and 0.50 for comfort. In this way, the system can be configured to balance cost savings and comfort in load scheduling. Table 7 shows the result of the simulations for the above parameters. It can be observed that the use of the proposed comfort function in this scenario is more beneficial when the SHC operates with the fz-tag-comf function, as it takes into account the user's comfort perception, increases the average comfort, and reduces the load scheduling cost.

ToU Scenario com
Otherwise, with the parameter α = 0.75, the user sets the SHC to 0.75 for cost savings and 0.25 for comfort. This configures the system to prioritize cost savings over comfort when scheduling loads. Table 8 shows the results of the simulations with the above parameters. Thus, in this scenario where cost savings are the main concern, it is advantageous for the SHC to use only the nfz-tag-comf comfort function, as it provides the greatest savings at the highest comfort level. This means that the SHC does not take into account the user's perception of comfort, only their preferences as predefined in the load registration, guaranteeing an average comfort level while focusing on reducing the cost when scheduling loads.

Discussion
Simulations were performed considering all possible combinations between ToU energy tariffs, user preferences in terms of cost-comfort, user perception, and number of loads in a residence. The results confirm our initial hypothesis that the use of a comfort function integrating the above variables allows user comfort to be maximized without affecting cost.
In addition, improved performance leads to more flexible load scheduling, which allows shifting loads to times closer to user preferences. Figure 9a,b shows the load scheduling graphs for scenarios with and without fuzzy comfort considering the tariff ToU, α = 0.25, and 10 loads. The range in the graphs between 17:00 (5 PM) and 22:00 (10 PM) corresponds to the highest tariff costs. Therefore, SHC should reduce energy consumption during critical periods and/or shift loads to off-peak hours.  The red area in Figure 9a,b represents an air conditioner ('F2 AC') that should be put into operation at 17:00 (see Figure 9a). The application of fuzzy comfort (fz-comf) allows the load to be shifted to near 20:00, where 20:00 is the user's preferred time according to Table 4 (Id 7), maximizing thermal comfort. This process occurs at the algorithm level; a comfort relevance level mitigation factor is calculated from Equation (15) to increase the comfort function f 2 in Equation (14), and consequently the fitness evaluation function of each PSO solution according to Equation (16).
In general, in keeping with the initial hypothesis, the integration of user perception variables (humidity and temperature) results in an SHC model with fuzzy comfort than can lead to significant gains in the evaluated scenarios.
Overview and Other Possible Scenarios Figure 10a,b provides an overview of the tradeoff between comfort and cost for the features originally proposed in [5,25]. Figure 10a shows the user's comfort gain when the SHC is operated with different comfort functions, while Figure 10b shows the corresponding cost, optimizing the cost-comfort threshold defined for the SHC in each scenario. Thus, it is fair to say that the use of the proposed comfort function allows the SHC to maximize the user's comfort while including their perception of temperature and humidity and reducing the cost of load scheduling.

Conclusions
In previous studies, SHCs have been proposed that interact with users' comfort preferences; however, the dynamics of users' comfort perceptions have not been studied before. In this context, the present work addresses the problem of modeling user perception of home comfort. Our main objective was to mathematically model the dynamics of user perception of home comfort using fuzzy logic. Based on this model, we analyzed the proposed functions for the housing cost-comfort ratio and compared them with other comfort functions under the same conditions.
The results show that it is more beneficial to use our proposed fz-comfort comfort function in cases when the user asks the SHC to prioritize comfort over financial savings. In other cases, it is more beneficial to use a comfort function that only considers the user's comfort preferences, i.e., tag-comfort, and not the user's perceptions. This study makes an initial contribution to modeling users' comfort perceptions relative to their comfort preferences. A limitation of this study is the context of home comfort, which for the purposes of this study is associated with a single user interacting with the SHC. As a suggestion for future research, there remains a need to analyze user perceptions in multiuser scenarios, such as condominiums or houses, where a single SHC is operated by multiple users.

Data Availability Statement:
The data presented in this study are available upon request from the corresponding author.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript: