Iterative Game Approach for Modelling the Behavior of Agents in a Competitive Flexibility Trading

The potential of end-users to modify their consumption pattern makes them an interesting resource for providing energy flexibility in energy communities. Thus, active end-users require sufficient incentives and automated trading and management schemes. In order to enable increased small-scale end-users participation for flexibility service provision, a new design for flexibility trading is required to model the behavior of different agents and their interactions in energy communities. The novelty of our work lies in proposing an iterative game-based approach in which all agents – consisting of the distribution system operator (DSO), aggregators, and customers– can determine their decision variables to optimize their own objective functions and interact with others to modify their decisions according to others’ decisions. In addition, three scenarios are considered to study the effects of agents’ freedom while setting their decision variables (by removing one of their constraints in their corresponding decision-making problem). Moreover, the impact of the presence of interruptible loads in comparison with shiftable loads is investigated in this paper. According to the simulation results, it is found that in the scenario where end-users have fewer constraints, in presence of interruptible loads, end-users gain greater income compared to the absence of interruptible loads.


I. INTRODUCTION
A. BACKGROUND D UE to the increase in the utilization of renewable energies as variable and non-dispatchable resources, the power system is facing new problems related to the balance between demand and generation [1]. In this regard, new resources for providing the required balance management and other flexibility services are needed [2]. End-users can provide energy flexibility for the power system due to their ability to modify their consumption [3]. For instance, by adjusting their loads, utilizing the energy storage systems, or making use of the thermal inertia of buildings, end-users can provide flexibility for the system [4]. As a consequence, they are more engaged in the decisions related to the local commu-nity [5]. Therefore, conventional centralized approaches are not efficient enough to model the active participation of endusers [6]. In this regard, new approaches are needed to model the new type of energy transactions and interactions among different agents in the local communities. Several works proposed new models to follow the active behavior of endusers in energy and flexibility markets. In [7], a theoretical and mathematical foundation for the decentralized participation of consumers in the energy market has been presented. Moreover, challenges related to the specific characteristics of decentralized participation of flexible demands have been addressed in [7]. Furthermore, authors in [8] proposed an energy management mechanism to pave the way for residential buildings with distributed resources to trade energy in the distribution system. Ref. [9] proposed a decentralized mechanism to manage the operation of electric vehicles in charging mode and energy flexibility provided by end-users.
Some papers in the literature concentrated on the novel frameworks for flexibility trading in the distribution system. In [10], the authors proposed a two-stage approach that enables end-users to trade flexibility and energy in a peer-to-peer (P2P) platform that is supervised by the local market operator and the DSO. The authors in [11], presented a chance-constrained approach to manage uncertainties in the flexibility transaction among microgrids and the DSO. In [12], a pricing and bidding mechanism is proposed for the local flexibility market to boost its coupling with other markets such as retail, ancillary service, and the wholesale market. Ref. [13] proposed a stochastic model for optimal bidding strategy of aggregated prosumers to facilitate their flexibility provision. In this way, the uncertainty related to the PV generation, loads, outdoor temperature, and end-users' behavior has been considered by deploying scenario-based programming. In [14], a distributed local flexibility market is proposed where the uncertainty of demand and network congestion have been considered to assist the DSO in reserving and utilizing the demand flexibility most efficiently.
It is crystal clear that Handling the power system consisting of a large number of prosumers who are in charge of providing the system flexibility is very difficult. Therefore, an agent e.g aggregator is needed to aggregate energy and flexibility provided by prosumers. Authors in [15] presented a model for local flexibility market where aggregators control different devices for providing various services in the distribution system. In [16], the authors presented a decentralized market design in which aggregators are in charge of motivating prosumers to provide energy flexibility for the DSO. Authors in [17] proposed a two-stage stochastic optimization to facilitate the engagement of aggregators in energy and ancillary service markets. In ref. [18], the performance of aggregators for delivering the provided flexibility by residential end-users to the DSO in presence of large uncertainties is evaluated. In [19], authors proposed a control strategy based on a decentralized bottom-up approach to utilize the flexibility potentials of virtual power plants. Authors in [20] presented a cooperative market mechanism to determine energy transaction and price for micro-grids in isolated and connected modes considering the uncertainty of renewable energy sources and demand.
In addition to the necessity of the presence of an agent to aggregate the provided flexibility on the demand side, it should be noted that prosumers have a right to trade flexibility with the DSO directly owing to their important role in providing flexibility [21]. In this way, flexibility trading in the distribution system will be more competitive. Thus, an approach is needed to model the competition between different agents and their interactions. In this respect, a part of the literature deployed the models based on the game theory. Game-based approaches allow modeling the behavior of strategic agents and interactions among them by presenting a mathematical framework [22]. This characteristic makes the game-based approach an ideal method for modeling the energy and flexibility trading in energy communities. The proposed approach in [22] is based on a game theory analysis to investigate the behavior of the flexibility providers and their optimal strategy for choosing the best business partner that maximizes their profit. In [23], the demand response management problem has been studied using a game among utility companies and end-users. The proposed approach in [23] deployed the Stackelberg game between utility companies and end-users. The goal of utility companies and endusers is to optimize their income and payment, respectively. In [24], monopolistic and game-based approaches for trading energy flexibility are presented and compared. In this regard, in the monopolistic method, just aggregators or consumers decide on flexibility management. In addition, two scenarios are considered for the game-based approach, where in the first scenario, the DSO and aggregators are strategic agents and in the second scenario, the DSO and aggregators are the decision-maker agents.
Additionally, in [25], authors proposed a generic model for the geographical and economic evaluation of the flexibility potentials of the alternative flexibility providers using cooperative game theory. In [26], a two-level game is used for demand response management. In this regard, in the bottom level, households determine their purchased demand from utility companies according to the power price, and utility companies define their generation and price according to the power demand of residential users at the higher level. Ref. [27] presented a decentralized approach scheme for energy transactions among microgrids based on a game. In [28], an event-driven approach is proposed for energy trading between microgrids. For this sake, in their game-based model, authors deployed the concept of reward to make an incentive for the transaction. In [29], a design based on contributions is used for energy trading among microgrids in a competitive market. In this regard, energy is collected from providers and distributed to the consumers according to their historical contributions. Ref. [30] proposed a game-theoretic model in which aggregators compete with each other to maximize their profit by selling the demand response to the distribution system company. In [31], a novel scheme has been proposed for a non-convex community energy management problem based on the game theory and the constraints of resources. Ref.
[32] presented a stochastic multi-layer model to investigate the behavior of different players in the electricity market. In their proposed approach, consumers are in charge of selecting their supplying agent using a game-theoretic model. Therefore, supplying agents should compete with each other to maintain their customers.

