Energy Communities Design Optimization in the Italian Framework

: Energy communities (EC) are expected to have a pivotal role to reach European decarbonization targets. One of the key aspects is the regulatory framework adopted by each Member State to properly manage such new customers’ aggregation. The paper ﬁrstly provides an updated overview of the EC regulation, focusing on the current Italian legislation. Next, a novel methodology for the design and management of energy community initiatives is proposed. The procedure ﬁrstly solves a design and operation optimization problem to calculate the best size of energy assets (boiler, heat pump, photovoltaic, thermal storage) to be installed. Second, a Shapley value-based approach is exploited to distribute a part of the community’s incomes to members, based on their contribution to the overall welfare. Results demonstrate that the adopted methodology is effective in ensuring a proper cash ﬂow for the community, while pushing its members towards energy efﬁcient behaviors.


Energy Communities and the Decentralized Energy Production Paradigm
When talking about energy communities, we generally refer to groups of citizens who organize themselves to actively contribute to energy transition, producing energy and meeting their energy needs through the exploitation of renewable sources. This form of organization has experienced important growth since the 2000s due to the liberalization of electricity markets, favorable environmental policies, and the falling price of renewable energy plants. Several successful "bottom-up" projects have been developed over the past two decades and the evolution process reached an important milestone with the recognition, from the European Union (EU), of the importance of energy communities in the energy transition. In fact, with two Directives [1,2], the EU has recently provided formal definitions for the energy communities and has required all the Member States to introduce this subject into their national legislations, ensuring an enabling framework to promote and facilitate their development. The context in which energy communities are emerging is the huge transformation that electrical systems are undergoing. The paradigm based on centralized generation is being abandoned in favor of a system based more and more on distributed generation. According to the Directive of the European Union 2018/2001 [1], "The move towards decentralized energy production has many benefits, including the utilization of local energy sources, increased local security of energy supply, shorter transport distances and reduced energy transmission losses. Such decentralization also fosters community development and cohesion by providing an economical income sources and creating jobs locally", resulting in a complex and multidisciplinary problem. Focusing on the aforementioned elements, decentralized energy production has to deal with four aspects, discussed in the following.

1.
Local energy sources. The exploitation of local sources should consider all the externalities related to architectural and landscape modification or competition with other local activities such as tourism or agriculture.

2.
Local security of energy supply. EU energy dependency rate on foreign countries in 2018 was equal to 58% [3]. Because of this, it is fundamental to consider the impact on internalization of primary energy procurement.

3.
Shorter transport distances and reduced energy transmission losses. While distances, hence energy losses, of electricity transport decrease, distribution networks become more complex to be managed. 4.
Community development and cohesion. The acceptability of new infrastructure is higher when decisions (and even investments) are taken collectively. This increases the awareness of local communities about the positive impact of business initiatives on social relations and economic activities.
The required change of paradigm in the energy sector would have a wide impact in all the mentioned aspects of our society. Indeed, energy communities can be a tool to foster distributed generation, since they naturally have a holistic view on all the aspects of their local reality. From a purely technological perspective, such a change of paradigm requires a smart integration of the different energy production, storage, and distribution systems, in order to meet the various energy needs of the users. This way, the electricity, heating, and cooling demands can be satisfied by maximizing the possible synergies among the available energy vectors and networks. This approach is usually called sector coupling and its implementation is considered as a valuable means to increase the share of renewable energy sources (RES) into the production mix and so decarbonize our final energy demand. As an example, heat pumps can be used to convert the electricity produced by photovoltaic panels to accumulate thermal energy to be used at another time during the day, so reducing the use of fossil fuels to meet the heating remand.

