Skip to Content
EnergiesEnergies
  • Article
  • Open Access

20 November 2025

32 Pages

Distributed EMS Coordination via Price-Signal Control for Renewable Energy Communities

,
,
,
,
and
Department of Information Engineering, Università degli Studi di Firenze, Via di Santa Marta 3, 50139 Firenze, Italy
*
Author to whom correspondence should be addressed.

Abstract

This work presents a two-level Energy Management System (EMS) for Renewable Energy Communities (RECs) combining rule-based local control with Particle Swarm Optimization (PSO) coordination. A central Energy Management Hub (CEMH) uses digital twins of each Home EMS to optimize community performance through price-signal adjustments rather than direct control. The method achieves near-optimal self-consumption and incentive gains, largely within 10% of an MILP benchmark, while reducing computational time by about threefold. The approach ensures scalability, resilience, and fairness through a transparent incentive redistribution mechanism, enabling real-time and socially accepted REC coordination.

1. Introduction

The electricity infrastructure is undergoing a substantial transformation. The traditional electricity production–consumption model relied on a limited number of large-scale power plants supplying the entire network of passive end-users. In contrast to this paradigm, the current trend is toward Distributed Generation (DG), also referred to as microgeneration, characterized by a high number of small- and medium-size power plants, typically located close to the point of consumption [1]. The recent significant growth in the number of these distributed generation units, primarily photovoltaic and wind installations, has been largely driven by the strong push for energy independence and for the reduction in greenhouse gas emissions. In parallel, electricity demand has been steadily increasing, further boosted in recent years by the widespread adoption of electric vehicles, which require a high power capacity for charging, particularly in the case of fast charging [2]. As a result, ensuring service continuity and grid stability poses serious technical challenges.
In this scenario, the technologies provided within the framework of Smart Grids are of fundamental importance. In particular, the development of intelligent systems for monitoring and managing the electrical grid plays a central role. Indeed, the topic of Energy Management Systems (EMSs), tools primarily designed for the optimal management of power flows, often supported by Artificial Intelligence (AI) algorithms, has attracted considerable attention in recent years, both in academia and in industry. The typical operation of an EMS can be summarized in four main steps:
  • Data acquisition, including energy data from smart meters and other relevant information, such as weather forecasts and energy market prices.
  • The forecasting of future energy consumption and generation based on the collected data. The forecasting horizon depends on the EMS planning window, i.e., the number of future time steps for which the EMS is required to generate a management strategy. The topic of forecasting, especially electrical load forecasting, has been widely studied. Among the several techniques investigated in literature, neural networks appear to be the most effective, in particular, Recurrent Neural Networks (RNNs) and Temporal Convolutional Neural Networks (TCNNs), as argued in the interesting review in [3].
  • The computation of the optimal scheduling for controllable devices—typically batteries and flexible loads—to achieve some objectives (e.g., maximizing an economic return, reducing emissions, or balancing power flows) within the EMS planning window. The methods adopted to generate the scheduling are discussed in the literature review proposed in the following.
  • The dispatch of control commands, i.e., the actuation of the controllable devices according to the scheduling.
These control systems can be categorized according to the voltage level at which they operate. At the low-voltage level, there are industrial EMSs and EMSs designed for individual private users, more commonly referred to as Home Energy Management Systems (HEMSs) [4]. At the medium-voltage level, more complex systems are found, responsible for managing entities such as districts or small towns (more generically, microgrids), usually integrating local renewable energy sources and energy storages [5]. Finally, there are management systems operating at a high-voltage level, such as the tools employed by Transmission System Operators (TSOs) for the coordination of substations and generation plants [6]. From a holistic perspective of electricity grid management, these different systems must interact to achieve common objectives, such as energy balancing and efficiency.
Before providing a review of the scientific literature on scheduling techniques, it is opportune to introduce the concept of RECs and provide a concise overview of the Italian regulatory framework [7,8], which is the reference context for this study. In general terms, a Renewable Energy Community, as defined in the EU Directive 2018/2001 RED II [9], is an association of consumers and prosumers (i.e., users owning a renewable energy generation plant) who cooperate to develop shared strategies for energy use. The distinctive feature of Italian energy communities is that they allow only virtual energy exchanges among the members [10]. Consumers and prosumers belonging to the community continue to trade energy under their individual supply contracts, but they seek to align energy injections with withdrawals. The objective is to minimize the overall impact of the community on the main grid by balancing the net exchange. This gives rise to the concept of collective self-consumption, or virtual self-consumption, defined as the minimum between the total energy injected into the grid and the total energy withdrawn by the REC, calculated on an hourly basis. The community receives an economic incentive for virtual self-consumption, amounting to around 110 €/MWh. The REC may dispose of these incentives freely, according to a statute drafted at the time of foundation. For instance, the revenues from self-consumption may be redistributed among the members: in such cases, different percentages of the incentive are often allocated to producers and consumers. Alternatively, the incentive may be invested in community services or social initiatives. Another opportunity for RECs, even though currently only envisioned by some pilot projects, is participation in balancing markets, namely, in the provision of flexibility and dispatching services for the electricity grid. Recent research is also exploring peer-to-peer coordination frameworks that integrate both energy production (kilowatt) and demand reduction (negawatt) trading within local communities, enabling prosumers to dynamically switch market roles based on optimization and price signals. In [11], an encryption-based coordinated P2P trading system has been proposed, combining HEMS-level optimization and secure communication protocols to ensure both economic efficiency and privacy protection in residential energy exchanges. In this perspective, the REC would operate as an actor capable of absorbing or injecting energy according to specific needs. Participation in this kind of marketplace is particularly interesting since the economic compensation is considerably higher than the incentive for virtual self-consumption. Exhaustive overviews of energy communities can be found in [12,13].
Regardless of the final allocation of the revenues, one of the primary objectives in managing an energy community is the maximization of virtual self-consumption, and, consequently, of the associated incentives. This task is essentially reduced to determining the optimal scheduling of the controllable devices available within the REC, to align the consumption and production of the members. It is important to note that, in some cases, the collective interest of the energy community diverges from that of individual members. This may occur, for instance, when a prosumer is requested to inject the surplus of their energy production into the grid rather than storing it locally, to cover the demand of other users. Such a situation is typically disadvantageous for the prosumer, whose best option is usually physical self-consumption. From this, it follows that, unless environmental and sustainability concerns are the driving motivations, for persuading a group of human users to cooperate to achieve communitarian objectives, it becomes necessary to carefully assess the strategies for managing the community’s financial resources, to be able to compensate for potential losses of some members fairly and transparently.
The topic of management systems for RECs and similar microgrid-like entities has become highly popular in the scientific literature in recent years [14]. The methods employed to compute the optimal scheduling plan for achieving specific objectives can be broadly categorized into four main methodological families [15].
Deterministic optimization approaches (primarily Mixed-Integer Linear Programming (MILP)) accurately model the BESS, load, and market constraints, providing optimal day-ahead schedules for hundreds of dwellings in a few minutes and achieving significant cost reductions compared to uncoordinated optimizations. However, they suffer from scalability limitations such as the number of users, time steps, and binary variable increases, and rely on fully centralized architectures [16].
Heuristic and metaheuristic methods (Particle Swarm Optimization, Genetic Algorithms, Ant Colony Optimization, and hybrid fuzzy–rule systems) offer greater flexibility for nonlinear and multi-objective problems, are easily parallelizable, and suit rolling-horizon control. They lack guaranteed optimality and require tuning; yet, the literature reports improved cost efficiency and operational stability, achieving quasi-real-time performance when coupled with local rule-based control [17].
Reinforcement Learning (RL) (particularly multi-agent RL) enables decentralized decision-making with millisecond-level execution and adaptability to unmodeled dynamics. Nevertheless, it faces challenges in training convergence, non-stationarity, and transparency or fairness. Most implementations rely on offline training within digital-twin environments, followed by on-device deployment without continuous data exchange [18].
Finally, a hierarchical architecture enhanced by digital twins is emerging to coordinate prosumer communities via layered control (local iEMS and central eEMS). Digital twins provide a virtual environment to validate coordination strategies, test value-sharing mechanisms, and mitigate dependency on real-time communication [19].
In summary, MILP-based methods provide theoretical upper bounds and mathematical rigor; metaheuristics and RL introduce scalability and adaptability at the cost of optimality and explainability; and digital-twin-based hierarchical frameworks bridge these paradigms, enabling resilient, fair, and human-centric coordination in edge-oriented Renewable Energy Communities.
The work in [20] presents an architecture that resembles the one proposed in this study, with a centralized manager coordinating distributed local controllers. These local controllers, operating at the level of individual users, aim to minimize the daily household energy cost. The central controller, on the other hand, must minimize the joint costs of the users, considering the possibility of sharing energy among members in a peer-to-peer fashion (it should be noted that this mode of energy sharing is not permitted under Italian regulations and, therefore, it is not considered in our study). Both problems are formulated as linear optimization problems and solved using MILP. The results are interesting and include extensive analyses under varying conditions of consumption, installed renewable capacity, storage size, and energy prices. However, the community under consideration comprises a very limited number of users (only four). By contrast, the present study aims to simulate larger communities (in the order of a hundred users), which can more realistically have a significant impact on a medium-voltage distribution network.
Using the MILP approach requires a linear problem formulation. The objective must be a linear combination of the decision variables, typically minimizing c T x . All relationships among variables are captured through linear equality and inequality constraints. Discrete behavior can be represented by restricting some variables to integer, or even binary, values. Nonlinear effects can be accommodated by linear approximations, for example, piecewise-linear models with auxiliary variables and big-M constraints, so the overall model remains linear. In energy-system optimization, MILP provides certified optimality for linear models and benefits from mature solvers; yet, its tractability depends on how efficiently one linearizes nonlinear physics and time couplings. For such reason, especially when handling big problems, metaheuristic approaches are often chosen.
Particle Swarm Optimization (PSO) is a population-based, gradient-free method. A set of particles encodes candidate solutions x ; at each iteration, the objective f ( x ) , that can be any black box including simulations, is evaluated. Particles update their positions via velocities influenced by each particle’s personal best and the swarm’s global best, modulated by inertia and cognitive/social coefficients. Constraints are enforced through feasibility rules, penalty terms, or repair operators; discrete choices can be made via binary PSO or encoded mappings. PSO offers a tunable compute budget (population size, and iteration cap) and parallel evaluation, making it practical for large, nonlinear, nonconvex problems and near-real-time operation. It does not guarantee global optimality like the MILP but typically yields good solutions quickly with minimal modeling effort.
Reviews for polygeneration document recurring limits, including the need for piecewise linearization, full-horizon coupling, and clustering to control dimensionality, all of which raise solver burden and modeling effort [21]. Evidence from intraday hydropower with fine time discretization further shows that, as physical detail and system size grows, MILP faces a steep computation and modeling overhead relative to heuristic alternatives [22]. PSO trades optimality certificates for simplicity, model agnosticism, and tunable compute budgets, which suits real-time large-scale EMSs where high-fidelity digital twins sit in the loop. Hardware studies demonstrate feasible real-time PSO on low-cost microcontrollers with small footprints and predictable timing via caps on population and iterations [23]. In microgrid scheduling with detailed, nonlinear battery-and-inverter efficiency, a coordinated MILP/PSO approach outperforms either method alone and avoids constraint violations that can arise from MILP simplifications, indicating practical value when fidelity is essential [24].
The present paper focuses on the intermediate level of EMSs and constitutes the second stage of a study that we initiated with the publication of the article in [25], where a rule-based scheduling algorithm for a Battery Energy Storage System (BESS) was proposed for implementation within an HEMS. The reference to [25] is necessary, as the algorithm presented therein constitutes a subsystem of the EMS proposed hereafter. For the sake of completeness of the discussion, the rule-based HEMS algorithm is shortly summarized in Section 2.3.1. The peculiarity of this algorithm lies in the fact that, being based on a set of predefined rules structured as an if-statement tree, it requires approximately one-thirtieth of that required by the more common linear programming optimization counterparts. This property is fundamental to allowing an easy scalability of the whole system.
More specifically, the objective of this work is to introduce a scheduling algorithm to be implemented in a two-level EMS intended for the control of a Renewable Energy Community (REC). We propose a novel approach featuring Particle Swarm Optimization (PSO) for the higher-level controller, and the mentioned rule-based strategy for the lower-level distributed HEMS controllers. The overall architecture of the proposed system is depicted in Figure 1 and described in detail in Section 2.3. Since it represents the central control node of the community, in the following, the high-level EMS will be referred to by the acronym CEMH (Community Energy Management Hub).
Figure 1. Proposed architecture for two-layer EMS for the RECs showing the main information exchanges.
Beyond their technical and economic aspects, the success of Renewable Energy Communities (RECs) in Europe critically depends on human and social factors. Studies highlight that social acceptance, trust, and member engagement are decisive for long-term sustainability. Participation in community energy projects is strongly correlated with perceived fairness, transparency, and trust in both peers and community management [26,27]. Equally important is the fair and transparent distribution of economic rewards among members. Research shows that perceived inequity in benefit-sharing can undermine participation, while transparent, participatory governance increases trust and acceptance and various allocation mechanisms have been proposed, all seeking to balance efficiency and equity [28,29].
On this aspect, the work proposes a specific approach for the redistribution of community incentives, described in Section 2.1. In this scheme, a portion of the total incentive is allocated to reward individual user merit, which is evaluated in real time based on the user’s contribution to the community objectives. The remaining part is retained by the community, which collectively decides how to reinvest or redistribute it.
Moreover, in scenarios where the energy community participates in flexibility services, the role of the Community Energy Management Hub (CEMH) is to align the REC’s aggregated energy exchange profile with a reference profile requested by the Transmission or Distribution System Operator (TSO/DSO). To achieve this, the CEMH coordinates the individual Home Energy Management Systems (HEMSs) associated with each user, managing controllable loads and storage systems to optimize the energy exchanges between the REC and the main grid.

