Prosumer Community Portfolio Optimization via Aggregator: The Case of the Iberian Electricity Market and Portuguese Retail Market

: The participation of household prosumers in wholesale electricity markets is very limited, considering the minimum participation limit imposed by most market participation rules. The generation capacity of households has been increasing since the installation of distributed generation from renewable sources in their facilities brings advantages for themselves and the system. Due to the growth of self-consumption, network operators have been putting aside the purchase of electricity from households, and there has been a reduction in the price of these transactions. This paper proposes an innovative model that uses the aggregation of households to reach the minimum limits of electricity volume needed to participate in the wholesale market. In this way, the Aggregator represents the community of households in market sales and purchases. An electricity transactions portfolio optimization model is proposed to enable the Aggregator reaching the decisions on which markets to participate to maximize the market negotiation outcomes, considering the day-ahead market, intra-day market, and retail market. A case study is presented, considering the Iberian wholesale electricity market and the Portuguese retail market. A community of 50 prosumers equipped with photovoltaic generators and individual storage systems is used to carry out the experiments. A cost reduction of 6–11% is achieved when the community of households buys and sells electricity in the wholesale market through the Aggregator.


Introduction
Considering the targets imposed by the European Commission [1] about greenhouse gas emission reductions, the installation of distributed generators (DG) based on renewable energy sources (RES) can make a positive contribution to the cause. The successful implementation of national energy policies can contribute also for a global economic growth (one average of 3.4% by 2040) [2]. DG based on RES includes small-scale generation units connected essentiality to distribution grids in low or medium voltage. They can provide challenges and opportunities to the users and participants of the distribution system (utilities, end-users, operators, and retailers) [3]. The use of distributed energy resources (DER) based on RES or non-RES from the costumers side, can improve local dependability, and reduce costs with energy supply [4], from the grid side can minimize the operation costs [5] or help to avoid some expensive investments in planning actions [6]. Due to the price reduction of photovoltaic (PV) systems, the global installed capacity increased from 23 GW and flexibility). Another relevant issue of this work is its application in a real setting, like in [18]. References [25][26][27] presented the wholesale market's participation in the Electricity Iberian Market (Mibel) as also presented in this work. The presented paper compared with [26,27] describes an innovation, which considers the day-ahead spot market and the intraday sessions. Ref. [25] uses a non-deterministic resolution to solve the problem, which can compromise the results and provoke losses for the user. The model proposed in the current paper solves this problem using a deterministic method that guarantees the optimal global best result. Aggregators' activities in the electricity system and electricity markets have been widely explored, showing positive results in theoretical applications but also real simulations. The study [28] concludes that more guidance is needed for convergence on a more harmonized approach.
Considering this study's aim, the Aggregator represents the market's facilitator (enunciated by Portuguese legislation), finding the best opportunity to export the surplus electricity. This paper offers an optimization model to minimize the energy costs of an energy community, considering the possibility of buying or selling electricity in the wholesale electricity market via an Aggregator. The model also allows the management of PVbattery systems to take the most advantages of them. Figure 1 presents a scheme of the proposed approach. As can be seen in Figure 1 the proposed approach considers an energy community, a retailer and wholesale electricity market, an Aggregator, and the main grid. Prosumers constitute the energy community, and each of them can be equipped with PV panels and storage units. Prosumers can purchase electricity in the retail market and wholesale market, and also sell its electricity to the main grid and, also in the wholesale market. To participate in the wholesale market, a minimum quantity of participation is needed, to overcome this issue, an Aggregator represents the energy community in the wholesale market. The Aggregator's business is to buy and sell electricity in the wholesale market, receiving each prosumer's fee. As main contributions of this work, the following aspects are highlighted:

•
An optimization model that jointly solves the minimization of the operating costs (energy usage) of an energy community and the optimal participation of an Aggregator in the Spot market and intraday sessions. • A real scenario (prices and condition of participation) is modeled considering the Portuguese retail market and MIBEL wholesale electricity market.
• A thorough analysis of different case studies, demonstrating interesting insights on the importance of Aggregator participating in the wholesale electricity market. • A consumer-centric approach that can bring empowerment of small electricity endusers in the power systems.
The rest of the paper is organized into five different sections. Section 2 presents the participation conditions in the MIBEL wholesale market and Portuguese distributed generation installation options. The mathematical formulation of the model is explained in Section 3. In Section 4, the case studies and respective characterization are presented. The achieved results using the proposed model in the case studies are presented in Section 5. Finally, conclusions and future works are drawn in Section 6.

