Holonic System Model for Resilient Energy Grid Operation

: The transformation of energy grids towards smart grids is driven by numerous political, economic, and ecological goals. As part of this process, the centralized top-down architecture of energy grids changes towards increasingly decentralized structures. It is widely accepted that the challenges emerging from this transition threaten the resilient operation of energy grids. For instance, the volatility of renewable energy sources challenges the required balance between demand and supply; their distribution in the energy grid likewise complicates their coordination. Holarchies are a promising (systems-of-systems) architectural pattern for smart grids fostering fast isolation and self-sustained operation of subparts (so-called holons), as well as supporting dynamic reconﬁgura-tions of the grid’s structure. To leverage these properties to increase the resilience of smart grids, we propose a system model that combines a holonic architecture and locally available resources offered by prosumers. Our model organizes the participants in the grid as holarchy and enables the application of ﬁne-grained control mechanisms. We show the capabilities of the model by resolving an overproduction situation and a situation of severe electricity scarcity using a modiﬁed binary ant colony optimization approach. Our evaluation with the simulation environment HOLEG shows that the system model and the proposed algorithm can quickly mitigate balancing problems in holonic energy grids.


Introduction
Energy grids are transitioning from centrally managed, hierarchical structures towards decentralized, distributed ones. The ever-growing contingent of small and distributed renewable energy sources (RESs) challenges the resilient operation of the grid by increasing the production volatility compared to an energy grid that is supplied by a few large-scale power plants based on fossil fuels or nuclear reactors. This development exacerbates the challenge of maintaining the balance between demand and supply, which is crucial for all energy grids [1].
Today, the mitigation of such balance deviations strongly relies on the availability of large amounts of operating reserves-hot-standby resources for adjusting the production and consumption in the grid [2]. In cases where these resources are insufficient to redeem the issue, load-and production-shedding mechanisms must be applied and may separate parts of the grid to restore the balance and curtail cascading failures [3]. However, the applicability of these mitigation measures suffers from the ongoing transition of the energy grid: • The amount of operating reserve capacity that is required to compensate the effects of the volatile production of RESs increases [1]. • Due to the reduced number of large-scale producers in smart grids (SGs), operating reserve capacity needs to be increasingly provided on lower layers in the grid. How-ever, access to those resources by control entities may be limited, or they may not be controllable at all [4]. • Traditional measures for problem mitigation, like rolling blackouts, are not easily applicable in SGs, where parts of the grid can operate autonomously [5]. The separation of parts may prevent local resources from being used for mitigating the overall issue. Furthermore, to maintain stability in the separated parts of the grid, prosumers become increasingly important. However, detailed information about them is not available, and their role in problem mitigation processes is overwhelmingly passive [6].
The drawbacks outlined above can be mapped to three main challenges: (i) how can a future SG be organized to support a high degree of distribution and dynamic changes of its participants and the corresponding infrastructure, (ii) how can detailed information about prosumers be made available to support the mitigation of emerging issues, and (iii) how can this information be leveraged to improve the decision-making during mitigation processes to increase the resilience of energy grids?
Novel and updated grid architectures and control schemes are required to address the challenges stated above. In this context, related work investigated cellular-and micro-grids as suitable architectures to support the stability of future energy grids by enabling the separation of energy grids into subparts [7][8][9]. Based on these architectures, novel concepts were developed that leverage the properties of these architectures to support the resilient operation of energy grids [10][11][12]. However, within these works, prosumers participate within energy grids as overwhelmingly passive entities. Although, prosumers are considered to be capable of supporting the resilient operation of energy grids substantially by deploying local RESs and battery storage systems and by supporting sector-coupling technologies [13][14][15].
A promising candidate for a system architecture that is capable of addressing the aforementioned challenges and strongly involves prosumers into processes for emerging issues are holarchies. Holarchies are based on the concept of holons, which are simultaneously a part of larger systems and a whole system themselves [16]. Such a systems-of-systems architecture allows incorporating heterogeneous stakeholders in the grid (e.g., prosumers, enterprises, service providers) using various abstraction layers. Holarchies support both hierarchically organized and distributed relations between these stakeholders. Moreover, the dynamic adaptability of holarchies facilitates system reconfiguration and supports the development of novel mechanisms for resilient system operation. In this paper, we make the following main contributions: • We present a detailed holarchy-based system model that facilitates strong prosumer integration and enables the application of novel control mechanisms. • We introduce flexibilities as a concept that enables prosumers to offer local resources to grid control authorities for mitigating demand and supply imbalances. • We present an algorithm based on binary ant colony optimization (BACO) for finding near-optimal solutions to the joint issue of reconfiguring holarchies and allocating flexibilities to mitigate and overcome balancing problems. • We show the capability of our approach to quickly find high-quality solutions in a simulated large-scale example holarchy.
The remainder of the paper is structured as follows. Section 2 provides information materials and methods used within this work, e.g., holarchies, the HOLEG simulation environment, and ant colony optimization (ACO). In Section 3, related work of holonic systems and home energy management systems (HEMSs) are presented. Subsequently, in Section 4, the proposed holonic system model and the flexibility concept are explained. In Section 5, our case study is discussed before we conclude in Section 6.

Materials and Methods
In this section, we provide a brief introduction of the fundamental concepts used within this work and the required tools to understand and replicate the results within this work. First, the concept of holons and their basic properties are introduced. Second, the HOLEG simulation environment is briefly explained. Finally, information about system control is explained in detail.