Energy Communities in the Italian Regulatory Framework
The Clean Energy Package is a set of eight legislative acts with which the European Union has reformed its energy policy framework. It contains two definitions of energy community: renewable energy community (REC), which is defined in the Renewable Energy Directive 2018/2001 (RED II) [1], and citizen energy community (CEC), which is contained in the Electricity Market Directive 2019/944 [2].
Italy, as the other European Member States, has to transpose the Directives into its national law respectively before the 30th December 2020 and the 30th June 2021. Energy communities have stimulated a great interest in the Italian context and pilot legislative initiatives have been introduced. In March 2020, Italy implemented the first law anticipating transposition of Articles 21 and 22 of the RED II [4]. Article 42 of the law is named "Autoconsumo da fonti rinnovabili" (Self-consumption from renewable sources) and allows the activation of initiatives of collective self-consumption and renewable energy communities. The proposed configurations are transitional and two of the main purposes are to obtain lessons from the regulatory point of view and study the reactions of the various stakeholders, such as citizens and network operators. This experimental phase has some limits regarding the time windows for the activation of the project and the characteristics of the configurations. In order to access this model of experimentation, the plants of the renewable energy communities or collective self-consumption must have come into operation after the date of entry into force of Legge n. 8 and within sixty days from what will be the date of the measure transposing Directive (EU) 2018/2001.
In these new configurations, energy is produced by means of new plants powered by renewable sources to satisfy members' consumption. The maximum power of each plant cannot exceed 200 kW. In the case of RECs, both consumers and generators are connected to the same low voltage grid, while in the case of collective self-consumption they are located in the same building. The energy produced is shared using the existing distribution network. It is interesting to notice that also jointly acting self-consumers formally use the distribution network to share energy. Indeed, even if they are located in the same building, each user is connected to the network by means of a different point of delivery (POD). The shared energy is equal to the minimum, in each hourly period, between the electrical energy produced and fed into the grid by the renewable plants of the community and the electrical energy withdrawn by all the associated end customers. Although, in the future, participation in RECs will be opened also to existing plants, it is evident that the legislator wants to use the transitional regime as a tool for creating new renewable energy sources capacity [5]. Within the REC, however, the members still detain their end customers rights, such as free choice of their energy retailer and freedom of being self-consumers. Furthermore, the energy withdrawn from the grid will be charged with the individual contracts between the members and their retailers. From the commercial point of view, the energy is retired from the publicly owned company Gestore dei Servizi Energetici (GSE), that provides revenue comprising the market value plus an incentive for the amount of energy that results to be shared. The revenues are given to a reference subject, chosen by the community, and then the members regulate the internal redistribution via private contracts. It is important to notice that, with the proposed scheme, the current legislation tries to emulate a "pure" mechanism of energy sharing with another one, that has the same economic effect for users. Specifically, the energy that is formally "shared" is actually withdrawn by the GSE, while the members continue to buy the energy from their retailer. The incentive is intended to give back to the users the value already paid to their retailers. A more "direct" energy sharing should be based on aggregated net metering. In this case, the energy produced by the generators of the community should be directly discounted from the electricity bill of the community members, without the intervention of a third party (e.g., GSE). Despite the simplicity of the concept, the implementation of such a model would require important changes in the current regulation. On the contrary, the scheme of energy sharing chosen for the transitional regime is very simple and allows immediate implementations. The Authority, with Resolution 318/2020/R/eel [6], defined that the unitary tariff components related to the transmission and distribution network are not applicable to the shared energy. Furthermore, it defined that jointly acting selfconsumers receive extra revenue for shared energy, motivated by the reduction of network losses. This revenue is evaluated as a percentage of the zonal price (1.2% if the generator is connected to the medium voltage network, 2.6% if it is connected to the low voltage network). The Ministry of Economic Development identified the incentive tariff to reward instantaneous self-consumption and to ensure return of investment ("Decreto 16 settembre 2020" [7]). The incentive is differentiated for RECs and jointly acting self-consumers and will last for 20 years. In Table 1, the economic benefits obtained sharing energy in the two configurations are summarized.