Legal Framework
This section presents the legal framework to participate in the wholesale market and rules imposed by the Portuguese legislation to install distributed generation in endconsumers facilities.

MIBEL Operation
As most wholesale electricity markets in Europe, MIBEL is divided into day-ahead and intraday sessions. MIBEL also has a particularity for trading electricity in future markets. The asset (electricity) may not require physical delivery, and the negotiation is considered for a later date.
Considering the day-ahead spot market, the players should submit their bids until the gate close (12:00 of day d), after that they cannot modify their bids. Two different types of bids are available, one from the demand side and the other from the generation side, each of these types of bids is comprised of a price and energy volume for a specific hour. The equilibrium between the demand curve and generation curves determines the price and the volume transacted in each hour of the day ahead spot market. Figure 2 presents the negotiation options in the MIBEL market. The day-ahead spot market is available for 24 h. The MIBEL market option in intraday has six different sessions, represented in Figure 2. The intraday sessions have the same day-ahead operation mode, but the bids process submissions have different times. In the six different sessions, presented in the Figure 2, the agents can adjust their generation and consumption schedules to adapt to the new forecasts or unpredicted events.
The MIBEL wholesale market contains two different operators, the OMIE and OMIP. OMIE represents the market operator for the management of day-ahead and intraday electricity markets of the Iberian Peninsula. OMIP corresponds to the market operator for the derivatives exchange energy market, namely, futures, forwards, swap and options. The stock associated with these contracts is electricity and natural gas. In the MIBEL market, only physical agents located in Portugal and Spain can participate. Due to the physical restrictions of interconnection between the two countries, there may be a separation from the wholesale market, and each country can have a different electricity price.

Distributed Generation in Portugal
According to the Decreto-Lei n.º153/2014, 2014 [14] (Portuguese regulation) there are two types of distributed generation in consumers facilities the UPP (Portuguese acronym for units of small generation) and UPAC (Portuguese acronym for units of small generation for self-consumption). UPP facilities are dedicated to electricity generation from renewable sources using only one generation technology, where the connection to the main grid is equal to or less than 250 kW. All the electricity generated must be sold in full to the main grid, but must be equal to or less than 50% of the consumer's electricity consumption. Figure 3 presents typical UPP connection schemes.   Figure 3b has two meters, but one of them is only for production, the other is bidirectional and allows the power flow in both directions. Three different categories of UPP are available. Category I consists of producers that install a small generation unit, category II comprises producers with a small generation unit and an electric vehicle charging station, and category III represents producers with a small generation unit and solar thermal accumulator. Portaria n.º 80/2020 [10] defines 45 EUR/MW (0.045 EUR/kW) as the reference tariff that corresponds to the payment that producers receive from each unit of electricity exported to the grid.
UPAC is defined as being electricity generation facilities from renewable and nonrenewable sources used primarily for self-consumption, with the possibility of connection to the grid for sale. The surplus energy from self-consumption can be traded in the wholesale market with the help of an Aggregator. Figure 4 presents typical UPAC connection schemes.
In Figure 4a there are two different meters, and the generation power installed is greater than 1.5 kW. When the generation power installed is equal to or less than 1.5 kW the facility only needs a single meter as seen in Figure 4b where there is no possibility of exporting electricity to the grid.

Model Overview
The proposed model considers an energy community that intends to minimize the costs of electricity usage, and able community members to buy and sell electricity in different markets. The model considers the Aggregator operation, which is responsible for representing the energy community in the wholesale market (day-ahead and intraday sessions) and also for determining the best scheduling the usage of the battery storage system installed in each household. The retail market is used by households as a backup where they can purchase electricity when needed, or when wholesale market participation is not advantageous. The public network is responsible for absorbing the feed-in electricity provided by each household when the Aggregator cannot sell in the wholesale market.
The considered wholesale market refers to the MIBEL operator which is divided into day-ahead and 6 intraday sessions. The Aggregator is responsible for complying with the rules imposed for participation in the wholesale market. The presented model considers that a minimum value of electricity is required to participle in the wholesale market, according to MIBEL participation rules. For the energy community in the study, the minimum can be reduced. The Aggregator has other methods to obtain more electricity for participation when it is required. The rule imposed by the market operator regarding the participation in intraday sessions is only valid if the participation in the wholesale market, is not considered in this model, however, the Aggregator has to comply with this rule.

