# An Evaluation of a Metaheuristic Artificial Immune System for Household Energy Optimization

Authors: Maria Navarro-Caceres; Pramod Herath; Gabriel Villarrubia; Francisco Prieto-Castrillo; G. Kumar Venyagamoorthy
Journal: Complexity
 (2018)

---

## Abstract

Devices in a smart home should be connected in an optimal way; this helps save energy and money. Among numerous optimization models that can be found in the literature, we would like to highlight artificial immune systems, which use special bioinspired algorithms to solve optimization problems effectively. The aim of this work is to present the application of an artificial immune system in the context of different energy optimization problems. Likewise, a case study is performed in which an artificial immune system is incorporated in order to solve an energy management problem in a domestic environment. A thorough analysis of the different strategies is carried out to demonstrate the ability of an artificial immune system to find a successful optima which satisfies the problem constraints.


---

## Body

## 1. Introduction

A Home Energy Management System (HEMS) is a key element in a domestic environment that improves household economy through automated technologies.In the recent years, different domestic buildings equipped with communication channels (smart houses) have actively participated in electrical networks [1] as building blocks in smart grids (SGs). Therefore, they play an important role in optimizing the scheduling of electric power [1, 2].There are a number of strategies that employ different techniques to optimize the scheduling of energy use in the home. Among many other strategies, statistical models are one example of them. We can see how they are leveraged in the work of [3], which models controllable loads using a Markovian approach. These loads depend on weather conditions. In [4], a demand-response program is automatically applied from classical methods to control the devices connected to the network under the uncertainty of the outside temperature and the price of electricity. In [5], three problems related to HEMS have been solved by applying an observable Markovian decision process. This work made it possible to reduce domestic energy costs in the electricity price market.Classical approaches had some limitations [6]; thus, new paradigms have been applied to solve HEMS. One successfully developed paradigm is that which uses bioinspired algorithms to solve optimization problems. These algorithms try to mimic the behavior of some biological entities to find solutions which, applying classical computation, would be too costly or even implausible in terms of time and resources. Some widely used and noteworthy algorithms are artificial neural networks (ANN), genetic algorithms (GA), or swarm intelligence [7]. Some bioinspired algorithms work in different contexts, and they render good results. One of these algorithms is the artificial immune system (AIS) which follows the principles of the vertebrae immune system to find solutions in an optimization problem. The AIS algorithm can be designed in a variety of ways. From the different variants, in this work, it is decided to use Opt-aiNet [8], which has been used successfully for the optimization of functions in different contexts [8]. Opt-aiNet allows finding several solutions in parallel. By using operations such as mutation, cloning, and suppression, each solution corresponds to different optima (maxima or minima) points in the optimization function.In the area of intelligent network optimization, several works that follow the bioinspired paradigm have been proposed. These include [9], who propose an energetic services modeling method based on the particle swarm optimization (PSO) algorithm. Soares et al. [10] propose a multiobjective genetic approach for scheduling domestic charge in an energy management system. Yuce et al. [11] present a neural network with a genetic algorithm (ANN-GA) to optimize energy management in the domestic sector. However, to the authors’ knowledge, AIS has only been implicated in some preliminary achievements in power management, such as solving power supply problems, or electrical reconfigurations. For example, in [12], an AIS is used to control thermal units in residential buildings, and in [13], the authors optimize a wind energy-generating system also with an AIS.In this paper, an in-depth review of the AIS concept and its application to different electrical problems is made. From the results of this review, a case study on a problem of home energy management optimization is described and solved using this algorithm. We aim to demonstrate that AIS can be successfully applied to electrical management problems in domestic settings. Part of our objective has been to adapt the Opt-aiNet algorithm to include complex constraints on the optimization problem and to work efficiently with a large number of variables.This paper presents a simple electric context with different devices, namely, a photovoltaic panel (PV), a battery system, a space heater or heater, a water heater, and must-run services. All of them are connected in a smart home, within an electrical system. It is aimed at optimizing the scheduling for the next 24 hours so that the electrical benefit is maximized between the energy that is sold and the energy that is bought.Two strategies are designed in our case study to represent two different electrical situations. In strategy 1, the HEMS manages the electric power with the electricity grid without considering any internal restriction. In other words, we do not consider any variable related to the maintenance of the domestic electric charge through the electrical energy produced by the PV system. Therefore, this strategy only seeks to optimize energy benefits. However, strategy 2 is aimed at supplying the electricity demand autonomously whenever possible. Therefore, the surplus generated by the PV is stored in the battery. HEMS will sell electricity to the grid when the battery is fully charged. Also, the battery is discharged when the electrical demand is greater than the power generated by the PV. If the battery cannot supply all the electrical charge, then the HEMS must buy electricity from the power grid. Based on these two strategies, three different experiments were developed. Firstly, a comparison of AIS with two different bioinspired algorithms is made, namely, the classical genetic algorithm (GA) and the particle swarm optimization (PSO). Secondly, both strategies are compared to analyze the influence of the battery in the home network. Finally, a deep analysis is carried out with different situations of the battery charge in the home network. The results obtained in all situations are expected to validate the AIS as an appropriate algorithm for the optimization of HEMS.This document is structured as follows. Section2 provides an overview of the design of AIS and a review about its involvement in electrical problems. Section 3 describes the technical details of the addressed electrical problem. Section 4 presents the configuration of AIS and its application to the electrical problem. In Section 5, the results obtained in the three case studies are outlined and discussed. Finally, Section 6 presents the conclusions of our research and future work.


## 2. Artificial Immune Systems

The organisms of many species have developed immune systems to protect them from external agents. Above all, vertebrate immune systems consist of different molecules, cells, and organs that are distributed throughout the body and are not controlled by any central entity. From an immunological point of view, any element present in the immune system is called an antigen. If this antigen belongs to the internal organism to protect the body, it is called self-antigen or antibody. Otherwise, the antigens from the external environment are called non-self-antigens and can provoke different diseases. Therefore, immune systems are aimed at distinguishing between self-antigens and non-self-antigens through a pattern recognition process, attacking only those that are harmful for the body [14].Drawing on the concept of the immune system, [15] developed the CLONALG algorithm, a clonal selection procedure that allows mutating some antibodies according to their affinity to an external antigen; therefore, in order to perform pattern recognition, it generates copies of the antibodies according to their affinity with the antigen. The copies are mutated following a rate δ inversely proportional to their affinity with the antigen (1).
(1)δ=efiβ,where β is a constant obtained empirically to normalize the effect of the fitness value fi of each cell. These new individuals are added to the general population and reevaluated to be reproduced and mutated again.In order to give a new solution for the optimization of functions, [8] developed Opt-aiNet, an artificial immune system (AIS) based on the CLONALG behavior. The information is encoded as antigens which should be recognized by the antibodies of our immune system. Then, the fitness value of an antigen is defined as the affinity between the antigen and the antibody and can be compared with a distance metric. Henceforth, small distances between an antigen and an antibody represent high affinity, whereas longer distances represent lower affinity.The Opt-aiNet algorithm follows the general description of an artificial immune system. Firstly, antibodies, which represent the different data to optimize, are randomly generated. Then, they are presented to the antigens, which encode the objective function, in order to calculate the affinity between them when the data are applied to the function. If one antibody obtains a good rating in the objective function, that means it has high affinity and therefore is selected. These chosen antibodies are reproduced and mutated based on their fitness value according to theCLONALG algorithm and the β parameter. In order to preserve diversity, antibodies whose affinity is lower than a given threshold ts are removed from the population.Artificial immune systems, in particular Opt-aiNet, are able to find several optima of the objective function in parallel. This means that AIS can find a set of good candidates for the solution of optimization problems that are different from one another. Additionally, AIS can preserve those individuals that are good enough to be reproduced and mutated in consecutive iterations.