2. Materials and Methods

2.1. Generic Consideration

In this work, a methodology is proposed to handle and coordinate large numbers of prosumers and users. Only domestic users are considered, with different degrees of flexibility depending on their typology: prosumers are equipped with BESS, while simple users are modeled with controllable loads. The dataset from which the load and production profiles are drawn to simulate the user group is described in detail in the corresponding section.
The focus of this study is placed solely on the optimization technique; therefore, the forecasting process is not described in detail. The optimization strategy relies on a rolling-horizon architecture with a one-hour time step, meaning that user behavior is forecast and then optimized at the beginning of each step. For the remainder of the work, predictions are assumed to be perfect, while the impact of forecasting uncertainty is left for future research. This choice was made to focus the study on the performance of optimization techniques without the noise introduced by forecasting uncertainty. For the rest of the paper, the term “prosumption” is used to represent the energy exchange between a user and the grid. The sign convention is defined such that the value is positive when energy is injected into the grid and negative when it is drawn from it.
The proposed architecture relies heavily on data exchange between the nodes of the distributed system. The use of digital twins in the CEMH helps minimize the number of such exchanges. Moreover, since the Energy Management problem is a “slow” one, with time steps of one hour or, at minimum, fifteen minutes, latency and bandwidth are not expected to pose significant issues. It can therefore be assumed that, especially in the case of many users, the most critical time requirement and main contributor to computational load will be the time needed to perform the optimization.
As will be shown in the following section, some important considerations must be made regarding the prices at which energy is bought and sold. The selling price S e l l p r i c e   at which prosumers sell their excess energy is assumed to be equal to the PUN (Prezzo Unico Nazionale, i.e., the Italian single national price), while, for the buying price, a realistic contract was modeled. The PUN is an array that contains the result of the day-ahead-market listing, hour by hour, the cost of the energy for the day ahead. The actual energy price is only one part of the purchasing cost. Some components are fixed and independent of consumption, while the variable parts are proportional to it. Since only the variable part can affect load planning and BESS scheduling, the hourly buying price definition considers only these variable components:
E p r i c e = P U N a v g m o n t h + F p r i c e
B u y p r i c e = ( E p r i c e + T p r i c e + S p r i c e ) × V A T  
with
P U N a v g m o n t h = m e a n   o f   t h e   m o n t h   ( P U N )   [ € / k W h ]
F p r i c e = 0.011   [ € / kWh ]   S u n d a y   a n d   f r o m   23 p m   t o   7 a m 0.0286   [ € / kWh ]   o t h e r w i s e
T p r i c e = 0.012   [ € / k W h ]
S p r i c e = 0.038 [ € / k W h ]
V A T = 1.1
P U N a v g m o n t h represents the average of the PUN evaluated over the month. F p r i c e represents an additional cost that depends on the time of the day. T p r i c e is the transport cost, and S p r i c e represents the systems cost. V A T takes into account the billing. Another important aspect to consider is the concept of virtual self-consumption within the community. Italian legislation defines it as the minimum, calculated hour by hour, between the total energy injected into the grid from renewable production by the community and the total energy requested by the community from the grid.
This parameter is relevant because the community receives a reward for each kWh self-consumed in this way. The amount of the reward may vary slightly depending on the time of day and the geographical location, but, on average, it is very close to 0.10 €/kWh. Therefore, for this study, we assumed a flat reward of 0.10 €/kWh, regardless of the hour of the day.
Regarding the REC, an internal compensation mechanism has been proposed. In the simulated RECs, the cumulative incentive obtained through self-consumption is partially allocated to reward and compensate individual users who incur losses while contributing to the achievement of community objectives. The remaining share of the incentive is not distributed among users but remains at the community level.
To apply both benchmark and proposed methods, there are some information about the users that must be known:
  • H : horizon of the prediction, or number of the step ahead of the forecasting;
  • N u : number of users.
Then, ∀   u s e r   u ∈ 1 , N u , and the following data must be collected:
  • p t : prosumption forecasted;
  • S O C M a x ,   S O C m i n , S O C 0 : BESS SOC limitations and starting value;
  • N C : Number of Controllable Loads;
  • B u y p r i c e ,   S e l l p r i c e : hourly price for the user to sell and buy energy;
  • L o a d M a x ,   P r o d M a x : peak hourly consumption and production.