Formulation
Equation (1) presents the objective function of the problem. The objective function minimizes the sum of the total operating costs of all energy community members.
where, SM costs represents the spot market costs, IDS costs represents the intraday sessions costs, R costs represents the retailer's costs and AGG income represents Aggregator income. Equation (2) presents the calculation of the cost for the spot market.
where, p SM buy i,t represents the electricity purchased in the spot market, p SM sell i,t represents the electricity sold in the spot market, π SM i,t corresponds to the price of electricity in the spot market, i is the respective player, t the respective period, Ni the numbers of players, and Nt the numbers of periods. Only one option of sell or buy can be applied at the same time. Equation (3) presents the calculation of the costs in intraday sessions.
where, p IDS buy i,t,s represents the electricity purchased in intraday sessions, p ISD sell i,t,s represents the electricity sold in the intraday session, π IDS i,t,s corresponds to the price of electricity in intraday session, s is the respective session and Ns represents the number of intraday sessions. Equation (4) presents the costs in the retailer market.
represents the electricity purchased in the retail market, π TOU i,t is the price of purchased electricity denominated as time of use tariff, p Grid sell i,t represents the electricity sells in the grid, π FIT i,t is the price of selling electricity to the grid denominated the feed-in tariff and FixedCosts i represents the fixed costs that users should pay to retailers for the supply guarantees. Equation (5) presents the Aggregator income calculation.
where, Fee AGG represents the fee in EUR per Kilowatt that the Aggregator charges for the aggregated user participation in the spot market and intraday sessions. Equation (6) presents the balanced equation for each user.
where, p gen i,t represents the electricity generated, p dch i,t represents the electricity discharged from the battery, p load i,t represents the load of each end-user, and p ch i,t is the electricity that charges the battery. Equations (7)-(9) represent the constraints applied to the spot market for each user. p where, x SM buy i,t represents a binary variable for the individual spot market buy action, p SM max buy i,t represent the maximum individual limit for each user to buy electricity in the spot market, x SM sell i,t represents a binary variable for the individual spot market sell action and p SM max sell i,t represents the maximum individual limit for each user sell electricity in the spot market. Equation (9) imposes that it is only possible to buy or sell in the spot market. Equations (10) and (11) represent global constraints for participation in the spot market.
where, L SM buy represents the minimum amount of electricity necessary to purchase electricity in the spot market, X SM buy t represents the global binary variable to participate in the spot market, L SM sell represents the minimum amount of electricity necessary to sell electricity in the spot market and X SM sell t represents the global binary variable to participate in the spot market. Equations (10) and (11) allows that when each binary variable X SM buy t and X SM sell t is active, the minimum amount should be respected. In the other case, the constraint is also satisfied. Equations (12)-(14) represent the constraints applied to the intraday sessions for each user.
where, x IDS buy i,t,s represent the binary variable for the individual intraday session buy action, p IDS max buy i,t,s represents the maximum electricity amount limit to buy in intraday sessions, A IDS t,s is an input binary parameter that indicates the availability of each intraday session, x IDS sell i,t,s represent the binary variable for the individual intraday session sell action and p IDS max sell i,t,s represents the maximum electricity amount limit to sell in intraday sessions. Equation (14) imposes that it is only possible to buy or sell in the intraday session. Equations (15)-(18) represent global constraints for participation in intraday sessions.
where, L IDS buy s represents the minimum amount of electricity needed to purchase electricity in intraday sessions, X IDS buy t,s represents the global binary variable to participate in the intraday session to purchase electricity, L IDS sell s represents the minimum amount of electricity necessary to sell in intraday sessions, X IDS sell t,s represents the global binary variable to participate to sell in the intraday session. Equations (15) and (16) performs the same process of Equations (10) and (11). Equations (17) and (18) where, x R buy i,t represents the individual variable for the retailer by action, p R max buy i,t represents the maximum limit to purchase electricity from a retailer, x Grid sell i,t represents the individual variable to sell electricity in the grid, p Grid max sell i,t represents the maximum quantity to sell electricity in the grid. Equation (21) imposes that it is only possible to buy in the retail market or sell to the grid. Equation (22) represents the constraints applied to buying and selling electricity in different markets in the same period.
x SM buy i,t x SM buy i,t Equation (28) represents the energy storage system balance.
where, p Bat i,t represents the status of the battery, η ch i represents the efficiency of a charge action, and η dch i represents the efficiency of the discharge action. Equations (29)-(31) present constraints applied to the battery charge and discharge actions.
where, p ch max i,t represents the maximum value for charge action, x ch i,t represents the binary variable for the charge action, p dch max i,t represents the maximum value for the discharge action and x dch i,t represents the binary variable for the discharge action. Equation (31) presents the constraints applied to control the charge and discharge of the batteries in the same period, Equations (32)-(40) present the limits for the continuous variables of the problem.
where, p Bat min i,t represents the minimum possible limit for the battery level and p Bat max i,t represents the maximum possible limit for the battery level. Equations (41)-(52) represent the minimum and maximum limit for the binary variables.