### 2.1. AIS Applications in Energy Contexts

The concept of a next-generation power system such as smart grid, efficient energy management, and better power system planning cannot be achieved without electrical load forecasting [16]. Consequently, multiple time horizons which are associated with the regulation, dispatching, scheduling, and unit commitment of the power grid are analyzed and solved using different methods. Artificial intelligence (AI) is widely applied to a variety of applications, as it can handle the complexity derived from such electrical problems. In particular, bioinspired algorithms, such as artificial neural networks or swarm intelligence, are especially effective in solving this kind of problems. In this section, a brief but comprehensive literature review of a special bioinspired algorithm, the artificial immune systems, is provided. AIS was applied in different contexts with positive results: when solving combinatorial problems [17, 18], to detect intrusions in wireless sensor networks [19], or even to generate chord progressions [20]. The major goal of this section is to review, identify, evaluate, and analyze the performance of AIS in power systems and model research.Regarding the electrical context, there are plenty of proposals focusing on diverse fields. One of them is related to the control of variables and configuration of an electrical system. de Mello Honorio et al. [21] model an optimal power flow (OPF), which is a nonlinear, nonconvex, and large-scale problem with both continuous and discrete control variables, using a modified artificial immune system (AIS). The AIS makes use of hypermutation, which is responsible for local search, and receptor edition, which explores different areas in the solution space. The proposed AIS is combined with a gradient vector to improve the final results. This combination is also aimed at collecting valuable information during the hypermutation process, decreasing the number of generations and clones, and, consequently, speeding up the convergence process while reducing the computational time. Belkacemi and Feliachi [22] use a multiagent system (MAS) which follows the human immune system behavior to propose a new technique for power system reconfiguration and restoration, applied to a model of Southern California Edison’s Circuit of the Future. Each element of the MAS represents a natural immunological element that interacts with the other elements to heal the body. Similarly, the MAS is able to detect and isolate faults and restore power to the affected loads taking into consideration line capacity, voltage profile, and power losses [22]. de Oliveira et al. [23] present a methodology for the reconfiguration of radial electrical distribution systems to minimize energy losses making use of the bioinspired metaheuristic artificial immune system. The AISs have to plan the system operation considering both radiality and connectivity constraints and different load levels. Consequently, the AIS algorithm is adapted to accommodate the features of the problem better and to improve the search process. The algorithm developed is tested in well-known distribution systems, with very successful results. Souza et al. [24] solve the reconfiguration problem of electrical distribution systems (EDSs) with variable demand, using the artificial immune algorithm. As the reconfiguration problem with variable demand is a complex problem of a combinatorial nature, Copt-aiNet (artificial immune network for combinatorial optimization), which is a combinatorial version of the algorithm Opt-aiNet, is applied to identify the best radial topology for an EDS in order to minimize the cost of energy losses in a given operation period. A specialized sweep load flow for radial systems was used to evaluate the feasibility of the topology with respect to the operational constraints of the EDS and to calculate the active power losses for each demand level. The obtained results were compared with those in the literature in order to validate and prove the efficiency of the proposed algorithm. Souza et al. [25] also aim to solve the reconfiguration problem of EDS by comparing the results of the Copt-aiNet (artificial immune network for combinatorial optimization) and the Opt-aiNet (artificial immune network for optimization) algorithms. A specialized forward/backward radial power flow was used to evaluate each of the proposed solutions in order to determine its power losses and its feasibility regarding the operational constraints of the EDS. To validate the use of an AIS, the final results were compared with other solutions obtained with other algorithms in the literature.Other important field of application is the forecasting of electrical variables (loads and power generation or consumption). Abdul Hamid and Abdul Rahman [26] propose an artificial neural net (ANN) trained following the behavior of an artificial immune system (AIS) to generate a short-term load forecasting model. Two sets of electrical energy demand data were used to test the capability of the proposed algorithm. The results presented in the manuscript show that the proposed AIS learning algorithm is capable of providing a forecast comparable to that of an artificial neural network with an integrated back propagation (BP) algorithm. Consequently, the AIS is an alternative learning algorithm for an artificial neural network. The work proposed by [27] is one of the first studies using an integrated AIS simulation for improved forecasting of electricity consumption with random variations. They develop a new system with different algorithms, namely, AIS, genetic algorithm (GA), and particle swarm optimization (PSO), to simulate annual electricity consumptions in selected countries. The mean absolute percentage error (MAPE) is applied to evaluate the results and select the best forecasting model. A case study with data of the annual electricity consumptions for 16 countries from 1980 to 2006 is analyzed. For the selected countries, the AIS method with the clonal selection algorithm (CLONALG) shows satisfactory results when applied with simulated data and has been selected as the preferred method. Hernandez et al. [28] model a hybrid artificial immune system (AIS) combining the back propagation method with the artificial immune system, to achieve higher accuracy, lesser input load data requirement, and faster convergence. The hybrid approach is implemented, and its results are compared with a GA and a PSO. This analysis reveals that AIS solves the problem in a more efficient way than do GA and PSO.Dudek [29] proposes a short-term load forecast model based on an AIS to predict the hourly load demand of a week. In this proposed technique, each antigen of AIS, which contains the time series load sequences (some part is a forecast sequence), is compared with historical load patterns. MAPE is also used to evaluate the performance of the proposed forecast model. The system achieves a minimum MAPE of 1.77%, which means the AIS obtains very successful results. AISs are also applied for economic optimization in an electrical environment. Dynamic economic dispatch determines the optimal scheduling of online generator outputs with predicted load demands over a certain period of time taking into consideration the ramp rate limits of the generators [30]. Basu [31] presents an artificial immune system algorithm that solves a heat and power economic optimization problem. The AIS is adapted to this problem, adding new operations such as hypermutation and tournament, and is then used in a preliminary test system.Basu [30] implements adaptive cloning, hypermutation, aging operation, and tournament selection. In order to validate the new AIS, numerical results of a ten-unit system with fuel cost function have been developed. The results obtained from the proposed algorithm are compared with those obtained from particle swarm optimization and evolutionary programming. From numerical results, it is shown that the proposed AIS provides a more efficient solution than do particle swarm optimization and evolutionary programming in terms of minimum cost and computation time. Aragón et al. [32] present an AIS-inspired algorithm, called IA EDP, which tries to solve an economic dispatch problem. It makes use of two versions of a redistribution power operator which tries to keep the solutions that it finds. The proposal is applied to eight problems taken from the literature. The results are compared with those derived from several other approaches to determine the advantages of the IA EDP against classical evolutionary computing.This brief background leads us to the conclusion that AIS can be applied to a variety of electrical contexts with very successful results. This fact encourages us to work with a specific AIS, called Opt-aiNet, also leveraged in different papers [24, 25] and to adjust it specifically to our case study. The classical Opt-aiNet usually works with a low number of variables (each individual contains about 6 variables at most) and without constraints encoded as mathematical functions. In the present work, this algorithm is adjusted to admit up to 336 variables and 25 linear constraints (inequalities and equations).