with n   ∈   1 , . . , N c :
  • C L v n : absorption of the load n in [ k W h ] ;
  • C L w n : window of hours in which the load may be turned on;
  • C L r n : number of hours in which the load must be turned on once.
from which the maximum request from controllable loads is defined as follows:
C L v M a x =   ∑ n = 1 N c C L v n  
For each of load n , the following parameters must be defined:
■
C L r e q n : number of hours in which the load must be triggered at least once;
■
C L T W n : set of hours in the day when the load may be scheduled;
■
C L o f f s e t n : size of the first slot;
■
C L b l o c k e d _ n : parameter indicating whether the load request has already been fulfilled in the first slot.

2.2. Definition of the MILP Benchmark

Mixed-Integer Linear Programming (MILP) is one of the most common and reliable approaches in the literature for addressing the problem of energy management. The first steps are the definition of a set of variables representing the state of the problem, followed by a cost function and a set of constraints describing the relationships among the defined variables. In this work, a mixed-integer linear formulation of the problem was developed, starting from the linearization of the single user–prosumer case and then extended to cover the entire community.

2.2.1. Definition of the MILP for Single Users

The optimization problem for the single user is meant to schedule the usage of the BESS and/or the available controllable loads to maximize its own cash flow. To proceed, the following variables are going to be defined and ordered as shown in Figure 2:
  • x t : prosumption forecasted after optimization;
  • b t : action on the BESS forecasted after optimization;
  • C L T t : total consumption of the controllable loads;
  • C L B n , t : hourly scheduling of the controllable load n , binary values;
  • C L V n , t : hourly consumption of the controllable load n ;
  • I n j t : grid injection forecasted after optimization;
  • A b s t : grid absorption forecasted after optimization;
  • x s t : supporting binary variable for sign handling.
Figure 2. Visual representation of the order of the variables for the single-user problem.
Counting all of them, the number of variables of the problem is as follows:
N u s e r v a r s = 6 + 2 × N c × H
  • Definition of Inequality constraints (total 12 × H ):
  • BESS Constraint ( 2 × H )
The summatory of the BESS Actions must keep the SOC of the BESS between the known limits ∀   t ∗ ∈   1 , … , H :
S O C 0 +   ∑ t = 1 t ∗ b t   ≤   S O C M A X S O C 0 +   ∑ t = 1 t ∗ b t   ≥   S O C m i n   = > ∑ t = 1 t ∗ b t   ≤   S O C M A X − S O C 0   − ∑ t = 1 t ∗ b t   ≤ − S O C m i n +   S O C 0
  • Prosumption Sign Constraint ( 2 × H )
x s t ∗   is a supporting variable meant to identify the sign of the presumption   x t ∗ , ∀   t ∗ ∈   1 , … , H :
x s t ∗ = 0   i f   x t ∗ < 0 x s t ∗ = 1   i f   x t ∗ > 0   = > x t ∗ M ≤ x s t ∗   x t ∗ M + 1 ≥ x s t ∗   = > x t ∗ M −   x s t ∗ ≤   0 − x t ∗ M   +   x s t ∗ ≤ 1
with M = m a x ( L o a d M a x   , P r o d M a x ) > x t ∗ ,   ∀   t ∗ ∈   1 , … , H .
  • Grid Injection Constraint ( 4 × H )
Linearization of I n j t ∗ = m a x ( 0 , x t ∗ ) , ∀   t ∗ ∈   1 , … , H :
x t ∗ ≤   I n j t ∗ ≤ x t ∗ + M 1 − x s t ∗ 0 ≤   I n j t ∗ ≤ M x s t ∗   = >   x t ∗ − I n j t ∗ ≤   0 − x t ∗ + I n j t ∗ +   M x s t ∗ ≤ M − I n j t ∗ ≤   0 I n j t ∗ +   M x s t ∗ ≤ 0
with M = m a x ( L o a d M a x   , P r o d M a x ) > x t ∗ ,   ∀   t ∗ ∈   1 , … , H .
  • Grid Absorption Constraint ( 4 × H )
Linearization of A b s t ∗ = max 0 , − x t ∗ , ∀   t ∗ ∈   1 , … , H :
− x t ∗ ≤   A b s t ∗ ≤ − x t ∗ + M x s t ∗ 0 ≤   A b s t ∗ ≤ M 1 − x s t ∗   = >   − x t ∗ − A b s t ∗ ≤   0 x t ∗ + A b s t ∗ −   M x s t ∗ ≤ 0 − A b s t ∗ ≤   0 A b s t ∗ +   M x s t ∗ ≤ M
with M = m a x ( L o a d M a x   , P r o d M a x ) > x t ∗ ,   ∀   t ∗ ∈   1 , … , H .
  • Definition of Equality constraints (total ( 1 + 3 N c ) × H ):
  • Actions Constraint ( H )
The sum of all contributions must equal the original forecasted prosumption,   ∀   t ∗ ∈   1 , … , H :
x t ∗ + C L T t ∗ + b t ∗ =   p t ∗
  • Ctrl Loads Total Constraint ( N c × H )
C L T t ∗ must be equal to the sum of all C L V n , t ∗ ,   ∀   t ∗ ∈   1 , … , H and ∀   n ∈   1 , … , N C :
C L T t ∗ =   ∑ n = 1 N C C L V n , t ∗   = >   C L T t ∗ −   ∑ n = 1 N C C L V n , t ∗ = 0
  • Ctrl Loads Value Constraint ( N c × H )
C L V n , t ∗ must be equal to L v n  for each of the slots in which the load is scheduled,   ∀   t ∗ ∈   1 , … , H and ∀   n ∈   1 , … , N C :
C L V n , t ∗ =   L v n ×   C L B n , t ∗   = >   C L V n , t ∗ −   L v n ∗   C L B n , t ∗ = 0  
  • Ctrl Loads Schedule and Slots ( N c × H )
C L B n , t ∗ represents the scheduling of the controllable load n along the prediction horizon. In Figure 3, it is shown how all the different parameters interact and are distributed on the horizon.
All of this applied, ∀   t ∗ ∈   1 , … , H and ∀   n ∈   1 , … , N C .
Figure 3. Visual representation of the variables of the controllable load n with C L r e q n = 24 , C L T W n   f r o m   2   t o   15 , and C L o f f s e t n = 19 .
From these variables, it is possible to define a matrix A C L n with N S L O T s rows and H columns, as shown in Figure 4. In each row, the hours corresponding to the time window in the slot are set to be equal to 1. Then, to each of them, a C L t r i g g s , n is associated, equal to 0 if the load has already been activated in that slot, and equal to 1 otherwise. b C L n is defined as an array listing the C L t r i g g s , n ∀   S L O T   s . For each of the slots, the relation became
∀   S L O T   s   ∑ t ∗ = 1 H S L O T r o w × C L B n , t ∗ = C L t r i g g s , n
Figure 4. Example of the architecture of the matrix A C L n .
  • Definition of the cost function:
Finally, as the objective of the single user is to optimize the cash flow of the user, the cost function f c o s t  is reduced as follows:
  • f c o s t ( I n j t )  = S e l l p r i c e ;
  • f c o s t ( A b s t )  = B u y p r i c e ;
  • Equal to zero for the rest of the positions.

2.2.2. Definition of the MILP for the REC

The goal of this optimization problem is to coordinate the actions of N u users to maximize self-consumption and to perform peak shaving. The definition on the problem of handling a whole group of users is grounded on the definition for the problem for single users. For each user of the community, the whole set of variables must be assigned, and then another group to consider the REC properties must be added to the total:
  • x R E C t : total community prosumption forecasted after optimization;
  • I n j R E C t : total community grid injection forecasted after optimization;
  • A b s R E C t : total community grid absorption forecasted after optimization;
  • S e l f R E C t : community virtual self-consumption;
  • G a p R E C t : gap between the point of the prosumption and the following;
  • G a p R E C t m o d : absolute values of the gaps.
In Figure 5, the order of the variables is shown. The boundary variables L o a d M a x R E C   and P r o d M a x R E C , respectively, the theory peak consumption and production of the community, are defined as follows:
L o a d M a x R E C =   ∑ u = 1 N u L o a d M a x u   P r o d M a x R E C =   ∑ u = 1 N u P r o d M a x u
Figure 5. Visual representation of the order of the variables for the whole REC problem.
Counting all of them, the number of variables of the complete problem become the following:
N R E C v a r s = N u ×   N u s e r v a r s + 6 × H
The constraints for the REC definition must integrate all the sets for the users of the community, plus the ones for the new one for the community itself. For both the equalities and inequalities matrix, the structure of the constraints follows the shape shown in Figure 6.
Figure 6. Visual representation of the content on the constraint matrices of the REC problem.
  • Definition of Inequality constraints (total 12 × N u + 4 × H ):
  • Self-Consumption ( 2 × H )
