Household Energy Management

: Ensuring flexibility and security in power systems requires the use of appropriate management measures on the demand side. The article presents the results of work related to energy management in households in which renewable energy sources (RES)can be installed. The main part of the article is about the developed elastic energy management algorithm (EEM), consisting of two algorithms, EEM1 and EEM2. The EEM1 algorithm is activated in time periods with a higher energy price. Its purpose is to reduce the power consumed by the appliances to the level defined by the consumer. In contrast, the EEM2 algorithm is run by the Distribution System Operator (DSO) when peak demand occurs. Its purpose is to reduce the power of appliances in a specified time period to the level defined by the DSO. The optimization tasks in both algorithms are based on the Greedy Randomized Adaptive Search Procedure (GRASP) metaheuristic algorithm. The EEM1 and EEM2 algorithms also provide energy consumer comfort. For this purpose, both algorithms take into account the smart appliance parameters proposed in the article: sections of the working devices, power reduction levels, priorities and enablingof time shifting devices. The EEM algorithm in its operation also takes into account the information about the production of power, e.g., generated by the photovoltaic systems. On this basis, it makes decisions on the control of smart appliances. The EEM algorithm also enables inverter control to limit the power transferred from the photovoltaic system to the energy system. Such action is taken on the basis of the DSO request containing the information on the power limits. Such a structure of EEM enables the balancing of energy demand and supply. The possibility of peak demand phenomenon will be reduced. The simulation and experiment results presented in the paper confirmed the rationality and effectiveness of the EEM algorithm.