## 2.1. AIS Applications in Energy Contexts

The concept of a next-generation power system such as smart grid, efficient energy management, and better power system planning cannot be achieved without electrical load forecasting [16]. Consequently, multiple time horizons which are associated with the regulation, dispatching, scheduling, and unit commitment of the power grid are analyzed and solved using different methods. Artificial intelligence (AI) is widely applied to a variety of applications, as it can handle the complexity derived from such electrical problems. In particular, bioinspired algorithms, such as artificial neural networks or swarm intelligence, are especially effective in solving this kind of problems. In this section, a brief but comprehensive literature review of a special bioinspired algorithm, the artificial immune systems, is provided. AIS was applied in different contexts with positive results: when solving combinatorial problems [17, 18], to detect intrusions in wireless sensor networks [19], or even to generate chord progressions [20]. The major goal of this section is to review, identify, evaluate, and analyze the performance of AIS in power systems and model research.Regarding the electrical context, there are plenty of proposals focusing on diverse fields. One of them is related to the control of variables and configuration of an electrical system. de Mello Honorio et al. [21] model an optimal power flow (OPF), which is a nonlinear, nonconvex, and large-scale problem with both continuous and discrete control variables, using a modified artificial immune system (AIS). The AIS makes use of hypermutation, which is responsible for local search, and receptor edition, which explores different areas in the solution space. The proposed AIS is combined with a gradient vector to improve the final results. This combination is also aimed at collecting valuable information during the hypermutation process, decreasing the number of generations and clones, and, consequently, speeding up the convergence process while reducing the computational time. Belkacemi and Feliachi [22] use a multiagent system (MAS) which follows the human immune system behavior to propose a new technique for power system reconfiguration and restoration, applied to a model of Southern California Edison’s Circuit of the Future. Each element of the MAS represents a natural immunological element that interacts with the other elements to heal the body. Similarly, the MAS is able to detect and isolate faults and restore power to the affected loads taking into consideration line capacity, voltage profile, and power losses [22]. de Oliveira et al. [23] present a methodology for the reconfiguration of radial electrical distribution systems to minimize energy losses making use of the bioinspired metaheuristic artificial immune system. The AISs have to plan the system operation considering both radiality and connectivity constraints and different load levels. Consequently, the AIS algorithm is adapted to accommodate the features of the problem better and to improve the search process. The algorithm developed is tested in well-known distribution systems, with very successful results. Souza et al. [24] solve the reconfiguration problem of electrical distribution systems (EDSs) with variable demand, using the artificial immune algorithm. As the reconfiguration problem with variable demand is a complex problem of a combinatorial nature, Copt-aiNet (artificial immune network for combinatorial optimization), which is a combinatorial version of the algorithm Opt-aiNet, is applied to identify the best radial topology for an EDS in order to minimize the cost of energy losses in a given operation period. A specialized sweep load flow for radial systems was used to evaluate the feasibility of the topology with respect to the operational constraints of the EDS and to calculate the active power losses for each demand level. The obtained results were compared with those in the literature in order to validate and prove the efficiency of the proposed algorithm. Souza et al. [25] also aim to solve the reconfiguration problem of EDS by comparing the results of the Copt-aiNet (artificial immune network for combinatorial optimization) and the Opt-aiNet (artificial immune network for optimization) algorithms. A specialized forward/backward radial power flow was used to evaluate each of the proposed solutions in order to determine its power losses and its feasibility regarding the operational constraints of the EDS. To validate the use of an AIS, the final results were compared with other solutions obtained with other algorithms in the literature.Other important field of application is the forecasting of electrical variables (loads and power generation or consumption). Abdul Hamid and Abdul Rahman [26] propose an artificial neural net (ANN) trained following the behavior of an artificial immune system (AIS) to generate a short-term load forecasting model. Two sets of electrical energy demand data were used to test the capability of the proposed algorithm. The results presented in the manuscript show that the proposed AIS learning algorithm is capable of providing a forecast comparable to that of an artificial neural network with an integrated back propagation (BP) algorithm. Consequently, the AIS is an alternative learning algorithm for an artificial neural network. The work proposed by [27] is one of the first studies using an integrated AIS simulation for improved forecasting of electricity consumption with random variations. They develop a new system with different algorithms, namely, AIS, genetic algorithm (GA), and particle swarm optimization (PSO), to simulate annual electricity consumptions in selected countries. The mean absolute percentage error (MAPE) is applied to evaluate the results and select the best forecasting model. A case study with data of the annual electricity consumptions for 16 countries from 1980 to 2006 is analyzed. For the selected countries, the AIS method with the clonal selection algorithm (CLONALG) shows satisfactory results when applied with simulated data and has been selected as the preferred method. Hernandez et al. [28] model a hybrid artificial immune system (AIS) combining the back propagation method with the artificial immune system, to achieve higher accuracy, lesser input load data requirement, and faster convergence. The hybrid approach is implemented, and its results are compared with a GA and a PSO. This analysis reveals that AIS solves the problem in a more efficient way than do GA and PSO.Dudek [29] proposes a short-term load forecast model based on an AIS to predict the hourly load demand of a week. In this proposed technique, each antigen of AIS, which contains the time series load sequences (some part is a forecast sequence), is compared with historical load patterns. MAPE is also used to evaluate the performance of the proposed forecast model. The system achieves a minimum MAPE of 1.77%, which means the AIS obtains very successful results. AISs are also applied for economic optimization in an electrical environment. Dynamic economic dispatch determines the optimal scheduling of online generator outputs with predicted load demands over a certain period of time taking into consideration the ramp rate limits of the generators [30]. Basu [31] presents an artificial immune system algorithm that solves a heat and power economic optimization problem. The AIS is adapted to this problem, adding new operations such as hypermutation and tournament, and is then used in a preliminary test system.Basu [30] implements adaptive cloning, hypermutation, aging operation, and tournament selection. In order to validate the new AIS, numerical results of a ten-unit system with fuel cost function have been developed. The results obtained from the proposed algorithm are compared with those obtained from particle swarm optimization and evolutionary programming. From numerical results, it is shown that the proposed AIS provides a more efficient solution than do particle swarm optimization and evolutionary programming in terms of minimum cost and computation time. Aragón et al. [32] present an AIS-inspired algorithm, called IA EDP, which tries to solve an economic dispatch problem. It makes use of two versions of a redistribution power operator which tries to keep the solutions that it finds. The proposal is applied to eight problems taken from the literature. The results are compared with those derived from several other approaches to determine the advantages of the IA EDP against classical evolutionary computing.This brief background leads us to the conclusion that AIS can be applied to a variety of electrical contexts with very successful results. This fact encourages us to work with a specific AIS, called Opt-aiNet, also leveraged in different papers [24, 25] and to adjust it specifically to our case study. The classical Opt-aiNet usually works with a low number of variables (each individual contains about 6 variables at most) and without constraints encoded as mathematical functions. In the present work, this algorithm is adjusted to admit up to 336 variables and 25 linear constraints (inequalities and equations).