The self-consumption, hour by hour, is defined as the minimum between the hourly grid injection and grid absorption ∀   t ∗ ∈   1 , … , H :
S e l f R E C t ∗ = min ( I n j R E C t ∗ ,   A b s R E C t ∗   )
S e l f R E C t ∗ ≤ I n j R E C t ∗ S e l f R E C t ∗ ≤ A b s R E C t ∗ = > S e l f R E C t ∗ − I n j R E C t ∗ ≤ 0 S e l f R E C t ∗ − A b s R E C t ∗ ≤ 0
To make these constraints work, the objective function must be developed to maximize S e l f R E C t ∗ .
  • Absolute value of the gap ( 2 × H )
To obtain the absolute value of the difference between each point of the REC prosumption and the closest one, ∀   t ∗ ∈   1 , … , H :
G a p R E C t ∗ m o d = G a p R E C t ∗
G a p R E C t ∗ ≤ G a p R E C t ∗ m o d − G a p R E C t ∗ ≤ G a p R E C t ∗ m o d = > G a p R E C t ∗ − G a p R E C t ∗ m o d ≤ 0 − G a p R E C t ∗ − G a p R E C t ∗ m o d ≤ 0
To make these constraints work, the objective function must be developed to minimize G a p R E C t ∗ .
  • Definition of Equality constraints (total ( N u + 3 ∑ u = 1 N u N C u + 4 ) ∗ H ):
  • REC grid injection ( H )
The REC grid injection is equal to the sum of the grid injection of the users, ∀   t ∗ ∈   1 , … , H :
I n j R E C t ∗ =   ∑ u = 1 N u I n j u , t ∗   = >   I n j R E C t ∗ −   ∑ u = 1 N u I n j u , t ∗ = 0  
  • REC grid absorption ( H )
The REC grid absorption is equal to the sum of the grid absorption of the users, ∀   t ∗ ∈   1 , … , H :
A b s R E C t ∗ =   ∑ u = 1 N u A b s u , t ∗   = >   A b s R E C t ∗ −   ∑ u = 1 N u A b s u , t ∗ = 0  
  • REC prosumption ( H )
The REC prosumption is equal to the difference between the REC’s total grid injection and the absorption, ∀   t ∗ ∈   1 , … , H :
x R E C t ∗ =   I n j R E C t ∗   −   A b s R E C t ∗   = >   x R E C t ∗ −   I n j R E C t ∗ +   A b s R E C t ∗ = 0
  • REC prosumption gap ( H )
The REC prosumption is the difference between each point of the prosumption and the following one, ∀   t ∗ ∈   1 , … , H − 1 :
G a p R E C t ∗ =   x R E C t ∗   −   x R E C ( t ∗ + 1 )   = >   G a p R E C t ∗ −   x R E C t ∗ +   x R E C ( t ∗ + 1 )   = 0
  • Definition of the cost function
The objective of the REC is a combination of the user’s and the community’s goal. For the slots of f c o s t latched to the user’s variables, the cost function is a repetition of the user’s values. Talking about the global goals instead, the REC variables used are S e l f R E C t and G a p R E C t m o d , while the rest have no weight in the objective function. Therefore, the array f c o s t R E C will assume the following form:
  • f c o s t R E C ( S e l f R E C t )  = 0.10 , value that represents the reward for each kWh self-consumed in the community;
  • f c o s t R E C ( G a p R E C t m o d )  = 0.01 , value chosed after a small calibration, to give priority to the maximization of the reward;
  • f c o s t R E C V a r u s e r N  = f c o s t N ;
  • Equal to zero for the rest of the positions.

2.3. Definition of the Proposed Approach

The proposed architecture combines a rule-based approach with metaheuristic optimization techniques, implemented on a distributed system. Each prosumer is equipped with a local EMS that interacts with a central coordination node. The distributed HEMS units send their forecasted prosumption profiles to this central CEMH.
At the CEMH, a digital twin of each prosumer’s HEMS is maintained. These digital twins enable the system to emulate the behavior of the entire community locally, minimizing communication delays. Once all forecasts are collected, a metaheuristic optimization method is applied to determine the optimal strategy for achieving the REC objectives. In this work, the PSO technique was used.
Importantly, this optimization does not directly alter the actions of individual users. Instead, it influences HEMS behavior indirectly by adjusting the perceived buy and sell prices, effectively steering the distributed systems toward the desired global outcome. These updated commands, expressed as price modifications, are then sent back to the distributed HEMS network.
Note that the label “CMD” assigned to some of the following variables indicates that they are evaluated after accounting for the effect of storage management within the system.

2.3.1. User’s HEMS

The HEMS of each user is responsible for optimizing the energy exchange between the household and the grid to maximize cash flow. Those systems are designed to always look to improve their associated user outcome, and this choice has been deliberately taken to increase the chances, in a real-world scenario, to see a real human user agreeing to renounce some of the control on its own household. On the user side, the HEMS receives as input the real-time measurements of household consumption, the production of any local generation plant, and the state of charge (SOC) of the BESS. On the CEMH side, HEMS receives the forecast buy and sell prices for the upcoming hours. In Figure 7 the implemented architecture is represented.
Figure 7. Architecture of the HEMS for the single user.
The degrees of freedom available to the HEMS are the scheduling of the BESS and, where present, controllable loads. For BESS scheduling, the system adopts a rule-based approach previously developed by the authors [25], designed to provide a lightweight optimization method with particular emphasis on computational efficiency.
To handle controllable loads, a small add-on module is introduced. The objective is to schedule all controllable loads within their respective windows, while satisfying their daily activation requirements and respecting the constraint on maximum hourly grid absorption, with the goal of minimizing total expenses. For pure consumers, the scheduling relies solely on the B u y p r i c e curve. For prosumers equipped with a production plant, the S e l l p r i c e is used instead during injection intervals, to account for the opportunity cost of unsold energy. Figure 8 shows an example of this procedure. To prioritize self-consumption, if the user is a prosumer with both BESS and controllable loads, the load scheduling is always performed before the storage scheduling.
Figure 8. Example of scheduling of a controllable load characterized by   C L v = 1   k W h ,   C L w = 9 − 22 ,   C L r = 1   for a user with L o a d M a x = 3   k W h .
Since prices are similar across users, it is expected that users with comparable resources will produce similar schedules. For example, storage charging or load activation may occur simultaneously across many prosumers. To avoid such synchronization and to shape the collective exchange with the grid toward community objectives, a second coordination layer is introduced at the CEMH level.

2.3.2. Energy Management Hub

Figure 9 shows the information flow between the blocks of the system while Figure 10 illustrates the CEMH logic. After collecting the distributed load and production forecasts, the flow splits into two branches: Loads Coordination (left, blue) and BESS Coordination (right, green). Both rely on digital twins to emulate user’s HEMS behavior and employ PSO as a metaheuristic optimization technique. Load coordination is achieved by adjusting the B u y p r i c e , t , while BESS coordination is driven by altering the S e l l ( p r i c e , t ) . Defining S e l l ( p r i c e , t ) u and B u y p r i c e , t u as the price profiles that are going to be received as input by the HEMS of the user u ,  the following relationships hold:
S e l l ( p r i c e , t ) u = S e l l ( x , t ) u + S e l l ( p r i c e , t )
B u y p r i c e , t u = B u y x , t u + B u y p r i c e , t
where S e l l ( x , t ) u and B u y x , t u are the decision variables optimized by the CEMH to achieve coordination. Note that the HEMS’s digital twins are exact clones of the distributed ones. To complete a full coordination cycle, both paths must be executed once. The priority between them is determined by evaluating the variability of the controlled variables, defined as follows:
B u y p r i c e G A P = m a x B u y p r i c e , t − m i n   B u y p r i c e , t
S e l l p r i c e G A P = m a x S e l l ( p r i c e , t ) − m i n   S e l l ( p r i c e , t )
Figure 9. Architecture of the CEMH and information flow to and from the distributed EMS network.
Figure 10. Flowchart of the decision three of the optimization process performed inside of the CEMH.
As noted, the outputs of this process are not direct control commands to individual users, but price alterations perceived by their EMSs. Since these alterations translate into costs in real-world scenarios, it is desirable to minimize them. Therefore, the coordination process starts with the branch requiring smaller price adjustments to influence user behavior toward the REC objectives, which is assumed to be the one associated with the smaller GAP.
Both paths start with the same two steps: a preliminary digital-twin planning, followed by a forecast of REC behavior. First, the optimization and scheduling of all controlled users are executed without any alterations on the price profile, which will only be optimized later within the branch. This operation simulates the REC as it would behave without coordination, providing a baseline forecast of the community’s behavior.
The result of this step provides, for each user u, the following forecasted profiles:
  • I n j ( f l o w , t ) u : grid injection profile scheduled in absence of BESS;
  • A b s ( f l o w , t ) u : grid absorption profile scheduled in absence of BESS;
  • I n j ( C M D f l o w , t ) u : grid injection profile scheduled in presence of BESS;
  • A b s ( C M D f l o w , t ) u : grid absorption profile scheduled in presence of BESS.