Holonic System Structure
The concept of holons was first introduced by Koestler in 1967 [17]. He described them as an entity, which is, simultaneously, a part of a larger entity and a whole entity itself. From this, a recursive system structure emerges, where holons represent intermediate structures that are organized on layers. Holons may encompass smaller holons on lower layers and can be part of larger holons on higher layers alike. Holons that are organized in such a way form a holarchy.
Holons offer unique properties that can provide various benefits within the transitioning process of energy grids. Among the most prominent properties of holons are autonomy, self-sustainability, and their proclivity to recombine into larger holons. A holon's ability to act autonomously combined with its desire to sustain itself enables it to maintain "its purpose", even if issues appear at higher layers of the grid. For instance, failing communication from higher layers of the holarchy can be compensated on lower layers by operating according to the intrinsic goals of the individual holons, like maintaining an emergency supply with electricity. Furthermore, the recursive structure of holarchies allows incorporating hierarchical and distributed systems alike; and the high dynamic facilitates system adaptions to quickly adjust to emerging situations. Among these adaptions are splitting (separation into smaller holons), merging (recombination to form larger holons), and changing affiliation (reorganization of hierarchical dependencies) of holons. Figure 1 shows a holarchy that is applying a splitting operation to separate a faulty part from the grid.

HOLEG
HOLEG is a discrete-time simulation environment for simplified energy grids based on the holon concept [18]. The tool is used to conduct the case study presented later in this work. All evaluation results, the necessary algorithms, and the case study example grid were implemented in HOLEG and are available within the code repository (HOLEG Repository URL: https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons). Participants in the grid are designed using so-called holon objects. Each object represents either a prosumer or a more specialized component like an energy storage device or a separator switch. These objects can then be further aggregated to form holons on higher layers of the holarchy.
Adhering to the holon concept, all holons may encompass holon elements. These entities are considered as atomic because they cannot be further separated into smaller controllable entities. More precisely, holon elements represent individual actionable segments that consume or produce electricity within a holon. For instance, holon elements can be individual devices (e.g., TVs, solar panels) but can also be more complex entities, like (parts of) a house that does not allow for a more fine-grained control of subparts. During the simulation process, the state of a holon object is defined by aggregating the behavior of its holon elements. If holon elements are in an active state, they produce or consume electricity according to their modeled profile. When in an inactive state, holon elements neither consume nor produce electricity. The resulting states for all holon objects recursively define the state of holons on higher layers that encompass them.
HOLEG distinguishes six mutually-exclusive states for holon objects. These states depend on (i) the electricity required by holon objects (the amount of electricity that is necessary to supply the encompassed active holon elements), (ii) the amount of electricity that is locally produced within the holon object, and (iii) the amount of electricity that can be provided by the energy grid.
Here, HOLEG differentiates between one producer state and several consumer states: a holon object is in a producer state, if its producing holon elements provide sufficient electricity to supply the active consuming holon elements, and, furthermore, provide excess electricity to the grid.
In comparison, HOLEG distinguishes five consumer states: • Unsupplied. An undesired state, where no active holon element within the holon object can be supplied with electricity (i.e., a black-out state). • Partially supplied. An undesired state, where at least one of the active holon elements within the holon object can be supplied with electricity but not all active ones. • Supplied. The only desired state, where all active holon elements encompassed in the holon object can be supplied with electricity and there is no excess electricity in the energy grid that currently cannot be consumed. • Oversupplied. Undesired state, where the amount of produced electricity in the grid exceeds the current demand of the holon object. In contrast to the producer state, where a holon object produces surplus electricity, which is then used by other participants in the grid, the oversupply state is a result of excess electricity that cannot be consumed in the current situation. • Inactive. Undesired state, where all holon elements are inactive and the holon object does neither produce nor consume electricity.

System Control
Our holonic architecture (see Section 4.1) represents grid entities as aggregated holons on different layers and enables fine-grained control of locally available resources based on the concept of flexibilities for the mitigation of demand and supply issues. Especially for severe problem cases that need to be addressed on higher layers in the holarchy, the allocation of a suitable number of flexibilities for mitigating the problem can quickly pose a tremendous challenge.
Metaheuristic optimization approaches are known to cope well with large problem spaces, limited domain knowledge, and uncertainties. These properties are well suited to work with our proposed holarchy model, as problem sizes can quickly grow and information about the grid may be incomplete (e.g., appliances may not be identifiable). In the following, we present a BACO approach for quickly finding configurations (solutions) to mitigate challenging situations using the proposed holarchy model and corresponding flexibilities. Moreover, a penalty function is presented that is used for the assessment of the quality of found configurations.
BACO approaches perform well within complex problem scenarios and have been successfully applied for solving binary problems in various domains [19][20][21]. In these contexts, the BACO approaches provided high-quality solutions and were capable of efficiently balancing between solutions-quality, parameter configuration effort, and computational complexity while outperforming common metaheuristics like genetic algorithms and particle swarm optimization approaches. Due to these properties, BACO was selected as a suitable candidate for finding solutions to the optimization problem presented in this work. The BACO approach is explained next.

Binary Ant Colony Optimization
A prominent metaheuristic is ACO [22]. The method searches for near-optimal paths (solutions to the problem) by applying the path-finding rules of ants. The authors of [23] adapted ACO for the binary setting as binary ant colony optimization (BACO). In BACO, paths are encoded as binary combinations and "ants" aim to find well-suited combinations of these bits. The quality of a solution is assessed by an objective function and is then iteratively improved (over the course of g generations) until either convergence criteria are met or a certain solution quality is achieved.
A BACO is composed of µ ants. Each ant communicates information to other ants by leaving trails of pheromones that the ants can follow. The pheromones in BACO are represented using a pheromone table H = (τ jl ) n×2 , where n is the size of the problem space (i.e., n is the number of bits representing the problem space), and τ jl represents the amount of pheromones available at the solution bit with the index j, and l ∈ {0, 1} indicates its binary value. Each ant k ∈ µ traverses a binary trail by sequentially selecting bits with the probability While traversing a path, an ant updates the pheromone level of the taken path with Here, ϕ ∈ [0, 1] is an evaporation factor [23]. The process of updating pheromones increases the pheromone levels of those paths that yield the best paths (solutions). The convergence factor (c f ) [24] is used to avoid early convergence to local optima.
τ j0 , τ j1 represent the pheromone levels of selecting 0 or 1 as the value of bit j of the solution. When the BACO algorithm converges early, i.e., when c f exceeds a threshold, pheromones are reinitialized. The reinitialization process resets all pheromone levels to their starting values but provides an additional initial pheromone update for the current best solution.
The algorithm eventually returns a binary string that represents a reconfiguration of the holarchy and a combined use of (multiple) available flexibilities to address the problem at hand. The found solution is optimized and yields the highest quality (i.e., the highest fitness score or lowest penalty score) according to an objective function. In this work, the following penalty function is used.