## 3. Home Energy Management Problem

In the designed case study, we consider a home electrical system that has some household appliance connected to it (Figure1).Figure 1
Schematic image of domestic electrical system.The context can be thought as a domestic grid with a generation part and a consumption part, connected to the power grid. As shown in Figure1, the generation system or the PV system includes the PV generator and the battery. The consumption parts are the electric loads which contain the following appliances: a space heater, a storage water heater, and must-run services. To balance the profit of energy services between the PV system and the loads, the scheduler is connected to the grid. The scheduler aims at maximizing the profit of energy services provided in a domestic energy management system through (2) OF, which is the objective function to optimize.
(2)OF=∑tλsoldPsoldt−λboughtPboughtt−∑j∈ELsVOLLjLjtshed−Vpvst.OF is a linear combination of four electrical factors.λsold,λbought,VOLLj and Vpv are constants that provide the prices per unit of energy load and are given by the market. The first term λsoldPsoldt represents the income from the sale of energy produced by the PV panel to the electricity grid. The second factor is the total cost of electrical energy that is bought from the network, λboughtPboughtt. The value of electrical energy is not served, meaning the lo is encoded in the third part,∑j∈ELsVOLLjLjtshed. Finally, the spillage costs of PV panels, VpvsSpvt, are represented in the last term of the equation.We need to balance the loads between the energy generated (the PV systemPpvt, the energy provided by the battery Pb,outt, and the energy bought from the power grid Pboughtt) and the energy consumed, meaning the electrical loads of the different services Ljt−Ljtshed (heater, storage water heater, and mustrung services) and the battery charge Pb,int (3). Additionally, the power flow limitation through the distribution line is stated in (4), where fmax is a constant set to 6 according to [33].
(3)Pboughtt+Ppvt+Pb,outt=∑j∈ELsLjt−Ljshedt+Pb,int,(4)−fmax≤Pboughtt−Psoldt≤fmax.The specific definitions for all domestic appliances are described in the following subsections.


### 3.1. PV System

The PV system can generate the power outputPpvt of the grid, which can be modelled through Equation 5.
(5)Ppvt=Ppv,pt−Spvt,where S refers to the spillage costs of the PV system and Ppv,p(t) is the potential power generation for the PV system. Ppv,p(t) is limited to maximum and minimum bands due to the prediction of the PV power generation, following (6). σpvdownand σpvup are down and up prediction variances for the PV system, respectively, and are calculated following [34]. Ppvpredt is the predicted power generated by the PV system. This amount is positive or equal to zero and is limited to the actual power generation of the PV, Ppv,p(t), as represented in (7). In other words, the PV system can potentially generate this power but HEMS cannot operate it because of economic and technical constraints.
(6)Ppvpredt−σpvdown≤Ppv,pt≤Ppvpredt−σpvup,(7)0≤Spvt≤Ppv,pt.


### 3.2. Electrical Loads

Electrical loads include loads that can be controllable and/or shiftable. In this case study, three types of loads are modelled: space heater,Lsh(t), which is a controllable load, storage water heater, Lswh(t), which is a shiftable load, and must-run services, Lmrs(t), which are noncontrollable-shiftable loads. Equations 8 and 9 define the total electrical load and total load shedding of our domestic grid, respectively. These loads are described in the following subsections.
(8)∑j∈ELsLjt=Lsht+Lswht+Lmrst,(9)∑j∈ELsLjshedt=Lshshedt+Lswhshedt+Lmrsshedt.


#### 3.2.1. Space Heater

The space heater provides the desired indoor temperature. Equation10 represents the performance of the space heater based on the relationship between the indoor temperature and its electrical load. In (10), θ0 is the initial indoor temperature in time t = 1, which is assumed to be equal to the desired temperature. R is the thermal resistance, and C is the thermal capacity of
(10)θint+1=θinte−1/RC+LshtR1−e−1/RC+θoutpredt1−e−1/RC,t≥2θint=θ0=θdes,t=1.Equation11 represents the limitation of the indoor temperature. In our case study, this limitation is set to 1°C more or less than the desired temperature. Finally, due to physical factors, the loads and the load sheddings are both limited by their maximum and minimum constraints (12) and (13).
(11)−1≤θint−θdes≤1,(12)Lshmint≤Lsht≤Lshmaxt,(13)0≤Lsshshedt≤Lsht.


#### 3.2.2. Storage Water Heater

The storage water heater is responsible for preserving the heat in the water tanks. The maximum and minimum limitations of the storage water heater’s load are stated in (14). The maximum energy consumption of the storage water heater should be less than the maximum capacity of the tank Uswh, according to (15). Finally, the maximum of the load shedding of the storage water heater is always less than the energy consumption of the appliance (16).
(14)Lswhmint≤Lswht≤Lswhmaxt,(15)∑t=1NtLswht=Uswh,(16)0≤Lswhshedt≤Lswht.


#### 3.2.3. Must-Run Services

Must-run services consist of loads that should be provided quickly, and therefore, it is not easy to predict them, for example, lighting and entertainment. For the purposes of this paper, it is assumed that there is no uncertainty in predicting the electrical loads of must-run services (17). As in the storage water heater, the maximum of the load shedding Lmrsshedt must always be less than the energy consumed Lmrs(t) (18).Also, the load shedding constraint is stated in (18).
(17)Lmrst=Lmrspredt,(18)o≤Lmrsshedt≤Lmrst.


### 3.3. Battery System

The battery system can be used to apply the charge and discharge strategies in the HEMS. A flowchart (Figure2) is designed to operate with the battery in the domestic environment. The system aims at providing the required electrical demand, maximizing its benefits. When there is a surplus Pb,in(t) of the energy generated (i.e., the PV panel generates more energy Ppv(t) than the total load TL(t) demands), it is stored in the battery (Cb(t)). If the battery is fully charged Cbt>Cbmax, then it is sold to the grid Psold(t). On the contrary, the system makes use of the energy stored in the battery Pb,out(t) when the electrical demand is higher than the power generation of the PV panel. Additionally, if the battery cannot provide the energy needed (i.e., is unavailable or completely discharged, Cbt>Cbmin), the system will buy the electricity Pbought(t) from the power grid.Figure 2
Flowchart modelling the battery parameters.