From these, the cumulative injection and absorption profiles of all users can be evaluated as follows:
I n j ( f l o w , t ) t o t =   ∑ u = 1 N u I n j ( f l o w , t ) u  
I n j ( C M D f l o w , t ) t o t = ∑ u = 1 N u I n j ( C M D f l o w , t ) u
A b s ( f l o w , t ) t o t = ∑ u = 1 N u A b s ( f l o w , t ) u
A b s ( C M D f l o w , t ) t o t = ∑ u = 1 N u A b s ( C M D f l o w , t ) u  
Note that these profiles differ from those of the REC itself. A further step is required to compute the REC profiles, both in the case without BESS and after scheduling:
R E C f l o w , t =   I n j f l o w , t t o t −   A b s f l o w , t t o t  
R E C ( C M D f l o w , t ) = I n j ( C M D f l o w , t ) t o t − A b s C M D f l o w , t t o t
I n j ( f l o w , t ) R E C = m a x R E C ( f l o w , t ) , 0  
I n j C M D f l o w , t R E C = m a x R E C C M D f l o w , t , 0
A b s ( f l o w , t ) R E C = m a x − R E C ( f l o w , t ) , 0
A b s C M D f l o w , t R E C = m a x − R E C C M D f l o w , t , 0
From this point, the two branches diverge, and their steps are described in detail below. Starting from the BESS coordination, the steps are the following:
REC Ideal Injection Profile Definition
Assuming that BESS units are used only for the needs of their respective owners, virtual self-consumption can occur only during time intervals where a surplus of production and injection is forecasted. Under this assumption, the maximum possible injection at each hour cannot exceed the cumulative injection forecast without storage:
I n j ( f l o w , t ∗ ) t o t   ≥   I n j C M D f l o w , t ∗ t o t   ∀   t ∗   ∈   1 , … , H
Over the forecasting horizon, the energy profile can be segmented into a series of intervals, each characterized by energy exchanges of the same sign, alternating between injection and absorption periods. In the case of the injection profile, it is expected to consist of intervals where the energy exchange with the grid is positive, alternating with intervals where it is zero. Defining T W I n j t o t as a time window of adjacent hours with I n j f l o w , t t o t > 0 , it is possible to evaluate both the energy injected and the energy absorbed within this interval.
Defining hours with I n j f l o w , t t o t > 0 as “Injection hours”, it is possible to split the forecasting horizon H into multiple intervals, and evaluate both the energy injected and the energy absorbed within this interval:
E T W I n j = ∑ t ∗ ∈   T W I n j t o t I n j ( C M D f l o w , t ∗ ) t o t
  E T W A b s = ∑ t ∗ ∈   T W I n j t o t A b s ( C M D f l o w , t ∗ ) t o t
The objective is to define a target injection profile for each such time window that maximizes both peak shaving and self-consumption. Formally,
R E C ( C M D f l o w , t ∗ ) T a r g e t = I n j ( C M D f l o w , t ∗ ) ( t o t   T a r g e t ) − A b s ( C M D f l o w , t ∗ ) t o t   ∀   t ∗   ∈   T W I n j t o t
The idea is to regularize the REC profile as much as possible within each injection window. To this end, the available energy in each window is defined as follows:
E T W d i s p =   E T W I n j −   E T W A b s
A first approximation of the target profile is then computed as follows:
I n j C M D f l o w , t ∗ t o t   T a r g e t =   E T W d i s p s i z e   T W I n j t o t +   A b s C M D f l o w , t ∗ t o t   ∀   t ∗   ∈   T W I n j t o t
Since the feasibility condition expressed in (35) must always hold, the profile is iteratively corrected by redistributing excess energy from unfeasible hours across the others. This operation is repeated for each injection interval of the prosumers in the REC, obtaining a target profile that serves as the reference for subsequent optimization steps. In Figure 11 this procedure is visually represented while Figure 12 shows the logic flowchart of the process.
Figure 11. Examples of the definition of the Target Injection Profile.
Figure 12. Flowchart of the evaluation process of the Target Injection Profile.
BESS Coordination Through PSO Optimization
In this branch, the search for the optimal solution is carried out using Particle Swarm Optimization (PSO) in two distinct phases. In both phases, the digital twins of the community HEMSs are included in the optimization functional, meaning that the entire REC is fully simulated for each particle of the swarm and at every iteration of the algorithm.
The variables optimized are the alterations S e l l x u   applied   to   the   selling   price   S e l l p r i c e u perceived by each user.
For consumers, S e l l ( x , t ) u is used at every time step, while, for prosumers, an upper boundary is imposed. Since S e l l x u essentially represents an incentive for paying the prosumer to act against their individual interest to achieve community objectives, it is important to guarantee sustainability. In this work, that boundary is set to be equal to the self-consumption reward, i.e., 0.10 €/kWh.
The choice of a rule-based technique is essential here, as it reduces computational cost while still enabling multiple full REC simulations within an acceptable time frame. For each particle p of the swarm, there is an I n j ( C M D f l o w , t ∗ ) ( t o t , p ) and a corresponding C E R ( C M D f l o w , t ∗ ) p .
The first phase is the “Aiming” step, in which user selling prices are altered to drive the particle injections I n j ( C M D f l o w , t ∗ ) ( t o t , p ) as close as possible to the target profile I n j ( C M D f l o w , t ∗ ) ( t o t   T a r g e t )   ∀   t ∗   ∈   1 , … , H . Figure 13 offers a visual example of this step. The proximity is evaluated through RMSE, so the functional to minimize became the following:
A i m c o s t p =   ∑ t ∗ = 1 H I n j C M D f l o w , t ∗ t o t , p − I n j C M D f l o w , t ∗ t o t   T a r g e t 2   H
Figure 13. Example of the effect of the alteration on the selling prices and result after the aiming run of the PSO.
At the end of this run of the PSO, what is expected is a set of S e l l ( x , t ) ( u , a i m )   ∀   u ∈   1 , … , N u that corresponds to a I n j ( C M D f l o w , t ∗ ) ( t o t , a i m ) really close to the Target Injection Profile with a corresponding A i m c o s t .
It is possible to define S e l l x a i m   as sum of all contribution S e l l ( x , t ) ( u , a i m ) over both t and u , which represents the total set of promises made to achieve a given solution. A challenging property of the energy management problem at the user level is its discrete nature: to alter the scheduling of a storage unit in a given hour, the corresponding price adjustment must exceed a minimum threshold. An adjustment smaller than this value does not trigger any scheduling change, while one that is larger but still below a second threshold simply increases the price without effect. Both cases result in wasted resources, and, thus, the solution obtained at the end of the Aiming step does not take into account this behavior.
For this reason, a second “Refining” run of PSO is introduced. In this phase, the sets of S e l l ( x , t ) ( u , a i m ) obtained in the first step are used both as initial conditions and as upper bounds for the corresponding variables. An example of this phase is represented in Figure 14. The optimization functional is also modified. While it continues to include and rely on the digital twins of the community EMSs, the cost function is defined as follows:
R e f c o s t p ,   a p p =   ∑ t ∗ = 1 H I n j C M D f l o w , t ∗ t o t , p − I n j C M D f l o w , t ∗ t o t   T a r g e t 2   H
S e l l x p , r e f = ∑ u = 1 N u ∑ t ∗ = 1 H S e l l ( x , t ∗ ) ( p , u )
R e f c o s t p = α × R e f c o s t p ,   a p p − A i m c o s t 2 + β × S e l l x p , r e f  
Figure 14. Visual representation of the variables of the single-user problem.
By choosing α ≫ β , the swarm is driven to identify a solution equivalent to the one obtained at the end of the Aiming step in terms of proximity to the target injection profile, but with a significantly lower global cost in terms of promised alterations. This effectively eliminates unnecessary overpricing.
The resulting set of N u alterations profiles S e l l ( x , t ) ( r e f , u ) , obtained at the end of the Refining step, is considered the optimal solution for the set S e l l ( x , t ) u representing and used as commands to be sent to the distributed HEMSs.
The decision to split the optimization into two phases resulted from trial-and-error experimentation. Tests showed that this two-step process outperforms a single-step approach, both in terms of solution quality and computational efficiency.
Two additional strategies applied to sensibly reduce computation time are described as follows:
  • Interval independence: Given the assumption that prosumers always prioritize self-consumption, storing sufficient energy in their batteries to cover future demand regardless of market conditions, the total energy injected into the grid in each injection interval remains fixed, independent of actions taken in other intervals. Consequently, the optimization of each interval can be treated as an independent problem, decomposing a large, complex problem into a sequence of smaller subproblems, each focused only on the relevant variables for that interval. This approach allows the forecasting horizon to be divided into a series of intermittent injection and absorption intervals, each characterized by its own duration I length . The counting of these intervals starts from the one closest to the present moment.
  • Asymmetric resource allocation: Due to the receding-horizon structure of the problem, the same points and intervals are optimized multiple times before actual execution. To improve efficiency, more computational effort, expressed as the maximum number of PSO iterations, is allocated to intervals closer to real-time execution, while fewer resources are devoted to points further in the future. This reflects both practical considerations of rolling optimization and the real-world effect (though not addressed in this work) of increasing forecast uncertainty at longer horizons.