Penalty Function
A penalty function is an objective function used to assess the quality of a solution to a problem. In this work, a penalty function is used to assess the quality of configurations for the holonic grid found by our BACO algorithm. Based on this assessment, the BACO algorithm adjusts its decision making for modifying the holarchy and for selecting flexibilities to find high-quality solutions. For a penalty function, lower scores indicate higher solution quality, where an optimal solution would result in a penalty of 0. The penalty function used within this work is defined as follows: Here, q is the penalty score, a weighted sum of several sub-functions g i . These subfunctions penalize different criteria that are to be optimized by our BACO algorithm. The parameters ω i represent weight values that adjust the severity of the influence of individual sub-functions on the overall quality assessment. Additionally, for supporting Pareto optimal conditions, ω i ≥ 0 and ∑ k i=0 ω i = 1 [25]. The functions σ i are squashing functions of the sigmoid family that bound each penalty function g i to the interval [0, 100). This bounding simplifies comparing different results. The complete form of the functions σ i is shown in Equation (5).
Parameter x is the input to the squashing function (i.e., the result of the sub-functions) and κ i is responsible for scaling the σ i functions to a maximum value for which the function should still be sensible.
An example for the σ squashing function and the κ sensitivity control is show in Figure 2. In this example the sensitivity of the function is set to κ = 100. The values for x represent the input values for the σ function. The plot shows the output of the σ function for the x-values between 0 and 120. For the penalty function used in this work, five sub-functions are considered for penalizing the solutions found by our BACO algorithm. The sub-functions are g i (·) with i ∈ {ds, st, sat, eco, holon} and consider several criteria related to resilience [9] and holons for the optimization process: • Demand and supply balance. Function g ds penalizes a found solution based on the severity of the deviation between demand and supply in the grid. To maintain a continuous supply with electricity, balancing the current demand and the produced electricity is crucial. Deviations from this balance may lead to deterioration of the quality of supply and can, in severe cases, lead to blackouts in the grid. • Holon states. Function g st is concerned with penalizing undesired holon states and the corresponding severity of those states. As described in Section 4.1.2, holons can be in different states, where some states are more desirable than others. The function penalizes holons in undesired states, considering the severity of this state. For instance, partially supplied holons, which are 50% supplied, receive a smaller penalty compared to partially supplied holons that are 25% supplied or holons that are unsupplied. Consequently, fully supplied holons are are in a desired state and not penalized at all (penalty 0). • User satisfaction. The use of flexibilities may cause conflicts between the availability of devices and the desire of users to have them available. As the impact on user satisfaction is derived from the priority classes of flexibilities (see Section 4.1.1), function g sat penalizes the use of flexibilities that are likely to cause a decrease of user satisfaction. For instance, using a flexibility of a high priority class is penalized more than using a flexibility of a lower priority class. • Economical use of flexibilities. From the perspective of a control entity, numerous economic aspects of flexibilities need to be accounted for when selecting flexibilities to be considered for the mitigation of a problem. The function g eco penalizes the selection of economically inferior flexibilities. For instance, some flexibilities can be more expensive than others regarding the configured costs, such that cheaper flexibilities will receive a lower penalty in comparison to expensive ones. Another example is the duration of a flexibility, where long-lasting flexibilities are preferred over short-lasting ones, as they can provide their service for a longer amount of time, reducing the need for subsequent activation of additional flexibilities. Further economic aspects that are considered are short cool-down periods for quick reusability and low delay such that the flexibility can quickly contribute to the mitigation of the problem. • Holon quality. Solutions found by the BACO algorithm may result in changes for the holarchy caused by reconfiguring and reorganizing the encompassed holons. As these holons represent vital parts of the holarchy, they need to be configured in such a way that they contribute to the resilience of the energy grid. The function g holon penalizes the configuration of holons that provide a lower degree of resilience based on the following criteria: (1) the energy density denotes the spread of production and consumption within a holon. If production and consumption are equally distributed among the participants in a holon, the misbehavior/malfunctioning of individuals has a decreased impact on the stability of the holon. (2) The flexibility density is concerned with the spread of negative and positive flexibility within the holon. More evenly spread flexibility capacity reduces the risk of severe consequences if individuals malfunction or change their flexibility offers. (3) The mitigation capacity denotes the degree to which positive and negative flexibilities can compensate deviations in consumption and production. Larger amounts of flexibility capacity are considered beneficial for compensating consumption and production deviations.

Related Work
In this section, we provide information about related work that incorporates holons in the domain of energy grids. Subsequently, we briefly present work from the area of demand-side management and home energy management systems (HEMSs).

Holon System Structures
Structuring the energy grid as holons is a relevant topic addressed in scientific literature [16]. One of the first approaches to transfer the holon concept to the energy grid was conducted by Higgins et al. [26]. The authors use a holonic approach to enable the interplay between two standards, namely IEC 61850 and IEC 61499, to improve the energy grids capabilities to react to upcoming problems. A bottom-up modeling approach for energy grids was proposed by Negeri et al. [27,28]. They use recursive holons for grouping prosumers at different layers of a holarchy, enabling them to dynamically change their affiliation towards different holons, if this reorganization yields a better fit for the behavior profile of the holon. For instance, a strongly consuming holon can change its affiliation to a holon that is expected to provide excess electricity. The authors of [29] present a holonic multi-agent system approach for modeling an electrical distribution grid and controlling the reactive power at consumer-site solar panels. Their approach uses multiple agents that are organized in a holarchy to represent different abstraction layers of a distribution grid and aim to match the reactive power requirements of their domain to support the balancing of demand and supply. A generic holonic control architecture is presented in [30]. The authors use holons to enable the simultaneous application of heterogeneous control solutions in a SG. The authors stress that the heterogeneity of the energy grid requires various controllers with potentially contradicting goals. Moghadam et al. [31] propose a holonic multi-agent system approach for organizing the IT-infrastructure for SGs to facilitate efficient information exchange and increase communication security. They apply the holon concept to organize different software aspects according to their domain. For instance, software (agents) related to outage management is integrated in a so-called outage-management-holon.