B. CONTRIBUTION
In the literature, numerous studies have been performed to propose an ideal framework for transacting energy flexibility in energy communities. Among all proposed solutions, gamebased approaches are more applicable and realistic because they model the behavior of agents to empower them to make a decision independently. An important point in this approach is that the interaction among all agents should be considered while making decisions. However, complete interaction among the DSO, aggregators and end-users has not been modeled in the literature. To the best of the authors' knowledge, a framework in which all agents including endusers, aggregators, and the DSO can decide independently and modify their decisions has been proposed in none of the papers in the literature. In this paper, we propose an iterative game for modeling the rational behavior of all agents (endusers, aggregators, and the DSO) in a competitive flexibility trading in which agents can play their role and change their decisions according to the other agents' decisions. The contribution of this paper can be summarized as follows: • A novel iterative game-based algorithm is proposed for modeling the flexibility transaction in the energy community considering interactions among all agents. • Effects of shiftable and interruptible loads based on the portion of interruptible loads are studied. • Three flexibility scenarios are considered (by removing one of their constraints in their corresponding decisionmaking problem) for assessing the impact of the freedom of agents on their decisions and validating the simulation results.
Our proposed iterative game-based approach has some advantages compared to other methods used in the literature. Firstly, it provides a competitive trading framework where all players have their decision variables and can solve their problems independently to find their optimal solutions. All agents in our proposed approach are engaged in the decision-making process, while there are limited decision-maker agents in other approaches. Secondly, our approach provides an equal power for all agents to update their decisions based on the last decisions of others, because the trading problem is solved from all agents' points of view considering their optimal strategies. For instance, bilevel optimization methodology solves the optimization problem from the leader's point of view. The autonomy of the followers in the bilevel optimization model is way less than the leader of the problem, as the leader can consider the objective function and constraints of the followers as a constraint in its optimization problem, to anticipate the logical actions of followers, while followers do not have a similar ability. In this regard, our proposed approach considers a similar power for all agents to make and update their decisions and prevents monopoly in the transaction process to serve the players with a competitive trading platform.
Furthermore, since our approach empowers all agents for making their decisions independently and modifying them based on others' decisions, it can simulate the real behavior of agents for flexibility trading where all agents have their optimal strategies. In this way, the energy sector policymaker can study the trading behaviors and interactions of agents. This will enable the policy-maker to investigate the The rest of the paper is organized as follows. In Section II, the problem formulation is presented. Section III explains three scenarios for studying the impact of agents' decisionmaking freedom. Section IV describes our iterative gamebased algorithm which is deployed for energy flexibility management. Simulation results for the 33-bus test system are discussed in Section V. Finally, our conclusions are presented in VI.