Case Study
Three different case studies are created to evaluate the application of the proposed model. The objective is to compare the market participation results of prosumers when considering an all-encompassing approach (case study 1 (CS1)) that includes the market opportunities for an installation without considering the rules imposed to both UPP and UPAC, the UPP-case study 2 (CS2)) and UPAC-case study 3 (CS3), according to the Portuguese regulation; and. Table 1 presents an overview of the considered case studies. As seen in Table 1 the case studies are CS1, CS2, and CS3, in all case study two different scenarios are implemented, one considering the normal operation without the possibility of trading electricity in the wholesale market (basis approach), and one considering the use of an Aggregator to trade electricity in the wholesale market (proposed approach). The UPP and UPAC case studies comply with the Portuguese legislation in both scenarios (basis and proposed approach). Thereby, in total, six different scenarios are simulated.
The all-encompassing case (CS1) considers the formulation presented in Section 3.2, in which there are no restrictions related to UPP or UPAC for trading electricity. The specificities of UPP (CS2) and UPAC (CS3) conditions require some modifications in the formulation, as follows.
Equation (53) is very similar to Equation (6), but as UPP must inject into the grid all generated electricity the power generated p gen i,t and p Grid sell i,t don't take part of the energy balance. Equation (54) imposes the condition that all electricity generated should be injected into the grid. p gen i,t = p Grid sell In the case of UPAC (CS3) the electricity should be used for self-consumption or can be sold in a wholesale market considering an aggregated entity. Equation (55) replaces Equation (6) of the generic formulation. An energy community with 50 prosumers is considered in the case study. It is important to note that the minimum amount required to participate in the MIBEL market has been reduced to 200 kW, as the legally required amount of 1000 kW (1 MW) would be impossible to obtain with the 50 prosumers. Figure 5 presents the accumulated consumption and generation of total energy community members, the values are randomly generated using the database used in [29]. The total consumption for the referred periods is 2145.59 kWh per day, which corresponds to an average of 89 kWh per hour. The energy community has installed 261 kWp of PV generations and is generated 1556.59 kWh per day in the 24 periods, an average of 64 kWh per hour. It was verified two different peaks of consumption, in the morning (09:00 h) and the afternoon (17:00 h). Figure 6 presents the electricity prices used in the simulations.  Figure 6a presents the retailer's electricity price provided by the EDP retailer and the export grid price considering the Portuguese legislation. A bi-horary tariff with two different periods and days is used, the period off-peak (23.00 to 08.00) and peak (09.00 to 22.00). Figure 6b presents the wholesale market price for the spot market and in the six intraday sessions, corresponding to real prices of September 01 of 2020 obtained with online access to the OMIE website [30]. In the wholesale market, the price has high variability. Figure 7 presents contracted power and battery characteristics used by the prosumers. Figure 7a presents the contracted power limits for the community member, the contracted power limits are established by the retailer and selected by the consumers. The community members use five different contracting powers. Export power limits correspond to the limit available to inject electricity into the grid. This limit also available in Figure 7a is imposed by Portuguese legislation [10] and corresponds to half of the contracted power. Figure 7b presents the batteries' characteristics and represents the battery capacity and charge/discharge capacity. Five different batteries are used in the case study and were randomly distributed among community members, the efficiency of charge and discharge actions is considered 90%.

