Research Article  Open Access
Maria NavarroCaceres, Pramod Herath, Gabriel Villarrubia, Francisco PrietoCastrillo, G. Kumar Venyagamoorthy, "An Evaluation of a Metaheuristic Artificial Immune System for Household Energy Optimization", Complexity, vol. 2018, Article ID 9597158, 11 pages, 2018. https://doi.org/10.1155/2018/9597158
An Evaluation of a Metaheuristic Artificial Immune System for Household Energy Optimization
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.
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 demandresponse 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 OptaiNet [8], which has been used successfully for the optimization of functions in different contexts [8]. OptaiNet 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 (ANNGA) 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 energygenerating system also with an AIS.
In this paper, an indepth 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 OptaiNet 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 mustrun 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. Section 2 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 selfantigen or antibody. Otherwise, the antigens from the external environment are called nonselfantigens and can provoke different diseases. Therefore, immune systems are aimed at distinguishing between selfantigens and nonselfantigens 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). where β is a constant obtained empirically to normalize the effect of the fitness value f_{i} 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 OptaiNet, 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 OptaiNet 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 the CLONALG algorithm and the β parameter. In order to preserve diversity, antibodies whose affinity is lower than a given threshold t_{s} are removed from the population.
Artificial immune systems, in particular OptaiNet, 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 nextgeneration 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 largescale 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 wellknown 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, CoptaiNet (artificial immune network for combinatorial optimization), which is a combinatorial version of the algorithm OptaiNet, 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 CoptaiNet (artificial immune network for combinatorial optimization) and the OptaiNet (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 shortterm 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 shortterm 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 tenunit 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 AISinspired 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 OptaiNet, also leveraged in different papers [24, 25] and to adjust it specifically to our case study. The classical OptaiNet 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 (Figure 1).
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 Figure 1, 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 mustrun 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.
OF is a linear combination of four electrical factors. and are constants that provide the prices per unit of energy load and are given by the market. The first term 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, . The value of electrical energy is not served, meaning the lo is encoded in the third part,. Finally, the spillage costs of PV panels, , are represented in the last term of the equation.
We need to balance the loads between the energy generated (the PV system , the energy provided by the battery , and the energy bought from the power grid ) and the energy consumed, meaning the electrical loads of the different services (heater, storage water heater, and mustrung services) and the battery charge (3). Additionally, the power flow limitation through the distribution line is stated in (4), where is a constant set to 6 according to [33].
The specific definitions for all domestic appliances are described in the following subsections.
3.1. PV System
The PV system can generate the power output of the grid, which can be modelled through Equation 5. where S refers to the spillage costs of the PV system and P_{pv,p}(t) is the potential power generation for the PV system. P_{pv,p}(t) is limited to maximum and minimum bands due to the prediction of the PV power generation, following (6). and σ_{pv}^{up} are down and up prediction variances for the PV system, respectively, and are calculated following [34]. 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, P_{pv,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.
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, L_{sh}(t), which is a controllable load, storage water heater, L_{swh}(t), which is a shiftable load, and mustrun services, L_{mrs}(t), which are noncontrollableshiftable 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.
3.2.1. Space Heater
The space heater provides the desired indoor temperature. Equation 10 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
Equation 11 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).
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 U_{swh}, 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).
3.2.3. MustRun Services
Mustrun 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 mustrun services (17). As in the storage water heater, the maximum of the load shedding must always be less than the energy consumed L_{mrs}(t) (18).
Also, the load shedding constraint is stated in (18).
3.3. Battery System
The battery system can be used to apply the charge and discharge strategies in the HEMS. A flowchart (Figure 2) 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 P_{b,in}(t) of the energy generated (i.e., the PV panel generates more energy P_{pv}(t) than the total load TL(t) demands), it is stored in the battery (C_{b}(t)). If the battery is fully charged , then it is sold to the grid P_{sold}(t). On the contrary, the system makes use of the energy stored in the battery P_{b,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, ), the system will buy the electricity P_{bought}(t) from the power grid.
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 between 48 and 2.4 kWh. The maximum heating power of the space heater (SH) 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 (U_{swh}) is 10.46 kWh (180 L) which has 2 kW as maximum of heating elements . 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.



