# Optimal Allocation of Agents among Collective Self-Consumption Communities

Youen Froger, Anthony Roy, Jean-Christophe Olivier, Salvy Bourguet, François Auger

► To cite this version:

Youen Froger, Anthony Roy, Jean-Christophe Olivier, Salvy Bourguet, François Auger. Optimal Allocation of Agents among Collective Self-Consumption Communities. 2025 IEEE Kiel PowerTech, Jun 2025, Kiel, Germany. 10.1109/PowerTech59965.2025.11180587. hal-05158464

HAL Id: hal-05158464

https://hal.science/hal-05158464v1

Submitted on 11 Jul 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Optimal Allocation of Agents among Collective Self-Consumption Communities

Youen Froger

Nantes Université, IREENA, UR 4642
Saint-Nazaire, France
youen.froger@etu.univ-nantes.fr

Anthony Roy

Nantes Université, IREENA, UR 4642
Saint-Nazaire, France
anthony.roy@univ-nantes.fr

Jean-Christophe Olivier

Nantes Université, IREENA, UR 4642
Saint-Nazaire, France
jean-christophe.olivier@univ-nantes.fr

Salvy Bourguet

Nantes Université, IREENA, UR 4642
Saint-Nazaire, France
salvy.bourguet@univ-nantes.fr

François Auger

Nantes Université, IREENA, UR 4642
Saint-Nazaire, France
francois.auger@univ-nantes.fr

**Abstract**—Progressive apparition of collective self-consumption communities leads to a yet-unanswered question: how to consider a community not only as a single entity, but as part of a bigger local ecosystem such as a neighbourhood or a city ? A first step in answering this question is to consider community design not from a single community's standpoint, but from a broader perspective, looking at which communities would be best to create in a local area context. This paper proposes an optimization-based approach for allocation of agents among potential Collective Self-Consumption communities, and compares two possible objective functions. The first is minimizing costs for all agents and the second is maximizing the savings for the agent with the least savings. The considered agent's trades are also optimally allocated as part of the optimization process, according to the same objectives. The proposed approach is applied to a fictitious case study. The results show that the second objective function leads to significantly lower savings for the whole group, while providing little or no savings to the least savings agent, compared to the results obtained with the first objective function. Finally, a lower bound for the maximum number of agents that can be allocated using this approach was measured, fixing 60 agents over a month of hourly energy data as a limit.

**Index Terms**—Collective Self-Consumption, energy community, optimal allocation, energy sharing, renewable energy.

## NOMENCLATURE

### Sets

$N_{set}$ Number of elements in set $set$. For instance, $N_A$ is the number of agents in A

A $\{a_i\}$ Set of the agents ($a_i$ is the i-th agent of the set)

C $\{c_j\}$ Set of the potential communities ($c_j$ is the j-th potential community of the set)

$A_{c_j}$ Set of the agents that could join $c_j$

$C_{a_i}$ Set of the communities that $a_i$ could join

T $\{t_k\}$ Time horizon ($t_k$ is the k-th time step)

### Energy

$E_{a_i}(c_j, t_k)$ Energy bought by $a_i$ to $c_j$ at time $t_k$ (negative values means sold to $c_j$)

$E_{a_i}(S, t_k)$ Energy bought by $a_i$ to its supplier $S$ at time $t_k$ (negative values means sold to $S$)

$E_{a_i}(\text{target}, t_k)$ Energy needs for $a_i$ at time $t_k$ (negative values means surplus). It is the energy $a_i$ aims to exchange

### Participation

Part$_{a_i}(c_j)$ Participation rate of $a_i$ to $c_j$

### Costs

$\Delta\text{Cost}_{a_i}(t_k)$ savings realized by $a_i$ due to its participation to a community

Cost$_{a_i}(t_k)$ Energy cost for $a_i$ at time $t_k$ (negative value means profit)

### Prices

$\pi_{C,b}$ Price at which agents buy their energy from their community

$\pi_{C,s}$ Price at which agents sell their energy to their community

$\pi_{S,b}(a_i)$ Price at which $a_i$ buys its energy from its supplier

$\pi_{S,s}(a_i)$ Price at which $a_i$ sells its energy to its supplier (purchaser of surplus)

## I. INTRODUCTION