Motivation
To unlock the potential of energy communities, novel models and methodology are required. The challenge is to merge multi-energy approaches with a multi-player perspective. Indeed, energy communities may take benefits from sharing electrical and thermal energy, and this benefit must be fairly distributed among the members of the Appl. Sci. 2021, 11, 5218 4 of 16 configuration. A novel methodology capable of accounting for both these elements is proposed in this paper.
In order to illustrate and discuss it, a case study has been chosen. It is representative of a typical energy community implementation in the Italian framework, that is a small/medium condominium. However, the considered case study cannot be considered as representative of the whole Italian context, for which a detailed statistical analysis would be required.
The paper is organized as follows: Section 2 describes the materials and methods adopted for the energy community modeling and for the benefits distribution among the community's members; Section 3 presents the case study of a condominium in Italy to which the methodology is applied; in Section 4 the results of the application are reported; and in Section 5 general conclusions are proposed.

Energy Community Model
The modeling of energy communities has been introduced in [8], wherein the approach proposed was limited to the electrical fluxes. As previously mentioned, in order to make ECs effectively contribute to the decarbonization of the energy system, it is necessary to adopt a multi-energy approach, wherein the objective is to maximize the synergies among different energy sectors (e.g., electricity and heating). To this aim, the advanced mathematical tools typically used in the field of multi-energy systems (MES) or districtenergy systems (DES) [9][10][11] can be of help. Such tools are based on optimization algorithms capable of selecting the proper mix of technologies and their sizes to meet multiple different energy demands in multiple locations in the most efficient and economically sustainable manner. In this study, one of such optimization models has been devised to identify the optimal design of the energy production and storage systems to be installed in an energy community, so as to guarantee the maximization of the economic benefits for the members coming from the rational use of energy sources to match the electricity, heating, and cooling needs of its members and the remuneration of the self-consumption, as it is now foreseen by the Italian regulatory framework.
The optimization problem has been formulated as a two-stage MILP problem, involving investment decisions (first stage) and operation decisions (second stage). This two-stage structure is represented by the following compact formulation:

Subject to
where TAC is the total annualized costs (CAPEX + OPEX), u ∈ U is the set of energy conversion and storage units, and t ∈ T is the set of time steps considered in the operation.
x (1) and y (1) are the continuous (unit size, storage capacity) and binary (unit yes/no installation) investment variables, and x (2) and y (2) are the continuous (unit load and consumption, storage level, exchange between the multiple locations) and binary (unit on/off status) operation variables. There are constraints that account only for the investment stage (Equation (2)), and they can be the available locations and space for units' installation.
There are also constraints referring only to the operation stage, as in Equation (3): the balances between the energy production and demand. Finally, there are constraints that bind the first and the second stage variables, as in Equation (4), e.g., the maximum and minimum loads of the units, which depend on their size. For more details about the energy conversion and storage technologies comprised in the model, see [12][13][14].
To reduce the computational complexity of the problem, instead of optimizing all the hourly time steps in a year (which would be the ideal approach), five representative days have been considered in this study, each one to represent a typical period/condition: extreme winter, winter, mid-season, summer, and extreme summer (for further details, see the following sections). It is worth noticing that, with this approach, in terms of intertemporal constraints, the operation of the energy conversion and storage systems is cyclical on a daily basis; that is, the last time step of the day is linked to the first one (for the energy storage system, this implies the same initial and final value). The total annual results are computed by weighting the typical days values, according to the fraction of the year that they represent. Hence, the OPEX part of the objective function can be formulated as follows: where: the t ∈ T time set is replaced by d ∈ D and h ∈ {1 . . . 24}, which are the sets of typical days and hours of the day; i ∈ PODs is the set of points of delivery; N d is the number of days represented by typical day d; ξ EB i,d,h and ϕ ER i,d,h are the electricity bill and the electricity remuneration, respectively, computed accordingly to the considered configuration; ξ NG i,d,h is the natural gas bill, whose computation method is independent of the configuration. The electricity bill features an energy, a power, and a fixed quota, plus taxes paid on total consumption, and hence ξ EB i,d,h is calculated as the hourly contribution to the total amount paid in the bill (further details on the electricity remuneration will be given in the following sections). Similarly, ξ NG i,d,h comprises the fixed and the energy quota, plus taxes for the natural gas bill.
The constraints of the model enforce the energy balances, the dependence of the energy conversion systems on the weather conditions (e.g., the specific photovoltaic production on the irradiation and ambient temperature, the coefficient of performance of the electric heat pumps on the ambient temperature), the storage management, the exchange profiles with the grid, and the bills' calculation.
To sum up, the optimization problem used in this study can be stated as follows: given (i) a set of available technologies (in terms of installation and operating costs, their characteristic performance and parameters), which depends on the scenario considered (see the case study below); (ii) the electricity, heating, and cooling demands of the residents (see the case study below for the total values and profiles); (iii) the prices and structure of the bills of natural gas and electricity; (iv) the production profiles of the intermittent RES; and (v) the renewable self-consumption configuration (condominium members as single users or part of a community, see the case study below for further details), determine the optimal design of the energy conversion and storage units and exchange with the grid so as to minimize the annualized investment and operating costs of the condominium as a whole.