Home Energy Management Systems and Energy Consumption Schedulers
Prosumers are envisioned to provide local production and storage capabilities (e.g., solar panels, batteries) in SGs. The current state of the art for managing these capacities locally are HEMSs and energy consumption schedulers (ECSs). These systems gained a lot of interest in recent years [32,33], and they aim to optimize the local energy management according to the intrinsic goals of prosumers and the goals of the energy grid as a whole.
Lee et al. [34] present an energy scheduling approach using a task-based model. They differentiate between three classes of tasks, which are then scheduled using a backtracking algorithm. The authors of [35] propose an algorithm for HEMSs that reduces the overall costs for energy consumption. Their scheduling process is separated into three phases for appliance monitoring, stochastic scheduling, and the real-time control of appliances. An approach based on devices that communicate using the ZigBee protocol is presented in [36]. The scheme reduces the overall costs for energy consumption by shifting appliances to off-peak hours. Additionally, the locally stored energy is used to supply running appliances. If local energy is insufficient, the execution is delayed depending on the comfort level of the consumer. A global solution for the optimal use of appliances to control electricity consumption and provide heat management is presented in [37]. Their approach uses mixed-integer quadratic programming model to schedule the devices while taking into account price, local production, and energy storage.
Our system architecture exploits the adaptability of holarchies as a (semi-) centralized control structure in combination with the concept of flexibilities to enable the dynamic allocation of resources and quick system reconfiguration. In contrast to the holonic concepts presented by related work, this allows involving prosumers actively into processes for mitigating demand and supply problems by enabling them to offer locally available resources. These resources can be accessed as flexibilities on various layers within the holarchy, which allows addressing problems using the different scopes of holons. Changing the scope based on the severity of the problem at hand facilitates adjusting the complexity for reconfiguring the holarchy and for selecting suitable flexibilities. To address these problems, we propose a BACO approach as a suitable mechanism for quickly finding near-optimal solutions for reconfiguring the holarchy and selecting flexibilities for problem mitigation while considering various optimization criteria.

System Model
In this section, a detailed description of the semi-formal holon model for representing energy grids is explained and the flexibility concept is presented.

Holonic Grid Structure
The holonic system structure presented in this work is a formalization and extension of the work presented by the authors of [18]. Our main contributions in this section are the improvement, extension, and formalization of the underlying model of the HOLEG simulation environment. In particular, we extend the model with the concepts of flexibilities (see Section 4.1.3) to enable leveraging local resources and their prioritization via priority classes. Furthermore, we improve their holonic system model by replacing their concepts of holon objects and subnetworks with one unified concept of holons. This simplifies the recursive application of the holon concept. Our system model is structured bottom-up and comprises two core-concepts, namely holon elements and holons.

Holon Elements
Holon elements represent atomic building blocks of the holon model proposed in this work. From the perspective of a holonic energy grid, these entities cannot be further separated into smaller controllable parts. Therefore, holon elements are considered as the smallest entities that can be controlled using an information and communication technology (ICT)-infrastructure and actuators within SGs. Such parts include-but are not limited to-individual appliances (e.g., TV, air conditioning), parts of systems whose parts cannot be controlled individually (e.g., a floor within a house), and entire sub-systems (e.g., legacy consumers in the grid that do not have the required technology, like houses without ICT or actuators to facilitate fine-grained control).
It is assumed that three types of holon elements exist, namely consumers, producers, and prosumers. Holon elements are considered as being consumers if they consume more electricity than they produce. In contrast, holon elements are considered as being producers if their electricity production exceeds their consumption. Finally, holon elements are prosumers if they are capable of operating as both consumers and producers. Consequently, holon elements of this type can change between the two other types. Holon elements (he) in the proposed model are formally represented as four-tuples of power magnitude, role, state and priority class: A holon element he t i,l denotes the i th holon element at layer l within a holarchy. Time is measured at discrete points t = [0, . . . , T], where T depends on the granularity which is assigned for measurements within the energy grid (e.g., T = 17,280 for a measurement interval of 5 s during a day). At each point in time t, holon elements are in one of three mutually exclusive states s t = {active, inactive, standby}, which specify their current behavior within the energy grid. In an active state, holon elements produce or consume electricity according to their electrical profile (e.g., charging rate of a battery). Inactive holon elements do not produce or consume electricity. In a standby state, holon elements consume a small but constant amount of electricity.
More formally, the consumption and production behavior of a holon element he t i,l is specified as the power magnitude p t i : Function p(t) represents the power consumption (negative values) or production (positive values) of the holon element at time t. The constant p c represents the power consumption required for maintaining the standby state and φ is the null-function and the corresponding integration constant is zero. The function state(·) takes a holon element as input and returns its current state. Inactive holon elements do not produce or consume electricity.
Depending on the orientation of the power magnitude (positive for production, negative for consumption) a holon element takes on a specific role r t = {producer, consumer}. We emphasize that the role can change at any point in time t. As the number of prosumers in energy grids increases (e.g., battery storage units), the possibility for such changes needs to be taken into account.
Extending holon elements with priority classes c t ∈ N 0 allows expressing their relative importance to a responsible entity at each point in time. For instance, appliances in private households can differ in the relative importance for a user depending on the time of the day. Relative importance is also a measure of user satisfaction: a water heater may be more important to the user in the morning than at midday. Such information can be used to derive a measure of dissatisfaction if the holon element is not in the expected state when a responsible entity observes its state. A higher priority of a holon element yields a stronger decrease in user satisfaction if expectations are violated. Priority classes can be adjusted at any point in time to address changes in the perceived importance of holon elements.