Ongoing energy transition has raised new issues for electrical network management. These issues include, but are not limited to, congestion, intermittency, multiplication of energy actors making their coordination more difficult, flexibility requirement and citizen appropriation [1], [2], [3]. Part of these issues can be solved by decentralizing the energy management problem [2]. Local energy communities, in particular Collective Self-Consumption (CSC), are a way to decentralize energy management while involving citizens. A CSC community is a group of consumers and renewable energy producers that aims to self-consume locally-produced energy. A legal entity (usually a non-profit organisation) is in charge of the attribution of the locally produced energy. The CSC operations helps balancing locally produced energy and local consumption by rewarding participants consuming locally produced energy with lower energy costs.

<footnote>This work benefited from state aid managed by the Agence Nationale de la Recherche (ANR) under the "France 2030" programme, bearing the reference ANR-22-PETA-0009 (FlexTASE project, in the framework of PEPR TASE).</footnote>
Although energy community management has been extensively studied in literature [4], a gap remains regarding optimal community formation [5] and interactions of multiple communities in the same local area (Capper et al. [4] calls interactions between multiple communities in the same area "community-scale markets"). Having methods for optimal community formation would allow the study of optimal community size and would help in community design, especially when multiple communities will have to coexist in the same local area. These methods might be necessary if the community models were to become widespread or if a community expands beyond the size allowed by regulation. Moreover, studying groups formed using such methods could provide key factors linked to community efficiency, such as the diversity of its actors or the energy allocation rules. In this regard, Mariuzzo et al. [6] show that participation to multiple communities by some agents make them achieve better results.

Considering multiple communities at a time as well as their formation also enables to compare different objectives at different scales (agent scale, community scale and local area scale). In [5], Mustika et al. proposed a heuristic-based approach for the study of community extension. Bandara et al. [3] proposed a methodology for coalition formation through game theory. However, the formed coalitions change every five minutes, making them unsuitable for real CSC operations. Harighi et al. in [7] studied the impact that multiple communities could have on the power flow and costs, with users minimizing their costs, but did it in randomly allocated communities. As identified in the literature, a gap remains when it comes to optimal community formation [5].

The contributions of this paper are the following:

* A method for optimally allocating agents, as well as their trades, between several potential energy communities. A geographical criterion is considered to define these potential communities, based on French regulations for CSC communities.

* The formalization and comparison of two objective functions. One minimizing collective costs and another maximizing the lowest individual savings

This paper is organized as follows. The modelization of agents and potential energy communities is presented in Section II. Then, the optimization problem's formulation and the solving method are presented in Section III. The case study and results are presented in Section IV. Finally the approach and its limits are discussed in Section V.

## II. MODELING OF THE COMMUNITIES

### A. From potential to actual communities

The aim of this paper being to allocate agents among several potential energy communities, it is therefore necessary to explain what a potential community is. A potential community is a set of agents that could form a community together. All the agents that are in the same potential community are not bound to participate to that community, meaning that, after optimization, a formed community will not always be made

of all the agents that were in the potential community. A community is considered formed only if it contains at least two agents trading energy. It is therefore possible that some of the potential communities will not lead to an actual community after optimization.

### B. Assumptions

The approach proposed in this paper was carried out considering several assumptions. The agents have no means of flexibility (no battery and no shiftable production or consumption). Only the economic trades will be considered, regardless of the actual power flow. Indeed, CSC communities allocates their energy trades a posteriori, thus those trades do not necessarily represent the physical energy exchanges occurring in the system [8]. Only the energy surplus/deficit of each agent is considered and there is no explicit distinction between consumers, producers and prosumers, meaning that each agent can buy energy it needs at a time step and later sell his energy surplus.

The constituted communities are only administrative structures in charge of allocating the energy produced by their members. Formed communities' operation costs are not considered in this study. Exchanging energy through a community is always more advantageous for each agent due to lower taxation. There is no energy price fluctuation over the considered period, neither in selling prices nor in buying prices.

### C. Agents

Each agent $a_i$ is characterized by:

* a time series of the energy it needs to buy or to sell at each time sample $t_k$, $E_{a_i}(\text{target}, t_k)$,

* the price of the energy purchased from its supplier, $\pi_{S,b}(a_i)$,

* the price of the energy sold to the surplus buyer, $\pi_{S,s}(a_i)$,