## 3.1. PV System

The PV system can generate the power outputPpvt of the grid, which can be modelled through Equation 5.
(5)Ppvt=Ppv,pt−Spvt,where S refers to the spillage costs of the PV system and Ppv,p(t) is the potential power generation for the PV system. Ppv,p(t) is limited to maximum and minimum bands due to the prediction of the PV power generation, following (6). σpvdownand σpvup are down and up prediction variances for the PV system, respectively, and are calculated following [34]. Ppvpredt is the predicted power generated by the PV system. This amount is positive or equal to zero and is limited to the actual power generation of the PV, Ppv,p(t), as represented in (7). In other words, the PV system can potentially generate this power but HEMS cannot operate it because of economic and technical constraints.
(6)Ppvpredt−σpvdown≤Ppv,pt≤Ppvpredt−σpvup,(7)0≤Spvt≤Ppv,pt.


## 3.2. Electrical Loads

Electrical loads include loads that can be controllable and/or shiftable. In this case study, three types of loads are modelled: space heater,Lsh(t), which is a controllable load, storage water heater, Lswh(t), which is a shiftable load, and must-run services, Lmrs(t), which are noncontrollable-shiftable loads. Equations 8 and 9 define the total electrical load and total load shedding of our domestic grid, respectively. These loads are described in the following subsections.
(8)∑j∈ELsLjt=Lsht+Lswht+Lmrst,(9)∑j∈ELsLjshedt=Lshshedt+Lswhshedt+Lmrsshedt.


### 3.2.1. Space Heater

The space heater provides the desired indoor temperature. Equation10 represents the performance of the space heater based on the relationship between the indoor temperature and its electrical load. In (10), θ0 is the initial indoor temperature in time t = 1, which is assumed to be equal to the desired temperature. R is the thermal resistance, and C is the thermal capacity of
(10)θint+1=θinte−1/RC+LshtR1−e−1/RC+θoutpredt1−e−1/RC,t≥2θint=θ0=θdes,t=1.Equation11 represents the limitation of the indoor temperature. In our case study, this limitation is set to 1°C more or less than the desired temperature. Finally, due to physical factors, the loads and the load sheddings are both limited by their maximum and minimum constraints (12) and (13).
(11)−1≤θint−θdes≤1,(12)Lshmint≤Lsht≤Lshmaxt,(13)0≤Lsshshedt≤Lsht.


### 3.2.2. Storage Water Heater

The storage water heater is responsible for preserving the heat in the water tanks. The maximum and minimum limitations of the storage water heater’s load are stated in (14). The maximum energy consumption of the storage water heater should be less than the maximum capacity of the tank Uswh, according to (15). Finally, the maximum of the load shedding of the storage water heater is always less than the energy consumption of the appliance (16).
(14)Lswhmint≤Lswht≤Lswhmaxt,(15)∑t=1NtLswht=Uswh,(16)0≤Lswhshedt≤Lswht.


### 3.2.3. Must-Run Services

Must-run services consist of loads that should be provided quickly, and therefore, it is not easy to predict them, for example, lighting and entertainment. For the purposes of this paper, it is assumed that there is no uncertainty in predicting the electrical loads of must-run services (17). As in the storage water heater, the maximum of the load shedding Lmrsshedt must always be less than the energy consumed Lmrs(t) (18).Also, the load shedding constraint is stated in (18).
(17)Lmrst=Lmrspredt,(18)o≤Lmrsshedt≤Lmrst.


## 3.2.1. Space Heater

The space heater provides the desired indoor temperature. Equation10 represents the performance of the space heater based on the relationship between the indoor temperature and its electrical load. In (10), θ0 is the initial indoor temperature in time t = 1, which is assumed to be equal to the desired temperature. R is the thermal resistance, and C is the thermal capacity of
(10)θint+1=θinte−1/RC+LshtR1−e−1/RC+θoutpredt1−e−1/RC,t≥2θint=θ0=θdes,t=1.Equation11 represents the limitation of the indoor temperature. In our case study, this limitation is set to 1°C more or less than the desired temperature. Finally, due to physical factors, the loads and the load sheddings are both limited by their maximum and minimum constraints (12) and (13).
(11)−1≤θint−θdes≤1,(12)Lshmint≤Lsht≤Lshmaxt,(13)0≤Lsshshedt≤Lsht.


## 3.2.2. Storage Water Heater

The storage water heater is responsible for preserving the heat in the water tanks. The maximum and minimum limitations of the storage water heater’s load are stated in (14). The maximum energy consumption of the storage water heater should be less than the maximum capacity of the tank Uswh, according to (15). Finally, the maximum of the load shedding of the storage water heater is always less than the energy consumption of the appliance (16).
(14)Lswhmint≤Lswht≤Lswhmaxt,(15)∑t=1NtLswht=Uswh,(16)0≤Lswhshedt≤Lswht.


## 3.2.3. Must-Run Services

Must-run services consist of loads that should be provided quickly, and therefore, it is not easy to predict them, for example, lighting and entertainment. For the purposes of this paper, it is assumed that there is no uncertainty in predicting the electrical loads of must-run services (17). As in the storage water heater, the maximum of the load shedding Lmrsshedt must always be less than the energy consumed Lmrs(t) (18).Also, the load shedding constraint is stated in (18).
(17)Lmrst=Lmrspredt,(18)o≤Lmrsshedt≤Lmrst.


## 3.3. Battery System

The battery system can be used to apply the charge and discharge strategies in the HEMS. A flowchart (Figure2) is designed to operate with the battery in the domestic environment. The system aims at providing the required electrical demand, maximizing its benefits. When there is a surplus Pb,in(t) of the energy generated (i.e., the PV panel generates more energy Ppv(t) than the total load TL(t) demands), it is stored in the battery (Cb(t)). If the battery is fully charged Cbt>Cbmax, then it is sold to the grid Psold(t). On the contrary, the system makes use of the energy stored in the battery Pb,out(t) when the electrical demand is higher than the power generation of the PV panel. Additionally, if the battery cannot provide the energy needed (i.e., is unavailable or completely discharged, Cbt>Cbmin), the system will buy the electricity Pbought(t) from the power grid.Figure 2
Flowchart modelling the battery parameters.


## 4. Experimental Setting