Holons
Holons are controllable non-atomic entities in our proposed holonic model. Holons can represent aggregated entities within the grid, like individual prosumers (e.g., houses, enterprises), streets, communities, or larger parts of the grid. In comparison to holon elements, holons are assumed to have the following properties: Janus-faced. Derived from the two-faced image of the roman deity "Janus", holons are considered to possess two views. An internal view that aims to pursue inherent goals of the entities encompassed within the holon (e.g., optimize local use of electricity). An external view that is responsible for considering aspects that are important for higher layers in the grid. • Split. Splitting operations allow holons to separate one or more previously encompassed holons of lower layers from their internal structure. This operation forms new holons at the same layer of the holon conducting the splitting operation. • Merge. Holons can merge to form a new larger holon represented at a higher layer in the holarchy.
Holons encompass lower-layer holons and corresponding holon elements. More formally, they can be defined as a seven-tuple: The individual parameters of holons are explained next.

Holrachy Set
Here, the jth holon h j of holarchy layer l + 1 encompasses a holarchy H t j,l of lower layer holons, which is specified as follows: where m ∈ N denotes the number of holons that comprise layer l from the perspective of the jth holon of layer l + 1 and are affiliated to it. A holon can be affiliated to only a single holon of the next higher holarchy layer. Therefore, the following property must hold at each point in time t: ∀H t j,l , H t k,l , ∀j = k, ∀l : (H t j,l ∩ H t k,l ) = ∅ Consequently, holons that are located on the same layer within a holarchy do not share holons of the next lower layer. The recursive application of this definition yields a unique affiliation of each holon to a holon of the next higher layer.

Holon Element Set
Similar to lower layer holons, holon elements can be present at each layer within a holarchy. The set HE t j,l comprises the holon elements of layer l from the perspective of the corresponding higher layer holon. The set is defined as follows: Parameter n ∈ N denotes the number of holon elements that are encompassed within layer l from the perspective of the jth and are affiliated to a holon of the next higher layer. Similar to the disjointness requirement of holon affiliations presented above, the following property holds for all sets of holon elements: Therefore, holons at the same layer do not share holon elements.

Power Magnitude
The power magnitude P t j of a holon represents its electrical behavior-which is the aggregated amount of consumed or produced electricity-at time t. The power magnitude depends on the encompassed holarchy and the holon elements located at the current layer. The power magnitude for a holon is calculated as follows: Here, H t j,l denotes the holarchy encompassed in the jth holon at layer l + 1 and HE t j,l represents the set of holon elements located at layer l from the perspective of the holon. At each point in time, the power magnitude of a holon is either positive, which indicates that it consumes more electricity than it produces, or the power magnitude is negative and the holon provides excess electricity.

Forecasts
The set of available forecasts for the consumption or production behavior of a holon is denoted as the set F t j = { f o i , . . . , f o m } for i, m ∈ N and t < i < m. In this work, it is assumed that the majority of areas within an energy grid that are capable of operating as a holon can provide a forecast that indicates their future electricity demand and production. Towards this end, each holon calculates an aggregated forecast based on the electricity demand and production of its encompassed entities for m future time intervals. If a holon is not capable to calculate a forcast, the set F t j is empty. Parameter m defines the number of time intervals that are part of the forecast and f o ∈ F t j is the expected, aggregated power magnitude anticipated for a certain time interval.

Role and State
The current role r t j of a holon is defined similarly to the role of holon elements, such that holons can be either producers or consumers at each time t. This role depends on the current electrical behavior of the holon. Consequently, holons can change their roles at any point in time, when their local production exceeds their demand and vice versa.
The state s t j of a holon is more complex compared to the state of holon elements as it (partially) depends on the state of its encompassed entities. The proposed model differentiates between six mutually exclusive states. At each point in time, the following definition must hold: Consequently, a holon remains in a dedicated state at least for the time interval [t, t + 1). The possible states for holons are the following: • Producing. The holon produces excess electricity for the grid. The aggregated demand of the holon is fully covered. • Inactive. All encompassed holons are inactive and do not produce or consume electricity. • Unsupplied. Not a single encompassed holon can be supplied with the available electricity. • Partially supplied. The available electricity is sufficient for at least partially supplying one of the encompassed holons. • Fully supplied. All encompassed holons are fully supplied. • Oversupplied. The ongoing electricity production exceeds the demand of the holon. This state is similar to the producing state, but the excess electricity is currently undesired.

Flexibility
Finally, Flex t j = { f i , . . . , f r } is the set of available flexibilities within the jth holon. Note that this set comprises all flexibilities that are available within the encompassed holarchy of the holon. Consequently, a holon at layer l + 1 has access to r flexibilities, which is the number of flexibilities on all lower layers within its scope. This allows higherlayer holons to have access to larger number of resources for the mitigation of hazardous situations. However, this also increases the complexity of managing and using these resources accordingly. The flexibility concept is explained next in detail.

Flexibility Concept
Holon elements located within holons can be offered as so-called flexibilities f i ∈ Flex t jvirtual energy resources-for supporting the mitigation of demand and supply deviations. The set Flex t j represents the set of all flexibilities-throughout the entire encompassed holarchy-that is currently available within a holon. Consequently, if problems are to be addressed on lower layers, fewer resources might be available compared to addressing problems on higher layers. The general flexibility concept is presented in Figure 3.
For a holon element to be offered and safely operated as a flexibility, a lot of information (element properties) needs to be accessible by control authorities. Such information mainly depends on the properties of the underlying holon element but may also be configurable by the entity that offers the flexibility. Additionally, constraints for the safe use of flexibilities and the underlying holon element are required. More formally, a flexibility f t i is represented as a ten-tuple: The parameter p t i denotes the power capacity (Watt) provided by a flexibility. The corresponding type of flexibility is defined by ty t i . Numerous performance parameters are required to assess a flexibilities applicability to resolve a problem situation. Parameters dly t i , dur t i , and cool t i denote the delay, duration, and cool-down period of a flexibility. Parameter cost t i specifies the reimbursement required to use the flexibility and pr t i represents the priority class. The sets C t T,i and C t P,i comprise technical and personal constraints specified for the flexibility and s t i represents the state of a flexibility. All parameters are explained next in more detail.