A. PROBLEM FORMULATION
In this section, we explain our proposed model for transacting energy flexibility between agents in the energy community, i.e. end-users, aggregators, and the DSO, as illustrated in Fig.  1. In our model, end-users, aggregators, and the DSO transact flexibility in a hierarchical structure. In this way, the total energy transacted among end-users and aggregators is traded through aggregators and the DSO. In addition, end-users can trade flexibility with both their corresponding aggregator and the DSO. In this way, the monopoly is prevented, and the freedom of agents for participation in flexibility trading is promoted. Moreover, when end-users have the opportunity to trade flexibility with both the aggregators and the DSO, they are motivated to be more involved in the flexibility provision [21]. These factors can pave the path toward a competitive trading framework. It is considered that each aggregator has a bilateral contract with its corresponding end-users. In this way, end-users and aggregators can transact flexibility in both directions. Each end-user can adjust its load to provide positive or negative energy flexibility as represented in Eq. (1). Here, L f jt is the amount of flexibility provided by enduser j at time slot t, and L c jt is the scheduled load of enduser j. Besides, L jt represents the load of end-user j after providing the flexibility in real-time. Accordingly, Eq. (2) presents the upper and lower bounds for provision flexibility of end-users. Here, γ j represents the flexibility factor which is introduced in [24]. The flexibility provided by an end-user VOLUME , is traded with the DSO or aggregator or both of them. The relation between the energy flexibility provided by an enduser (L f jt ) and its flexibility traded with the DSO (P D2L jt ) and its corresponding aggregator (P L2A jt ) is represented in (3).
Furthermore, Loads of end-users have been categorized into three general classifications; non-flexible, shiftable, and interruptible loads. Thus, shiftable and interruptible loads have the potential to be a source of flexibility, while end-users cannot adjust non-flexible loads for the sake of flexibility provision. The portion of interruptible and shiftable loads of consumers is described in (4) and Fig. 2. In this way, the portion of interruptible loads is determined by setting α. If α = 0, energy consumption after providing flexibility over a time horizon, e.g. 24 hours, should be equal to the energy of scheduled load in the assumed time horizon. In other words, the sum of provided flexibility over a time horizon must be equal to zero by setting α = 0. In this case, all flexible loads are shiftable. As the amount of α increases, the difference between the sum of scheduled load and the sum of the real-time load over a time horizon can be bigger which increases the portion of the interruptible load of enduser j. In addition, as mentioned before, end-users can trade flexibility with aggregators. In this way, if end-user j sells energy flexibility to its corresponding aggregator, P L2A jt is positive. However, if end-user j buys energy flexibility from its corresponding aggregator, P L2A jt is negative. Moreover, the relation between flexibility traded among aggregator k and its end-users (P L2A jt ), and flexibility traded among aggregator k and the DSO (P A2D kt ) is presented in (5).
In our proposed structure, the DSO and end-users are also able to trade flexibility in both directions. The positive sign of P D2L jt is considered for the trade of flexibility from the DSO to the end-user j, whereas if the DSO buys flexibility from end-user j, P D2L jt is negative. Additionally, end-users determine the amount of flexibility traded with their corresponding aggregators, P L2A jt , and the price of flexibility which is exchanged with the DSO, λ D2L jt . To prevent the possibility of arbitrage in the flexibility transaction between end-users and aggregators, upper and lower limits are considered for P L2A jt which is represented in (6). In addition, maximum and minimum limits related to λ D2L jt which is the decision variable of end-users is presented in (7).
On the other hand, aggregators determine the price of their flexibility transacted with the DSO, λ A2D jt . The upper and lower bands of λ A2D jt are presented in (8).
Finally, the DSO sets the flexibility traded among the DSO and end-users, P D2L jt . A limitation is considered for P D2L jt , in both directions, to prevent the possibility of arbitrage in flexibility trading among end-users and the DSO as presented in Eq. (9). Moreover, the DSO transacts flexibility with the RTEM and all agents as expressed in (10).