To assess the performance of the proposed HEMS, some parameters have been set to optimize the system. The maximum power produced by the PV system is 2 kW. The battery can store betweenCminb 48 and Cmaxb 2.4 kWh. The maximum heating power of the space heater (SH) Lshmaxt equals 2 kW to maintain the temperature of the house within ±1 of the desired temperature (θdes 23°C). The thermal resistance, R, of the building shell is equal to 18°C/kW, and the capacity C equals 0.525 kWh/°C. The energy capacity of the storage water heater (Uswh) is 10.46 kWh (180 L) which has 2 kW as maximum of heating elements Lswhmax. Table 1 displays the predicted data that has been used in [33]. Table 2 gives the price data of the system. VOLL and spillage costs of PV power generation are shown in Table 3.Table 1
Predicted data of uncertain variables.
t
Ppvpred(t)
σpvup
σpvdown
θoutpred(t)
Lpredmrs(t)
1
0
0.03
0.01
5.5
0.3
2
0
0.03
0.01
5.5
0.3
3
0
0.03
0.01
5.2
0.3
4
0
0.03
0.01
5.2
0.3
5
0
0.03
0.01
4.8
0.4
6
0
0.03
0.01
5.5
0.6
7
0.25
0.03
0.01
6.5
0.8
8
0.75
0.03
0.01
7.5
0.8
9
1.25
0.03
0.01
9.8
0.7
10
1.75
0.03
0.01
10.1
0.55
11
1.9
0.03
0.01
11.5
0.5
12
1.9
0.03
0.01
12
0.5
13
1.9
0.03
0.01
12.5
0.5
14
1.75
0.03
0.01
12
0.5
15
1.25
0.03
0.01
11.5
0.6
16
0.75
0.03
0.01
10
0.8
17
0.25
0.03
0.01
9
1.5
18
0
0.03
0.01
8.5
1.8
19
0
0.03
0.01
8
1.7
20
0
0.03
0.01
7.5
1.1
21
0
0.03
0.01
7
0.9
22
0
0.03
0.01
6.5
0.7
23
0
0.03
0.01
6.2
0.6
24
0
0.03
0.01
6
0.4Table 2
Price data of the system.
Price ($/MW)
Time (hour)
λi
λnet
23–7
2.2
0.0814
8–14
2.2
0.1408
15–20
2.2
0.3564
21-22
2.2
0.1408Table 3
VOLL and spillage costs.
VOLL ($/MW)
Spillage cost ($/MW)
Time (hour)
SH
SWH
MRS
PV
22–7
1
1
2.2
4
8–21
1
1
2.2
4These data are used in our HEMS to optimize the function (2). The objective function is integrated into Opt-aiNet to get an optimized schedule of 24 hours in a domestic environment. Following the Opt-aiNet procedure, the initial population randomly generated, where each individual is a set of electrical values for 24 hours, must comply with the constraints modelled in the electrical management problem. For this purpose, each datum of the individual is considered as an electrical parameter to optimize for 24 hours. Initially, the parameters which only depend on some fixed boundaries (6), (7), (12), (14), and (17) are generated. Then, these parameters are used as new boundaries for those electrical parameters that depend on them (the rest of the equations are given in the model of Section 3). This methodology is recursively applied until all the parameters needed for each individual are generated. Finally, to obtain the parameters related to the battery load, the parameters previously calculated and the flowchart of Figure 2 are applied to generate the new ones.With the individuals generated, Opt-aiNet work follows these steps:(1)
InitiateN population following the method above, to respect the linear constraints and the flowchart if it is the case.
(2)
Evaluate each individual according to the optimization function given in (2).
(3)
CreateNc clones of each individual. The elements of each clone should be slightly changed according to the mutation equation (1).
(4)
For each cell or antibody, select the best clone with the highest objective value.
(5)
If the mean objective of the last iteration and the present one are below a limit, then similar individuals are suppressed according to the similarity thresholdts that measures distances between two antibodies.
(6)
If some individuals are suppressed, then it is needed to add a new random population. These new solutions are generated following the method given above to respect the constraints and the flowchart if that is the case.
(7)
This work flow is repeated until the convergence criterion (maximum number of iterationsgen). The result is one or more individuals with an optimum objective value.As we can see, AIS contains five parameters, namely, number of individualsN, number of clones Nc, similarity threshold ts, maximum number of generations gen, and the mutation parameter β. Depending on the problem, they can take several values and are essential for a correct operation. AIS needs some parameters to be set beforehand in order to optimize a problem correctly. These parameters are related to the cloning and mutation process, the suppression algorithm, and the convergence criterion. For each iteration, a number of clones Nc is generated per cell. This number Nc is set empirically and can influence the final results. Generally, if Nc is set with a very low value, the convergence criterion can be delayed, as we are not able to find enough diversity to select better individuals for each cell. Otherwise, if too many clones are generated, the time upon convergence might be longer than expected.We empirically set the AIS parameters according to Table4, which gave the optimal performance in terms of fitness and time.Table 4
Optima values set forN, Nc, gen, ts, and β in both strategies.
N
Nc
gen
ts
β
Strategy I
250
12
250
10
100
Strategy II
250
18
300
3
10The next section will describe the simulations and results with Opt-aiNet configured for the presented HEMS.


## 5. Simulation Results

The evaluation is twofold. Firstly, it is expected that Opt-aiNet obtains positive results in solving optimization problems in the created setting and comparing them with other classical bioinspired approaches. Consequently, a comparative analysis was carried out between a classical genetic algorithm (GA) and a particle swarm optimization (PSO). Additionally, we analyzed the impact of the flowchart (Figure2) on our system, when the battery was involved. Therefore, two strategies that represent two electrical situations are designed. In the first strategy (strategy 1), the domestic environment does not consider any variable related to the maintenance of the domestic electric charge through the electrical energy produced by the PV system. This strategy only aims at optimizing its energy benefits. In the second strategy (strategy 2), the home environment aims at supplying the electricity demand autonomously. Therefore, the surplus generated by the PV is stored in the battery. In this strategy, the electricity could be sold to the grid if the battery is completely charged. On the contrary, if the battery cannot supply all the electrical charge, then the HEMS must buy electricity from the power grid.Based on these two main goals, three different experiments are considered:(i)
Experiment I: comparative study between GA, PSO, and AIS
(ii)
Experiment II: comparison between strategy 1 and strategy 2
(iii)
Experiment III: analysis of strategy 2 when the battery is disconnected or connectedExperiment I makes a comparison between GA, PSO, and AIS. Experiment II optimizes the parameters related to the PV system, the space heater, the water heater, and the must-run services; therefore, the parameters related to the battery charge are not considered (strategy I). The results obtained from the optimization process are compared with the results that are retrieved when the parameters of the battery are included in the system, although all are set to 0. That means the battery is disconnected from the home environment but the AIS follows the flowchart to optimize the system.Finally, experiment III performed two different analyses: when the battery was disconnected and when the battery was connected, to study the impact of this device on the system.


### 5.1. Comparison between GA, PSO, and AIS