* the set of potential communities it could join, $C_{a_i}$.

### D. Costs

The cost paid by an agent $a_i$ at each time step $t_k$ is calculated by

$$ \begin{aligned} \text{Cost}_{a_i}(t_k) = & \pi_{S,s}(a_i) \min(0, E_{a_i}(S, t_k)) \\ & + \pi_{S,b}(a_i) \max(0, E_{a_i}(S, t_k)) \\ & + \sum_{c_j \in C_{a_i}} \pi_{C,s} \min(0, E_{a_i}(c_j, t_k)) \\ & + \sum_{c_j \in C_{a_i}} \pi_{C,b} \max(0, E_{a_i}(c_j, t_k)) \end{aligned} \quad (1) $$

To calculate the savings due to the participation to a community, we subtract this value to the initial cost where all the energy was bought and sold to the supplier

$$ \begin{aligned} \Delta \text{Cost}_{a_i}(t_k) = & \pi_{S,s}(a_i) \min(0, E_{a_i}(\text{target}, t_k)) \\ & + \pi_{S,b}(a_i) \max(0, E_{a_i}(\text{target}, t_k)) \\ & - \text{Cost}_{a_i}(t_k) \end{aligned} \quad (2) $$
### III. FORMALIZATION OF THE OPTIMIZATION PROBLEM

To optimally allocate agents as well as their energy exchanges (according to objectives functions defined in III-B), a MILP (Mixed-Integer Linear Programming) optimization problem has to be formalized and solved. The rest of the section is dedicated to the formulation of the optimization problem.

#### A. Decision variables

The decision variables are:

* $E_{a_i}(S, t_k)$, the energy each agent exchanges with its supplier or surplus buyer S for each time step $t_k$,

* $E_{a_i}(c_j, t_k)$, the energy each agent exchanges with the potential community $c_j$ it could join for each time step $t_k$,