Introduction
The European Parliament resolution, prepared on the basis of the European Commission communication [1], obliges European Union Member States to reduce greenhouse gas emissions. These obligations are, among others, implemented by limiting the carbon dioxide emissions by national power systems (NPS). The consequence of this is the introduction of low-carbon renewable energy sources (RES) in many countries. The variability of RES power generated, as well as the need for periodic maintenance of conventional power plants and the occurrence of high power demand at certain peak times and seasons of the year may cause difficulties in power management in national power systems. Therefore, ensuring NPS flexibility and security becomes an important problem, which can be addressed through the use of appropriate activities in the field of Demand Side Management and Response (DSM&R). DSM&R consists in identifying, assessing and using resources on the demand side of electricity by their end-use customers (household, commercial and industrial). This type of operation is only possible in Smart Grid (SG). Especially with awell-designed DSM&R, energy consumers can contribute to effectively ensuring the flexibility and security of NPS and further save money. This requires the cooperation of Transmission System Operator (TSO) and Distribution System Operator (DSO) in the scope of:  properly developed price programs, e.g., Real-time pricing (RTP) and Time-of-Use (ToU) [2][3][4][5],  load shift services for off-peak periods based on specific delivery methods .
On the one hand, a significant part of the publication concerns optimization algorithms used to solve a very important problem, which is DSM&R optimization carried out at the TSO, DSO and final consumer level. Selected algorithms of this type were reviewed in [19], dividing them into two categories: classical (linear and non-linear) and heuristic optimization algorithms (particle swarm optimization-PSO, genetic, simulated annealing-SA, teaching learning-based optimization-TLBO). Examples of optimization algorithms used in specific DSM&R solutions, which in most cases are an extension of the analyses in [19], are presented below. The methodology for assessing the possibilities of ensuring technological flexibility in the German power grid with a large RES share, based on a linear algorithm, is presented in [8]. The presented approach focuses on the solution for TSO and DSO. Peak demand reduction for large energy consumers in Brazil was presented in another paper [9]. To this end, two models were developed. The statistical model enables simulation and estimation of peak demand scenarios. The stochastic model is designed to optimize the peak demand value that will be contracted in future contracts. The stochastic model was also used to implement DSM&R based thermostatic devices (fridge-freezer) [10][11][12]. On the other hand, energy management using a genetic algorithm for DSO is presented in [13]. This work concerns Chinese micro-networks also containing RES and energy storage. The developed genetic algorithm is designed to provide DSM&R while minimizing the cost of purchasing energy and maximizing the use of RES. In [14], concerning micro-networks also containing RES, an energy management strategy was proposed based on the response on the demand side, taking into account the application of the PSO algorithm. The PSO algorithm was also used to minimize the costs of energy consumption by the household consumer [15]. The objective function takes into account the expected electricity costs for the next day (RTP with Inclining Block Rate) and satisfaction with the comfort of using energy by the consumer based on historical data defining the trends in the work of household consumers. Another DSM&R optimization model based on heuristic evolutionary algorithm is presented in [20]. It presents the results of simulation tests for various loads in three areas of services with final consumers.
In addition to the algorithms belonging to the two mentioned groups: classical and heuristic, there are other solutions known in the literature, presented below. In micro-networks containing energy storage, DSM&R solution was proposed based on modelling of state space [16]. This model integrates the structural, time and logical features of micro-networks to identify and build a wide variety of energy management strategies. The Demand Response Optimization (DROP) algorithm was used to make optimal decisions for DSM&R activities in plants equipped with distributed energy resources (DER) [21]. Issues concerning the use of DSM&R in industrial plants are presented in [22]. Optimal models of industrial load scheduling in SG environment were determined and methods of solving optimization models were discussed. An example of using game theory in DSM&R to smooth the ratio of the peak value to the average power value while rewarding customers for an accurate load forecast is presented in [17]. In [23] a model is presented taking into account hourly profiles of electricity consumption for various household appliances and their share in annual consumption. The result of this research was to offer households economic and/or ecological incentives to change consumption at specific times. Similar activities, but in relation to asmall group of households on a small island are presented in [24].
The correct operation of DSM&R at national level depends on its implementation at the final consumer level [25]. In most cases, DSM&R optimization was used for households. The use of the Internet of Things (IoT) [15] is a favorable step towards introducing DSM&R in households. In this approach two classifications are distinguished: Energy-efficient Solutions and Energy Harvesting [26]. A characteristic feature of this solution is collecting a large data set from the distributed system that requires processing. To this end, the approaches presented in [27,28] can be used.
The selected publications presented above confirm the need for work in the field of DSM&R for final consumers. The largest final consumers of energy are industrial consumers, followed by households. The application of DSM&R to industrial consumers may be more complex compared to households. This is related to reliability management, which is definitely more important for industrial consumers [29]. In [19] it was pointed out that from the group of final consumers analyzed, households respond more in DSM&R programs. This requires work to develop further DSM&R optimization concepts that will mobilize households to more actively save energy and take into account their comfort while implementing DSM&R.
The following conclusions can be drawn from the presented analysis of the literature. The introduction of a DSM&R optimization algorithm in households based on the work schedule of individual appliances [15], determined on the basis of historical data specifying the trends in the work of these appliances, will not ensure optimal implementation of DSM&R. A better solution is to optimize energy consumption on-line using heuristic algorithms. This requires the use of two-way communication allowing change of the operating mode of the appliances planned to be switched on or off at a given moment. On the other hand, ensuring greater comfort for the individual consumer in the use of energy receivers during the implementation of DSM&R may take place by taking into account the parameters of smart appliances [30] and energy generated by RES in the optimization algorithm. Currently, results of works on appliances of this type are being implemented in the scope of their intelligent functionality [31], and in the near future implementations in the field of intelligent energy consumption control should be expected. Both groups of measures should contribute to increasing the number of households participating in DSM & R. In households with RES, solutions based on photovoltaic panels and inverters are most often used ( Figure 1). Some of these households are equipped with power management modules [32,33]. In the first place, they make it possible to use the power generated locally to supply the appliances. However, the excess of generated power is stored or sent to the NPS. The inverters also have the option of switching on individual appliances (e.g., boiler, heat pump). In some countries, situations arise that limit the use of excess power by the NPS. In that case, the power management module controls the inverter to limit the generated power (even to zero) [33]. A significant problem of RES is also the dependence of the produced power on the weather, which can be taken into account in the energy managing module. A very important problem to be solved is also the mitigation of the peak power demand phenomenon. The optimization algorithm should take into account, on the basis of the information sent from the DSO, the reduction of the consumed power taken from NPS into the household to the indicated value in a specific time interval. The main purpose of the article, including the above conclusions, were the development of an energy management strategy based on a pricing program (ToU) and an optimization algorithm taking into account the comfort of energy consumers and the requirements of DSOs to reduce the peak demand phenomenon. The main contribution in this regard is as follows: 1. Parameters for smart appliances were defined so that the planned comfort of the energy consumer is maintained when using the energy management algorithm. 2. An algorithm for elastic energy management (EEM) was developed, which takes into account:  current functionalities of the power management module in inverters, including inverter control in terms of limiting power production by RES,  current power production by RES and current power consumed by enabled appliances,  minimization of power consumption costs by appliances,  DSO request to reduce the load within the given time.
The algorithm respectively runs EEM1 or EEM2 algorithms, implementing the proposed DSM&R solution.
The conducted simulation tests confirmed the correct operation of the EEM algorithm as well as its rationality and effectiveness. This algorithm is planned to be implemented in the software part of the inverter management module (Figure 1).