In this section, we aim to compare the results obtained with three different bioinspired algorithms: genetic algorithm, particle swarm optimization, and artificial immune system. The genetic algorithm (GA) is widely used in optimization problems with many configurations. In this paper, a classical approach of GA is applied so that the mutation and crossover as well as the number of generations are empirically set to 0.3, 0.8, and 2000, respectively. Additionally, the selection function chosen was the roulette algorithm.The particle swarm optimization (PSO) was first introduced by Eberhart and Kennedy [35] and consists of a population-based optimization algorithm which is deemed to be a nature-inspired optimization methodology. PSO employs a set of particles which would move through the search space at every iteration and would calculate the fitness value at each point. After a termination condition is met, the best optimized value is selected by choosing the best value found in the history of particles. The success of PSO lies in its “velocity equation”; this equation decides on the next point in space that each particle would move to. The velocity equation can be shown as
(19)Vid,k+1=wVid,k+c1×rand1×Xpbestid,k−Xid,k+c2×rand2×Xgbestd,k−Xid,k.Here,Vid,k+1 is the velocity of the dth dimension of the ith particle in the next iteration (k + 1st), w is the inertia of the particle, Vid,k is the velocity of the dth dimension of the ith particle in the current iteration (kth iteration), c1 is the cognitive acceleration constant, c2 is the social acceleration constant, Xpbestid,k is the position of the particle in the dth dimension at which the best solution was found so far by the ith particle, Xgbestd,k is the value of the dth dimension at which the best solution so far was found by the whole system, Xid,k is the current position of the ith particle in the dth dimension, and c1 and c2 are random numbers. Using the velocity calculated, the next position to be evaluated is calculated as
(20)Xid,k+1=Xid,k+Vid,k.The above velocity equation works well when the system is under no constraints. However, when there are constraints, some of the particles might fall off the feasible region. In this case, the particles should not update their personal best when a particle is outside the feasible region. Neither should the global best be updated in case of a particle being outside the feasible boundary, having a better value than the current global best. In case a particle has not found a personal best that falls in the feasible region, the particle should rely only on global best to guide its movement. In this case, the calculation of velocity would change to(21)Vid,k+1=wVid,k+c1+c2×rand×Xgbestd,k−Xid,k.However, equality constraint satisfaction is more difficult than the inequality constraint satisfaction. To solve this problem, a mending procedure is carried out at every iteration to make sure all particles satisfy the equality constraint. The mending procedure calculates the overshoot of each of the particle and adds a correction value to correct the error. The correction is equally added to each of the intervals of the particle.In order to demonstrate the efficiency of the artificial immune system in the energy management optimization problem, we performed a comparative test with a version of constrained PSO adopted from [36] and an approach of the genetic algorithm. The goal was to predict the optimum values for each variable during 24 hours, following strategy 1 and strategy 2. The linear constraints proposed in the electrical model are applied, and subsequently, the objective function for the optimized variables is measured.Table5 shows the results obtained when the objective function and the energy are bought and consumed when AIS, GA, and PSO are applied with an optimal setting.Table 5
Results of the objective function and the energy bought and consumed when AIS and PSO are applied with an optimal setting.
Objective value
Energy bought
Energy sold
Strategy 1
PSO
23.52
46.61
14.12
GA
22.48
46.94
14.09
AIS
23.86
45.66
14.22
Strategy 2
PSO
4.86
37.60
5.40
GA
4.92
32.66
5.22
AIS
5.11
26.53
4.64As Table5 shows, AIS obtains slightly better results in the objective function for both strategies when both settings are optimal to solve this problem. That means AIS is a better configuration of the electrical parameters to optimize the problem stated. Likewise, AIS is able to find lower values for the amount of energy bought, which means the algorithm allows saving energy and money to the customer. The results of the AIS for the energy sold are lesser than in PSO and in GA. That could be explained because in PSO and in GA, the mean amounts of energy that are managed are greater than in AIS. However, PSO also obtained positive results (at least, better than with the classical approach of GA); therefore, we propose to make a deeper comparison with more complex problems to validate both algorithms and study the limitations of each one.


### 5.2. Analysis of the Energy Management Strategy

In this section, the two strategies described below are deeply analyzed and compared. The first strategy looks for maximizing the domestic energy profit. However, the second strategy aims at maximizing energy profit and acting as an autonomous energy system. It is expected that strategy II obtains better results, as this strategy pursues the autonomous management of energy, saving more money than in strategy I.Opt-aiNet worked with individuals or vector of 264 elements with equality and inequality constraints, as each individual contains all the variables for 24 hours. Each value corresponds to the different electric loads and powers described in Section3 for the PV panel, the storage water heater, the space heater, and the must-run services. We run the algorithm with two different configurations, one with strategy 1, excluding all the constraints related to battery management, and one with strategy 2, including all the constraints related to battery management, but with the battery variables set to 0. Table 6 shows the results according to the fitness value of the objective function OF and the parameters of sold and bought energy.Table 6
Impact of energy management strategies on the amount of sold/bought electrical energy to/from power grid and OF.
Strategy 1
Strategy 2
OF
23.8613
5.11
Esold
14.22
4.64
Ebought
45.66
26.53As we can see, the value of the objective function in strategy 1 is higher than that of strategy 2. However, the transacted energy between home and power grid is lesser in strategy 1, which means that Strategy 2 allows for the autonomous management of energy at home.


### 5.3. Impact of the Battery

In this analysis, strategy 2 is applied to study the influence of the battery in the domestic environment. In this case particularly, individuals in the AIS have 336 elements because the parameters corresponding to the battery charge and load are set as elements of optimization. Each individual is constructed following the linear constraints and the flowchart before being inserted into the population. Two different executions are made, firstly, with all the variables related to the battery management set to 0. In the second execution, the variables of the battery could change according to the corresponding equations and flowchart (Figure2). The results obtained are shown in Table 7.Table 7
Impact of battery system on the amount of sold/bought electrical energy to/from power grid and OF.
Strategy 2
With battery
Without battery
OF
12.31
5.11
Esold
6.22
4.64
Ebought
10.47
26.53From the data in Table7, we can see that the battery system can improve the value of the objective function. Table 7 also considers a situation in which the battery increases the amount of electrical energy sold from the smart home to the grid, and it decreases the amount of electrical energy that a home buys from the network.


## 5.1. Comparison between GA, PSO, and AIS