These data are used in our HEMS to optimize the function (2). The objective function is integrated into OptaiNet to get an optimized schedule of 24 hours in a domestic environment. Following the OptaiNet 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, OptaiNet work follows these steps: (1)Initiate N 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)Create N_{c} 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 threshold t_{s} 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 iterations gen). The result is one or more individuals with an optimum objective value.
As we can see, AIS contains five parameters, namely, number of individuals N, number of clones N_{c}, similarity threshold t_{s}, 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 N_{c} is generated per cell. This number N_{c} is set empirically and can influence the final results. Generally, if N_{c} 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 Table 4, which gave the optimal performance in terms of fitness and time.

The next section will describe the simulations and results with OptaiNet configured for the presented HEMS.
5. Simulation Results
The evaluation is twofold. Firstly, it is expected that OptaiNet 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 (Figure 2) 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 connected
Experiment 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 mustrun 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 populationbased optimization algorithm which is deemed to be a natureinspired 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
Here, V_{id,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, V_{id,k} is the velocity of the dth dimension of the ith particle in the current iteration (kth iteration), c_{1} is the cognitive acceleration constant, c_{2} is the social acceleration constant, X_{pbestid,k} is the position of the particle in the dth dimension at which the best solution was found so far by the ith particle, X_{gbestd,k} is the value of the dth dimension at which the best solution so far was found by the whole system, X_{id,k} is the current position of the ith particle in the dth dimension, and c_{1} and c_{2} are random numbers. Using the velocity calculated, the next position to be evaluated is calculated as
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
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.
Table 5 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.

As Table 5 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.
OptaiNet 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 Section 3 for the PV panel, the storage water heater, the space heater, and the mustrun 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.

As 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 (Figure 2). The results obtained are shown in Table 7.

From the data in Table 7, 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 OptaiNet 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 mustrun services. Subsequently, the OptaiNet 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 OptaiNet. 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 OptaiNet obtained a better solution than did GA with a classical configuration. This encourages the use of OptaiNet 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.
Conflicts of Interest
The authors declare that they have no conflicts of interest.
Acknowledgments
This work has been partially supported by the European Commission H2020 MSCARISE2014: DREAMGO Project (Marie SklodowskaCurie grant agreement no. 641794) and by the National Science Foundation (NSF) of the United States, Grant IIP no. 1312260.
References
 M. A. A. Pedrasa, T. D. Spooner, and I. F. MacGill, “The value of accurate forecasts and a probabilistic method for robust scheduling of residential distributed energy resources,” in 2010 IEEE 11th International Conference on Probabilistic Methods Applied to Power Systems, pp. 587–592, Singapore, July 2010. View at: Publisher Site  Google Scholar
 A. Molderink, V. Bakker, M. G. C. Bosman, J. L. Hurink, and G. J. M. Smit, “Domestic energy management methodology for optimizing efficiency in smart grids,” in 2009 IEEE Bucharest PowerTech, pp. 1–7, Bucharest, Romania, July 2009. View at: Publisher Site  Google Scholar
 M. Nistor and C. H. Antunes, “Integrated management of energy resources in residential buildingsa markovian approach,” IEEE Transactions on Smart Grid, vol. 9, no. 1, pp. 240–251, 2018. View at: Publisher Site  Google Scholar
 S. Althaher, P. Mancarella, and J. Mutale, “Automated demand response from home energy management system under dynamic pricing and power and comfort constraints,” IEEE Transactions on Smart Grid, vol. 6, no. 4, pp. 1874–1883, 2015. View at: Publisher Site  Google Scholar
 T. M. Hansen, E. K. P. Chong, S. Suryanarayanan, A. A. Maciejewski, and H. J. Siegel, “A partially observable markov decision process approach to residential home energy management,” IEEE Transactions on Smart Grid, vol. 9, no. 2, pp. 1271–1281, 2018. View at: Publisher Site  Google Scholar
 T. G. Kolda, R. M. Lewis, and V. Torczon, “Optimization by direct search: new perspectives on some classical and modern methods,” SIAM Review, vol. 45, no. 3, pp. 385–482, 2003. View at: Publisher Site  Google Scholar
 J. L. FernandezMarquez, G. Di Marzo Serugendo, S. Montagna, M. Viroli, and J. L. Arcos, “Description and composition of bioinspired design patterns: a complete overview,” Natural Computing, vol. 12, no. 1, pp. 43–67, 2013. View at: Publisher Site  Google Scholar
 L. N. De Castro and J. Timmis, “An artificial immune network for multimodal function optimization,” in Proceedings of the 2002 Congress on Evolutionary Computation. CEC'02 (Cat. No.02TH8600), pp. 699–704, Honolulu, HI, USA, May 2002. View at: Publisher Site  Google Scholar
 M. A. Pedrasa, E. D. Spooner, and I. F. MacGill, “Improved energy services provision through the intelligent control of distributed energy resources,” in 2009 IEEE Bucharest PowerTech, Bucharest, Romania, July 2009. View at: Publisher Site  Google Scholar
 A. Soares, C. H. Antunes, C. Oliveira, and A. Gomes, “A multiobjective genetic approach to domestic load scheduling in an energy management system,” Energy, vol. 77, pp. 144–152, 2014. View at: Publisher Site  Google Scholar
 B. Yuce, Y. Rezgui, and M. Mourshed, “Ann–ga smart appliance scheduling for optimised energy management in the domestic sector,” Energy and Buildings, vol. 111, pp. 311–325, 2016. View at: Publisher Site  Google Scholar
 J. Zhu, F. Lauri, A. Koukam, V. Hilaire, and M. G. Simoes, “Improving thermal comfort in residential buildings using artificial immune system,” in 2013 IEEE 10th International Conference on Ubiquitous Intelligence and Computing and 2013 IEEE 10th International Conference on Autonomic and Trusted Computing, pp. 194–200, Vietri sul Mere, Italy, December 2013. View at: Publisher Site  Google Scholar
 K. Lakshmi and S. Vasantharathna, “Gencos wind–thermal scheduling problem using artificial immune system algorithm,” International Journal of Electrical Power & Energy Systems, vol. 54, pp. 112–122, 2014. View at: Publisher Site  Google Scholar
 L. N. De Castro and J. Timmis, Artificial Immune Systems: A New Computational Intelligence Approach, Springer Science & Business Media, 2002.
 L. N. De Castro and F. J. Von Zuben, The Clonal Selection Algorithm with Engineering Applications, Proceedings of GECCO, 2000.
 M. Q. Raza and A. Khosravi, “A review on artificial intelligence based load demand forecasting techniques for smart grid and buildings,” Renewable and Sustainable Energy Reviews, vol. 50, pp. 1352–1372, 2015. View at: Publisher Site  Google Scholar
 M.H. Chen, P.C. Chang, and C.H. Lin, “A selfevolving artificial immune system ii with tcell and bcell for permutation flowshop problem,” Journal of Intelligent Manufacturing, vol. 25, no. 6, pp. 1257–1270, 2014. View at: Publisher Site  Google Scholar
 L.F. Hsu, C.C. Hsu, and T.D. Lin, “An intelligent artificial system: artificial immune based hybrid genetic algorithm for the vehicle routing problem,” Applied Mathematics & Information Sciences, vol. 8, no. 3, pp. 1191–1200, 2014. View at: Publisher Site  Google Scholar
 S. Shamshirband, N. B. Anuar, M. L. M. Kiah et al., “Cofais: cooperative fuzzy artificial immune system for detecting intrusion in wireless sensor networks,” Journal of Network and Computer Applications, vol. 42, pp. 102–117, 2014. View at: Publisher Site  Google Scholar
 M.’ı. Navarro, M. Caetano, G. Bernardes, L. N. de Castro, and J. M. Corchado, “Automatic generation of chord progressions with an artificial immune system,” in International Conference on Evolutionary and Biologically Inspired Music and Art, pp. 175z–1186, Springer, 2015. View at: Publisher Site  Google Scholar
 L. de Mello Honorio, A. M. Leite da Silva, and D. A. Barbosa, A GradientBased Artificial Immune System Applied to Optimal Power Flow Problems, Artificial Immune Systems, 2007. View at: Publisher Site
 R. Belkacemi and A. Feliachi, “Multiagent design for power distribution system reconfiguration based on the artificial immune system algorithm,” in Proceedings of 2010 IEEE International Symposium on Circuits and Systems, pp. 3461–3464, Paris, France, June 2010. View at: Publisher Site  Google Scholar
 L. W. de Oliveira, E. J. de Oliveira, F. V. Gomes, I. C. Silva Jr, A. L. M. Marcato, and P. V. C. Resende, “Artificial immune systems applied to the reconfiguration of electrical power distribution networks for energy loss minimization,” International Journal of Electrical Power & Energy Systems, vol. 56, pp. 64–74, 2014. View at: Publisher Site  Google Scholar
 S. S. F. Souza, R. Romero, J. Pereira, and J. T. Saraiva, “Artificial immune algorithm applied to distribution system reconfiguration with variable demand,” International Journal of Electrical Power & Energy Systems, vol. 82, pp. 561–568, 2016. View at: Publisher Site  Google Scholar
 S. S. F. Souza, R. Romero, and J. F. Franco, “Artificial immune networks coptainet and optainet applied to the reconfiguration problem of radial electrical distribution systems,” Electric Power Systems Research, vol. 119, pp. 304–312, 2015. View at: Publisher Site  Google Scholar
 M. B. Abdul Hamid and T. K. Abdul Rahman, “Short term load forecasting using an artificial neural network trained by artificial immune system learning algorithm,” in 2010 12th International Conference on Computer Modelling and Simulation, pp. 408–413, Cambridge, UK, March 2010. View at: Publisher Site  Google Scholar
 A. Azadeh, M. Taghipour, S. M. Asadzadeh, and M. Abdollahi, “Artificial immune simulation for improved forecasting of electricity consumption with random variations,” International Journal of Electrical Power & Energy Systems, vol. 55, pp. 205–224, 2014. View at: Publisher Site  Google Scholar
 L. Hernandez, C. Baladron, J. M. Aguiar et al., “A multiagent system architecture for smart grid management and forecasting of energy demand in virtual power plants,” IEEE Communications Magazine, vol. 51, no. 1, pp. 106–113, 2013. View at: Publisher Site  Google Scholar
 G. Dudek, Artificial Immune System for ShortTerm Electric Load Forecasting, Artificial Intelligence and Soft Computing–ICAISC, 2008.
 M. Basu, “Artificial immune system for dynamic economic dispatch,” International Journal of Electrical Power & Energy Systems, vol. 33, no. 1, pp. 131–136, 2011. View at: Publisher Site  Google Scholar
 M. Basu, “Artificial immune system for combined heat and power economic dispatch,” International Journal of Electrical Power & Energy Systems, vol. 43, no. 1, pp. 1–5, 2012, ISSN 01420615. View at: Publisher Site  Google Scholar
 V. S. Aragón, S. C. Esquivel, and C. A. Coello Coello, “An immune algorithm with power redistribution for solving economic dispatch problems,” Information Sciences, vol. 295, pp. 609–632, 2015. View at: Publisher Site  Google Scholar
 A. S. Gazafroudi, F. PrietoCastrillo, and J. M. Corchado, “Residential energy management using a novel interval optimization method,” in 2017 4th International Conference on Control, Decision and Information Technologies (CoDIT), pp. 0196–0201, Barcelona, Spain, April 2017. View at: Publisher Site  Google Scholar
 M. Pedrasa, T. D. Spooner, and I. F. MacGill, “Scheduling of demand side resources using binary particle swarm optimization,” IEEE Transactions on Power Systems, vol. 24, no. 3, pp. 1173–1181, 2009. View at: Publisher Site  Google Scholar
 R. Eberhart and J. Kennedy, “A new optimizer using particle swarm theory,” in MHS'95. Proceedings of the Sixth International Symposium on Micro Machine and Human Science, pp. 39–43, Nagoya, Japan, October 1995. View at: Publisher Site  Google Scholar
 Y. del Valle, J. Perkel, G. K. Venayagamoorthy, and R. G. Harley, Optimal Allocation of Facts Devices: Classical versus Metaheuristic Approaches, Transactions of the South Institute of Electrical Engineers, 2009.
Copyright
Copyright © 2018 Maria NavarroCaceres et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.