Power
Parameter p t i represents the power (Watt) that is provided by a flexibility for a specified amount of time. This power can be provided as production or consumption capacity (e.g., 3 kW (dis-) charging rate for a battery).

Type
Flexibilities can be classified as positive or negative. A flexibility is considered to be positive if using it increases the grid frequency (by providing electricity or by reducing consumption). A flexibility is considered to be negative if it lowers the grid frequency (by increasing the consumption or reducing the production) in the grid.

Delay
Holon elements may require a certain amount of time until they can operate according to the specification of the flexibility, for example, the time to power up or shut down safely. The delay dly t i specifies the amount of time (in seconds) that is required until a flexibility provides its specified power and affects the power grid frequency. This information is important to plan the use of flexibilities depending on the time criticality of the problem to solve.

Duration
The duration dur t i defines the expected amount of time (in seconds) for which a flexibility provides its service (e.g., charging a battery for 3600 s). The duration depends on numerous aspects, like the current state of the holon element and its requirements for safe operation, but the duration can also be affected by environmental conditions. For instance, activating an air conditioning lowers the temperature in a room but increases the internal temperature of the corresponding holon element. The duration of a flexibility based on this air conditioning may be limited according to the current room temperature or the internal temperature of the holon element.

Cool-Down
Device operation can be restricted due to user preferences or operational constraints. The Cool-down parameter cool t i specifies the amount of time (in seconds) for which a flexibility is not usable after successful prior activation. Note that a time-based specification for reusing a flexibility may not be sufficient to decide at which point a flexibility may be usable again but can depend on various other factors. For instance, prosumers can decide that certain holon elements can only be used with a certain frequency. Other limitations may depend on the state of a holon element, like the state-of-charge of batteries, which can only be charged again after their state-of-charge is below a certain threshold.

Costs
The parameter costs t i represents a form of reimbursement, which has to be paid for using a flexibility. This payment should act as both a form of incentive for prosumers to offer flexibilities in the first place but also to compensate for (some of) the emerging expense resulting from offering flexibilities. Activating flexibilities depletes local resources (e.g., stored electricity) and leads to a wear of corresponding holon elements (e.g., by turning devices on/off). Therefore, a compensation is required. Costs are currently represented as monetary compensation costs t i ∈ R + 0 , but other means for compensation may be applicable in the future.

Priority
Each holon element is assigned to a priority class c t ∈ N 0 to indicate its relative importance to the entity that is responsible for it (see Section 4.1.1). For the proposed model it is assumed that flexibilities inherit the priority class pr t i ∈ N 0 from the underlying holon element. However, for flexibilities the meaning of the class is diametrical to the meaning of priorities for holon elements. More precisely, a higher priority class of a flexibility reduces its priority for being used for mitigating demand and supply problems. The assumption for this is that if the underlying holon element is assigned to a high priority class, it is currently considered important to the entity to which it belongs. Therefore, it is likely that the entity needs the holon element at this specific point in time and a change in its state (e.g., by using it as a flexibility) may likely cause a decrease in user satisfaction.

Constraints
Constraints represent both requirements and limitations for the use of flexibilities. Towards this end, constraints specify rules that need to be fulfilled for a flexibility to be usable in the first place and to ensure the safe operation of the underlying holon element, its environment, and to take into account the preferences of the entities who offer the flexibilities. For each flexibility, two sets of constraints that need to be fulfilled can be defined. If the constraints are not met, the respective flexibility cannot be offered. The set C t T,i = {c T,0 , . . . , c T,k } denotes the set of technical constraints and the set C t P,i = {c P,0 , . . . , c P,l } for k, l ∈ N 0 comprises personal constraints. • Technical constraints. These constraints specify technical requirements that need to be met; otherwise, the safe operation of the underlying holon element cannot be guaranteed. For instance, the internal temperature for the safe operation of holon elements can be represented as a technical constraint for limiting the use of the holon element as a flexibility. Other constraints can be interdependencies with other devices. • Personal constraints. The constraints limit the use of flexibilities based on personal preferences and requirements defined by the entity that is responsible for managing the flexibility. For instance, the use of flexibilities can be limited according to the specified priority class of the underlying holon element, which allows flexibilities to be used only if the priority class is sufficiently low.
Constraints limit the use of flexibilities mainly in two ways: firstly, if any constraint is violated during the configuration phase of a flexibility, the flexibility cannot be offered. This aims to prevent entities from offering flexibilities that cannot be operated under safe conditions. Secondly, constraints must be repetitively checked-within reasonable time intervals-during the lifetime of a flexibility and need to remain fulfilled during this process. If constraints are violated during use, the flexibility may become unavailable. To represent the various operational conditions of flexibilities, they can be in different Flex-States s t i .

State
A flexibility has four mutually exclusive Flex-States s t i , namely Not-offered, Offered, In-use, and Cool-down: • Not-offered. A flexibility remains in the Not-offered state after its configuration process until it is offered by the responsible entity. Whenever an offering command is issued, the constraints are checked, and if all constraints are met, the flexibility transitions into the Offered state. • Offered. A flexibility is in the Offered state if it fulfills the specified constraints and, successively, was offered to support the energy grid operation. In this state, it can be used to support the mitigation of unbalanced demand and supply. If a control entity decides to use a flexibility, the flexibility transitions into the In-use state. • In-use. A flexibility in this state is currently used in a problem mitigation process and cannot simultaneously be used for other purposes. During the use of a flexibility, the constraints are checked repeatedly, and, if any violations occur, the flexibility transitions into the Not-offered state. • Cool-down. After a flexibility was used for its intended duration, it transitions to the Cool-down state for its specified amount of time. In this state, the constraints are checked and it automatically transitions into the Offered state if no violations occur and the specified amount of time has passed; otherwise, the flexibility transitions into the Not-offered state. If no cool-down is specified, the flexibility immediately transitions into the Offered state and becomes available again.
A flexibility can transition between the different Flex-states based on events. Figure 4 shows the four Flex-states and corresponding transitions between them. The events that trigger a change of state are explained next: • configured. The configured event is the entry event after the successful configuration of a flexibility. • offer. The offer event occurs if an entity starts the process of offering a flexibility to support the mitigation of problems in the energy grid. This event leads to a state change to the Offered state if no constraint violation occurs. • violated. The violated event indicates that at least one constraint of the flexibility is not met. Therefore, the flexibility cannot be operated according to its specification and transitions into the Not-offered state. • withdraw. The withdraw event occurs if an entity manually withdraws a flexibility from being offered to support the grid. Flexibilities can only be withdrawn from states where they are not actively used to support the grid. • inquire. The inquire event occurs if a control entity decides to use a specific flexibility to support the mitigation of a problem situation. If an offered flexibility is inquired, and no constraint violations occur, this event leads to a state change towards the In-use state. • duration. The duration event occurs when a flexibility has been used for its specified duration. This event leads to a transition of the flexibility into the Cool-down state. • cool-down. This event indicates that a flexibility currently remains in a Cool-down state. After the event, the flexibility transitions into the Offered state or, if it is withdrawn, changes to the Not-offered state.