In this section, we aim to compare the results obtained with three different bioinspired algorithms: genetic algorithm, particle swarm optimization, and artificial immune system. The genetic algorithm (GA) is widely used in optimization problems with many configurations. In this paper, a classical approach of GA is applied so that the mutation and crossover as well as the number of generations are empirically set to 0.3, 0.8, and 2000, respectively. Additionally, the selection function chosen was the roulette algorithm.The particle swarm optimization (PSO) was first introduced by Eberhart and Kennedy [35] and consists of a population-based optimization algorithm which is deemed to be a nature-inspired optimization methodology. PSO employs a set of particles which would move through the search space at every iteration and would calculate the fitness value at each point. After a termination condition is met, the best optimized value is selected by choosing the best value found in the history of particles. The success of PSO lies in its “velocity equation”; this equation decides on the next point in space that each particle would move to. The velocity equation can be shown as
(19)Vid,k+1=wVid,k+c1×rand1×Xpbestid,k−Xid,k+c2×rand2×Xgbestd,k−Xid,k.Here,Vid,k+1 is the velocity of the dth dimension of the ith particle in the next iteration (k + 1st), w is the inertia of the particle, Vid,k is the velocity of the dth dimension of the ith particle in the current iteration (kth iteration), c1 is the cognitive acceleration constant, c2 is the social acceleration constant, Xpbestid,k is the position of the particle in the dth dimension at which the best solution was found so far by the ith particle, Xgbestd,k is the value of the dth dimension at which the best solution so far was found by the whole system, Xid,k is the current position of the ith particle in the dth dimension, and c1 and c2 are random numbers. Using the velocity calculated, the next position to be evaluated is calculated as
(20)Xid,k+1=Xid,k+Vid,k.The above velocity equation works well when the system is under no constraints. However, when there are constraints, some of the particles might fall off the feasible region. In this case, the particles should not update their personal best when a particle is outside the feasible region. Neither should the global best be updated in case of a particle being outside the feasible boundary, having a better value than the current global best. In case a particle has not found a personal best that falls in the feasible region, the particle should rely only on global best to guide its movement. In this case, the calculation of velocity would change to(21)Vid,k+1=wVid,k+c1+c2×rand×Xgbestd,k−Xid,k.However, equality constraint satisfaction is more difficult than the inequality constraint satisfaction. To solve this problem, a mending procedure is carried out at every iteration to make sure all particles satisfy the equality constraint. The mending procedure calculates the overshoot of each of the particle and adds a correction value to correct the error. The correction is equally added to each of the intervals of the particle.In order to demonstrate the efficiency of the artificial immune system in the energy management optimization problem, we performed a comparative test with a version of constrained PSO adopted from [36] and an approach of the genetic algorithm. The goal was to predict the optimum values for each variable during 24 hours, following strategy 1 and strategy 2. The linear constraints proposed in the electrical model are applied, and subsequently, the objective function for the optimized variables is measured.Table5 shows the results obtained when the objective function and the energy are bought and consumed when AIS, GA, and PSO are applied with an optimal setting.Table 5
Results of the objective function and the energy bought and consumed when AIS and PSO are applied with an optimal setting.
Objective value
Energy bought
Energy sold
Strategy 1
PSO
23.52
46.61
14.12
GA
22.48
46.94
14.09
AIS
23.86
45.66
14.22
Strategy 2
PSO
4.86
37.60
5.40
GA
4.92
32.66
5.22
AIS
5.11
26.53
4.64As Table5 shows, AIS obtains slightly better results in the objective function for both strategies when both settings are optimal to solve this problem. That means AIS is a better configuration of the electrical parameters to optimize the problem stated. Likewise, AIS is able to find lower values for the amount of energy bought, which means the algorithm allows saving energy and money to the customer. The results of the AIS for the energy sold are lesser than in PSO and in GA. That could be explained because in PSO and in GA, the mean amounts of energy that are managed are greater than in AIS. However, PSO also obtained positive results (at least, better than with the classical approach of GA); therefore, we propose to make a deeper comparison with more complex problems to validate both algorithms and study the limitations of each one.


## 5.2. Analysis of the Energy Management Strategy

In this section, the two strategies described below are deeply analyzed and compared. The first strategy looks for maximizing the domestic energy profit. However, the second strategy aims at maximizing energy profit and acting as an autonomous energy system. It is expected that strategy II obtains better results, as this strategy pursues the autonomous management of energy, saving more money than in strategy I.Opt-aiNet worked with individuals or vector of 264 elements with equality and inequality constraints, as each individual contains all the variables for 24 hours. Each value corresponds to the different electric loads and powers described in Section3 for the PV panel, the storage water heater, the space heater, and the must-run services. We run the algorithm with two different configurations, one with strategy 1, excluding all the constraints related to battery management, and one with strategy 2, including all the constraints related to battery management, but with the battery variables set to 0. Table 6 shows the results according to the fitness value of the objective function OF and the parameters of sold and bought energy.Table 6
Impact of energy management strategies on the amount of sold/bought electrical energy to/from power grid and OF.
Strategy 1
Strategy 2
OF
23.8613
5.11
Esold
14.22
4.64
Ebought
45.66
26.53As we can see, the value of the objective function in strategy 1 is higher than that of strategy 2. However, the transacted energy between home and power grid is lesser in strategy 1, which means that Strategy 2 allows for the autonomous management of energy at home.


## 5.3. Impact of the Battery

In this analysis, strategy 2 is applied to study the influence of the battery in the domestic environment. In this case particularly, individuals in the AIS have 336 elements because the parameters corresponding to the battery charge and load are set as elements of optimization. Each individual is constructed following the linear constraints and the flowchart before being inserted into the population. Two different executions are made, firstly, with all the variables related to the battery management set to 0. In the second execution, the variables of the battery could change according to the corresponding equations and flowchart (Figure2). The results obtained are shown in Table 7.Table 7
Impact of battery system on the amount of sold/bought electrical energy to/from power grid and OF.
Strategy 2
With battery
Without battery
OF
12.31
5.11
Esold
6.22
4.64
Ebought
10.47
26.53From the data in Table7, we can see that the battery system can improve the value of the objective function. Table 7 also considers a situation in which the battery increases the amount of electrical energy sold from the smart home to the grid, and it decreases the amount of electrical energy that a home buys from the network.


## 6. Conclusions

Artificial immune systems are a bioinspired algorithm that is capable of optimizing problems in a variety of research fields. This paper focused specifically on the application of AIS to electrical problems, such as demand response and scheduling optimization.A specific AIS called Opt-aiNet is selected, which is an improved version of an AIS used in different contexts [8], and it is applied to solve a power system optimization problem efficiently.We modelled a domestic environment with different appliances connected to the network, namely, a PV panel, a space heater, a storage water heater, a battery, and must-run services. Subsequently, the Opt-aiNet algorithm is adapted to include complex constraints in the optimization problem and to work with a large number of variables derived from this domestic environment.Two strategies have been developed to test Opt-aiNet. The first one aimed at maximizing the energy profit of a home. The main purpose of the second strategy is to maximize its energy profit and act as an autonomous energy system simultaneously and independently of whether the battery variables are considered or not.In order to demonstrate the validity of this proposal, three different experiments were carried out. The first one consisted of a formal comparison between the application of a GA and a PSO in the same context. The results were very positive as Opt-aiNet obtained a better solution than did GA with a classical configuration. This encourages the use of Opt-aiNet as a solution that gives very good results.The second experiment aimed at comparing two different electrical strategies. The final results showed that strategy II, which aims at maximizing the autonomy of the system, increases the efficiency of the model in terms of energy saving and therefore household economy.Finally, another experiment is performed to analyze the impact of the battery considering two different situations: when the battery is available (can be filled and used in our system) or unavailable (the battery is full and cannot be used). This last comparison showed the importance of using a battery for improving the general profit of our residential electrical system. In fact, the final results led us to conclude that the battery helps to maximize the profit of the whole system.Future work will consist of improving the results of the optimization problem with the GA and presenting a more complex case considering the uncertainty of predicted variables to encourage the use of evolutionary computing.



---

*Source: 9597158-2018-07-02.xml*