Characteristics of Smart Appliances
Smart appliances taking part in the application of the EEM algorithm operating in the household should have the following properties:  have specific power demand for a specified period of time,  can be powered only at certain known intervals,  the time during which these devices are powered is important for the functioning of the household.
The group of smart appliances with the properties listed above, whose energy consumption can be managed, include:  induction hobs, ovens, microwaves,  dishwasher,  washing machine and dryer,  refrigerators and freezers,  lighting,  air conditioning system equipment with heat accumulators, flow and non-flow electric water heaters (boilers), floor heating,  electric and hybrid vehicle batteries.
The energy consumption of each consumer results from the parameters of their appliance and the way these are used. For proper operation of the EEM algorithm it is required to define appropriate appliance parameters. This mainly applies to determining if and when a given load can be used during power reduction. A very small number of types of appliances currently used in households have the possibility of gradual reduction of power. The article proposes the introduction of a work section (WS) in these appliances for manufacturers of the smart appliances. This will increase flexibility in reducing the power of such appliances and improve the comfort of their use in the household. The section should be understood as the phase of the appliance's work. An example of such an appliance in which WS occurs can be a washing machine, e.g., prewash, main wash, spinning, etc. For each WS ( Figure 2) there will be independently determined values of minimum (PA_MIN) and nominal (PA_NOM) power parameters. The manufacturer, based on their own experience, will determine for each WS whether at any given time the power reduction from PA_NOM to PA_MIN, with possibly more k levels of its changes, will not have a negative impact on the task carried out by the smart appliances. The introduction of a certain number of power reduction levels is possible in smart appliances intended for maintaining the set air and water temperature. Examples of this are boilers and electric floor heating, which are heat stores. Limiting the smart appliance power consumption may, from the user's point of view, be associated with a slight decrease in comfort, e.g., a lower water temperature in the boiler or a higher room air temperature obtained by the air conditioner. However, these slight inconveniences transform into reduced costs for energy consumed in expensive time periods. From the point of view of TSO and DSO, such action will increase flexibility and improve NPS security.
Based on the example of smart appliances usage (Figure 2), the EEM algorithm will be run in: WS2, WS4and WS5. Only in these WS, the EEM algorithm can choose a new power value (PA_SEL) in the range (PA_MIN, PA_NOM). WS3 presents a situation in which the manufacturer of the smart appliances has determined that for the correct operation of the smart appliances no reduction of power can occur. In this case PA_NOM=PA_MIN. In contrast, WS1 may reflect the smart appliances standby time mode. In this case, for most of the time the smart appliance waits for 24 h to turn it on, power could be reduced to zero. For example, power reduction in standby time mode could consist in turning off the LED display indicating the current value of the hour, e.g., in the oven or microwave. The power of a single LED display, from the point of view of a single household does not matter much. However, for a larger scale, e.g., city or DSO, running the EEM algorithm in households to reduce power in WS1 may help to alleviate peak demand. In this way, distributed processing functionality would be obtained, resulting in a noticeable reduction in power in the NPS.
The producer will also specify priority values (pr) for each WS. An example of a 5-step scale of priorities was proposed, which corresponds to the following meanings:  For smart appliances with pr=1 and pr=2 there is always the possibility of power reduction, because limiting the power of these appliances or their lack of operation does not cause side effects for the functioning of the household.  For smart appliances with pr=3 the power reduction occurs only if for smart appliances with pr=1 and pr=2 the power reduction did not bring the intended effects.


The values of pr=4 and pr=5 allow the smart appliances power to be reduced only in crisis situations for the stability of the NPS.
For loads with pr=2 and pr=3, the user decides whether he agrees to reduce power. Figure 3 shows an example of a situation in which two smart appliances (A1 and A2) with different priority values were started at different times,t0_A1and t0_A2. Calling the EEM algorithm at time ti will result in the need to select new PA_SEL settings for A1 and A2. The order of the smart appliances in which the power reduction to the PA_SEL level should take place will be determined by the pr values assigned to these appliances. If prA1>prA2, then the power reduction will be performed first by the EEM algorithm for A2. The EEM algorithm will decide on the PA2_selvalue, one of several possible levels, and then turn on A2 with the selected power value.
Currently, there are a few appliances available on the market (e.g., washing machines, dryers), in which it is possible to set the start time (ts) of such a device. The ts time setting is done directly in the device or remotely, e.g., from a tablet or smartphone [30]. This type of functionality is planned in the EEM algorithm to reduce costs for consumed energy by shifting turning on smart appliances to off-peak periods. In cases where ts=0, the smart appliances are immediately activated by EEM.
It has been proposed that the parameters for each type of smart appliance should be defined according to the entry (PA_MIN, PA_NOM, k, pr, ts), (1) where:  PA_MIN-a vector containing the minimum power values specified for each WS; if in the extreme case PA_MIN=0, it means that the smart appliances can be turned off by EEM,  PA_NOM-a vector containing nominal power values specified for each WS,  K-a vector containing the number of additional power reduction levels in each WS,  pr-a vector containing priority values for each WS,  ts-time by which the smart appliances activation can be shifted.
The length of each vector appearing in (1) describing the parameters of a given smart appliance is equal to the number of defined WS.
It is assumed that the user may overwrite the priority value for each WS. However, such action will require confirmation of the power reduction performed by the EEM algorithm, which may adversely affect the functions performed by the given smart appliance.
For smart appliances in which the section is not highlighted, the vectors will be one-piece, and the priority value will then be set only by the user.