* $\text{Part}_{a_i}(c_j)$, an integer variable, representing the participation rate of the agent $a_i$ to the potential community $c_j$ ($\text{Part}_{a_i}(c_j) = 1$ means it participates and $\text{Part}_{a_i}(c_j) = 0$ means it doesn't). In practice, $\text{Part}_{a_i}(c_j)$ acts as an upper bound for the energy exchanged with a community. Since this paper aims to allocate agents between multiple communities and since agents can only be in one community at a time, this variable is a binary variable.

#### B. Objective functions

Two objective functions are considered in this paper:

* minimization of $f_1$, the sum of economical costs paid by all agents:

$$f_1 = \sum_{a_i \in A} \sum_{t_k \in T} \text{Cost}_{a_i}(t_k) \quad (3)$$

* maximization of $f_2$, the savings due to community participation for the agent that have the least savings:

$$f_2 = \min_{a_i \in A} \sum_{t_k \in T} \Delta \text{Cost}_{a_i}(t_k) \quad (4)$$

#### C. Constraints

The optimization problem is subject to the following constraints:

* The agent must buy all the energy it needs from either a supplier or a community and sell all its surplus:

$$\begin{gathered} \forall a_i \in A, \forall t_k \in T, \\ E_{a_i}(\text{target}, t_k) - E_{a_i}(S, t_k) - \sum_{c_j \in C_{a_i}} E_{a_j}(c_j, t_k) = 0 \quad (5) \end{gathered}$$

* The participation of an agent to a potential community cannot be negative and cannot exceed 100%:

$$\forall a_i \in A, \forall c_j \in C_{a_i}, 0 \le \text{Part}_{a_i}(c_j) \le 1 \quad (6)$$

Hence, as $\text{Part}_{a_i}(c_j)$ is an integer variable, it can only take two values: 0 and 1.

* An agent can only participate in one community:

$$\forall a_i \in A, 0 \le \sum_{c_j \in C_{a_i}} \text{Part}_{a_i}(c_j) \le 1 \quad (7)$$

* An agent cannot exchange more energy with a community than its participation in said community allows it to:

$$\begin{gathered} \forall a_i \in A, \forall c_j \in C_{a_i}, \forall t_k \in T, \\ |E_{a_i}(c_j, t_k)| \le \text{Part}_{a_i}(c_j) |E_{a_i}(\text{target}, t_k)| \quad (8) \end{gathered}$$

* An agent cannot exchange more energy with the supplier than its needs:

$$\begin{gathered} \forall a_i \in A, \forall c_j \in C_{a_i}, \forall t_k \in T, \\ |E_{a_i}(S, t_k)| \le |E_{a_i}(\text{target}, t_k)| \quad (9) \end{gathered}$$

* A community cannot store or produce energy, meaning all the energy that it buys must be sold and all the energy that it sells must be bought:

$$\begin{gathered} \forall c_j \in C_{a_i}, \forall t_k \in T, \\ \sum_{A_i} E_{a_i}(c_j, t_k) = 0 \quad (10) \end{gathered}$$

* An agent cannot buy energy from a community to sell it to its supplier, and it cannot buy energy from a supplier to sell it to a community. Hence, $E_{a_i}(\text{target}, t_k)$, $E_{a_i}(c_j, t_k)$ and $E_{a_i}(S, t_k)$ must have the same sign.

### IV. APPLICATION TO A CASE STUDY AND RESULTS

#### A. Case study

<figure><img src="image_2.png" /><figcaption>Fig. 1. Positions of the agents and the potential communities in the considered case study.</figcaption></figure>

The fictitious case study considered in this article is made of three types of agents, to ensure diversity in energy profiles and costs: producers (to provide energy to the communities), residential consumers (to have low consumers) and professional consumers (to have heavy consumers). The method used to define potential communities is a geographical one. They are centered on each producer and each potential community includes all agents that are no further than one kilometer away from the producer. It should be noted that this method to construct potential communities was chosen for the sake of readability, as this paper focuses on the methodology to allocate consumers between the potential communities and not on the way to construct them. This limits the amount of
potential communities to be considered. This is necessary as the amount of potential communities that could be constituted is upper-bounded by

$$ \sum_{k=1}^{N_a} \binom{N_a}{k} = 2^{N_a} - 1 \quad (11) $$

The power profiles considered for the agents are taken from three databases: ELMAS [9] for professional consumers, EtudElec [10] for residential consumers and Sundance [11] for solar production. The profiles used are based on one day of hourly data. For each of these databases, profiles were randomly selected (5 producers, 16 residential consumers and 3 professional consumers). A scaling factor has been applied to the production so that it is on average equal to the demand over the time horizon. To generate the geographic distribution, the agents were randomly placed on a 2 km by 2 km grid. Distributions where each agent could not be in at least one community were dropped. The generated agents are located according to Fig.1. The potential communities are represented by circles. The selected agents features are summarized in Tab. I and in Fig. 2. Supplier prices are assigned by category, with values given in Tab. II. Community prices are the same for all agents, considering $\pi_{C,b} = 0.21 \, \euro/kWh$ and $\pi_{C,s} = 0.20 \, \euro/kWh$. It should be noted that only the order in which prices are ordered really matters for the optimization results.

<table><caption>TABLE I
AGENT CHARACTERISTICS</caption><thead><tr><th>id</th><th>name in the database</th><th>category</th><th>total energy (kWh)</th></tr></thead><tbody><tr><td>0</td><td>SD_100703</td><td>Producer</td><td>-1479</td></tr><tr><td>1</td><td>SD_1002705</td><td>Producer</td><td>-1003</td></tr><tr><td>2</td><td>SD_1001554</td><td>Producer</td><td>-886</td></tr><tr><td>3</td><td>SD_100704</td><td>Producer</td><td>-861</td></tr><tr><td>4</td><td>SD_1002705</td><td>Producer</td><td>-2393</td></tr><tr><td>5</td><td>EE_district_heating_apartment</td><td>Consumer res.</td><td>4</td></tr><tr><td>6</td><td>EE_fuel-oil_apartment</td><td>Consumer res.</td><td>6</td></tr><tr><td>7</td><td>EE_fuel-oil_apartment</td><td>Consumer res.</td><td>6</td></tr><tr><td>8</td><td>EE_district_heating_apartment</td><td>Consumer res.</td><td>2</td></tr><tr><td>9</td><td>EE heat-pump_apartment</td><td>Consumer res.</td><td>6</td></tr><tr><td>10</td><td>EE_otherraj_hu</td><td>Consumer res.</td><td>15</td></tr><tr><td>11</td><td>EE_gas_apartment</td><td>Consumer res.</td><td>5</td></tr><tr><td>12</td><td>EE-electricity_apartment</td><td>Consumer res.</td><td>7</td></tr><tr><td>13</td><td>EE-wood-pellets_hu</td><td>Consumer res.</td><td>13</td></tr><tr><td>14</td><td>EE_district_heating_apartment</td><td>Consumer res.</td><td>4</td></tr><tr><td>15</td><td>EE-electricity_hu</td><td>Consumer res.</td><td>15</td></tr><tr><td>16</td><td>EE_fuel-oil_hu</td><td>Consumer res.</td><td>4</td></tr><tr><td>17</td><td>EE_district_heating_apartment</td><td>Consumer res.</td><td>4</td></tr><tr><td>18</td><td>EE_otherraj_hu</td><td>Consumer res.</td><td>9</td></tr><tr><td>19</td><td>EE_district_heating_apartment</td><td>Consumer res.</td><td>4</td></tr><tr><td>20</td><td>EE_gas_apartment</td><td>Consumer res.</td><td>2</td></tr><tr><td>21</td><td>ELMAS_8</td><td>Consumer pro.</td><td>2607</td></tr><tr><td>22</td><td>ELMAS_4</td><td>Consumer pro.</td><td>2091</td></tr><tr><td>23</td><td>ELMAS_2</td><td>Consumer pro.</td><td>1810</td></tr></tbody></table>

## B. Results

The proposed MILP problem was solved using Python and the HIGHS solver [12] through the scipy.optimize.milp library.

<table><caption>TABLE II
PRICE DISTRIBUTION FOR ALL $a_i$</caption><thead><tr><th>category</th><th>π<sub>S,s</sub>(a<sub>i</sub>) (€/kWh)</th><th>π<sub>S,b</sub>(a<sub>i</sub>) (€/kWh)</th></tr></thead><tbody><tr><td>Producer</td><td>0.1024</td><td>0.2516</td></tr><tr><td>Consumer res.</td><td>0.1024</td><td>0.2516</td></tr><tr><td>Consumer pro.</td><td>0.1124</td><td>0.2406</td></tr></tbody></table>

<figure><img src="image_3.png" /><figcaption>Fig. 2. Production and consumption energy time series (abs($E_{a_i}(\text{target}, t_k)$), grouped by category (top: producer, middle: residential consumers, bottom: professional consumers)</figcaption></figure>

The agents were successfully allocated between the communities that were constituted according to both objectives. Fig. 3 and Fig. 5 are maps representing which agent groupings have been made. In these figures, the agents connected by the same color belongs to the same community, respectively for objectives $f_1$ and $f_2$. Energy exchanges are summarized in Fig. 4 and 6, respectively for objectives $f_1$ and $f_2$. A summary of the results according to both objectives is given in Tab. III.

The optimal communities differ based on the chosen objective. With $f_1$ as an objective (minimization of total cost paid by agents), there are 3 agents who do not participate to any community and only two communities are constituted. All the producers are included. Indeed, for this objective, only the amount of energy exchanged and the price at which it is exchanged matter. It should be noted that if it were possible to form a single community with all agents, then this solution would be optimal as it allows all agents to trade within the community. However, unfair energy distribution (for instance giving more energy to the professional consumers, while ignoring residential consumers) is bound to happen, as no fairness criteria is part of the objective. In the studied case, professional consumers have lower per-Wh costs than

<table><caption>TABLE III
SUMMARY OF THE RESULTS</caption><thead><tr><th>Objective</th><th>f<sub>1</sub> (€) ↓</th><th>f<sub>2</sub> (€) ↑</th><th>total savings (€) ↑</th><th>Gini coef ↓</th><th>computation time (ms) ↓</th></tr></thead><tbody><tr><td>min f<sub>1</sub></td><td>453</td><td>0</td><td>462</td><td>0.23</td><td>974</td></tr><tr><td>max f<sub>2</sub></td><td>573</td><td>0.12</td><td>343</td><td>0.15</td><td>452</td></tr></tbody></table>
<figure><img src="image_4.png" /><figcaption>Fig. 3. Constituted communities using objective function $f_1$.</figcaption></figure>

<figure><img src="image_5.png" /><figcaption>Fig. 4. Energy exchanged with communities and supplier for each agent when using objective function $f_1$.</figcaption></figure>

residential consumers. Therefore, professional consumers get-
ting energy represents lower global cost reduction per-Wh,
hence prioritizing energy attribution to residential consumers
if possible, thus mitigating partly this unfair distribution. The
main takeover is that, when taking $f_1$ minimization as an
objective, the price distribution is an important factor for the
energy distribution.

With $f_2$ as an objective (maximization of the agent with
the least savings), all agents are bound to participate to a
community. Indeed, if an agent was to not participate to
any community, it's savings would be 0, making $f_2$ to be
0. Hence, if an agent can't trade with any community, all
allocations would be optimal $f_2$-wise. Hence, when using $f_2$
as an objective, it's important to ensure that all agents are in
at least one potential community including a supplier.

In the studied case, this prevents from not including the
three left agents, therefore preventing from forming the large
orange community $C_2$ (see Fig. 3). This community enables
the producers to sell their energy to the large consumer agent
$A_{23}$ in $f_1$ objective. Its absence causes producers to sell more
energy to the supplier.

V. DISCUSSION AND LIMITS

According to Tab. III, the Gini [13] coefficients show that maximizing $f_2$ significantly reduced inequalities, even though it penalized a lot professional consumers to allow only a small saving (0.12€) for the smallest agents (residential), compared to minimizing $f_1$. This is caused by the diversity of the considered agents, including big consumers (professional

<figure><img src="image_6.png" /><figcaption>Fig. 5. Constituted communities using objective function $f_2$.</figcaption></figure>

<figure><img src="image_7.png" /><figcaption>Fig. 6. Energy exchanged with communities and supplier for each agent when using objective function $f_2$.</figcaption></figure>

as well as small consumers(residential). It should be noted
that even optimizing the energy exchanges of the $f_2$-generated
communities with $f_1$ didn't increase total savings. Therefore
the drop in total savings is due to the formed communities and
not only to the savings above the ones made by the smallest
saving agent not contributing to $f_2$.

The smallest savings are achieved by $A_7$ (bottom-right agent of $C_3$). Thus other communities do not contribute to $f_2$, as long as all their agents achieve greater savings than $A_7$. Hence, it may be possible to achieve greater savings by changing the generated communities. An example of such changes would be merging $C_1$ and $C_2$, allowing 20€ of further total savings without changing $f_2$'s value.

If an agent only needs a small amount of energy for $f_2$, or
production and consumption are very different for objective $f_1$,
this leads to a wide variety of optimal solutions. A potential
way to distinguish between solutions would be to have an
objective composed of a weighted sum of $f_1$ and $f_2$, with a
low weight attributed to one of the two objectives.

The approach proposed in this paper also allows to allocate
agents in multiple communities. This can be done in two
distinct ways :

* Allowing agents to participate to all their potential communities at once, limiting the amount of energy they can get from each one by relaxing the constraint forcing $\text{Part}_{a_i}(c_j)$ to be an integer. $\text{Part}_{a_i}(c_j)$ is then the upper bound to the proportion of the energy that agent $a_i$ can exchange with the community $c_j$.
* Allowing agents joining entirely multiple communities by changing the upper bound in (7). This value is then the amount of communities each agent can join and could be defined per-agent, making it possible to only allow multiple participation to some strategic agents.

While the proposed approach guarantees an optimal solution to the problem given the objective function, the memory complexity of this approach ($O(N_A N_C N_T)$) decision variables and $O(N_A N_C N_T)$ constraints) makes it unsuitable for bigger problems. Indeed, for each day count, a dichotomy method was used to find the largest $N_A$ for which the problem could be solved without failure due to low memory. The results are summarized in Fig. 7. The formulated problem differed slightly as there were 30 % producers and 70 % consumers, and all agents could be the center of a potential community. This makes the measured largest $N_A$ (agent count) more pessimistic than the case that is treated in this paper, as more potential communities are added to the case, hence increasing the memory cost. However the same kind of measures could be made with cases studies similar to the paper's, and the figure would have the same shape, only offseted by an amount of agents.

These computations were realized on a computer with 15 GiB of RAM + 1 GiB of Swap, making a total of 16 GiB of working memory. Working memory was always the limiting factor, as the longest computation time recorded while making Fig. 7 was 45 minutes on a single thread of a i9-13900. Swap's access time is significantly slower, so we believe that a major part of those 45 minutes was spent accessing this memory. As this time is not prohibitive and should be faster if not using swap, time was not a factor in deciding the maximum agents that can be solved.

<figure><img src="image_8.png" /><figcaption>Fig. 7. Lower bound of the largest $N_A$ for each $N_T$.</figcaption></figure>

## VI. CONCLUSION

In this paper, a methodology was proposed for the optimal allocation of different agents into several communities. Two objective functions were proposed and compared. As part of the optimization process, the agents' energy exchanges has been optimally allocated. The comparison of both objective functions showed that in a highly diverse set of agents, taking the smallest agent into account can highly degrade the group's results.

The proposed methodology can be applied to relatively small-scale problems. The limit, considering each agent as a center of a potential community, is 60 agents among 60 communities over 30 days (on a 16 GiB of RAM computer).

To further improve the allocation, future work could take flexibility into account. The flexibility, such as demand-side management or addition of batteries, wasn't taken into account in this paper as it would increase the complexity of the optimization problem, thus the computation time. Therefore, to consider flexibility in the optimization problem whilst avoiding impacting the amount of agents that could be considered, another approach would be necessary. Further work could also include design approaches for larger scale problems and investment allocation.

## REFERENCES

[1] IEA and RTE. *Conditions and Requirements for the Technical Feasibility of a Power System with a High Share of Renewables in France Towards 2050*. OECD, 2021. DOI: 10.1787/6be9f3ac-en.

[2] B. Thomas et al. "GPU Optimisation of an Endogenous Peer-to-Peer Market with Product Differentiation". *IEEE Belgrade PowerTech*. 2023, pp. 01–07. DOI: 10.1109/PowerTech55446.2023.10202823.

[3] K. Y. Bandara, S. Thakur, and J. Breslin. "Renewable Energy Integration through Coalition Formation for P2P Energy Trading". *IEEE 3rd International Conference on Renewable Energy and Power Engineering (REPE)*. 2020, pp. 56–60. DOI: 10.1109/REPE50851.2020.9253870.

[4] T. Capper et al. "Peer-to-peer, community self-consumption, and transactive energy: A systematic literature review of local energy market models". *Renewable and Sustainable Energy Reviews* 162 (2022), p. 112403. DOI: https://doi.org/10.1016/j.rser.2022.112403.

[5] A. D. Mustika et al. "New Members Selection for the Expansion of Energy Communities". *Sustainability* 14.18 (2022). DOI: 10.3390/su141811257.

[6] I. Mariuzzo et al. "Economic assessment of multiple energy community participation". *Applied Energy* 353 (2024). DOI: https://doi.org/10.1016/j.apenergy.2023.122060.

[7] T. Harighi et al. "Optimization Model for the Analysis of Multiple Energy Communities in the Same Distribution Network with Different Providers". *IEEE Belgrade PowerTech*. 2023, pp. 1–6. DOI: 10.1109/PowerTech55446.2023.10202985.

[8] A. Roy et al. "A comparison of energy allocation rules for a collective self-consumption operation in an industrial multi-energy microgrid". *Journal of Cleaner Production* 389 (2023), p. 136001. DOI: 10.1016/j.jclepro.2023.136001.

[9] K. Bellinguer et al. *ELMAS dataset*. 2023. DOI: 10.6084/m9.fishshare.23889780.v1.

[10] S. Osonuga et al. *EtudELEC Data, aggregated electricity consumption data from 400+ residential customers in France*. Recherche Data Gouv, 2024. DOI: 10.57745/WIWMMK.

[11] D. Chen and D. Irwin. "SunDance: Black-box Behind-the-Meter Solar Disaggregation". *Proceedings of the Eighth International Conference on Future Energy Systems*. e-Energy '17. Shatin, Hong Kong: Association for Computing Machinery, 2017, pp. 45–55. DOI: 10.1145/3077839.3077848.

[12] Q. Huangfu and J. J. Hall. "Parallelizing the dual revised simplex method". *Mathematical Programming Computation* 10.1 (2018), pp. 119–142. DOI: 10.1007/s12532-017-0130-5.

[13] R. Dorfman. "A Formula for the Gini Coefficient". *The Review of Economics and Statistics* 61.1 (1979), pp. 146–149. DOI: 10.2307/1924845.