Grid Control
Our holonic system model allows for the addressing of issues on appropriate, yet varying layers of the holarchy by utilizing the resources of individual holons. The emerging problem size varies significantly and can be adjusted according to the problem severity.
We consider two problem cases: firstly, small-scale problems, where a reduced number of flexibilities is sufficient to mitigate the problem situation. For instance, a production shortage in a lower-layer holon can be compensated by a smaller number of geographically close flexibilities. Let there be a holon that encompasses 25 offered flexibilities. Resolving an issue using the locally available resources yields a resource allocation problem of the size 2 25 (the decision of using a flexibility is binary). The complexity of this problem can be addressed by various methods, like optimal solvers.
Secondly, large-scale problems are considered, which may have-if not mitigated properly-more severe consequences for the energy grid operation (e.g., damage to larger producers in the network may destabilize the entire grid). Locally available resources on lower layers in the holarchy are insufficient for mitigating problems of this scale. However, higher layers in the holarchy possess an extended scope and can therefore utilize more resources for the mitigation of the problem situation. Simultaneously, the availability of an increasing number of resources on higher layers in the holarchy increases the problem size significantly. For instance, a higher layer holon may contain 100 houses that offer two flexibilities each. Furthermore, 2 200 potential flexibility configurations need to be explored in order to find high-quality solutions. Such a problem size exceeds the solving capabilities of numerous solvers and efficiently addressing such problem sizes requires heuristic approaches.

Case Study
In this section, a simulation study is provided to stress the applicability of the proposed system model in a large scale holarchy and investigate the performance of the BACO approach within two problem scenarios. First, the exemplary grid is described in detail and the problem scenarios are explained, where one represents a situation of severe oversupply due to high production of RESs and the second scenario represents a grid facing a undersupply situation due to failing RESs. Second, the parameter selection for our BACO algorithm is detailed. Finally, the results of the application of the BACO approach for resolving the problem situations are presented and discussed.

Scenario Descriptions
An exemplary holarchy was generated using the HOLEG simulation environment. Numerous simulation environments for various purposes are available in the context of energy grids [38,39]. The decision for using HOLEG as the designated simulation environment in this work was made based on its inherent capabilities for structuring energy grids in a holonic fashion. Furthermore, HOLEG is an open-source project and allows applying arbitrary optimization algorithms on top of the simulated grids [18].
The exemplary holarchy encompasses 760 layer-0 holons, which represent 742 prosumers and 18 medium-sized producers. On average, 14 prosumers are encompassed in each layer-1 holon (e.g., a street) and three streets are considered as one layer-2 holon, which are further aggregated on higher layers. All holons are connected via distribution busses and holons at layer-1 and higher can be separated using 123 separator switches in total. The switches are closed initially, such that the holarchy is represented as one large grid.
Each prosumer encompasses 4-8 holon elements, which represent typical household appliances. In total, 4487 holon elements are present in the grid and their consumption and production information is chosen uniformly at random from a list of typical appliances [40]. Out of these holon elements, 3821 (85.2%) are currently in an active state and the remaining ones are inactive. To represent the relative importance of these devices to the prosumers, the holon elements are assigned to priority classes, such that 40% of the appliances are assigned to low priority, 30% to medium priority, 20% to high priority, and 10% to essential priority.
A strong adaption of the flexibility concept (see Section 4.1.3) is assumed. In this work, each prosumer offers 0-3 flexibilities. This yields 3867 flexibilities, out of which 1653 (42.8%) are negative flexibilities (i.e., flexibilities that either increase consumption or decrease production) and 2214 (57.2%) flexibilities are positive ones (i.e., flexibilities that reduce consumption or increase production). The flexibilities inherit the priority classes from their underlying holon elements. As flexibilities are not always offered, only a subset of the configured flexibilities is available for mitigating the problem. In total, 1643 flexibilities are offered for mitigating the problem.
The problem size that needs to be addressed by the BACO approach is 2 1766 as 123 switches can be used to reconfigure the holarchy and 1643 flexibilities can be used to adjust the production and consumption within the holons.

Oversupply Scenario
The problematic situation is modeled as a forecast announcing a significant amount of excess electricity due to a large amount of production by RESs. The available excess electricity cannot be exported and the problem needs to be resolved within the local grid.
The aggregated consumption and production yields a situation with excess electricity production of 571.55kW, which needs to be mitigated using the flexibilities in the grid. Consequently, 447 (58.8%) prosumers are in an oversupplied state, where each prosumer is oversupplied by 54% on average (i.e., the amount of excess energy produced within the grid exceeds the consumption by 54%). The remaining prosumers are currently acting as producers due to their local production. The assessment of this problem situation yields a score of 50.52 by using the presented penalty function. Table 1 shows an overview of the problem situation. This situation is modeled as a strong drop in electricity production due to several failures in large producers.
The aggregated consumption and production yields a situation where the electricity consumption exceeds the production by 508.45kW, which needs to be mitigated using the flexibilities in the grid. Consequently, 109 (14.7%) prosumers are in a partially supplied state, where each of these prosumers is able to cover only 11.9% of their required electricity on average. The remaining prosumers remain fully supplied or are currently acting as producers due to their local RESs. The assessment of the undersupply situation yields a penalty score of 28.3. Table 2 shows an overview of the problem situation.