Elastic Energy Management
The concept of the developed elastic energy management algorithm (EEM) is shown in Figure4. The purpose of this algorithm is to ensure the implementation of DSM&R in households (single-family and multi-family homes) in which RES can be installed, defining the currently available total power PRES.
The EEM algorithm operates continuously in the first loop, checking if:  when RES is used, there is an overproduction of power (∆P<0) relative to the power consumed by all connected appliances (Ph), according to the dependence  there was no change in the total power of all switched-on appliances (∆Ph(i)) by the ∆Phys value set in the algorithm according to the dependence  when the DSO indicates the need to limit the transfer to the NPS of the excess generated power by RES to a value not greater than PRES_DSO, at the indicated time (tRES1, tRES2), information is sent to the inverter about limiting the generated power (Pthreshold) to the value determined with the dependency  no information was sent from DSO about the need to reduce the load Ph(i) to at least Ph_DSO in the desired time interval (tDR1, tDR2), specified individually for each household (in this case, status of DSO=0).
If any of the conditions ∆P(i)≥0 and DSO=0, and |∆Ph(i)|≤∆Phys (5) is not met, then the EEM algorithm goes into operation in the second loop, in which the parameters of the appliances switched on are read and one of the two algorithms is started: EEM1 or EEM2. If the status of DSO=0, then the EEM1 algorithm is launched, the goal of which is to reduce the power of appliances in time zones with a higher energy price. In the case when DSO=1, the EEM2 algorithm is activated, which reduces the appliance power to the level in the time interval requested by DSO (tDR1, tDR2) so that the sum of the power of all switched-on appliances is not greater than Ph_DSO. This functionality of EEM2 is dictated by the fact that households do not have a clearly defined timetable for switching on specific appliances with their specific operating functions. The goal of EEM2 is to support actions taken at the TSO and DSO level in the reduction of peak demand phenomenon, especially in critical situations for NPS. In order to ensure the effective operation of the EEM algorithm, instructions for:  limitation of transferring excess power generated to NPS by RES (PRES_DSO) in a given time (from tRES1 to tRES2),  reduction of the power consumed from NPS (Ph_DSO) in a given time (from tDR1 to tDR2) should be given by DSO well in advance. A detailed description of the operation of the EEM1 and EEM2 algorithms is presented in the following sections. The introduction of the condition (3) to the EEM algorithm ( Figure 4) solves the problem of excessive triggering of the EEM1 algorithm ( Figure 5). Without this condition, switching on an appliance, e.g., a refrigerator could modify the power settings for other appliances. For the next iteration (i) the total power value of all connected Phys(i) appliances is compared with the Ph(i−1) value from the previous iteration. Examples illustrating the impact of condition (3) on the launch of the EEM1 algorithm are shown in Figure 5. The developed EEM algorithm includes two groups of appliances:  classic appliances that can be controlled only in a binary way (on or off),  smart appliances whose control method depends on their parameters defined by (1).

EEM1 Algorithm
First step of the EEM1 algorithm ( Figure 6) is the reading of the current time zone value (t_z) for the tariff applied in the household. If t_z= 1 (the time zone with the lowest energy price), then the EEM1 is terminated. However, when t_z>1, the EEM1 starts optimizing the power reduction of appliances. For the EEM1 algorithm, the optimization criterion defines the target function specified by the following formula: where:  U=1-is the optimal value of the household's demand for capacity for its supply in this household,  USEL-current value of power demand for its supply, calculated by the EEM1, based on selected values of appliance power, using the following equation:  FRES, FDSO, FA-components of the objective function related to RES, DSO and A, defined by formulas: The objective function (6) takes into account the electricity costs and the consumer comfort resulting from:  smart appliance parameters defined by the vector (1),  Phmax power value determined by the consumer,  U and USEL value, which counteract redundant power reduction.
In the case of excess energy originating from a RES in a given household (ΔP ≥ 0), EEM1 will attempt to use it inside the given household, and in case of its excess, for sale the energy to the DSO.
In the case when ΔP<0 or RES are not installed in the household, the task of EEM1 will be to determine the value of the power reduction in the relevant consumers. The power reduction will be carried out taking into account the values of the parameters, defined by vector (1), assigned to the appliances accordingly. The power reduction for priority 2 and 3 loads requires the user to interact with the algorithm as part of the "User Confirmation" subprogram. The user may knowingly allow or reject a power reduction proposal to the selected PA_SELlevel. If, however, the user does not want or cannot respond to such a message from EEM1, then after a set period of time, automatic consent to power reduction will occur. The choice of the automatic consent option is based on the assumption that users are aware of the need to use EEM1.

EEM2 Algorithm
The block diagram of the EEM2 algorithm is shown in Figure 7. EEM2 shall be triggered only if the DSO has sent a request to reduce the power of appliances in the household within a specified period of time (tDR1, tDR2),to a value of at least equal to Ph_DSO or less. For EEM2, the target function is also defined by the Equation (6). Due to the different purpose of this algorithm compared toEEM1, the dependency defined in Equation (7) is determined as follows Based on the objective function (6), taking into account the formula (11), the appliance power level will be selected to match the level of power reduction of appliances in the household to the specified Ph_DSO level. With the known time frame of power reduction (tDR1, tDR2) the EEM2 will also work for smart appliances with a specific value ts>0 to implement the shift of their activation beyond the time tDR2. The target function (6) also prefers solutions that will optimize the use of available RES power for household appliances.