Benefit Distribution
The collective self-consumption can be modeled as a cooperative game [15], where the players are the condominium itself and the set of private users located in the building. The economic value generated hour by hour depends on the presence and the interaction between load and production; in particular, on the quantities of energy injected in the network and shared. The revenue obtained by the configuration can be represented with the following value function: where S is the coalition of players that join the configuration, EP is the value of the energy injected into the distribution network and is equal to the market price, Inc is the value of the incentive according to the Italian regulation (see Table 1). Both the condominium and the single consumers want to take advantage of the participation in the collective configuration. The condominium invests in the installation of new generators and equipment and wants to obtain a return from the investment. On the other hand, when considering consumers, they have a certain contractual power, as they are necessary to generate the profit (mainly based on the incentive for shared energy). As a consequence, they can require an appropriate return for their participation in the collective self-consumption configuration. The objective of studying the game is to find a stable and fair allocation rule that gives an adequate payoff to the players, so that each one is encouraged to take part in the EC. The adopted solution is based on the Shapley value, a well-known solution that reflects the fairest payoff for the players, taking into account the marginal contribution of each one. Indeed, value should be distributed among consumers according to their contribution to value generation (not everyone contributes in the same way). The contribution of a passive user will be zero if their energy demand occurs at a time when the total load already exceeds the current production. On the contrary, a user will produce a greater value if they consume the energy produced by the facilities of the community when there are no other users who require it. The Shapley value takes into account this effect. For user i it is evaluated as: that considers the possible orders in which player i can join the coalition S. The distribution rule defines a payoff for each member of the community.