Results
This section presented the results of the proposed methodology. The simulations were carried out on a computer with an Intel Xeon(R) E5-2620v2@2.1 GHz processor with 16 GB of RAM running Windows 10. To implement the optimization problem, a MATLAB2018a with TOMLAB optimization toolbox is used. CPLEX is the solver used to optimize the problem. Six different variants are constructed considering the possibility of transacting electricity in the wholesale market via Aggregator. A list of variants is presented below: • Scen1-CS1-All-encompassing, without the possibility of transacting electricity in the wholesale market. In variants Scen1-CS1, CS2 and CS3, the Aggregator only does the management of the battery systems. Scen1-CS1, CS2, and CS3 the Aggregator can transact electricity in the wholesale market, buying electricity to supply the needs of the energy community or selling surplus electricity. In all scenarios, the FIT (export grid price) is established at 0.045 EUR/kWh, according to the Portuguese legislation [10]. Table 2 presents the comparison of the results of operation costs, considering the scenarios defined previously.  Table 2 presents all results for the six scenarios implemented, the scenario of the group presents the scenario where the possibility of transacting electricity in the wholesale market is unavailable. In variants of Scen2, the possibility of transacting electricity in the wholesale market is available. Scen1-CS1 presents a reduction of 58% and 10% compared with Scen1-CS2 and Scen1-CS3, respectively. Scen1-CS3, where the facility uses the generation only for self-supply, presents a reduction of 53% in total costs when compared with Scen1-CS2. Considering scenario 2 (wholesale transactions available) the same tendency of scenario 1 is verified, the best variant is Scen2-CS1, the following is Scen2-CS3, and in last Scen2-CS2. A reduction of 60% (compared with Scen2-CS2) and 10% (compared with Scen2-CS2) is verified for Scen2-CS3. A reduction of 55% is verified for Scen2-CS3 when compared to In Scen2-CS2 (UPP). Comparing the results between the variants of the two scenarios, Scen2-CS1 presents a reduction of 11% compared with Scen1-CS1. Scen2-CS2 compared with Scen1-CS2 presents a reduction of 6% in total costs, and Scen2-CS3 with Scen1-CS3 obtain a 10% reduction in total costs. As can be seen by the comparison showed above, the scenarios where the wholesale transactions are available present reductions between 6% and 11% compared with the same scenarios but without wholesale market transactions. In the variants considered, Scen2-CS2 presents the best results, and Scen1-CS2 the worst result for total costs. Attending to the optimization time, it can be seen a great increment in variants of scenario 2, which is explained by the fact that the optimization problem incorporates more variables due to the wholesale market transactions. Figure 8 presents the costs and revenues in each different variant.
As can be seen in Figure 8, the costs are the positive values, and the revenues are negative. For Scen1-CS1, Scen1-CS2, and Scen1-CS3 the costs or revenues associated with the wholesale market do not exist. Scen1-CS2 presents higher costs for buying electricity in retailer market and presents a higher revenue to sell electricity in the grid. Scen1-CS3 doesn't present revenues for the sale of electricity on-grid because the type of facility (UPAC) does not allow it. The revenues and costs of wholesale transactions only appeared in Scen2-CS1, Scen2-CS2, and Scen2-CS3. UPP facility (Scen1-CS2 and Scen2-CS2) is buying a great amount of electricity in a retailer compared to the other variants. The fixed costs are always the same in all scenarios defined. The sales revenues in the wholesale market are not presented, because no electricity is sold (minimum limit required not reached). Figure 9 presents the electricity transactions in each period considering Scen1-CS1, Scen1-CS2, and Scen1-CS3, where the wholesale transaction is not available.   Figure 9b,c have presented the free sales to the grid as the sale of electricity on the grid is limited to half the contracted power and at certain periods the excess electricity cannot be stored in the batteries and must be injected into the network but at zero cost. Only in scenarios covered by Portuguese legislation do free sales to the grid. Scen1-CS2 presents 122.53 kW, and Scen1-CS3 has 270.03 kW. It can also be seen that free sales occur in the periods that photovoltaic generation exists. Scen1-CS2 shows almost twice as much electricity bought at the retail market as the electricity produced which is obligatorily all injected into the grid. Figure 10 presents the electricity trading in each period for Scen2-CS1, Scen2-CS2, and Scen3-CS3, where the wholesale transaction is available. In all of the representations of Figure 10, it is presented the purchases made from the wholesale market. Considering Scen2-CS1, the purchases from retailers decrease 83% when compared with Scen1-CS1. Scen2-CS2 the purchases on the retail market also decrease by 37% compared with Scen1-CS2. Comparing the buy-in retailer market of Scen1-CS3 with Scen2-CS3, the decrease is about 83%, in the same scenarios but comparing the free sales on the grid in Scen2-CS3 we have a decrease of 17%. Scen2-CS1 and Scen2-CS3 present the same value for electricity purchases from the wholesale market, however, Scen2-CS2 presents a small value (minus 5%). Figure 11 presents the accumulated state of the battery for all variants tested. In Scen1-CS2 at 8:00, the community members have the batteries at the maximum level of capacity, the same happens in Scen2-CS2 for periods 5:00 to 8:00. The identified scenarios are both UPP facilities. Figure 11b presents the state of the batteries but considering the possibility of the wholesale transaction and in the case of Scen2-CS2 the full state of batteries is obtained when the purchases in the wholesale market occur (Figure 11b). Considering the comparison of Scen2-CS1 and Scen2-CS2 Scen1-CS1 and Scen1-CS3, the state of battery increases when wholesale market purchases occur. Table 3 the portfolio of electricity transactions in all scenarios tested. The transaction's portfolio in Scen1-CS1, Scen1-CS2, and Scen1-CS3 are divided into purchases from the retail market and sales to the grid. In Scen2-CS1, Scen2-CS2, and Scen2-CS3 the portfolio of transaction increases considering the wholesale availability. Considering the wholesale transactions, there are the spot market and the intraday sessions, considering the results only traded in intraday sessions. The sales in the wholesale market are not used due to the minimum amount not reached. Figure 12 presents the electricity transacted in different options of the wholesale market.
With Figure 12 it is possible to identify the intraday sessions where the electricity transactions are made. Scen2-CS1 uses intraday session 1 and session 2 to buy electricity in the wholesale market, the same happens for Scen2-CS3. Considering Scen2-CS2, only on intraday session 2 it is used to buy electricity from the wholesale market. The representation of wholesale market sales is not presented as it is not registered.

