A Cyber-Physical Residential Energy Management System via Virtualized Packets

: This paper proposes a cyber-physical system to manage ﬂexible residential loads based on virtualized energy packets. Before being used, ﬂexible loads need to request packets to an energy server, which may be granted or not. If granted, the energy server guarantees that the request will be fulﬁlled. Each different load has a speciﬁc consumption proﬁle and user requirement. In the proposed case study, the residential consumers share a pool of energy resources that need to be allocated by the energy server whose aim is to minimize the imports related to such a group. The proposed solution shows qualitative advantages compared to the existing approaches in relation to computational complexity, fairness of the resource allocation outcomes and effectiveness in peak reduction. We demonstrate our solution based on three different representative ﬂexible loads; namely, electric vehicles, saunas and dishwashers. The numerical results show the efﬁcacy of the proposed solution for three different representative examples, demonstrating the advantages and drawbacks of different allocation rules.


Introduction
In electric power systems, it is necessary to generate sufficient energy to fulfill its demands almost in real-time. The traditional way of managing power systems focusing on generation has changed in recent years, giving more attention to the demand-side aspects [1,2]. Due to the old fashion of uncoordinated charging, the power grid has been exposed to load fluctuations with peaks, which are costly, since it requires more transport capacity. Among all residential loads, thermostatic loads are the major contributors to peak usage [3] and consequently play a major part in grid congestion.
With the significant development in communication services and network-controlled system technologies, novel approaches to carry out demand-side management have appeared based on the so-called "smart appliances". One promising idea has been to consider energy networks as a packetized system similar to the data internet; it was first introduced in [4] by two Japanese researchers based on the idea of packet electric power transportation as a way to manage excess energy via discretized energy packets. This idea has also been described comprehensively in [5] with the innovative concept of a quantum grid. Here, power transmission is based on energy packets in a synchronous way and involves core features such as, power plane, routing and control, and business plans.
In a more theoretical vein, the G-Network theory [6] was applied by Gelenbe and his group to analyze packetized energy networks [7,8]. Along similar lines, Liu et al. proposed in [9] a queuing-based energy management system including delay-sensitive and delay-tolerant demand.
Focusing more strongly on implementation, Abe et al. proposed the concept of a Digital Grid [10,11] where the synchronous grid is divided into smaller asynchronous regions that are connected via direct current (DC) links. These links exchange physical energy packets based on power-line communications using an Internet-Protocol-like solution.
This idea was extended in [12,13] by including transmission between intelligent power routers. Other contributions by Rojas-Cessa and his collaborators follow similar lines considering physical energy packets [14][15][16]. This includes the details of how this could be physically implemented by physical energy routers and switches in testbed [17,18], also considering technical aspects like digital micro-grids [19] and their routing algorithms [20]. In other recent contributions, the authors proposed in [21] an energy internet based on a distribution grid composed by local area packetized power networks where an efficient transmission and subscriber matching protocol was used for its operations. This enables the routers to supply power over different routes by matching the subscribers and demand supplier. Subscriber matching phenomenon helps in creating an algorithm for the problem and also increases the benefits of the subscribers. In another contribution, the authors proposed in [22] a management strategy based on a multi-mode energy distribution system based on a storage phase in off-peak times and a consumption phase to follow real-time fluctuations. In the case of energy reallocation, the dominant view of an energy internet is presented in [23,24] to achieve optimal energy management by applying deep reinforcement learning and optimization, respectively, to guarantee optimal control and economic viability. Various business models, big data analytics, and core elements of energy internet are also discussed in [25].
Unlike the physical packet solution, the authors in [26] assume for management purposes that the power consumption comprises virtualized discrete packets. In this sense, we consider that the management system becomes cyber-physical, in accordance with the following NIST definition (https://www.nist.gov/el/cyber--physical-systems): cyber-physical systems comprise interacting digital, analog, physical, and human components engineered for function through integrated physics and logic. Therefore, the physical energy consumption of the specific appliances is virtualized in discrete packets as a management tool to achieve set pre-determined quality requirements. For example, Lee et al. proposed in [27] an air conditioner load management technique based on queuing theory and a Markov birth-death process, which are based on discrete mathematics In this technique, energy tokens (packets) are used for turning the air conditioner on and off .
In [28], Zhang and Baillieu proposed a packetized direct load control method for controlling the temperature of an air conditioner based on a thermal dynamic model to check the duty cycles. In [29], they proposed an extension by allowing appliances to request or withdraw packets according to their need. This process of request and withdrawal is a queuing system that has numerous servers and probabilistic returns.
A packetized approach has also been used in manage electric vehicle (EV) charging in [30]. Each EV needs to request to be charged and, depending on the time availability of energy packets, the request can either be approved or rejected. This concept has been taken from process and network scheduling commonly used in computing and communications to serve all users fairly while considering the network constraints. The same group of researchers has been actively working on the topic, as evidenced by their latest papers [31][32][33][34][35], describing a real-time approach to manage thermostatically controlled appliances, known as packetized energy management (PEM).
Their approach is the basis of a start-up company called Packetized Energy (http://www. packetizedenergy.com/) [36]. In this scheme, a probabilistic approach is used for delivering energy. For instance, thermostatically controlled loads asynchronously request an energy packet, which is either approved or rejected, depending on the analysis of total population. From a case study of one thousand heaters, it was concluded that their method can track the reference signal without significantly downgrading the quality-of-service (QoS). More recently, the authors in [35] used PEM to analyze the population of varied distributed energy resources (DERs) by a bi-linear system modelling for DER aggregation. The number of approved requests is maximized by a simple discrete-time control law that also tracks the regulation signal produced by the regional transmission operator. A QoS controller is also provided for PEM and an extended Kalman filter is used to check and provide estimation from the different states of a diverse DER population. In [37], the authors suggested that packetized energy management will be the key enabling technology to build an energy internet.
This kind of more decentralized solutions fits in a broader context of a home energy management system (HEMS) [38], which has played a vital role in implementing demand response programs for the residential consumers attempting to manage daily energy consumption. Demand response typically aims to encourage the end consumers to reshape their load profile in response to the electricity price market [39,40]. Following the systematization proposed by [39], demand response can be categorized into incentive-and price-based programs. An incentive-based program requires customers to participate and shift their load consumption to off peak hours in exchange for a reward (discounted rate) for their participation in the program. Incentive programs are related to direct load control, curtailable loads, demand-bidding and buy-back, and emergency and demand. Price-based programs involve various pricing signals at designated times to lessen energy consumption by providing monetary benefits to the consumers. It includes time of use, real-time pricing, critical-peak pricing and day-ahead pricing.
The present contribution focuses on a similar idea, but with key differences. The most remarkable difference is that our solution is based on requests and services that are not mediated by price signals, or any monetary incentives. The proposed management is built upon direct requests that impose a "deadline" when the service must be complete; the HEMS would then aggregate the information of energy usage, demand and time of operation constraints and communicate it to the energy server as a service request related to specific classes of flexible loads.
These direct requests, in contrast to price-or incentive-based mediated solutions, provide greater ability to build aggregate load profiles. The energy server therefore mainly manages and (re)allocates (available) energy resources based on service requests, which also includes users' constraints. More specifically, the loads are discretized in 10-min energy packets, which are used by the energy server to decide whether to run the service or not. The server owns "a pool of energy" to share between the group members and its goal is to maximize the energy usage from the pool while trying to avoid "importing" electricity. If the service is granted, the server allocates the discretized loads based on their requirements.
This technique is also different from the usual optimized dispatching, which usually depends on fairly heavy computations and/or direct one-way load control. In this sense, our solution is computationally light while effective in peak-shaving. Although simple, the proposed packetized management could be useful in supporting the market integration of demand-response based on Exclusive Group bids [41] where retailers or aggregators bid daily profile curves in the day-ahead market that should be realized. Note, however, that direct allocation using packetized energy makes any quantitative comparison with existing distributed (price-based, or incentive-based) or centralized (globally optimizer) allocation unfair-even unfeasible-since the scenarios used to analyze the algorithm performance are built upon quite a different set of assumptions and methodological choices. All in all, the proposed solution presents qualitative advantages due to its rule-based nature if compared to mainstream approaches, but these advantages cannot be fairly quantified due to inherent differences in the way the resource allocation is modelled and solved.
The rest of this paper is divided as follows. Section 2 introduces the concept of residential PEM using three different dispatchable loads. Section 3 contains the numerical results to evaluate the proposed packetized management algorithm for three different representative examples. Section 4 proposes a discussion related to the present result, while Section 5 concludes this paper.

Proposed Solution
The proposed management works as a cyber-physical system that discretizes dispatchable loads in virtual energy packets of 10 min. The physical system is the interchange of energy from a shared pool of energy resources to different appliances in different households. The control of this system is virtualized: specific loads are mapped to the cyber domain as "discretized energy packets" of 10-min durations. These loads will send requests based on their particular characterization in the cyber domain to an energy server, which will either accept the request or not. It is worth noting that here, we are only considering specific flexible loads and a shared pool of energy resources, which is exclusively used to supply these loads. This management is then performed virtually so that we can call this a cyber-physical system. The management goal is to allocate the requests of those flexible loads based on the proposed algorithm considering the individual requests and the overall state of the energy pool. Consequently, the other loads that build up the actual household load energy consumption is beyond our focus here, which is to assess the details of the proposed management algorithm under ideal conditions. A further analysis including realistic and heterogeneous load profiles will be performed as a future work.
The decision is purely in the cyber domain, which controls the physical power flows in the system defined by energy exchanges. As the cyber decisions affect and are affected by the physical system dynamics, the feedback loop between physical and cyber entities are closed. We consider that each appliance has intelligent switches [42] that can regulate the power consumption of appliances following the proposed PEM. This will also allow for two-way communication to allow the needed request/service messages. The request from an individual appliance is based on its power requirements and length of usage (i.e., its power envelope in the assumed 10-min time step), as well as time constraints such as starting time and deadline for running/completing charge. Each appliance makes a request via a residential energy router that will forward this request to the energy server to have access to a given amount of energy during a time slot (or a full request for the usage period in the case of uninterruptible loads, such as a dishwasher), and the server either approves or denies the request for that period, according to its own energy availability/forecast. A schematic of the proposed solution is presented in Figure 1. Further, a flowchart of the proposed solution is shown in Figure 2. There are three applications with intelligent switches (e.g., EV, dishwasher and sauna) that have a communication link to a relay node (Energy Router). The relay node communicates by sending requests for virtualized energy packets via a data network to the Energy Server. The communication is two-way. The communication links can use different technologies. Since the solution is not strongly constrained by latency, packet retransmissions can be used to guarantee reliability in each hop. In the proposed packetized management algorithm, the energy server allocates an exclusive shared pool of energy resources to a pre-defined set of specific flexible loads.
In more specific terms, the appliance-server relationship is based on three steps (like handshake procedures in data networks), as follows.

•
Step 1: A given dispatchable appliance sends a request to the energy server via its associated energy router containing its energy needs and consumption requirements.

•
Step 2: The server may accept or deny the request based on its internal state (to be described later).

•
Step 3: The service is delivered.
In more practical terms, the energy router would aggregate the information about dispatchable loads (their power envelope, total energy demand and time constraints) and send this as a list to the energy server, which will allocate the aggregate power demand from all houses based on the available pool of resources. The energy server is the entity that manages the energy inventory of several residential consumers. For simplicity, we assume that the server controls a given amount of energy to be allocated among its group of residential consumers. This can be exemplified by a given retailer or aggregator that bought energy in the day-ahead market, or a micro-grid aggregator that manages the resources (renewable generation and storage) of its members.
Here, we will analyze a case with three different loads that have particular characteristics that are suitable for the proposed virtual discretization and packetized management, following the classification of delay-sensitive and delay-tolerant demand proposed in [9]. We consider in our analysis three typical delay-tolerant loads, namely: sauna (thermal load), EV (battery charging) and dish-washer (fixed, uninterruptible consumption profile, but flexible starting hour), as illustrated in Figure 1. These loads were chosen to be representatives of specific classes of flexible loads that are suitable for the packetized management proposed here.
The basic types of dispatchable delay-tolerant loads are: (i) cyclic loads, such as heating or cooling loads that are represented by the electric sauna profile (electric heaters, or air conditioning would work similarly, but with specific different functions and relations with outside temperature), (ii) uninterruptible but schedulable loads that are represented by the dishwasher profile (laundry machine and dryers are similar examples), and (iii) fully controllable loads that are represented by the EV profile (note that electric batteries or other kinds of energy storage from electricity would be similar, but having a different, more specialized, storage function).
Besides these three main classes, there are other loads that are not suitable for the proposed management and are therefore outside the scope of the study. Appliances that are related to human occupation and activities (e.g., lighting, cooking and entertainment) offer very little or no flexibility. These loads directly affect comfort levels by, for instance, postponing/advancing food preparation or other leisure activities like TV, radio, or computer. As a side note, these loads could be served by an in-home battery energy storage system (BESS) to provide flexibility, but then, the consumption behavior from the grid's point-of-view would be somewhat similar to the "EV" profile that will be described now.

Description of the Appliances
We created a population of houses with loads that could be dispatched based on the average consumption profiles from real appliances with randomized deadlines, which were calculated from empirical data. This randomization is modeled in our simulations as normal or uniform random variables. A description of each appliance is given now.

Electric Vehicles (EV)
EVs are one of the main electric loads that is increasingly present in houses nowadays. Their high-capacity batteries (ranging from around 10 kWh for plug-in EVs to 100 kWh for some all-EVs), high power drawing capacity (several kW, even from conventional power sockets) and long charging time (several hours, typically overnight) present both challenges and opportunities for electricity distribution systems. Table 1 shows the parameters used for the EV fleet. The battery values are based on existing EV technologies (https://batteryuniversity.com/). We estimated the arrival and leave times based on a daily routine where the EVs leave home at around 7 a.m. and are back at around 6 p.m.; the individual arrival and leave times are generated as an independent and identically distributed Gaussian random variable with means 7 and 18, with variance 1. The arrival is denoted as N p18, 1q, and the leaving time as N p7, 1q. These values were arbitrarily chosen to illustrate the scenario.

Dishwasher
Dishwashers are another example of household appliances that could be controlled to some extent. They are usually operated somewhere in the late evening (after dinner), and the dishes are left to dry until the next morning, which means that it can be scheduled to run during the night. The program of the dishwasher in our simulation is simplified in order to fit our time step, being composed of six periods of 10 min with power of either 0.25 or 1.5 kW. We also assume that, once the program has started, it cannot be interrupted, since that is usually the case with real appliances. Table 2 summarizes the information about the appliance, and Figure 3 shows measurements from dishwasher cycles. The model of the dishwasher is taken from the REDD database [43], which were used to create the simulated profile with 10-min resolution. The starting time is also modeled as Gaussian random variable N p21, 1q representing the "end of dinner" time around 9 p.m. and a chance of 95% of this event happening between 7 p.m. and 11 p.m. However, all requests have a deadline of 5 a.m. the next day. As before, these values were arbitrarily chosen to simplify the analysis.

Sauna
Saunas are also another equipment that have high power, as with most thermal loads. The sauna operation is characterized by an initial cycle, in which the heating element is turned ON for a long amount of time until it reaches its maximum temperature (E max ), and after that, the heating element is turned OFF until the lower temperature limit (E min ) is reached, when it starts another heating cycle. In the modeling of this dispatchable sauna, we enable the sauna to begin charging earlier (preheating) if there is energy available and, upon a given deadline in which the sauna must be ready (here noted as "start time"), it turns ON in forced mode to reach the desired temperature set-point. In the early charging, we consider that the sauna has idle losses and, when in use, it has usage losses, which are obviously higher. We assumed that the cycles are 10 min long (the time increment unit used in the simulations). Table 3 shows the parameters utilized in the simulation for the saunas. The parameters were set based on a heater for a small size sauna (http://splashpools.co.th/wp-content/uploads/ 2015/04/Waterjet-Sauna-Steam.pdf). The sauna is used in the evening, around 8 pm, and the use time is randomized in two ways: starting time is a Gaussin variable with variance of 30 min (i.e., N p20, .5q) and the duration is an uniform random variable between 30 min and 90 min (denoted by Up.5, 1.5q). As with the other appliances, these numbers were arbitrarily chosen.

Communication System
The proposed solution leads to a general communication architecture for the cyber-physical management systems based on PEM, as presented in Figure 1. The communication occurs in two hops: (i) from end-applications (e.g., EVs or dishwashers) to the residential energy router that acts as a relay node, and (ii) from the router to the energy server. Among the already available standardized solutions for the first hop, ZigBee, WiFi, Bluetooth or other device-to-device wireless technologies could be applied. The easiest way to build the second hop is to use the data internet, but other dedicated data network are possible. Internet access can happen through fiber or cellular technologies (4G, or even 3G). Clearly, the communication happens in both directions, uplink and downlink.
Note that the Packetized Energy Management application shall work regardless of the specific set of technologies employed. Hence, we assume the communication between the loads, the relay and the energy server is perfect for the application requirements. Although this assumption might be strong at the first sight, we argue that the proposed energy management algorithm can support delays in the order of minutes, which is considered (very) high in communication networks based on current technologies. The most important feature for the proposed solution is availability and reliability, considering such almost unbounded delay levels. For example, in [9], these energy applications are classified as delay-tolerant demand. Then, the required performance can be already achieved with existing technologies using, for instance, persistent medium access protocols for availability and retransmissions for reliability.
On the other hand, following the predictions of massive inclusion of wireless devices in upcoming years, our proposed technology shall also be capable of working under the standardized 5G and its ongoing developments defined by 3rd Generation Partnership Project (3GPP), which is the standardization body for mobile systems; for example, 5G standard has its initial definitions given in their Release 15 (https://www.3gpp.org/release-15). All in all, although communication networks have their own specific challenges and requirements, we foresee that recent advances in the Internet of Things [44], 5G technologies for vertical applications [45] and machine-type wireless communications [46,47] will also provide the level of reliability and availability required by the proposed energy management system, allowing it to scale up [37].
Another key aspect to be taken into account in relation to the communication system is the existence of cyber threats. From Figure 1, a few points of potential vulnerabilities can be ascertained. For example, it may be possible to attack the energy server with jamming, or ny introducing "fake requests". However, we expect that the packetized solution is robust against these attacks due to the hierarchical structure of request and service in the cyber domain. In the case of the jamming attack, the energy server may become unavailable for handling the services, leading to a worst case scenario where the requests would not be processed; this is easily identifiable and contingency measures may be taken like turning on the device without being granted the service by the server, or keeping the device on hold until the service processing is normalized. In either case, the class of loads handled by the energy server are not critical in a more strict sense. Regarding fake cyber requests, this is easier to handle since the on and off states of the machines depend on the existence of the physical entity in need for the service.
In general, the structure of the proposed management system preserves the physical system integrity; the worst case scenario for the physical system is to have either all requests accepted, therefore having a (predictable) peak, or all devices being turned off, which could cause a local "brownout". In addition, we understand that most of the available technological solutions indicated before have standardized minimal levels of security, that increase the reliability.
Nevertheless, we acknowledge the existence of cyber-security issues, whose impacts on the proposed solution deserve a specific investigation that goes beyond the present work. The present work targets the technological feasibility and advantages of the packetized management in a more idealized scenario. Nevertheless, as previously argued, the proposed cyber-physical system can avoid cyber attacks due to its peculiar physical structure.

Numerical Results
In this section, we will illustrate the potential of the proposed residential packetized energy management. As previously discussed, the key idea is to make better use of the available energy resources by taking into account the time-of-use flexibility of each individual house and its appliances, and then allocate the activities based on the available power within different time slots considering the individual requisites of each customer and the state of the shared pool of energy resources. Our focus is to exemplify how this method can spread the power usage along time, to reduce peaks in the aggregate demand. In specific terms, we will present three series of numerical results. The first one is a small-scale setup containing only 20 EVs as flexible appliance so that we can thoroughly assess the dynamical behaviour of the allocation algorithm. The second case is a larger scale scenario with 1000 households with the three proposed flexible appliances with different penetration levels. In this case, our goal is to show how priorities related to the different appliances work. The last example is also based on 1000 households, but considering only EVs. Our goal in this scenario is to illustrate how the priorities related to the same appliance work based on different ordering rules.

Small-Scale Study Case
In this subsection, we present, for didactic purposes, a simple example using just one of the appliances to illustrate how the proposed allocation scheme works. We simulated a fleet of n " 20 EVs following the distributions on the previous subsection. The total power limit for normal charging is set to P lim = 25 kW (sufficient for charging five cars simultaneously at nominal power). The priority for charging was defined as "earliest deadline" (described in more detail in Section 3.3, together with other strategies), which means that the EV that leaves the earliest has preference over the others. Figure 4a shows a realization of the simulation from the service point of view. Black squares represent times when the load in question is not available (e.g., the EV is out of the house) or is not meant to be used. Yellow means that the load is available for charge but the request was not granted. Blue means that the load has its request granted and it is drawing power from the energy pool. Red means that the request was not granted but the load has reached its deadline (e.g., the EV is expected to leave the house soon but its battery will not reach the desired charge level by then), and so, it entered forced charge mode. The charge levels over time for each vehicle are shown in Figure 4b.
The corresponding power draw is shown on Figure 4c, in the blue line. Note that the power limits are respected until it is detected that one vehicle will not be able to charge in time, so that vehicle enters in "forced" mode to complete its charge, thus exceeding the desired limit. It is also shown how the same loads would behave without any coordination between them (in the red line). One can clearly see the formation of a peak of about 3 times the power limit from the coordinated case.
It is worth noting that the behavior of the individual charging is continuous as soon as it starts since we do not consider a reallocation priority here (i.e., the charging cannot be interrupted after it started). This comes from the allocation rule "earliest deadline" used here and the scenario with only one kind of appliance. In the following subsection, we will present a study case where different appliances have different priorities so that EV charging can be stopped and restarted afterwards by the proposed packetized management algorithm.

EV Number
(a) Status of charging from EV 0 to 19 using earliest deadline rule with P lim " 25 kW. Legend: N/A , WAITING , CHARGING , FORCED , CHARGED .

EV Number
(b) Battery charge levels from EV 0 to 19 using earliest deadline rule with P lim " 25 kW. Darker grey tones indicate lower values. Green color means that the battery is charged.

1000 Houses Scenario
Using the same power allocation scheme as defined in the previous subsection, we ran a simulation of a hypothetical neighborhood of n " 1000 houses, with 30% of penetration of sauna, 50% of EVs, and 85% of dishwashers, and a power limit of P " 800 kW. The scheduling algorithm runs based on priorities for every load in the group as: The reason for this choice is that the sauna has the most strict requisites (the usage deadline is the first to occur, the power usage is fixed per cycle), followed by the dishwasher (which can be run at any time before 5 a.m.), and finally the EV (which, although more energy demanding on average, has both a long time to complete the charging and allows for variable power demand). The procedure is presented in Algorithm 1 (note that for flexible power loads such as EVs, there is an implicit rule that allows for power draw lower than the nominal power of the charger, which is not stated in the code to simplify it).
The results of the combined power allocation of the appliances for all houses under the "earliest deadline" allocation can be seen in Figure 5. The power limits are respected globally most of the time, except for the later periods, in which the EVs had to exceed the global power limit because, otherwise, their batteries would not be fully charged at the desired/needed time. This "forced charging" means that under critical conditions, the appliances ignore the dispatch from the aggregator to satisfy their own demands. It is worth noting that, even though the power limit (i.e., the available pool of energy resources for the flexible loads) was set to a constant value, it could have been set to any arbitrary value for each timestep, and the loads would follow it.  Figure 5. Results for the coordinated demand response for 1000 houses considering the aggregate power consumed from 3 p.m. to 9 a.m. in the following day.

Ordering Algorithms
In this subsection, our goal is to evaluate the impact of the different ordering algorithms that determine the priorities among the same appliance class, while also assessing the impact of a "soft" and a "hard" limit in the available power (i.e., if energy "imports" are allowed or not, respectively). We consider a scenario with 1000 EVs that need to have their charging coordinated based on a sorting strategy that defines the allocation priorities. Below we describe a list of possible ordering schemes that were implemented by the following Algorithm 1.

•
Random: The houses are selected in a random fashion so that all of them have the same chance to be chosen.

•
Ordered: This is the simplest ordering scheme amongst all. The list of the houses for a given appliance is run in an ordered fashion, until the available power is exhausted. For the next time period, the first house that was not allocated is the first to be served.
• Lower initial charge first: This considers how much energy will be demanded by each house during the charging time for a given appliance, with appliances with lower initial energy (in percentage) having priority over the ones with higher initial energy. • Higher initial charge first: This is the opposite of the previous case. The house with the higher charge states have priority over the others. • Earliest deadline first: This gives priority to the houses whose appliances have to be ready earlier. Note: In our preliminary simulations, the random and ordered methods gave virtually indistinguishable results except for some special cases; therefore, we will only show the results for the ordered method.
The performance of the proposed allocation algorithm based on such ordering rules are also affected by the availability of "energy imports" (i.e., if the power limits used by packetized energy management are "hard" or "soft"). Specifically, the quality of the charging service requested by the EVs to the Energy Server would have the following characteristics: • A hard limit affects the fairness of allocation outcomes: some EVs will have their batteries fully charged, while others will not have them fully charged. • A soft limit provides a fair resource allocation where all EVs have their batteries fully charged, but at cost of a peak consumption.
To evaluate the performance of the allocation rules under these two conditions, we simulated a population of n " 1000 EVs (without any other appliances) with the same parameters as in Table 1. The power limit is set to 1000 kW, which is not sufficient to completely charge all the vehicles if the power limit is to be obeyed. Setting the limit as "hard" gives us the results from Figure 6, while the results for the "soft" limit are shown on Figure 7. For the "hard limit", the load profile curves are somewhat similar, but the policies that favor higher battery states ("high battery % first", "less P avg first") reduce the power demand sooner. This is because some of the batteries that were not fully charged went past their deadline, and so they were not available anymore. This is reflected in the boxplot distribution of the final charge levels, where the spread of the battery charge levels is bigger. Conversely, the policies that favor low charge levels ("low battery % first", "more P avg first") reduce this spread, although the median battery level is slightly lower. The "ordered" and "earliest deadline" case fall in between these cases. This indicates that the ordering rule has a strong effect on the quality of service (QoS) experienced by the end users, as evaluated by the charging levels by the individual requested deadlines.
For the "soft limit" case, the final charge levels are the same, as expected. On the other hand, the power profiles are quite different in some cases, going from an early gradual increase (as can be seen in the "high battery % first" power profile) to a late, abrupt increase (in "more P avg first"). This solution is clearly fair for the individual users, but can create dramatic peaks (three to four times more than the limit). In any case, this clearly shows the impact of the allocation rules on the performance of the proposed solution.
From the combination of both results, when the energy available from the shared pool of resources to be allocated among the flexible loads is not sufficient to supply all requests, it is a clear trade-off between the fairness of service provided to the different end users and the strictness of the power limits. In other words, if soft limits are allowed, fairness may lead to peaks in aggregate consumption. Conversely, if hard limits are imposed, the outcome of resource allocation may be unfair (some users will have their requests fully served, while others will not). This indicates that a hybrid strategy based on a fairer allocation rule (e.g., lower initial charge first) with a softened hard rule allowing for a small variation around the limit would be sufficient to provide a fair service without significant impacts at the aggregated level.

Discussions
These results indicate the potential of this distributed residential management due to its simple implementation of "following a control line" based on discretized loads. Instead of optimizing the dispatching based on price, the proposed solution aims to allocate 10-min energy packets over time following rule-based priorities focusing on self sufficiency in regard to the shared pool of resources. While this scenario is still simple, it could be already useful for utilities that bid in the European electricity market (Exclusive Groups [41]) where they offer different daily load profiles. This market mechanism is useful when flexible loads can be effectively managed.
Note that the proposed algorithm is flexible enough to support different QoS and system level goals. For instance, if we impose the "hard limit" constraint to the system in a scenario where the power is insufficient to satisfy all the requests, then the QoS criterion might be fairness, or else, utilization of as many available resources as possible (total energy available in the period). On the other hand, if we allow for exceeding the power limits, the performance criterion could be the smallest peak power demanded by an algorithm, or the maximum usage of available resources before exceeding the power limit (which basically has the opposite effect of the previous criterion). Nevertheless, this solution is not a "dispatching-optimizer" is the usual sense but rather a rule-based approach that guarantees a given QoS, which is determined during the appliance request to the server. This algorithm might also be the basis of the management of micro-grids whose users share their distributed generation, creating a cooperative Virtual Power Plant, or a Virtual Micro-grid. The generation and storage capabilities would offer the system management the energy that needs to be shared among users. The server would then allocate the flexible loads following the guidelines used in Section 3.3.
We have strong evidences that the proposed management can be already implemented based on a variation of the packetized management proposed in [31][32][33][34][35] and commercialized by their authors in the start-up company Packetized Energy [36]. Their approach considers a similar "appliance-server" relationship but focuses on the real-time conditions from both individual appliances and the grid perspective. Their approach is based on local randomization of the frequency that the requests are sent (like random access problems in sensor networks [48]). Although this solution is effective (and already commercialized) in smaller scales, our proposed packetized energy management can offer scalability by incorporating longer time horizons (minutes to hours) via a more proactive energy server based on priorities and allocation rules. One could go further and think about this solution as scalable and based on modular relations between micro-grids similar to [10,21]. The service allocation would be based on a distributed planning hierarchical relation as in [49], which provides an efficient way to deal with the respective distributed combinatorial problems that can emerge. In this sense, the energy system management for residential users would resemble the data internet. We argue here that, if this cyber-physical solution of the energy management system based on packets scale up to many interconnected micro-grids [50], the energy system would become a real Energy Internet [37].
Similar to the data internet and other cyber-physical systems, the proposed management is vulnerable to cyber attacks [51]. This issue is even more dramatic in critical infra-structures such as electricity grids [52]. Therefore, the proposed solution should be further investigated in terms of cyber-security. In more general terms, the algorithm to be effectively used as a management tool should be trustworthy, avoiding issues related to "free-riding" behavior of users. This is partly guaranteed by the hierarchical approach of "requesting the server", and in this sense, the scheduling is given from the retailer/aggregator/utility to a home automation controller, based on previously agreed user preferences and with specific constraints. As in the case of cyber-security, regulations and incentives must be studied to strengthen the trust in relation to the system and among the users themselves.

Conclusions
In this paper, we focused on the idea of a cyber-physical system that packetized the management of residential loads in energy systems. Our solution is different from the mainstream approach of optimizing dispatching based on price, or other (usually monetary) incentives. Instead, we assume an energy server that needs to share a pool of energy resources among different delay-tolerant appliances. The different appliances have their own service requirements that shall be fulfilled if the energy server accepts the request.
Our numerical results show the scalability of the solution in the proposed simplified scenario based on three different classes of loads, namely, EVs, dishwashers and saunas. For the case under investigation, we showed that the proposed packetized management can effectively coordinate the loads' demand, while being capable of decreasing the peak time and/or shifting the consumption based on prioritization rules. We specifically showed that different allocation rules lead to different performances based on fairness and peak reduction. This trade-off shall be further investigated in a future work.
We also plan to extend this study in order to incorporate more diverse classes of loads, using more detailed consumption behavior based on real data from retailers/utilities/aggregators. This would include different appliances and temperature-dependent consumption (heaters and air conditioning). Aspects related to congestion management and possible contingency actions that might be needed upon production-demand mismatch shall be also included together with different energy allocation curves/ This will then be similar to the Exclusive Groups bids used in wholesale energy markets. Another necessary extension is related to the impacts of a more realistic communication system in the proposed management algorithm, including high packet loss, low network availability, hour-long delays, jamming attacks and other potential cyber threats including secrecy issues. In addition, we also plan to formalize this as a theoretical problem in order to not rely solely on simulation results. The idea is to combine existing results from queuing theory (e.g., [8]) and control of multi-agent systems (e.g., [32]) so that we can evaluate the performance of different management techniques.