To preserve progress across successive temporal steps, at the start of a new optimization cycle, 10% of the swarm particles are initialized from the best solution obtained at the end of the previous step, shifted by one temporal step. This anchoring effect stabilizes the optimization process while enabling adaptation to updated forecasts.
For both phases, the PSO hyperparameters were tuned experimentally and heuristically and the chosen are shown in Table 1 and Table 2 while Figure 15 represents the concept of the two optimization runs and how they are connected to each other. Some of them were kept constant, while others were adjusted to implement the two strategies described above, aimed at improving computation time. This is particularly true for the PSO used in the Aiming phase, where the computational resources are focused on searching for solutions within the Injection intervals closer to the present moment. In both phases, the swarm size depends on the length of the interval; however, the upper bound used in the Refining phase is smaller, as this problem is easier to solve.
S w a r m S i z e A i m = m i n ( max N u , I l e n g h t ,   200 )  
S w a r m S i z e R e f = m i n ( max N u , I l e n g h t ,   100 )  
Table 1. PSO hyperparameters for the Aiming Run.
Table 2. PSO hyperparameters for the Refining Run.
Figure 15. Visual representation of the two PSO runs employed in the BESS coordination process, illustrating how they interact with each other.
Load Coordination Through PSO Optimization
This branch is essentially constituted by the PSO for Load Coordination, carried out in a single phase. Figure 16 helps to recap the details of this passage. In this case, the digital twins of the community HEMSs are included in the optimization functional, but only for the controllable load component. The variables optimized are the alterations B u y x u   applied   to   the   buying   price   B u y p r i c e u perceived by each user.
Figure 16. Representation of the PSO run employed in the load coordination process.
The objective of the CEMH in this branch is to distribute controllable loads across the time horizon to limit peaks in grid absorption and maximize self-consumption. The REC simulation is first performed without considering controllable loads, obtaining C E R ( C M D f l o w , t )   , which allows us to identify in which hours the self-consumption can be achieved and those in which grid absorption will be critical. For each swarm particle, the load scheduling of all users is then performed, producing sets of grid absorption profiles due to controllable loads, A b s C L , t u , p . The total grid absorption due to controllable loads for each particle is given by the following:
A b s C L , t t o t , p = ∑ u = 1 N u A b s C L , t u , p  
By combining this with the forecasted REC profile, an approximation of the community behavior once controllable loads are included is obtained:
R E C ( C L , t ) p =   R E C ( C M D f l o w , t ) − A b s C L , t t o t , p
A b s C L , t R E C , p = m i n R E C ( C L , t ) p , 0
The functional cost is defined as the RMSE of the REC grid absorption:
C L c o s t p =   ∑ t ∗ = 1 H A b s C L , t ∗ R E C , p 2 H
This cost function naturally reduces total grid absorption by pushing controllable loads to be scheduled during hours of forecasted REC injection. At the same time, it penalizes high peaks, leading to a smoother load distribution across the horizon. The rolling-horizon framework, already described in previous branches, is also applied here.
At the end of the optimization cycle, the result is a set of N u alteration profiles B u y ( x , t ) ( C L , u ) , considered as the optimal solution for the set B u y ( x , t ) u , and subsequently used as commands to be sent to the distributed HEMSs.
Table 3 shows the used hyperparameter for the PSO in the load coordination phase
S w a r m S i z e R e f = m i n ( max N u , I l e n g h t ,   100 )  
Table 3. PSO hyperparameters for Load Coordination.

2.4. Dataset

To emulate the behavior of users and prosumers, historical data of loads and productions were taken from the Ausgrid dataset. Meanwhile, to take into account the day-ahead energy market, the 2024 PUN history was downloaded directly from the GSE portal.
  • Ausgrid, dataset from which are collected the load and production profiles of prosumers from Australia with steps of half-hours. From the set, the data for a whole year were extracted and, from them, 126 profiles, the ones with less holes, were selected and then converted to hourly based. Those profiles were then used to represent the first set of prosumers.
  • PUN, downloaded from the GSE portal representing the historical result of the MGP. This data represents the cost reached by an MWh of energy, hour by hour, on every zonal market in Italy. The PUN is the mean, performed hour by hour, of all those zonal prices.
For this work, the year 2024 of PUN was used.
To combine these datasets, the Ausgrid dataset must be shifted by six months to align the seasonal cycles. This adjustment ensures that both load and production profiles correspond to the appropriate price curves, resulting in a more realistic case study.
To normalize the behavior of prosumers, all profiles were rescaled in the same way. All load profiles were adjusted to reach an annual consumption of 3 MWh. The same process was applied to the production profiles to simulate 3 kWp plants, with profiles being scaled to simulate a production of 3 MWh in a year. For each prosumer, a 6 kWh BESS was considered.
For pure users, the presence of two controllable loads was also considered. The first has a consumption of 0.5 kWh, schedulable once per day within the time window from 8 a.m. to 6 p.m. The second has a request for 1 kWh, schedulable once every two days within the time window from 3 p.m. to 11 p.m.

3. Results

To evaluate performance, both the MILP benchmark and the proposed methodology were applied to simulated RECs over a one-year test period performing the optimization problem three days ahead, under the constraint of prioritizing storage for self-consumption. The algorithms were implemented in MATLAB R2024a and executed on a machine equipped with an Intel Core i9-13900K processor (Santa Clara, CA, USA) and 32 GB of RAM. The simulated RECs consisted of 100 domestic users, including 60 pure consumers and 40 prosumers. User profiles were randomly drawn from the Ausgrid dataset until the required community size was reached. Three optimization approaches were tested under the different REC scenarios:
  • The MILP benchmark, used as the golden standard to provide the best achievable results in terms of cash flow;
  • Distributed HEMSs without CEMH, representing the baseline behavior of the REC in the absence of coordination;
  • Distributed HEMSs with active CEMH, i.e., the proposed methodology.
Across all tests, the results showed that the performances of the defined benchmark are consistent with what is presented in the literature already, taking an average time of 20 s to solve the problem in each of the single iterations, leading to an improvement in the self-consumption of the community of 35% on average with respect to the case without any coordination. In Figure 17, an example of a full year of energy exchanges between the REC and the grid is shown. It can be observed that, in the case of active coordination, most of the peaks are shaved, both for the EMH ON and MILP cases. Figure 18 shows the same example; however, this time, the curves are not overlapped, allowing for a clearer comparison of the effects of the two different techniques.
Figure 17. Visual comparison of the energy exchange between REC and Grid in case of different methodology. The profiles are shown overlapped.
Figure 18. Visual comparison of the energy exchange between REC and Grid in case of different methodology. The profiles are shown on different plots.
Therefore, the tests show that the introduction of the CEMH, in place of the MILP, improved REC performance to a similar extent, both in terms of the regularity of the community profile and the incentives collected. The latter parameter is easier to quantify and provides an indirect indication of the quality of coordination. The proposed approach achieved results within the range of the 8 − 1.6 + 6.2   % of the optimum obtained by the MILP benchmark, with a confidence of 95%.
In Figure 19, an example of the trend of the self-consumption incentive is presented, illustrating the resulting REC behavior under different coordination approaches. Table 4, instead, reports the results obtained for all the RECs tested, using the following definitions:
I n c M I L P   a b s =   I n c M I L P f i n a l −   I n c C E M H o f f f i n a l
I n c C E M H o n a b s = I n c C E M H o n f i n a l − I n c C E M H o f f f i n a l
I n c M I L P   r e l = I n c M I L P a b s / I n c C E M H o f f f i n a l
  I n c C E M H o n r e l = I n c C E M H o n a b s / I n c C E M H o f f f i n a l