B. AGENTS' OBJECTIVE FUNCTIONS
In this section, we introduce objective functions of endusers, aggregators and the DSO which are presented in (11), (12) and (13), respectively. As seen in (11), the objective function of end-user j consists of two parts. The first term represents the cost of buying flexibility from the DSO and the second term expresses the income of selling flexibility to its corresponding aggregator. The objective function of aggregators also consists of two parts consisting of the cost of exchanging flexibility with end-users and the income of flexibility exchanging with the DSO, accordingly. However, the DSO is in charge of minimizing the trade with the RTEM to increase the self-sufficiency of the distribution system. Fig.  1 shows interactions among agents and decision-making flow in our proposed energy flexibility trading model.

III. SCENARIOS DEFINITION
In this paper, three different scenarios are defined in which the DSO and end-users have different levels of freedom for determining their decision variables due to the presence or absence of the constraint on the amount of the traded flexibility between end-users and the DSO (Eq. (9)), as well as the constraint on the amount of the traded flexibility between end-users and their corresponding aggregator (Eq. (6)). On the other hand, the freedom of aggregators is constant in all scenarios. In this regard, the freedom of endusers and the DSO is increased by removing one of their constraints in their corresponding decision-making problem.
As mentioned in Section II, (6) and (9) were the constraints related to preventing the possibility of arbitrage. Therefore, with their absence and presence, there are different levels of arbitrage avoidance. we consider three scenarios to analyze the behavior of the agents in the presence or absence of the arbitrage prevention constraints. Our proposed scenarios are explained in the following: • Scenario 1: In scenario 1, the constraints of end-users' problem is composed of (2), (3), (4), (6), and (7). Aggregators problem consists of 2 constraints; (5) and (8). In addition, (2), (3), (4), and (9) are the constraints of the DSO's problem in this scenario. Presence of ( (6)) in the problem of end-users, indicates that a restriction is set to prevent the possibility of arbitrage in the flexibility transaction between end-users and their corresponding aggregators. Furthermore, a limitation is imposed by (9) in the problem of the DSO to prevent the possibility of arbitrage in the flexibility transaction among end-users and the DSO. The objective function and constraints of all agents in scenario 1 is shown in Fig. 3 • Scenario 2: In scenario 2, problems of aggregators and the DSO are the same as scenario 1. However, in this scenario, (6) is removed from the constraints of endusers' problem. Therefore, an arbitrage may occur in the flexibility transaction between end-users and aggregators. However, owing to the presence of (9) in the constraints of the DSO's problem, the possibility of arbitrage in the flexibility transaction among the DSO and end-users is prevented. The objective function and constraints of all agents in scenario 2 is shown in Fig. 4. • Scenario 3: In scenario 3, the problems of end-users and aggregators are similar to scenario 1. However, in this scenario, (9) is removed from the constraints of the DSO's problem. Therefore, an arbitrage may occur in the flexibility trading between end-users and the DSO. However, owing to the presence of (6) in the constraints of the end-users' problem, the possibility of arbitrage in the flexibility transaction among aggregators and end-users is prevented. Agents' objective functions and constraints in scenario 3 are presented in Fig. 5.