Optimization Algorithm
The possibility of occurrence of different power selection combinations for appliances (PA_SEL) by the proposed algorithms EEM1 and EEM2 causes the realized optimization task to be classified as anondeterministic polynomial time (NP problem). These are high complexity tasks for which metaheuristic algorithms perform better than classical algorithms, e.g., [15]. The Greedy Randomized Adaptive Search Procedure (GRASP) algorithm [34,35] was used to perform optimization tasks in EEM1 and EEM2. This algorithm starts by creating vertices of graph that determine the possible selection of PA_SEL power setting for each of the appliances. All vertices of such a graph are connected with each other by paths. In the first phase of the algorithm's operation, the set of possible power settings for each smart appliance is determined in individual iterations (n). This means that for each selection of settings, the selected vertices are connected by paths and the value of the objective function is calculated. In the second phase, with the previous assumptions, it will be possible to resolve the situation in which the smart device would be turned on (turned off) or even reduce power at a time when there would be several devices with the same priority. The selection will be determined by the optimization criterion defining the target function FEEM (6). In this case, due to the minimization of the FEEM function, the selection of individual PA_SEL power settings will follow. In the PA_SEL settings you will define what will happen with the given smart appliance: turn on, turn off or modify the power consumed. Figure 8 provides examples of simulation test results for EEM1 and EEM2 algorithms specifying the value of the target function FEEM (6) for each iteration n, defining the power settings PA_SEL achieved for the smart appliances with the GRASP optimization algorithm. The test results presented concern three smart appliances, as described by (1) involved in the reduction of power. For the air conditioner, three power levels were adopted (kA_1=[0.7; 1.2; 1.7] kW) and for the boiler two additional power levels (kA_2=[0.5; 1.0] kW). It was also assumed that the EEM1 algorithm takes into account the ToU tariff with three time zones. For all considered cases, the priorities of the smart appliances are taken into account by the optimization process.
In example (a) the EEM1 algorithm started (for a time zone with average energy costs t_z = 2) optimization of power reduction at the moment of turning on the air conditioner with a nominal power of P1_NOM = 2.2 kW with the other two appliances turned on (P2_NOM = 1.5 kW andP3_NOM = 2.3 kW). The sum of the power consumed by the three appliances (Ph= 6kW) was greater than the assumed Phmax=5kW value for this time zone. For iteration n=2, the optimization process has been completed, which resulted in the boiler power being limited to 1kW and the air conditioner to 1.7kW. The sum of the power consumed by the three appliances was 5 kW. In example (b), the EEM1 algorithm started (for the time zone with the highest energy consumption costs) to optimize power reduction when the air conditioner is switched on with the remaining two appliances already switched on (as in example a). The sum of the power consumed by all the appliances (Ph= 6 kW) was greater than the assumed Phmax=3kW value for this time zone. The consumer did not agree to move the start of the dishwasher from this time zone (t_z = 3) to the next time zone (t_z = 1) with the lowest energy consumption costs. For iteration n=12, the optimization process has been completed, as a result of which the boiler was switched off and the power of the air conditioner was limited to 0.7kW. In examples (c) and (d), the EEM2 algorithm began reducing power on the DSO request (in the evening time zone t_z = 3 with the highest energy consumption costs) to a power consumption level of not greater than Ph_DSO=1kW in the time interval tDR1= 17:30 and tDR2=18:30. Example (c) applies to the situation when at 17:30 only the boiler was on. For iteration n=3, the optimization process was completed, as a result of which the boiler power was limited to 1kW. Whereas example (d) concerns the situation of inclusion at 18:08 air conditioner with a boiler on and reduced power to 1kW. For iteration n=3, the optimization process was completed, as a result of which the power of the air conditioner was limited to 0.7kW, and the boiler was turned off. The presented results indicate that the GRASP algorithm optimizes the selection of smart appliances power settings with a small number of iterations. Compared to the PSO algorithm [15], the GRASP algorithm requires fewer iterations to optimize the selection of power settings.

Assumptions
Considering that currently a small number of types of intelligent appliances are used in households, simulation tests of the EEM algorithm were carried out under the following assumptions: 1. Simulation studies were conducted in an environment developed for the evaluation of energy management algorithms. 2. Appliance control with EEM algorithm in the scope of DSM & R will only apply to its activation or deactivation. Practically it can be ensured by using for each appliance a separate intelligent socket, available on the market, meeting the assumptions of e.g., Fibaro Wall Plug [36]. This type of socket also allows the EEM algorithm to obtain the measurements of the current power consumed by the appliance. It can also, by highlighting it with an appropriate color, fulfill an information function for the user about the price level for energy, e.g., green-cheap energy, yellow-expensive energy, red-very expensive energy. 3. During one day,10 energy consumers with parameters specified in Table 1 will be used. For TV, kettle and induction hob, changes in their power over time were determined on the basis of measurements. For other appliances, their power changes over time were determined on the basis of [37]. All data were available with an interval of 1 min. 4. ∆Phys=0.2 kW. 5. Appliances for which ts>0 will be able to be switched on with a time offset from 0 to ts. 6. In the household under analysis, the ToU price program operates with three time zones (t_z) and energy charges are applicable in them (Table 2). This tariff applies throughout the year. On weekends and holidays the time zone t_z=1applies.