Parameter Configuration
The application of the BACO approach in combination with the presented penalty function requires the adaption of numerous parameters to optimize the performance and result quality. For the penalty function, the most important parameters are κ i , which control the maximum values for which the squashing function is still sensible, and the corresponding weights ω i for adjusting the impact of the sub-functions on the final penalty score. Table 3 shows the parameter configurations for the sub-functions. The κ-values were derived empirically by observing the worst score values of the individual sub-functions for random solutions to the problems that are addressed in the case study. These values provide a good indicator to adjust the sensitivity of the subfunction since they reflect the performance of the example grid when potentially bad solutions are applied. The weights ω i were also derived empirically using multiple runs of the BACO algorithm. The weights are configured to favor solutions that achieve a good demand and supply balance and improve the states of the holons.
The parameter configurations for the BACO approach influence both the execution time of the algorithm and its overall performance for finding high-quality solutions to the presented problem situations. The selected parameter configurations are shown in Table 4. The parameters were derived empirically by conducting a binary search to investigate well-performing parameter intervals. Within these intervals, parameter configurations were selected according to their computation time. The configuration BACO 1 enables the BACO algorithm to find solutions in less than 30s, whereas BACO 2 finds solutions in less than 60s, and BACO 3 represents an unconstrained scenario that aims at optimizing the quality of the solution.

Results
In this section, the results of the BACO application are presented in detail for both scenarios. First the results for the oversupply scenario are presented and discussed. Afterward, the results for the undersupply scenario are presented.

Results Oversupply Situation
All parameter configurations BACO 1,2,3 significantly improve the initial situation (score of 50.52), where BACO 1 achieves a penalty of 38.8, BACO 2 achieves 29.5, and BACO 3 finds solutions with an average penalty of 28.5.
A penalty of 0 cannot be achieved since using any flexibilities result in at least some user discomfort, which increases the final penalty score (see Section 2.3). The BACO parameter configurations vary in both solution quality and computation time. BACO 1 requires 28.5 s, BACO 2 takes 56.9 s, and BACO 3 takes 1934 s on average. Therefore, small parameter configurations may be beneficial when solutions need to be found quickly but solution quality does not require strong optimization. This shows that BACO-based approaches are well suited to work with our model and parameter configurations that foster quick conversion may already be sufficient to mitigate problems. The number of used flexibilities varies between 120 for BACO 1 , 80 for BACO 2 , and 178 for BACO 3 . With this, the BACO improves the situation by reducing the average oversupply of initial 54% to 6% for BACO 1 , 1.5% for BACO 2 , and 0.5% for BACO 3 . All configurations prevent partially supplied, unsupplied, and inactive holon states. Additionally, BACO 2,3 achieve a strong reduction of oversupplied holon objects by generating holons with balanced demand and supply, resulting in an increase of fully supplied holon objects. The high quality of found solutions illustrates the applicability of the proposed system model in combination with the BACO approach. The results are summarized in Table 5. Table 5. Results for algorithm runs with average timeT and the achieved average scoreS. The amount of unsupplied (US), partially supplied (PS), fully supplied (FS), oversupplied (OS), and producer (P) holon objects. The value AVG denotes the severity of the oversupply situation. Flex denotes the number of used flexibilities and the number of holons is shown as H.

Results Undersupply Situation
All parameter configurations BACO 1,2,3 significantly improve the initial situation (score of 28.30), where BACO 1 achieves a penalty of 9.07, BACO 2 achieves 4.57, and BACO 3 finds solutions with an average penalty of 3.06.
The BACO parameter configurations vary in both solution quality and computation time. BACO 1 requires 29.4 s, BACO 2 takes 58.4 s, and BACO 3 takes 1.972 s on average. Similar to the oversupply situation, small parameter configurations may be beneficial when solutions need to be found quickly but solution quality does not require strong optimization. This shows again that BACO-based approaches are well suited to work with our model and parameter configurations that foster quick conversion may already provide high quality solutions to the problem at hand. The number of used flexibilities varies between 278 for BACO 1 , 286 for BACO 2 , and 339 for BACO 3 . With this, the BACO improves the situation by reducing the average undersupply of initial 14.7% to 6% for BACO 1 , 4.3% for BACO 2 , and 2.4% for BACO 3 . All configurations prevent unsupplied and inactive holon states. The high quality of found solutions illustrates the applicability of the proposed system model in combination with the BACO approach. The results are summarized in Table 6. Table 6. Results for algorithm runs within the undersupply scenario. The average time is denoted as T and the achieved average score asS. The amount of unsupplied (US), partially supplied (PS), fully supplied (FS), oversupplied (OS), and producer (P) holon objects. Flex denotes the number of used flexibilities and the number of holons is shown as H.

Conclusions
The contributions made in this work are the following: first, we have presented a novel system model based on the concept of holons for representing energy grids and addressing emerging challenges for balancing demand and supply deviations. Our model uses the inherent properties of holons and empowers prosumers to offer local resources as so-called flexibilities to support the mitigation of demand and supply mismatches. We have then addressed the emerging challenge of jointly organizing holons within an energy grid holarchy and using flexibilities to resolve demand and supply balance deviations within two problem scenarios. Towards this end, we have presented an optimization method based on binary ant colony optimization (BACO), which is capable of finding near-optimal solutions to the aforementioned challenge. We have demonstrated the applicability of the BACO approach to our model and showed its capability to find near-optimal solutions in large problem spaces, efficiently mitigating the problem situations. The simulation results have shown that our model in combination with BACO is well suited to handle severe demand and supply deviations for both situations of excess and scarcity of electricity. Moreover, near-optimal solutions can be found quickly and are well suited to maintain the balance between demand and supply in holonic energy grids.

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