IV. PROPOSED FLEXIBILITY TRADING
In this paper, we proposed an iterative game-based approach that enables players to make and update their decisions, as shown in Fig. 6. Since the decision variables of one agent may be a parameter in the objective function of other agents, the decision of each agent influences the optimal  decision of other agents. In this regard, all agents are able to make their optimal decisions by optimizing their objective functions and finding the optimal value for their assigned decision variables. Then, in the next iteration, they can update their decision variables based on the last decisions of other agents. In this way, firstly, end-users solve their problem (problem E), and set their decision variables, P L2A jt and λ D2L jt , according to the initialized inputs and parameters. In the next step, aggregators find an optimal solution for their problem (problem A), and determine the amount of λ A2D kt . Moreover, P A2D kt is calculated according to P L2A jt determined in the previous step by end-users. Finally, the DSO solves its problem (Problem D) and determines the amount of P D2L jt . It is clear that the decision of the DSO depends on the previous decisions of end-users and aggregators in each iteration. Hence, the amount of P L2A jt affects the optimal amount of P D2L jt for Problem D. After P D2L jt is obtained, the decision-making procedure will be ended if the convergence condition is met as presented by (14). On the other hand, if Eq. (14) has not been met, the proposed game procedure will be iterated. This way, end-users make their decisions according to the updated value of P D2L jt which is determined by the DSO. Then, P D2L jt affects both decisions of end-users. Furthermore, it impacts on the constraints of P L2A jt according to (2) and (3). Moreover, the direction of the flexibility traded between the DSO and end-users influences the optimal value of λ D2L jt . In this paper, we proposed an iterative game-based approach where the decision of each agent influences the decision of other agents as shown in Fig. 6. Thus, all agents are able to make their optimal decisions and update their decision variables in an iterative interaction with other agents. In this way, firstly, end-users solve their problem (problem E), and set their decision variables, P L2A jt and λ D2L jt , according to the initialized inputs and parameters. In the next step, aggregators find an optimal solution for their problem (problem A), and determine the amount of λ A2D kt . Moreover, P A2D kt is calculated according to P L2A jt determined in the previous step by end-users. Finally, the DSO solves its problem (Problem D) and determines the amount of P D2L jt . It is clear that the decision of the DSO depends on the previous decisions of end-users and aggregators in each iteration. Hence, the amount of P L2A jt affects the optimal amount of P D2L jt for Problem D. After P D2L jt is obtained, the decision-making procedure will be ended if the convergence condition is met as presented by (14). On the other hand, if Eq. (14) has not been met, the proposed game procedure will be iterated. This way, end-users update their decision variables based on the last value of P D2L jt which was determined by the DSO. As, P D2L jt affects both decisions of end-users, and impacts on the constraints of P L2A jt according to (2) and (3). Moreover, the direction of the flexibility traded between the DSO and endusers influences the optimal value of λ D2L jt . After end-users update their decisions, the aggregators and the DSO update their decision variables based on the last decision of end-user. This procedure is repeated and agents update their decisions until the convergence condition is met. In general, iterative approaches do not have deterministic convergence criteria. We considered a convergence criterion that is represented in Eq. 14. The convergence criterion of our approach is based on the difference between agents' objective functions in two consecutive iterations. In this way, the summation of variations of the agents' objective functions in two consecutive iterations must be less than a sufficiently small value.

A. CASE STUDY
In this paper, a 33-bus test system is used from [21], [24] to assess our proposed flexibility trading algorithm between agents in the energy community as shown in Fig. 7. Three regions have been considered which are managed by their corresponding aggregators. The price data of energy traded between end-users and aggregators is came from [21]. Besides, we assume that γ j = 0.1, and δ kt = 1.1 according to Refs. [21], [24], respectively. In addition, it is considered that loads are totally shiftable (α = 0). Our proposed flexibility management problem is solved in MATLAB using particle swarm optimization (PSO) for determining the optimal decision of each agent in each iteration. Thus, agents solve their problem in each iteration independently via PSO.

1) Scenario 1
In this scenario in which none of the constraints of endusers and the DSO is removed, and both the DSO and endusers are more restricted for making their decisions, after 59 iterations the convergence condition is met. Fig. 8 shows the amount of objective function of end-users, aggregators, and the DSO in different iterations. As shown in this figure, aggregators are able to achieve a negative value for their FIGURE 7. 33-bus test system [21], [24]. objective function which means that flexibility trading is profitable for them. On the other hand, while end-users in the first iteration can gain income due to the negative value of their objective function, decisions of other agents push them to have a positive objective function in other iterations. It can also be realized that like aggregators, fluctuation of end-users' objective function in different iterations is very low. However, the fluctuation of DSO's objective function is considerable. It shows that decisions of end-users have a significant effect on the maximum and minimum band of P D2L jt , according to Eq. 9, 2, and 3. Therefore, the objective function of the DSO fluctuates with different decisions of end-users.
Figs. 10 and 9 shows the flexibility traded between aggregators and the DSO and their price accordingly. It is obvious that when an aggregator buys energy flexibility from the DSO (P A2D kt < 0), it sets the minimum band for λ A2D kt based on Eq. (8) which is δ kt λ L2A kt . On the other hand, when aggregators k sells energy flexibility to the DSO (P A2D kt > 0), λ A2D kt is set on its maximum band (λ rt t ). Fig. 11 shows energy flexibility traded among the DSO and the RTEM. It is observed that, in most hours, the amount of P rt t is near zero. Consequently, the amount of the objective function of the DSO is not considerable according to (13). Table 1 presents the amount of the objective function of end-users, aggregators, and the DSO in all three scenarios. The objective function of end-users, aggregators, and the DSO in scenario 1 are 943.62 , −1110.42 and 41.65 , accordingly.