Environment for Evaluation of Energy Management Algorithms
In order to be able to evaluate an energy management algorithm it is necessary to embed it in an environment that allows revealing the full potential of the algorithm. The real test sites often do not provide smart appliances or devoted participants in a number that allows testing of all the desired test scenarios.
A solution for that issue is to create an artificial environment that simulates the users and their appliances and allows reflecting the electrical phenomena on a chosen level of detail; for instance, using emulation of the components constituting the electrical grid.
We have such an emulation environment at hand, which also provides an execution opportunity for the management algorithms that allows reusing these in real deployments.
In this section, we introduce the prosumer block-part of the in-lab Smart Grid Emulator [39], based on the e-balance energy management platform [40,41], developed in the e-balance project [42]. Using the Smart Grid Emulator it is possible to create defined test cases that allow testing the performance and behavior of the implemented algorithms before heading for a real deployment. The emulator allows defining different grid topologies, built using connected blocks that represent different elements of the real grid, like the substations, transmission lines and prosumers. The advantage of this evaluation compared to pure simulations is that the platform emulates the grid by having real current flows between the blocks, allowing test scenarios related to the low level grid activities, like cut wires or shortcuts. It also allows testing algorithm implementations that can directly be applied in the real grid, within the e-balance platform.
The prosumer block is the most important one from the perspective of evaluating energy-balancing algorithms that operate on the household level. This block emulates the grid for customers of any kind. This general block can represent a variety of grid elements that consume and/or produce energy. It may represent a single household or a DER, but it may also represent a complex neighborhood on the low voltage or the medium voltagegrid level. It consists of the energy consuming part and the energy producing part, allowing the emulationof real life energy generation and consumption dependent on time and weather conditions. Figure 9 depicts the prototype of the prosumer block. Conducting our experiments on the prosumer block instead of pure simulations gives us the opportunity to increase the level of realistic results obtained. It is possible to introduce additional control signals, like the change human behavior. Additionally, the most important aspect here is the later possibility of applying our results on a larger scale in a connected emulated grid with multiple prosumers and other grid components. In the prosumer block the energy consumption and production are separated. They meet at the junction between the block and the grid. The consuming part of the prototype consists of a set of switchable resistive loads (main type of load) and a capacitive and inductive load that can introduce phase shift.This allows emulating not only the active power, but also the reactive and apparent power introduced by the customer appliances.
The part of the block that produces the energy can represent any kind of energy production that forces the energy into the grid. The sinus wave for the generated power can be influenced to emulate a diversity of energy quality scenarios. The energy generator is currently still under development as we are still working on extending it with additional features.
Both consumption and production are measured with a smart meter class sensor node. The voltage and current measurements are further processed to obtain all necessary parameters like the values of different power kinds, the power factor and the frequency. The core of the block is the management unit (MU)-a single board computer (SBC) based on the Beaglebone Black hardware [43] that collects these measurements and runs the e-balance platform middleware and the evaluated algorithms running on top of the middleware. Additionally, a switch controlled by the Smart Meter is available and allows the local logic, the energy supplier or the DSO to disconnect the given customer from the grid completely.
The emulation platform is a low power one. The management unit uses a single core Sitara processor [44], running at 1GHz clock and using 512MB of RAM. It is also the target machine for the real deployments.
To provide realistic test conditions, the prosumer block is configured with appliance configuration files and with user behavior configuration. These two configurations are used together to generate a live energy profile of the block that controls the energy producing and consuming elements. This flexible approach allows evaluation of energy management algorithms under reality-like conditions.
The user behavior and appliance configurations are very important aspects of the evaluation of energy management algorithms. An appliance configuration is a file (one for each appliance in the household) that defines the programs (or modes) available on the appliance and defines the resulting power profile while executing a given program. This device description file is similar to object oriented programming.
A user behavior file (one for each person in the household) defines the user's appliance usage profile. In contrast, this configuration file looks more like a crontab schedule, stating the order and periodicity of the usage of the specific programs provided by the appliances. In order to express the uncertainty of the periodicity, this schedule can be enriched with randomness. This helps to achieve more human-like results.
Finally, the household configuration file (one file per household) combines the user and device descriptions. Processing this set of files allows generating the summarized energy profile of the complete household.
The household configuration allows specifying priorities of the appliance, while the user configuration schedule allows defining the priorities of the individual program invocations.