Conclusions
The participation of household prosumers in the wholesale market is limited to minimum amount transacted, approaches using aggregators have been used to overco this particularity. Using energy management systems, aggregators can focus on the id periods for buying and selling electricity in the wholesale market, taking advantage of price differences observed over time. The case study presented where the possible scen ios used by Portuguese households (UPP and UPAC) are used, and it is possible demonstrate that the best option is UPAC, where self-consumption is prioritized. Co paring the UPP and UPAC scenarios where there is the possibility of transacting electri in wholesale markets, there is a 55% reduction in operating costs when opting for UPA considering the proposed methodology. By using managing the batteries and market portunities appropriately, the prosumers can reduce the consumption costs significan In view of the proposed methodology using the Aggregator to transact electricity in wholesale market, there is a reduction in the total operating costs of the community. T all-encompassing scenario is the one that presents the best results considering or not participation in the wholesale market, demonstrating that, despite not being legally p sible in Portugal, the prosumers participation in the wholesale market via Aggregat brings significant advantages for the whole energy community. As future work, we inte to increase the community's resources by increasing the number of prosumers to obt greater participation in the wholesale market. It is also intended to carry out a robust timization to study the influence of the price variability of the wholesale market.

Conclusions
The participation of household prosumers in the wholesale market is limited to the minimum amount transacted, approaches using aggregators have been used to overcome this particularity. Using energy management systems, aggregators can focus on the ideal periods for buying and selling electricity in the wholesale market, taking advantage of the price differences observed over time. The case study presented where the possible scenarios used by Portuguese households (UPP and UPAC) are used, and it is possible to demonstrate that the best option is UPAC, where self-consumption is prioritized. Comparing the UPP and UPAC scenarios where there is the possibility of transacting electricity in wholesale markets, there is a 55% reduction in operating costs when opting for UPAC, considering the proposed methodology. By using managing the batteries and market opportunities appropriately, the prosumers can reduce the consumption costs significantly. In view of the proposed methodology using the Aggregator to transact electricity in the wholesale market, there is a reduction in the total operating costs of the community. The all-encompassing scenario is the one that presents the best results considering or not the participation in the wholesale market, demonstrating that, despite not being legally possible in Portugal, the prosumers participation in the wholesale market via Aggregators brings significant advantages for the whole energy community. As future work, we intend to increase the community's resources by increasing the number of prosumers to obtain greater participation in the wholesale market. It is also intended to carry out a robust optimization to study the influence of the price variability of the wholesale market.

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