Case Study
The study reported in this paper considers a typical building in the north of Italy, which features nine apartments occupied by both residential (six) and commercial (three) users; hence, it entails a total of ten PODs: one for each apartment and a condominium one. In particular, the residential apartments are supposed to be occupied by two couples of elderly people, two couples of young workers, and two families with children; the commercial users are represented by offices. Reasonable reference values of annual demands for each category of users and the estimate of their daily profiles have been collected from previous papers and studies [16][17][18][19][20][21] (see Table 2). Some hypotheses about occupants' lifestyle have been introduced to differentiate such daily profiles among the same typologies of occupants and therefore consider a more realistic building energy consumption. Some of the considered typical lifestyle types are: different wake-up, lunch, and or sleep time; out-of-home vs. smart/at-home place of work; possibility for someone to come home for the lunch break; different intensity of the loads' usages; different opening/closing hours for the offices; different sizes of the offices (i.e., three-room vs. double-room). These aspects affect both mid and peak load values throughout the day, ramps up/down in the evening and in the morning as well. The resulting profiles are reported in Figure 1, whereas the daily peaks and total values for the electricity, heating, and cooling demand are reported in Tables 3-5, respectively. As already stated in Section 2.1, yearly demands of electricity, heating power, and cooling power are represented by means of "typical day" profiles. Typical days have been selected in order to consider the seasonality of the demands during the year: "Typical day 1" represents wintertime, "Typical day 2" represents spring/autumn days, while "Typical day 3" represents summertime. In addition to them, "Typical day 4" represents a harsh winter day, while "Typical day 5" represents a really hot summer day; their cardinality is therefore lower, as reported in Tables 3-5. Two electrification scenarios have been considered: A-the condominium can install up to 100 m 2 of PV panels on the roof; the cooling demand is satisfied by individual air conditioning units and the heating demand is satis- Figure 1. Breakdown of energy demands for each typical day. Note: to appreciate profile shapes, the graph scale is different for each typical day. Table 3. Electricity demand for each apartment in each typical day, in terms of peak and total electricity demand during the day. The yearly total demand is calculated by multiplying the total electricity demand of each typical day for its cardinality (N, according to the nomenclature used in Equation (6)).  Table 4. Heating demand (space heating + domestic hot water) for each apartment in each typical day, in terms of peak and total heating demand during the day. The yearly total demand is calculated by multiplying the total heating demand of each typical day for its cardinality (N, according to the nomenclature used in Equation (6)).  Table 5. Cooling demand for each apartment in each typical day, in terms of peak power demand and total cooling demand during the day. The yearly total demand is calculated by multiplying the total cooling demand of each typical day for its cardinality (N, according to the nomenclature used in Equation (6)).  Two electrification scenarios have been considered: A-the condominium can install up to 100 m 2 of PV panels on the roof; the cooling demand is satisfied by individual air conditioning units and the heating demand is satisfied by a centralized system fed by a natural gas boiler; B-like A, but the natural gas boiler can be substituted by an electric heat pump (HP), coupled with thermal energy storage (TES).

Typical Day 1 [N = 117]
For each electrification case, the energy community configuration (EC)-which in this case, according to the EU nomenclature, it should be named group of jointly acting renewable self-consumers-is compared to the current Italian economic support scheme for PV energy production named Scambio Sul Posto (SSP): such an option allows the prosumer to inject the energy surplus in the grid, and to have it back (when it is required) at given selling/purchase prices [22]. Within the EC configuration, there is the possibility to share the PV electricity production between all residents, through the distribution grid, hence using the so-called virtual model [23]. The quota of shared electricity is incentivized with the feed-in-tariff foreseen by ARERA resolution 318/2020 [6] and GSE rules [23], whereas the amount that is injected into the grid and not shared is remunerated at the hourly zonal price. Within the SSP configuration, the condominium acts as a group of single users who interact with the public grid independently. The combination of the two electrification scenarios (A and B) and the two configurations (SSP and EC) gives rise to four cases: A-SSP, A-EC, B-SSP, and B-EC.