Results of Evaluation Studies
The evaluation tests were carried out using the prosumer block and were divided into two groups. In the first group, research was conducted for a household powered only by NPS. The second group of tests concerns a household powered by NPS and RES.
In the first group the tests consisted of recording in time the power values consumed by the connected appliances for two cases:  The appliances were switched on automatically or by users during one day taking into account the properties of the ToU price program (Table 2).  The appliances were switched on as in the first case, but with the EEM1 algorithms working (for t_z=2 and t_z=3) and EEM2 in hours from 17:30 to 18:30.
For the first case (Figure 10), the appliances (Table 1) were switched on and off by their respective automation systems, ensuring that the correct air and water temperature were maintained. Other devices were turned on by users, taking into account their needs and prices for electricity, specified in the ToU price program ( Table 2). The devices were turned off as a result of the program being terminated or by the user.
For the second case (Figure 10), the EEM1 algorithm, for t_z=2, lasting from 7:00 to 10:00, proposed to postpone the start of the washing machine and dryer from 7:15 am 21:00 (t_z=1). This proposal was accepted by the user. In the same time zone at 9:15, when the boiler (8:42) was turned on earlier and the dishwasher (9:06) sooner, the air conditioner was reported to work. This meant exceeding Phmax=5kW. For the period of turning on the air conditioner, the EEM1 algorithm turned off the boiler, which is assigned a lower priority than the air conditioner and dishwasher. For t_z=3 at 10:00, the dishwasher was reported to work with the air conditioner and boiler already on, which meant exceeding Phmax=3kW. EEM1 proposed postponing the start of the dishwasher to 16:26 (t_z=2), which was accepted by the user. At 10:15 the air conditioner was reported to work, which caused the boiler to be turned off by EEM1. The boiler automatically turned on again at the end of t_z=3. At other times t_z=3 EEM1 did not interfere with the operation of the air conditioner and refrigerator, because the value of Phmax=3 kW was not exceeded. In zone t_z=2, lasting from 14:00 to 17:00 and from 17.00 to 17.30 (t_z=3) there was no interference from EEM1, because the total power of the appliances switched on at any time did not exceed the value of Phmax=5kW. The EEM2 algorithm worked at t_z=3, minimizing the power consumed by the appliances from 17:30 to 18:30 so that the power consumed during this time by the consumers' appliances switched on is not greater than Ph_DSO=1kW. Minimization of power consumed during this period of time was associated with turning off the boiler and blocking the re-activation of the boiler and any other appliance (in this case, the air conditioner), which would exceed Ph_DSO=1kW. During this time, only the fridge and TV were on. At 18:30 the boiler has been switched on again. From now until 21:00 the EEM1 algorithm worked again, causing the boiler to turn off at 19:08 when the air conditioner was turned on. At 19:52 the boiler turned off again as a result of turning on the microwave, kettle and air conditioner in turn. The EEM1 algorithm allowed the boiler to be switched on again at 20:14. At 20:23 the boiler was turned off by the automation after reaching the set temperature. In the second group, simulation tests were carried out for the same defined two cases as in the first group. In the first case, the appliances were turned on and off in the same way as in the first group of tests. The power generated by RES (PRES- Figure 11), between 7:05 and 15:30, first supplied the appliances, and its surplus was sent to the NPS. This allowed reduction of the power consumed from NPS and, at the same time, led to lower energy costs. In the second case ( Figure 11) the EEM1 algorithm, for t_z=2 lasting from 7:00 to 10:00, proposed to postpone the start of the washing machine and dryer from 7:15 to 11:18 (t_z= 3). This was due to the sufficient power generation by the RES at that time. This proposal was accepted by the user. Furthermore, for t_z=2, the boiler was turned off from 9:15 to 9:19 due to the dishwasher already working and the activation of the air conditioner at 9:15. Switching off the boiler resulted from the priority value (pr=1) and exceeding the adopted value of Phmax= 5 kW (the sum of the power of these appliances is 5.98kW). For t_z=3 at 10:00 a dishwasher was reported to work with the air conditioner and boiler already switched on. Switching on the dishwasher would result in exceeding the assumed value of Phmax=3kW for this time zone. Due to sufficient RES power generation, the EEM1 algorithm delayed the start of the dishwasher to 10:40. At 16:16, with the air conditioner working and the EEM1 kettle on, the boiler was turned off for a period of 1 min. As a result, the value of Phmax=5kW was not exceeded during this time. However, the shift of the air conditioner to being on from 8:05 p.m.to 8:10 p.m. was due to the kettle and microwave already being on. On the other hand, the EEM2 algorithm for the assumed value Ph_DSO=1kW turned off the boiler from 5:30 p.m. to 6:30 p.m. and during this period it blocked the activation of the microwave. During this period, two appliances (TV and fridge) were switched on.