Figure 19. Visual comparison of the cash flow obtained after one year of usage of the different optimization techniques on the same CER.
Table 4. Reward from self-consumption of the tested RECs and on the average.
The results are expressed as distributions, and, due to the limited number of tests, the standard deviation s  was evaluated using the Bessel correction. The chi-square distribution was then used to estimate the boundaries of the confidence interval. Here, x i   represents the observed value, x ¯ is the mean, n   is the number of observations, and d f = n − 1   denotes the degrees of freedom of the chi-square distribution.
s = 1 n − 1 ∑ i = 1 n x i − x ¯  
σ 1 − α = d f   s 2 χ 1 − α / 2 ,   d f 2 , d f   s 2 χ α / 2 ,   d f 2
All results were represented with a 95% confidence level ( α = 0.05 ), evaluating the chi-square distribution with d f = 5 . Following the used values,
χ 0.975,5 2 ≈ 12.833 , χ 0.025,5 2 ≈ 0.831
In Figure 20, the results in terms of G a p C E M H o n M I L P are presented over the full year in a box plot, allowing an evaluation of how the difference in quality between the two methods varies throughout the year. This improvement in performance is not, however, cost-free. Coordination imposes a burden on users, particularly prosumers, who must reschedule the operation of their BESS to sell energy at different, and sometimes less favorable, hours. Since these lost opportunities result from deliberate choices made for the collective benefit, it is essential that the members who incur them are This improvement in performance is not, however, cost-free. Coordination imposes a burden on users, particularly prosumers, who must reschedule the operation of their BESS to sell energy at different, and sometimes less favorable, hours. Since these lost opportunities result from deliberate choices made for the collective benefit, it is essential that the members who incur them are.
Figure 20. Boxplot of G a p C E M H o n M I L P during the year.
This improvement in performance is not, however, cost-free. Coordination imposes a burden on users, particularly prosumers, who must reschedule the operation of their BESS to sell energy at different, and sometimes less favorable, hours. Since these lost opportunities result from deliberate choices made for the collective benefit, it is essential that the members who incur them are adequately rewarded for their collaboration and compensated for their losses. In this regard, tracking the price alterations generated by the proposed method provides a fair, real-time evaluation of each user’s contribution, facilitating the redistribution of incentives and rewarding those who prioritize community objectives over individual gains. These values ultimately make it possible to estimate the lower bound of the incentive percentage that should be redistributed among the worthy users, while the remaining share can be retained by the REC and used at its own discretion.
Defining U s e r s l o s s f i n a l as the difference between the cumulative cash flow of all REC’s members with and without CEMH, U s e r s S e l l   r e w f i n a l   as the total of the incentive allocated to reward users that shift their injection scheduling, and U s e r s B u y   r e w f i n a l as the cumulative incentive used to reward users who modify their controllable load scheduling, the results of the rewards evaluation are shown in Table 5.
Table 5. User’s losses due to coordination and evaluated rewards.
Each reward is evaluated by valuing the energy exchanged by the users using the historical price alterations computed through the CEMH coordination, instead of the original market prices. Let x t ( u , h i s t ) denote the historical prosumption of user u at time t , and let S e l l x , t ( u , h i s t ) and B u y x , t ( u , h i s t ) denote, respectively, the historical sell- and buy-price alteration signals assigned to user u . We can then define the rewards, ∀   t ∈ h i s t , as follows:
S e l l R e w , t u = x t ( u , h i s t ) ×   S e l l x , t ( u , h i s t )
B u y R e w , t u = x t ( u , h i s t ) × B u y x , t ( u , h i s t )
S e l l R e w u , f i n a l = ∑ t   ∈ h i s t S e l l R e w , t u
  B u y R e w , t u , f i n a l = ∑ t   ∈ h i s t B u y R e w , t u
U s e r s S e l l   r e w f i n a l = ∑ u   ∈   N u S e l l R e w u , f i n a l
U s e r s B u y   r e w f i n a l = ∑ u   ∈   N u B u y R e w , t u
It should be noted that such evaluations are easy to be performed either at the end of each optimization cycle in real time or over longer aggregation periods, such as weekly or monthly intervals.
Another key aspect is the computational cost. As mentioned in the introduction, MILP formulations tend to grow rapidly in size and require significant computational resources. The MATLAB implementation required sparse matrix formulations and, more importantly, exhibited longer execution times. The main tests showed that MILP required, on average and in the case studies, roughly three times longer to complete an optimization cycle compared to the proposed method, for communities structured as described above. The computation time depends on the number of users N u and the proportion of prosumers within the community. This trend was further investigated and confirmed by additional tests in which the number of the community members N u was varied from 50 to 1000 users, and the prosumer-to-consumer ratio P C r a t i o was adjusted from 20% to 80% of the total. The composition of the community has been randomly generated and then tested for a full day of operation, which means a total of 24 iterations. The horizon of rolling optimization has been kept to three days ahead, i.e., H = 72   h .
In Table 6 and Table 7, the results of varying N u and P C r a t i o with respect to the average optimization time are presented, allowing for a direct comparison between the two methodologies. The number of constraints increases linearly with the number of users. The inequality constraints, however, which mainly define the controllable loads possessed only by pure consumers, decrease as the percentage of prosumers increases. It should also be noted that a higher share of prosumers implies that more variable bounds are relaxed, such as those related to battery operations, allowing MILP to explore a larger feasible region and thereby increasing the overall complexity of the problem.
Table 6. Average time cost of the proposed method to complete an iteration of optimization.
Table 7. Average time cost of MILP benchmark to complete an iteration of optimization and number of Inequality and Equality constraints required to define the problem.
Lastly, in our tests, the optimization horizon extends three days ahead, whereas, in the study [15], it covers only a single day. Preliminary tests using a one-day-ahead horizon produced comparable results in terms of computational time to the MILP formulation adopted as a benchmark.

4. Conclusions

As expected, the MILP benchmark outperformed the proposed methodology in terms of solution optimality. Nevertheless, the proposed approach achieved results sufficiently close to the theoretical optimum to justify a discussion of the trade-offs involved. As recognized in the literature, real-time energy management must operate under strict time constraints, where obtaining a near-optimal solution within an acceptable time is preferable to computing the true optimum too late for practical implementation. The proposed hybrid framework, combining a PSO metaheuristic with a rule-based control layer, was specifically designed for real-time deployment with particular attention to both computational efficiency and hardware constraints. Its light implementation and limited computational demand make it suitable for edge-computing environments and large-scale community deployment.
Beyond performance efficiency, the proposed coordination mechanism introduces a transparent price-based reward system that allows for the fair compensation of individual users contributing to community objectives at a personal cost. This transparency and fairness in value sharing are essential design choices, recognizing that Renewable Energy Communities depend on the active cooperation of real human participants. By ensuring that collective optimization does not penalize individual members, the proposed methodology fosters trust and increases user acceptance in delegating part of their control to the EMS. It is important to note, however, that the results shown in Table 4 were obtained by applying the proposed method to the specific case study. Although it is expected that the methodology will be able to approach the optimum under different conditions, the value of G a p C E N H o n M I L P may vary in terms of percentage points. Further analysis, applying the proposed method to different configurations, will be carried out in future works.
A further step toward the real-world implementation of the proposed architecture will involve addressing the communication layer and validating the system in operational environments. While this study primarily focused on the methodological aspects of coordination and optimization, future work will include a comprehensive analysis of communication requirements such as latency, bandwidth, and update frequency, and of the system’s resilience to data losses and network failures. The integration of digital twins within the central node already contributes to reducing communication overhead by performing most coordination tasks locally. At the same time, the architecture enhances resilience through distributed intelligence: independent EMSs operate close to users, ensuring local autonomy and maintaining partial coordination in the event of communication failures with the central hub. End nodes can continue executing the last received commands while adapting to unforeseen local events, preserving safety and operational continuity. These aspects will be further investigated through real-world tests to evaluate synchronization accuracy, fault tolerance, and scalability under realistic network conditions. Overall, these developments will represent a crucial step toward deploying the proposed framework as a fully operational, distributed, and fault-tolerant control system for Renewable Energy Communities.
One key limitation of this work lies, however, in its reliance on perfect forecasting. Unfortunately, in real-world scenarios, this assumption is unrealistic and will likely be the first to be removed, as forecasting errors can negatively affect coordination performance. As already stated, this choice has been taken to remove the noise of the forecasting errors and focus just on the contribution and performance of the optimization technique. Relaxing the assumption of perfect forecasting will therefore be a key objective in future research. The impact of uncertainty on performance will be explicitly evaluated, and the implementation of techniques such as robust optimization and stochastic model predictive control have already been evaluated for an integration both at the HEMS and into the digital twin environment of the CEMH, to effectively address this uncertainty.
Other extensions are planned already. One will involve the integration of adaptive learning mechanisms, such as reinforcement learning guided by digital-twin simulations, which will also be explored to enhance predictive robustness. Second, a third coordination layer will be investigated to enable cooperation among multiple EMHs, paving the way toward the management of multi-node, medium-voltage networks where several Renewable Energy Communities coexist.
Overall, the proposed framework represents a pragmatic and scalable step toward the realization of resilient, fair, and human-centric Energy Management Systems for next-generation Renewable Energy Communities.

Author Contributions

Conceptualization, L.B., G.M.L. and F.G.; methodology, L.B. and G.M.L.; software, L.B.; validation, L.B., M.B., M.I. and G.M.L.; formal analysis, M.I.; investigation, L.B., M.I. and G.M.L.; resources, M.B.; data curation, L.B., M.B. and M.I.; writing—review and editing, L.B., M.B., A.L. and M.I.; visualization, L.B. and M.I.; supervision, G.M.L. and F.G.; project administration, G.M.L., A.L. and F.G. All authors have read and agreed to the published version of the manuscript.

Funding