Optimal Design Results
The optimized selection of the energy conversion and storage systems to be installed in the condominium, to satisfy the energy needs of the users in the four cases, are reported in Table 6. To the aforementioned four cases (A-SSP, A-EC, B-SSP, and B-EC), two further cases have been added for the EC configuration, which feature the optimization of the units assuming there is no bound on the area available for the installation of the PV panels, which make them not practically feasible, though interesting from a speculative perspective. Table 6 reports also the results obtained by the objective function of the optimization model as TAC = OPEX + CAPEX; that is, total annualized costs = operating expenditures + annualized capital expenditures (for which it has been assumed a discount rate = 1% and lifetime of the investments = 20 years for PV and TES, 15 years for boiler and HP) in the considered cases. Values are normalized with respect to the TAC obtained in case A-SSP, which is the highest. Such results show the logic implemented by the optimization model: an increase of the CAPEX, due to the installation of better performing equipment, entails a sensible reduction of the OPEX, which finally leads to an overall reduction of the total annual costs. Such results become even better when the collective self-consumption scheme is adopted.  Table 7 reports the natural gas, electricity, CO 2 , and economic yearly balances. The electricity balance is expressed by condominium overall electricity consumption, production, import, and export; the electricity section features an outlook of the condominium self-consumption, expressed in terms of physical self-consumption (i.e., the amount of energy produced and consumed by the condominium POD) and collective self-consumption (i.e., the amount of energy injected by the condominium POD and consumed by the apartments' POD in the same hour). Values are expressed as a difference with respect to the reference scenario (wherein no electrification investment is made), except for self-consumption percentages, which refer to electricity production. Combining the values reported in Tables 6 and 7, it is possible to notice the potential economic and environmental benefits coming from the implementation of the EC configuration, which makes the investment in renewable energy sources, in this case PV, more attractive than the SSP configuration. Considering Scenario A, the possibility of sharing the RES production in the EC configuration leads to the utilization of all the available surfaces for the installation of PV (100 m 2 ), whereas the SSP configuration features a very limited installed PV surface (2.5 m 2 ), strictly limited by the low capability of the condominium POD to self-consume the RES production. On the other hand, in Scenario B, due to the installation of the PV-HP-TES bundle, the SSP configuration is also able to take advantage of the physical self-consumption (+5.5 MWh/y with respect to case A) with an optimal PV size of slightly more than 14 kW (pretty close to the maximum available surface). Indeed, the energy system design of B-SSP brings about an economic saving of almost 3 k EUR/y and a CO 2 emission reduction of around 15 ton/y with respect to case A.
Both in Scenario A and B, the EC configuration allows for a considerable rate of selfconsumption of the PV production: around 70% and 86%, respectively. In case A-EC, such a self-consumption rate brings about an economic pay-off for the members on the community (2.68 k EUR/y reduction of operating costs, equal to −23%) and an environmental benefit as well (4.42 ton/y reduction of CO 2 emissions, equal to −15%). In particular, the results in case B are due to the combination of a more extended electrification (PV-HP-TES) with the collective self-consumption (see Table 6), which, together, lead to an economic saving of 3.78 k EUR/y and a CO 2 emission reduction of almost 18 ton/y with respect to the reference case (operating costs: −32%; CO 2 emissions: −65%). In particular, the effect of the electrification investment can be estimated by comparing B-EC and A-EC (−1.1 k EUR and −14.3 t CO2 ), whereas the effect of the EC configuration by comparing B-EC and B-SSP (−0.27 k EUR and −3.6 t CO2 ). It is worth noticing that the virtual model assumed for the implementation of the EC configuration, nowadays, does not require any explicit investment.
Finally, given the possibility to install PV panels regardless of any surface limitation (A-EC-ideal and B-EC-ideal), the model finds the ideally optimal surface to maximize the energy shared by the members of the community, leading to both the best economic (operating costs: −28% for the A-EC-ideal and −105% for the B-CE-ideal with respect to the reference case) and environmental results (CO 2 emission: −17% for the A-CE-ideal and −74% for the B-CE-ideal with respect to the reference case). To be noted is that the lower percentage of self-consumption displayed in Table 7 for these two ideal cases (around 57% for the A-EC-ideal and 53% for the B-EC-ideal) with respect to the real cases (around 68% for the A-EC and 86% for the B-EC) should not be misinterpreted as a negative outcome; indeed, the total self-consumed energy, in their case, is larger: +1.5 MWh for the A-EC-ideal and +8.4 MWh for the B-EC-ideal with respect to their A-EC and B-EC counterparts.

Benefit Distribution Results
The distribution of the remuneration obtained from the energy sold and from the incentives has been computed with the proposed methodology for the scenarios in which the energy community is considered (A-EC and B-AC). Each member of the configuration receives a pay-off that depends on its contribution to the collective self-consumption (i.e., to the achievement of the incentives). The condominium receives a revenue that depends both on the energy injected into the grid and on the energy that is shared among the members of the configuration. Each of the other members receives a payoff for its contribution to the collective self-consumption. The families and the offices have a direct benefit thanks to the payoff they receive, but it is worthwhile to mention that also part of the revenues allocated to the condominium may represent an indirect advantage for them. Indeed, once the return of the investment is guaranteed, additional profits for the condominium can be used to cover shared costs for the building management.
The revenues of the passive members of the configuration depend on their contributions to the collective self-consumption and they are reported in Table 8. Considering Scenario A-EC, the minimum revenue is obtained by the user Young couple 1 and it is equal to EUR 31, while the higher one is achieved by the user Office 3 and it is equal to EUR 130. On average, each member receives EUR 71. On the other hand, the condominium receives the greater part of the generated value (EUR 1987). Indeed, the condominium is the owner of the PV power plant and its pay-off needs to guarantee the return of the investment. The Shapley value properly accounts for the importance of the condominium in the configuration. Specifically, it allocates the entire value of the produced energy to the condominium (EUR 1231). This constitutes 62.0% of the entire revenue. Moreover, it also allocates part of the incentive obtained due to the shared energy (54.2%).
When considering Scenario B-EC, the amount of energy physically self-consumed by the condominium increases and the revenues from the incentive based on the collective self-consumption decreases. The overall revenue of the configuration decreases from EUR 2627 to EUR 2159. Only EUR 1580 are allocated to the condominium. On the other hand, in this scenario, the condominium saves the cost of the gas, due to the installation of the heat pump. The revenues of a passive user can be increased if they are able to shift their electricity consumption in the hours of PV production. The effect of load shifting has been tested for Scenario A-EC. A simple load shifting model has been implemented, moving a percentage of the daily load in the hour of PV production according to the following equation: where Load(t) is the daily load profile for the considered user, LS % is the percentage of load shifted, and PV(t) is the power production profile, scaled by the factor ∑ Load(t) ∑ PV(t) . The results of the pay-off distribution, in the case Family 1 is performing load shifting, are reported in Table 9 and are depicted in Figure 2a. It is important to notice that the load shifting of one user affects the economic results of every stakeholder of the configuration. For the user itself, the load shifting increases the revenue up to EUR 154, with an increment of 155% with respect to the same result when considering no load shifting. For all the other users, the load shifting of Family 1 has a slightly negative effect. This is due to the competition generated by the distribution rule. The user that shifts its load becomes more important, in relative terms, with respect to the other members. This effect could stimulate virtuous behavior, since all the other users are motivated to follow Family 1 and shift also their load profile. At the same time, the condominium takes benefits for the load shifting of Family 1 since it increases its payoff to EUR 2081 (+4.7%).  As already mentioned, all the users are driven to shift their load to increase (or simply, not reduce) their pay-off. The effect of the load shifting provided at the same time by all the users has been tested. The resulting payoffs are reported in Table 10 and in Figure 2b. On average, the increment of the revenue of each single passive member is 41.7%. Nonetheless, the effect is strongly different among the users. In particular, the average increment of the young couples is equal to 129.2%, while for the offices there is an average reduction of 10.5%. Similarly, to what already observed in the previous case, the improvement of the performances of some users has a slightly negative effect on the revenues for the users that are not improving (or improving less). In other words, in the base case, the offices are awarded for their relative importance in the configuration. Indeed, without any load shifting they are the only users with relevant load during the hour of PV production, and they are fundamental to obtain the incentive. When all the users shift their profiles, offices lose this relative importance, and their revenues are reduced. From the perspective of the condominium, the load shifting is extremely beneficial, and its revenues increase by 22.3%. As already mentioned, all the users are driven to shift their load to increase (or simply, not reduce) their pay-off. The effect of the load shifting provided at the same time by all the users has been tested. The resulting payoffs are reported in Table 10 and in Figure 2b. On average, the increment of the revenue of each single passive member is 41.7%. Nonetheless, the effect is strongly different among the users. In particular, the average increment of the young couples is equal to 129.2%, while for the offices there is an average reduction of 10.5%. Similarly, to what already observed in the previous case, the improvement of the performances of some users has a slightly negative effect on the revenues for the users that are not improving (or improving less). In other words, in the base case, the offices are awarded for their relative importance in the configuration. Indeed, without any load shifting they are the only users with relevant load during the hour of PV production, and they are fundamental to obtain the incentive. When all the users shift their profiles, offices lose this relative importance, and their revenues are reduced. From the perspective of the condominium, the load shifting is extremely beneficial, and its revenues increase by 22.3%. It is important to point out that the load shifting has a positive result both for the overall revenues and for the payoff allocated to the condominium. In Figure 3, these revenues are represented in function of the load shifting percentages. It is possible to see that revenue increases in both the considered scenarios. If all the members are providing load shifting, the overall revenues of the configuration saturate to its maximum after a load shifting percentage equal to 40%. In this condition, the entire energy injected is collectively self-consumed and the incentive is fully obtained. For a higher load shifting percentage, the overall revenue is stable, while the condominium payoff slightly increases. This increment is obtained at a cost of a reduction of the payoff of the single members (see Figure 2b). This is another positive effect of the distribution rule that, when there is scarcity of production and abundance of load, stimulates the installation of new generators, increasing their reward. It is important to point out that the load shifting has a positive result both for the overall revenues and for the payoff allocated to the condominium. In Figure 3, these revenues are represented in function of the load shifting percentages. It is possible to see that revenue increases in both the considered scenarios. If all the members are providing load shifting, the overall revenues of the configuration saturate to its maximum after a load shifting percentage equal to 40%. In this condition, the entire energy injected is collectively self-consumed and the incentive is fully obtained. For a higher load shifting percentage, the overall revenue is stable, while the condominium payoff slightly increases. This increment is obtained at a cost of a reduction of the payoff of the single members (see Figure  2b). This is another positive effect of the distribution rule that, when there is scarcity of production and abundance of load, stimulates the installation of new generators, increasing their reward.

Conclusions
The article introduces a novel methodology to address the design and management of energy community initiatives. In particular, the work is focused on the Italian regulatory framework. Moving from a first step, where design and operation of energy assets are optimized to obtain the best cash flow for the condominium, revenues deriving from energy sharing in EC cases are distributed among the community's members exploiting a

Conclusions
The article introduces a novel methodology to address the design and management of energy community initiatives. In particular, the work is focused on the Italian regulatory framework. Moving from a first step, where design and operation of energy assets are optimized to obtain the best cash flow for the condominium, revenues deriving from energy sharing in EC cases are distributed among the community's members exploiting a solution based on the Shapley value. This approach assigns to each final user exactly the marginal added value of consuming electricity when local production is in excess.
The main evidence relates two different issues. First, electrification results in being a convenient option since it grants a cost saving linked to the heat pump replacing a natural gas-fired boiler, together with a greater opportunity to exploit the local electricity generation from the PV. Second, the use of Shapley value-based income distribution is effective in pushing final users to shift their electricity consumption in periods of high PV generation. This has a twofold positive consequence. On one hand, it reduces the impact of local overgeneration on distribution networks, thus increasing power system security and quality of service. On the other hand, it generates efficient behaviors from community members, that try to obtain higher revenues while increasing, at the same time, also the overall community incomes.
The reported results are valid for the considered case study, as in general the optimization applications are inherently case specific. However, the methodology is fully scalable and ready to be applied to larger and diversified case studies, to draw more general considerations, which is possibly sensible on a system level. Nevertheless, this will require the collection of data that are not readily available, for which a dedicated effort must be taken into account. Funding: This research was supported by the "Energynius-Energy networks integration for urban systems" project (CUP E31F18001040007), co-funded by Regione Emilia-Romagna through the European Regional Development Fund 2014-2020.