Analysis of Test Results
To illustrate the effects of the developed algorithms in a single household, the following analysis of energy consumption in a household were carried out using:  the ToU price program (without EEM),  the ToU price program and the EEM algorithm, without and with RES. The results of these analyses are presented in Table 3, where each analyzed case contains the value of energy consumed and its costs in each time zone and their sums per day. The comparison of the analysis of the obtained results of the tests for the first group (Table 3-without RES) shows that the use of the EEM algorithm resulted in a reduction in the cost of daily energy consumption by Polish monetary unit PLN 0.76 (−5.6%), despite an increase in energy consumption by 0.8kWh (+3.2%). The shifting of switching on of the washing machine and dryer from t_z=2 (07:00-10:00) to t_z=1 (21:00-24:00) had a significant impact on reducing energy costs. The increase in energy consumption was caused by the extended operation time of the boiler and air conditioner in their next work cycle, occurring after their earlier switching off by EEM1. Extending the working time of these appliances resulted from ensuring the required water and air temperature. On the other hand, activation of EEM2 ensured the implementation of power reduction with excess in the desired period of time. Turning off the boiler for a period of 1 h resulted in the extension of its work time in t_z=3 and shortening in t_z=1. During this period, the EEM2 algorithm also prevented turning on the air conditioner.
However, the comparison of the analysis of the obtained results of the tests for the second group (Table 3-with RES) shows that the use of the EEM algorithm resulted in a simultaneous reduction in daily energy consumption by 2kWh (11.2%) and its costs by PLN1.03 (13.6%). It was influenced by the amount of power generated by RES, part of which was transferred in the zone t_z=3 to NPS. This power did not exceed the value of 5kW reported by the DSO; therefore, there was no reaction of the EEM algorithm to the limitation of this power by the inverter. When calculating the costs of energy consumption for the zone t_z=3, it was assumed that the selling price of the surplus energy from RES is equal to its purchase in this zone. The use of the EEM algorithm also resulted in lower delays in the use of the washing machine, dryer and dishwasher, which significantly increased the comfort of their use by household residents.
The evaluation studies carried out clearly show that the use of RES in the household has a significant impact on the reduction of daily energy consumption and its costs. This is indicated by the results of simulation tests (Table 3) for both groups (without and with RES). If only the ToU tariff is used, the RES application reduces the daily energy consumption by 6.8kWh (−27.6%) and its costs by PLN5.84 (−43.5%). On the other hand, the simultaneous use of ToU and EEM and the use of RES reduce the daily energy consumption by 9.6kWh (−37.8%) and its costs by PLN6.11 (−48.2%).
In the performed evaluation tests of the EEM algorithm, there was a lack of choice of intermediate values of power levels in the appliances. For example, when operating EEM2 in the time period requested by DSO, the boiler was turned off and the option of switching on other appliances with a total power greater than Ph_DSO was blocked. If the boiler, as a smart appliance, had 2 additional power levels defined (as in Section 3.3), then for the comfort of using hot water at that time, EEM2 would reduce its power to 1kW. Thus, a power reduction of 0.5kW would be achieved in the given time period.

Discussion
The EEM algorithm proposed in the article is an on-line algorithm, i.e., for each moment the value of power consumed from the power grid and RES is analyzed, and the costs for energy consumed are reduced while ensuring a certain level of consumer comfort. The algorithm takes into account the presence of appliances and smart appliances. After a slight modification, the developed algorithm can also work with other price programs, e.g.,RTP.
The evaluation tests which were carried out on the prosumer block show that the applied GRASP algorithm with a given optimization criterion obtains the most favorable results of setting the power levels of appliances with a small number of iterations.
The novelty of the EEM algorithm is:  to increase consumer comfort by introducing additional U and USEL coefficients in the objective function,  using smart appliances with a certain number of power levels to be used in its reduction process and consumer power reduction thresholds (Phmax),  the ability to reduce power charged by the household to the level of Ph_DSO on demand DSO to reduce peak demand and excess power generated by RES (PRES_DSO).
The tests confirmed that the proposed EEM algorithm can contribute to a significant reduction in energy costs; in the analyzed example, about 5.6%, compared to the user's independent use of the ToU pricing program only. With RES, the reduction will be much greater. For the analyzed example, it is around 13.6%. At the same time, this algorithm performs an educational function, shaping the consumer behavior profile towards the activation of appliances in the cheapest time zones in order to mitigate the peak demand phenomenon at a higher level of energy management. The introduction of inverters from RES provides even greater user comfort in the use of appliances installed in the household.
Furthermore, the introduction of the EEM2 algorithm confirmed the possibilities of its application to increase the support of actions taken at the DSO and TSO level in the reduction of peak demand. EEM2 also translates into benefits for household energy consumers. In addition to the additional slight reduction in energy costs resulting from the ToU pricing program, there may be remuneration for not using equipment in the time set by DSO above the set power threshold Ph_DSO. This means that the proposed EEM algorithm makes it possible to plan energy consumer behavior and to plan energy demand.
Appliances, which should be intelligent appliances, play an important role in the energy management process. Manufacturers of such appliances, in addition to being able to control the EEM algorithm and shift in time, were proposed in the article to introduce additional parameters related to work sections (WS), power reduction levels (k) and priorities. This will allow, among others uses, an increase in flexibility in the use of such appliances.
Further work on the EEM algorithm is expected to take into account the existence of energy storage in households, including electric cars. Further work on the verification of other metaheuristic algorithms in order to compare their properties with the GRASP algorithm is also planned.
Funding: This work was partially funded by the European Union within the European Regional Development Fund (ERDF), in the context of the INTERREG V A BB-PL Programme. Part of this work was carried out as part of the INTERREG Project on "Smart Grid Platform for research on energy management", project number 85024423 as well as part of the H2020 ebalance plus project (grant number 864283).