This project was funded by the European Union, Next Generation EU, Mission 4, Component 1, CUP J53D23000760006. The authors also acknowledge the financial support of the National Research Center in High-Performance Computing, Big Data and Quantum Computing (https://www.supercomputing-icsc.it/en/icsc-home/, accessed on 1 October 2024) foreseen within Mission 4 (Education and Research) of the “National Recovery and Resilience Plan” (NRRP) that is part of the Next Generation EU (NGEU) program (https://www.italiadomani.gov.it/en/, accessed on 1 October 2024).

Data Availability Statement

The data presented in this study were derived from the following resources available in the public domain: Ausgrid dataset, https://www.ausgrid.com.au/ (accessed on 1 October 2024); Italian energy market trends, https://www.gse.it/ (accessed on 1 October 2024); and solar irradiation data, https://joint-research-centre.ec.europa.eu/photovoltaic-geographical-information-system-pvgis_en (accessed on 1 October 2024).

Conflicts of Interest

The authors declare no conflicts of interest.

Abbreviations

The following abbreviations are used in this manuscript:
AIArtificial Intelligence
BESSBattery Energy Storage System
CEMHCentral/Community Energy Management Hub
DGDistributed Generation
DSODistribution System Operator
EMSEnergy Management System
eEMSEdge/Central Energy Management System
GSEGestore Servizi Energetici (Italian Energy Services Operator)
HHorizon (Forecasting horizon or number of time steps)
HEMS/HEMSsHome Energy Management System/Systems
iEMSIndividual Energy Management System
kWhKilowatt-hour
kWpKilowatt-peak
MARLMulti-Agent Reinforcement Learning
MGPMercato del Giorno Prima (Italian Day-Ahead Market)
MILPMixed-Integer Linear Programming
NuNumber of users
NcNumber of Controllable Loads
P2PPeer-to-Peer (energy trading)
PCProsumer-to-Consumer ratio
PSOParticle Swarm Optimization
PUNPrezzo Unico Nazionale (Italian national electricity price)
REC/RECsRenewable Energy Community/Communities
RLReinforcement Learning
RMSERoot Mean Square Error
RNNRecurrent Neural Network
SOCState of Charge
TCNNTemporal Convolutional Neural Network
TSOTransmission System Operator
VATValue Added Tax

References

  1. Saad, O.; Abdeljebbar, C. Historical Literature Review of Optimal Placement of Electrical Devices in Power Systems: Critical Analysis of Renewable Distributed Generation Efforts. IEEE Syst. J. 2021, 15, 3820–3831. [Google Scholar]
  2. Yan, Q.; Wang, Z.; Xing, L.; Zhu, C. Optimal Economic Analysis of Battery Energy Storage System Integrated with Electric Vehicles for Voltage Regulation in Photovoltaics Connected Distribution System. Sustainability 2024, 16, 8497. [Google Scholar] [CrossRef] [Scilit]
  3. Gasparin, A.; Lukovic, S.; Alippi, C. Deep learning for time series forecasting: The electric load case. CAAI Trans. Intell. Technol. 2022, 7, 1–25. [Google Scholar]
  4. Gomes, I.; Bot, K.; Ruano, M.G.; Ruano, A. Recent Techniques Used in Home Energy Management Systems: A Review. Energies 2022, 15, 2866. [Google Scholar] [CrossRef] [Scilit]
  5. Zahraoui, Y.; Alhamrouni, I.; Mekhilef, S.; Basir Khan, M.R.; Seyedmahmoudian, M.; Stojcevski, A.; Horan, B. Energy Management System in Microgrids: A Comprehensive Review. Sustainability 2021, 13, 10492. [Google Scholar] [CrossRef] [Scilit]
  6. Sevilla, F.R.S.; Liu, Y.; Barocio, E.; Korba, P.; Andrade, M.; Bellizio, F.; Bos, J.; Chaudhuri, B.; Chavez, H.; Cremer, J.; et al. State-of-the-art of data collection, analytics, and future needs of transmission utilities worldwide to account for the continuous growth of sensing data. Int. J. Electr. Power Energy Syst. 2022, 137, 107772. [Google Scholar]
  7. GSE. Technical Rules for Energy Communities. 4 April 2022. Available online: https://www.autoconsumo.gse.it/ (accessed on 28 August 2025).
  8. ARERA. Deliberation 318/2020/R/EEL. 4 August 2020. Available online: https://www.arera.it/atti-e-provvedimenti (accessed on 28 August 2025).
  9. European Union. Directive 2018/2001 of the European Parliament and of the Council. 11 December 2018. Available online: https://eur-lex.europa.eu/eli/dir/2018/2001/oj/eng/ (accessed on 28 August 2025).
  10. Cutore, E.; Volpe, R.; Sgroi, R.; Fichera, A. Energy management and sustainability assessment of renewable energy communities: The Italian context. Energy Convers. Manag. 2023, 278, 116713. [Google Scholar] [CrossRef] [Scilit]
  11. Lin, J.; Qiu, J.; Zhang, C.; Lu, X.; Tao, Y.; An, S. An Encryption-Based Coordinated Kilowatt and Negawatt Energy Trading Framework. IEEE Internet Things J. 2025, 12, 48962–48977. [Google Scholar] [CrossRef] [Scilit]
  12. Ahmed, S.; Ali, A.; D’Angola, A. A Review of Renewable Energy Communities: Concepts, Scope, Progress, Challenges, and Recommendations. Sustainability 2024, 16, 1749. [Google Scholar] [CrossRef] [Scilit]
  13. Barabino, E.; Fioriti, D.; Guerrazzi, E.; Mariuzzo, I.; Poli, D.; Raugi, M.; Razaei, E.; Schito, E.; Thomopulos, D. Energy Communities: A review on trends, energy system modelling, business models, and optimisation objectives. Sustain. Energy Grids Netw. 2023, 36, 101187. [Google Scholar]
  14. Elmouatamid, A.; Ouladsine, R.; Bakhouya, M.; El Kamoun, N.; Khaidar, M.; Zine-Dine, K. Review of Control and Energy Management Approaches in Micro-Grid Systems. Energies 2021, 14, 168. [Google Scholar] [CrossRef] [Scilit]
  15. Esparza, A.; Blondin, M.; Trovão, J.P.F. A Review of Optimization Strategies for Energy Management in Microgrids. Energies 2025, 18, 3245. [Google Scholar] [CrossRef] [Scilit]
  16. Dinh, H.T.; Kim, D.; Kim, D. MILP-based optimal day-ahead scheduling for a system-centric community energy management system supporting different types of homes and energy trading. Sci. Rep. 2022, 12, 18305. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  17. Akter, A.; Zafir, E.I.; Dana, N.H.; Joysoyal, R.; Sarker, S.K.; Li, L.; Muyeen, S.M.; Das, S.K.; Kamwa, I. A review on microgrid optimization with meta-heuristic techniques: Scopes, trends and recommendation. Energy Strategy Rev. 2024, 51, 101298. [Google Scholar] [CrossRef] [Scilit]
  18. Wilk, P.; Wang, N.; Li, J. Multi-Agent Reinforcement Learning for Smart Community Energy Management. Energies 2024, 17, 5211. [Google Scholar] [CrossRef] [Scilit]
  19. Bâra, A.; Oprea, S.V. Enabling coordination in energy communities: A Digital Twin model. Energy Policy 2024, 184, 113910. [Google Scholar] [CrossRef] [Scilit]
  20. Elkazaz, M.; Sumner, M.; Thomas, D. A hierarchical and decentralized energy management system for peer-to-peer energy trading. Appl. Energy 2021, 291, 116766. [Google Scholar] [CrossRef] [Scilit]
  21. Urbanucci, L. Limits and potentials of Mixed Integer Linear Programming methods for optimization of polygeneration energy systems. Energy Procedia 2018, 148, 1199–1205. [Google Scholar] [CrossRef] [Scilit]
  22. Castro Freibott, R.; Gerbolés, C.; García- Sánchez, Á.; Ortega-Mier, M. MILP and PSO approaches for solving a hydropower reservoirs intraday economic optimization problem. Cent. Eur. J. Oper. Res. 2024, 33, 1343–1366. [Google Scholar] [CrossRef] [Scilit]
  23. Mohd Zakki, M.I.; Mohd Hussain, M.N.; Seroji, N. Implementation of Particle Swarm Optimization for tuning of PID controller in Arduino Nano for Solar MPPT system. J. Electr. Electron. Syst. Res. (JEESR) 2018, 13, 78–85. [Google Scholar]
  24. Kim, R.-K.; Glick, M.B.; Olson, K.R.; Kim, Y.-S. MILP-PSO Combined Optimization Algorithm for an Islanded Microgrid Scheduling with Detailed Battery ESS Efficiency Model and Policy Considerations. Energies 2020, 13, 1898. [Google Scholar] [CrossRef] [Scilit]
  25. Becchi, L.; Belloni, E.; Bindi, M.; Intravaia, M.; Grasso, F.; Lozito, G.M.; Piccirilli, M.C. A Computationally Efficient Rule-Based Scheduling Algorithm for Battery Energy Storage Systems. Sustainability 2024, 16, 10313. [Google Scholar] [CrossRef] [Scilit]
  26. Menegatto, M.; Bobbio, A.; Freschi, G.; Zamperini, A. The Social Acceptance of Renewable Energy Communities: The Role of Socio-Political Control and Impure Altruism. Climate 2025, 13, 55. [Google Scholar] [CrossRef] [Scilit]
  27. Caferra, R.; Colasante, A.; D’Adamo, I.; Morone, A.; Morone, P. Interacting locally, acting globally: Trust and proximity in social networks for the development of energy communities. Sci. Rep. 2023, 13, 16636. [Google Scholar] [CrossRef] [Scilit]
  28. Volpato, G.; Carraro, G.; Dal Cin, E.; Rech, S. On the Different Fair Allocations of Economic Benefits for Energy Communities. Energies 2024, 17, 4788. [Google Scholar] [CrossRef] [Scilit]
  29. Casalicchio, V.; Manzolini, G.; Prina, M.G.; Moser, D. Optimal Allocation Method for a Fair Distribution of Benefits in an Energy Community. Sol. RRL 2021, 6, 2100473. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.