2) Scenario 2
In the second scenario where one of the constraints of endusers is removed and they can decide more freely, the convergence condition is met after 11 iterations. The amount of objective function of end-users, aggregators, and the DSO in different iterations is shown in fig. 12    more than its amount in scenario 1. So, aggregators are able to increase their income. In all iterations, end-users' objective function is positive except the first iteration, and finally, in the last iteration, their objective function is 522.46 . Therefore, it is less in comparison with scenario 1 (943.62 ), in which they are more restricted while determining decision variables. Moreover, The objective function of the DSO in the second scenario (3253.48 ) is much more than its value in scenario 1 (41.65 ). Hence, the objective function of the DSO is about 77 times bigger than scenario 1. Therefore, it can be concluded that the freedom of end-users in scenario 2 is very destructive for the DSO in such a way that the loss of the DSO is way more than the benefit of end-users and aggregators. Fig. 15 shows the energy flexibility traded among the DSO and the RTEM. It is seen that its amount is much more than its amount in scenario 1, which causes the objective function of the DSO to increase dramatically according to (13).

3) Scenario 3
In this scenario in which one of the constraints of the DSO is removed and it can decide more freely in comparison with scenarios 1 and 2, after 13 iterations the problem is solved. fig. 16, shows the amount of objective functions for endusers, aggregators, and the DSO in different iterations. In Scenario 3, the DSO is able to improve its performance by decreasing its objective function from 41,65 in scenario 1 to 16,21 in scenario 3 (about 60%). Fig. 15 shows that in most hours the energy flexibility traded among the DSO and the RTEM in scenario 3 is less than its amount in scenario

C. PRESENCE OF INTERRUPTIBLE LOADS
In the previous sections, it has been assumed that loads of end-users only consist of shiftable loads (α = 0). In this section, the behavior of different agents in presence of interruptible loads is assessed. Tables 2 and 3 show the amount of objective functions of agents for α = 0.1 and α = 0.15 accordingly. Fig. 20, using a radar plot, depicts the objective function of end-users and aggregators in different scenarios in presence of shiftable loads (α = 0) and interruptible loads (α = 0.1 and α = 0.15). As seen in scenario 2, the amount of objective function of end-users decreases as α increases. On the other hand, in scenario 3, the objective function of end-users increases as α increases. However, in scenario 1, with increasing α from 0 to 0.1 objective function of end-users increases, and with increasing α from 0.1 to 0.15 objective function of end-users decreases. In addition, aggregators' objective function in scenarios 1 and 2 decreases as α increases. This trend is not similar in scenario 3. Because with increasing α from 0 to 0.1 objective function of aggregators decreases and with increasing α from 0.1  to 0.15 objective function of aggregators increases. Unlike aggregators and end-users, the DSO has a similar trend in all scenarios. The objective function of the DSO increases with increasing α.

D. CHALLENGES
The challenges of our proposed model should be taken into account in our future works to improve the quality of our proposed trading framework. For instance, Peer-to-peer (P2P) flexibility trading possibility that can incentivize peers to be actively involved in flexibility provision for the local energy communities , will be addressed in our future works. However, there will be serious scalability issues in the P2P trading platform as there are complex interactions among end-users. While in our approach, there is no interaction between end-users. Therefore, increasing the scale of the distribution system has no serious impact on the performance of our proposed approach. In addition, as there is no coupling constraint between end-users' flexibility trading, the computational burden of our approach is very low. Therefore, our approach does not require high computational units. In addition, the distribution network topology and optimal power flow that is missing in our work can be considered for shaping an energy flexibility market platform. VOLUME ,

VI. CONCLUSIONS
In this paper, we proposed a novel iterative game-based algorithm based on a complete interaction among agents for trading energy flexibility in the energy community. We considered three scenarios assigning different levels of freedom to end-users and the DSO in presence of both shiftable and interruptible loads for evaluating our proposed model. According to the simulation results, it is found that: • In almost all situations end-users and aggregators have a similar performance in the presence of shiftable loads. • The removal of one of end-users' constraints has a destructive effect on the performance of the DSO. • The presence of interruptible loads causes the objective function of end-users to be less when they have fewer constraints. • With increasing the portion of the interruptible loads, the condition of aggregators improves in almost all of the situations. • As the portion of interruptible loads increases the objective function of the DSO increases. In this work, peer-to-peer energy trading among end-users have not been addressed. In our future work, we will study a flexibility market considering distribution network constraints where end-users can transact flexibility through peerto-peer sharing. In addition, we will study the potential of end-user for providing flexibility such as adjusting the loads, utilizing energy storage systems, and making use of the thermal inertia of the buildings in more detail by considering a comprehensive model for each of them.