Distributed Peer-to-Peer Electricity Trading Considering Network Loss in a Distribution System

In this paper, a distributed peer-to-peer (P2P) electricity trading model was proposed to study economic interactions between load aggregators (LAs) and microgrid operators (MGOs) considering network losses in a distribution system. In this model, the economic interactions among market participants were formulated as a Nash bargaining game, where LAs and MGOs can bargain with each other on the trading volume of electricity and payment. To achieve the Nash bargaining solution, the game was divided into two sub-problems: social welfare maximization and payment bargaining. Then, the alternating direction method of multipliers was used to solve the two sub-problems with limited information exchange. Finally, we tested the proposed model on a 12 × 12 km2 distribution system, and the results verify its effectiveness.


Introduction
The traditional electricity trading market is a highly centralized top-to-bottom transaction model, in which electricity is unidirectionally transmitted from a distribution network operator (DNO) to consumers over long distances [1]. With the increasing penetration of distributed energy resources and the deepening reform of the electricity market into distribution networks, traditional electricity supply for distribution networks has undergone significant changes to encourage multidirectional electricity transactions within a local geographical area [2]. Consequently, a large number of emerging electricity trading participants, such as load aggregators (LAs) and microgrid operators (MGOs), are allowed to trade with each other directly, which can alleviate electricity demand pressure and improve economic efficiency of a distribution system by means of energy management [3][4][5].
Recently, enormous interest has grown in exploring different strategies to improve the benefits of participants in the future electricity market [6][7][8][9][10][11][12][13]. For an LA of residential consumers, it can reduce electricity cost by shifting the load from peak hours to off-peak hours or purchasing from other electricity suppliers when the time-of-use (TOU) tariffs of the corresponding DNO are at the peak [6][7][8]. Furthermore, the LA can also benefit from providing ancillary services to power systems such as frequency regulation service [9]. For an MGO, the basic strategy is to schedule the controllable units within a microgrid, such as formulating charging and discharging strategies for energy storage, and demand response mechanisms for internal loads [10]. Moreover, the self-interested MGOs can benefit from directly exchanging electricity among microgrid clusters or with consumers under signed agreements [11][12][13]. The direct electricity trading among suppliers and consumers is also known as peer-to-peer (P2P) electricity trading.
This P2P electricity trading, where suppliers are allowed to compete with the DNO, relies on multi-bilateral direct transaction contracts among participants [14][15][16]. Different from traditional centralized electricity market, P2P platforms have no need to store renewable energy and predict the load demand of all participants which avoids the issue of privacy and security [17]. Furthermore, the P2P platform can specify transaction rules, supervise sharing activities of energy resources, and provide associated metering and billing mechanisms [18]. However, there are conflicts of interest among market participants, and it is challenging to establish fair trading mechanisms for a P2P electricity market.
To address this challenge, game theory has been applied to a P2P electricity market [19]. A multi-level game trading model was proposed in Reference [20]. In this model, the competition among suppliers was firstly modeled as a non-cooperative game, where consumers use evolutionary game theory to choose suppliers, and the transaction between consumers and suppliers are finally formulated as a Stackelberg game. In Reference [21], a hierarchical framework was modeled to address the optimal electricity trading, where the direct trading mechanism between suppliers and consumers was studied to fairly allocate the coalition group's revenue based on the asymptotic Shapley value. In Reference [22], the competition among MGOs (i.e., electricity buyers) was modeled as a non-cooperative game to eliminate the selfish behavior of the MGOs.
In this paper, we investigated the impact of distribution network losses on P2P trading by building a distributed P2P trading model. Based on a distribution network, Nash bargaining solution (NBS) theory was applied to the model which can maximize the benefits of LAs and MGOs and offer a Pareto-efficient outcome to coalition participants [23][24][25][26]. In addition, the electricity scheduling and trading of all the LAs and MGOs were jointly optimized by taking advantage of their own diverse demand and supply patterns. The contributions of this paper are summarized as follows: (1) Compared with existing P2P trading models, our proposed model considers the impact of network losses on P2P trading. The LAs and MGOs need to provide the DNO with the wheeling costs based on the calculation results of network losses; (2) The economic interaction among LAs and MGOs in our proposed model are analyzed and formulated by NBS theory. The formulated non-convex bargaining problem is decomposed into two convex sub-problems: social welfare maximization and payment bargaining; (3) A distributed algorithm based on the alternating direction method of multipliers (ADMM) is applied to solve the two sub-problems which can protect the privacy of market participants and simultaneously realize the bargaining between LAs and MGOs with limited information exchange.
The rest of this paper is organized as follows. Section 2 introduces the structure of a distributed P2P electricity trading model, analyzes the impact of network losses on economic interactions in P2P electricity trading systems, and presents the trading models of LAs and MGOs. Section 3 formulates the NBS model to describe the economic interactions between LAs and MGOs. Section 4 elaborates an ADMM-based distributed solution to solve the bargaining model. Section 5 provides the simulation results. Finally, the conclusions are summarized in Section 6.

System Structure
The P2P electricity trading model built on a distribution network is shown in Figure 1, where the market participants include LAs and MGOs. For LAs, there are fixed loads, interruptible loads and shiftable loads. For MGOs, they are composed of an energy storage system (ESS), renewable energy generator, internal load, and communication equipment. For simplicity, this paper used the set C = {1, 2, · · · , C} to represent LAs and the set N = {1, 2, · · · , N} to represent MGOs. The operation horizon of the proposed model was one day, which was denoted by the set T = {1, 2, · · · , T}, where T = 24 h. In the proposed model, market participants can trade electricity not only with a DNO but also directly with each other via bargaining. Nevertheless, the DNO can charge participants the wheeling costs for network losses. There are conflicts of interest among participants in the P2P transactions. Generally, a reasonable P2P pricing model of electricity can resolve these conflicts, otherwise it is counterproductive. In this model, we no longer focused on the P2P transactions clearing at a certain time point, but on the whole time period in the day ahead. The NBS theory was used to clear the P2P trading, which enabled market participants to obtain fair and Pareto-efficient revenue. 24 h. In the proposed model, market participants can trade electricity not only with a DNO but also directly with each other via bargaining. Nevertheless, the DNO can charge participants the wheeling costs for network losses. There are conflicts of interest among participants in the P2P transactions. Generally, a reasonable P2P pricing model of electricity can resolve these conflicts, otherwise it is counterproductive. In this model, we no longer focused on the P2P transactions clearing at a certain time point, but on the whole time period in the day ahead. The NBS theory was used to clear the P2P trading, which enabled market participants to obtain fair and Pareto-efficient revenue.
The distributed P2P platform in Figure 1, hosted by local government on the distribution side, is a non-profit organization and serves free of charge to assist P2P trading for reducing the congestion in the network [20]. The platform, communicating with all market participants by advanced information and communication technologies (such as LTE cellular technology), acts like an auctioneer to supervise transactions, provides clearing services for all participants, and updates related variables in the process of distributed P2P trading so as to ensure the orderly and stable operation of the electricity market rather than for the purposes of profit. Owing to the differences in electric power trading system, this distributed P2P trading model is not applicable for all regions. The proposed model was mainly designed for China after the electricity market reform on the selling side. When using this model in other regions, please firstly follow the local specific policies.

Analysis of Network Loss
In existing P2P studies, network loss is usually overlooked. To illustrate the impact of network losses on economic interactions in P2P electricity trading systems, we show P2P electricity trading between one LA and two MGOs in different geographical locations in Figure 2. Obviously, LA1 in location l7 is closer to MGO1. Under the premise that MGO 1 and 2 have the same bargaining skills, if both of them have surplus electricity, LA1 should give a higher priority to purchasing electricity from MGO1 than MGO2 and only purchases electricity from MGO2 when the electricity from MGO1 is sold out. This analysis is based on the consideration of network loss. If network loss is ignored, it will be no different for LA1 to purchase electricity from MGO1 or MGO2, because there is no cost to transfer electricity through either of the distribution lines. Moreover, it may occur that MGO1 sells electricity to LA1 through lines l69 and l67, which transfer electricity via MGO2. This is totally unreasonable. Therefore, network loss cannot be ignored in P2P trading. The distributed P2P platform in Figure 1, hosted by local government on the distribution side, is a non-profit organization and serves free of charge to assist P2P trading for reducing the congestion in the network [20]. The platform, communicating with all market participants by advanced information and communication technologies (such as LTE cellular technology), acts like an auctioneer to supervise transactions, provides clearing services for all participants, and updates related variables in the process of distributed P2P trading so as to ensure the orderly and stable operation of the electricity market rather than for the purposes of profit. Owing to the differences in electric power trading system, this distributed P2P trading model is not applicable for all regions. The proposed model was mainly designed for China after the electricity market reform on the selling side. When using this model in other regions, please firstly follow the local specific policies.

Analysis of Network Loss
In existing P2P studies, network loss is usually overlooked. To illustrate the impact of network losses on economic interactions in P2P electricity trading systems, we show P2P electricity trading between one LA and two MGOs in different geographical locations in Figure 2. Obviously, LA1 in location l7 is closer to MGO1. Under the premise that MGO 1 and 2 have the same bargaining skills, if both of them have surplus electricity, LA1 should give a higher priority to purchasing electricity from MGO1 than MGO2 and only purchases electricity from MGO2 when the electricity from MGO1 is sold out. This analysis is based on the consideration of network loss. If network loss is ignored, it will be no different for LA1 to purchase electricity from MGO1 or MGO2, because there is no cost to transfer electricity through either of the distribution lines. Moreover, it may occur that MGO1 sells electricity to LA1 through lines l 69 and l 67 , which transfer electricity via MGO2. This is totally unreasonable. Therefore, network loss cannot be ignored in P2P trading. When an LA trades with a DNO and MGOs, there are network losses in electricity transaction. Usually, three kinds of network losses are considered. The first is the loss of power transmission through the distribution network. The second is the loss of transformers, which mainly contains copper loss and iron loss; copper loss refers to the loss caused by the resistance of the primary and secondary windings of the transformer and can be obtained by short-circuit test; core loss refers to the loss caused by alternating flux in the core, which is generally considered equal to a no-load loss and can be obtained from a no-load test. The last is the loss caused by other factors such as increasingly serious harmonic loss as a result of access to renewable resources and new electric equipment, dielectric loss of the capacitor, reactor loss including conductor loss, hysteresis loss, and eddy current loss. Owing to the wide variety of losses caused by other factors, it is unlikely that they will be listed one by one. Generally, the greater the current on the line, the greater the loss caused by other factors. Based on the above considerations, taking the LA c trading with the MGO n, as an example, these three kinds of losses can be expressed as: When the LA c and the MGO n are trading, the DNO has the right to charge them the wheeling cost for network loss at the time slot t as: where γ denotes the network loss penalty coefficient. This wheeling cost is considered to be shared equally by both parties.

The Model of LA
Under the P2P electricity trading model, each LA can trade independently with a DNO and MGOs. The objective (or benefit) function of LA c is defined as: When an LA trades with a DNO and MGOs, there are network losses in electricity transaction. Usually, three kinds of network losses are considered. The first is the loss of power transmission through the distribution network. The second is the loss of transformers, which mainly contains copper loss and iron loss; copper loss refers to the loss caused by the resistance of the primary and secondary windings of the transformer and can be obtained by short-circuit test; core loss refers to the loss caused by alternating flux in the core, which is generally considered equal to a no-load loss and can be obtained from a no-load test. The last is the loss caused by other factors such as increasingly serious harmonic loss as a result of access to renewable resources and new electric equipment, dielectric loss of the capacitor, reactor loss including conductor loss, hysteresis loss, and eddy current loss. Owing to the wide variety of losses caused by other factors, it is unlikely that they will be listed one by one. Generally, the greater the current on the line, the greater the loss caused by other factors. Based on the above considerations, taking the LA c trading with the MGO n, as an example, these three kinds of losses can be expressed as: P n,c t,loss = I 2 t R n,c + 2 P Cop t where P n,c t,loss denotes the network loss between the LA c and the MGO n at the time slot t for electricity trading; I n,c t and R n,c denote the line current and the transmission line resistance, respectively; P Cop t and P Iron t denote the copper loss and iron loss of transformers, respectively. The former coefficient of 2 indicates that the trading between LA c and MGO n passes through two transformers. α is the coefficient of the network loss caused by other factors. Let P n,c t represent the electricity that the LA c buys from the MGO n at the time slot t. Assuming the power factor angle and voltage of the grid connection point are δ t and U t , then I t = P n,c t /(U t cos δ). Therefore, Equation (1) can be reformulated as: When the LA c and the MGO n are trading, the DNO has the right to charge them the wheeling cost for network loss at the time slot t as: where γ denotes the network loss penalty coefficient. This wheeling cost is considered to be shared equally by both parties.
where the first term is the utility function of power consumption. Both a c and b c are the coefficients of the utility function; a c is usually negative, while b c is usually positive; P c,t denotes the load at the time slot t after optimal scheduling. The second term is the cost of buying electricity from the DNO, including electricity price b t and power drawn from the DNO P G c,t at the time slot t. The third term is the wheeling cost of the direct electricity trading between the LA c and the MGOs. The last term is the total payment that the LA c pays to the MGOs for electricity trading, where Z nc denotes the payment between the LA c and the MGO n. The specific amount is determined by the bargaining agreement which is given in follow section. The following constraints should be satisfied at the time slot t: where P f ore c,t denotes the forecasted total load consumption of LA c at time slot t. This is the original load predicted value of each period before the optimization strategy is added; this paper used historical data to evaluate it. P in c,t and P out c,t denote the load transferred in and out, respectively. P IL c,t represents the interruptible load. P in,max c,t and P out,max c,t denote the upper bound of load transferred in and out, respectively. Equation (8) guarantees that the total amount of the shiftable loads remain unchanged in the operation horizon. P IL,max c,t is the upper bound of the interruptible load. Furthermore, the constraints to maintain the balance of demand and supply of the LA system are considered as follows: where P min c,t and P max c,t denote the lower and upper bound of the power consumption of the LA at the time slot t. P G,max c,t and p max n denote the maximum trading electricity with the DNO and the MGO n, respectively. Equation (13) guarantees the power balance of the LA system.

The Model of MGO
For the MGO n, it can trade with the DNO, LAs, and other MGOs. The objective function of the MGO n is described as: u L n,t = a n P 2 n,t + b n P n,t , ∀t ∈ T, ∀n ∈ N (18) where s t denotes the selling electricity price that the MGO n sells the power P s,G n,t to the DNO at the time slot t. u L n,t is the internal load utility of the MGO n. a n and b n denote the load utility coefficient of the MGO n, and P n,t denotes the load consumption at the time slot t after optimization. P b,G n,t denotes the power that the MGO n buys from the DNO. C ESS n,t denotes the converted cost of charging and discharging of an ESS in MGO n. σ n is the converted cost coefficient. E + n,t and E − n,t denote the charging and discharging amount at the time slot t, respectively. Z n is the total payment that the MGO n trades with LAs and other MGOs. If the payment of Z nn in Equation (19) is greater than zero, it indicates that the MGO n is a seller in the microgrid when it is trading with the MGO n , otherwise it is a buyer in the microgrid. The specific payment amount is also determined by a bargaining agreement.
Considering the charging and discharging status of an ESS, the following constraints should be satisfied: where E max n denotes the maximum charging and discharging energy. S n,t denotes the energy storage level at the time slot t. η c and η d denote the charging and discharging efficiencies, respectively. S min n and S max n are the lower and upper bound of the energy storage level, respectively. S n,o and S n,T denote the initial and final energy storage level of the ESS in the operation horizon. In the MGO n, loads have the same characteristic as the loads in a LA, thus they can be simply represented by: where P FIX n,t denotes the fixed load in MGO n at the time slot t. P SL n,t and P IL n,t denote the shiftable load and interruptible load in MGO n, respectively. The specific constraints of the loads in MGO n have the same form as the loads in the LA. In order to maintain the safe and stable operation of a microgrid, the relevant constraints are considered as follows: 0 ≤ P s,G n,t , P b,G n,t ≤ P max n , ∀t ∈ T, ∀n ∈ N (25) where P max n denotes the maximum power trading with the DNO. P n,n t denotes the electricity that the MGO n buys from the MGO n through the transmission of distribution networks. P RG n,t denotes the renewable power generation in the MGO n at the time slot t.
Since there is a quadratic term in network losses P n,c t,loss and P n,n t,loss , Equation (26) is non-linear; the linearization of this equation is needed. The details can be seen in Appendix A.

Problem Analysis
The P2P platform provides a market mechanism for participants to improve their own interests. In the following, we will explain how P2P trading can produce extra benefits for the participants and fairly share the benefits among them compared with traditional trading.
Generally, TOU tariffs have the constraint s t ≤ b t [10]. When a DNO purchases/sells the power P t from/to the MGO n/LA c at the time slot t, the revenue/cost of the MGO n/LA c is within a day. Assuming that the LA c and the MGO n reach an agreement that the payment between them satisfies: where C loss denotes the wheeling cost charged to the LA c and the MGO n within a day. Obviously, trading electricity through the agreement in Equation (27) can reduce the purchasing cost of LA c and increase the selling benefit of MGO n. When Z nc is closer to the right side of the inequality in Equation (27), the benefit for MGO n will be greater, otherwise the benefit for LA c will be greater. Since both LA c and MGO n are rational individuals, it is important to establish the P2P trading mechanism to share benefits fairly and reasonably. The key to facilitating fair P2P transactions is to determine the specific amount of Z nc .

Nash Bargaining Solution
Nash bargaining theory, a branch of cooperative game theory, can stimulate electricity market participants to form a cooperative alliance, as it has the potential to achieve a Pareto-efficient and fair outcome. In the following, we will explain how Nash bargaining solution can solve problems in P2P trading to fairly distribute the benefits. As mentioned earlier, all participants in the proposed P2P electricity trading model are rational individuals in that they have equal skills in bargaining. For simplicity, we selected two individuals for analysis. Let Λ be a set of cooperative strategies of the two individuals. U = {u 1 , u 2 } is the set of the benefit functions of the two individuals. D = {d 1 , d 2 } is the set of the benefits for the two individuals when they are non-cooperative, which is called a disagreement point (DP) in Nash bargaining theory. We assumed equilibrium existed and let c(Λ) denote the solution in Λ for cooperation. Before introducing Nash bargaining theory for a distribution network, we first give four axioms.

2.
Symmetry: If the DP of the two individuals satisfies d 1 = d 2 , then u 1 = u 2 under the solution c(Λ). If these four axioms are satisfied, John Nash in Reference [27] pointed out that the solution, which is also called Nash bargaining solution, is the optimal solution for the constrained optimization problem as follows: varibles: P c,t , P G c,t , P n,c t , Z c , P c,t , P in c,t , P out c,t , P IL c,t , P n,n t P s,G n,t , P b,G n,t , Z n , E + n,t , E − n,t , P n,t , P UN n,t , P TL n,t , P IL n,t where U c ≥ U o c and U n ≥ U o n satisfy rational individual requirements. U o, * c and U o, * n are the DPs of the LA c and the MGO n, respectively. The DP is the benefit value of the electric entity under non-bargaining trading which is selected as the optimal value of trading only with the DNO in this paper. The optimal value can be obtained from the following model.

1.
DP model of LA c: 2. DP model of MGO n:

Model Equivalent Transformation
The NBS model described by Equation (28) is a non-convex problem which can be decomposed into two sequential convex sub-problems (SPs): social welfare maximization and payment bargaining. The detailed proof is shown in Appendix B.
SP1: social welfare maximization varibles: P c,t , P G c,t , P n,c t , P c,t , P in c,t , P out c,t , P IL c,t , P n,n t P s,G n,t , P b,G n,t , E + n,t , E − n,t , P n,t , P UN n,t , P TL n,t , P IL where δ c = U * c − U o, * c , δ n = U * n − U o, * n . The solutions of Z c and Z n in Equation (32) are the specific payments in the bargaining agreement that LAs and MGOs should agree to sign. All the participants in the cooperative alliance can increase their benefits and obtain Pareto optimal solution by solving the payment bargaining problem.
So far, Equation (28) was successfully decomposed into two sequential convex SPs, which can be solved efficiently by commercial software such as CPLEX. Firstly, LAs and MGOs cooperate together to trade electricity and to maximize social welfare. From this step, we can calculate the optimal trading power among the participants under the bargaining transaction in the day-ahead electricity market. Then, LAs and MGOs can settle the amount of electricity according to Equation (32), which finally leads to the NBS. In the following, we explain how to solve the two sub-problems in a distributed fashion.

Distributed Solution Method
Although Equations (31) and (32) can be computed in a centralized way, this method will reveal the privacy of alliance participants and is prone to single point failures owing to excessive data processing. Therefore, we use a distributed algorithm to address the bargaining problem in this section. As a distributed algorithm, ADMM has the characteristics of fast convergence speed and good convergence properties and is widely used at present. LAs and MGOs are power coupled through electricity transactions; therefore, they must be decoupled before the ADMM is used.

Distributed Solution of SP1
Since SP1 involves a larger number of emerging participants, we introduced the auxiliary variableŝ P n,c t andP n,n t to divide SP1 into an equivalent multi-block structure.
whereP n,c t,(k−1) denotes the updated value ofP n,c t after k − 1 iterations; and P n,c t,(k) and P n,n t,(k) denote the updated value of P n,c t and P n,n t after k iterations, respectively. ρ > 0 is the penalty parameter. λ is the Lagrange multiplier, which is updated in each iteration for the LA c and the MGO n as follows: λ n,c t,(k) = λ n,c t,(k−1) + ρ n,c t,(k) P n,c t,(k) −P n,c t,(k) λ n,n t,(k) = λ n,n t,(k−1) + ρ n,n t,(k) P n,n t,(k) −P n,n t,(k) In order to accelerate the convergence speed of the ADMM algorithm, the penalty parameter, ρ, is updated as follows for all participants in the cooperative alliance [28]: where τ incr , τ decr , and µ are constants, and r k and s k are the primal and dual residuals which are also often used as the convergence criterion of the ADMM algorithm.

Distributed Solution of SP2
To solve SP2, we also needed to introduce auxiliary variables to decouple the payments among participants. Noting that n∈N n ∈N/{n} Z nn = 0, we introduced auxiliary variablesẐ nc andẐ nn as follows: According to the ADMM algorithm, the iterative augmented Lagrange function of the LA c and the MGO n of SP2 are:

Algorithm Implementation
The detailed procedure to solve SP1 is summarized in Algorithm 1. For simplicity, we took LA c and MGO n as an example. A similar procedure was also applied to SP2 which is summarized in Algorithm 1.
As can be seen from Algorithm 1, LA c and MGO n only need to exchange the limited information on electricity trading and payments, which can greatly protect their privacy. The distributed P2P platform provides the service of updating the Lagrange multipliers and penalty parameter in the process of iteration to ensure fairness.

Case Study
The simulation results regarding distributed P2P electricity trading between 2 LAs and 3 MGOs are presented in this section. The simulations were all run on the MATLAB2016a-Yalmip with the solver of CPLEX.

Simulation Parameters
A 12 × 12 km 2 distribution system was chosen as the studied distribution network in this paper. The geographical locations of the LAs and MGOs in the distribution system are shown in Figure 3. The distances of the transactions among the participants are represented by the straight-line distance of the participants. The daily predicted load of LAs, load, and power generation in MGOs are all presented in Figure 4 [24]. The utility coefficients of consuming electricity in the LAs and MGOs were a = −0.005 RMB/kWh 2 and b = 15 RMB/kWh. The upper and lower bound of the optimized load in LA 1 and 2 were 1.1 and 0.95 times the predicted data, respectively. The ESS capacities in each microgrid were set to 400, 600, and 1000 kWh, respectively, where the corresponding maximum charging/discharging powers were 150, 200, and 300 kWh, respectively, and their charging/discharging efficiency was 95%. The converted cost coefficient of ESS in each microgrid was 0.05 RMB/kWh. Copper loss was 15 kW and iron loss was 10 kW. The penalty cost coefficients of network loss was 0.3 RMB/kWh and α = 0.5. The Power factor and voltage of the grid connection point were cos δ t = 0.81 and U t = 12.66 kV, respectively. The line resistance was 0.35 Ω/km. The hourly TOU tariffs are illustrated in Table 1. a = −0.005 RMB/kWh 2 and b = 15 RMB/kWh. The upper and lower bound of the optimized load in LA 1 and 2 were 1.1 and 0.95 times the predicted data, respectively. The ESS capacities in each microgrid were set to 400, 600, and 1000 kWh, respectively, where the corresponding maximum charging/discharging powers were 150, 200, and 300 kWh, respectively, and their charging/discharging efficiency was 95%. The converted cost coefficient of ESS in each microgrid was 0.05 RMB/kWh. Copper loss was 15 kW and iron loss was 10 kW. The penalty cost coefficients of network loss was 0. 3 Table 1.     Table 1.      Table 2 lists the benefits of market participants under a distributed P2P electricity trading model. The payments after bargaining among participants are also listed in Table 2 where negative means the payment to others and positive means it receives the payment. Through the payments, LAs and MGOs can obtain a fair and Pareto-efficient sharing outcome according to NBS theory. Compared with the benefit under the DP model, the benefit of participants under a distributed P2P model was improved. Besides, we can see the surplus benefit of each participant was generally the same, which satisfies the requirement of B1 shown in Appendix B. To further elaborate the activities of participants in the distributed P2P transactions, Figures 5  and 6 show the load curves after bargaining in LAs and MGOs, respectively. As can be seen from Figures 5 and 6, the load curves of the LAs and MGOs after bargaining were smoother than the original, which was obtained by the optimal demand response. For consumers, power consumption during 9:00-12:00 and 17:00-22:00 are the periods of peak TOU tariffs; thus, transferring the load of these periods to the flat or valley of periods can effectively reduce the cost of load power consumption. Moreover, MGOs can have more surplus electricity during peak TOU tariff periods through peak shaving and valley filling. Selling surplus electricity to consumers through bargaining agreements during peak periods of electricity price can improve the benefit of the coalition, as the objective of SP1 is to maximize social welfare. does not trade with LA2. This is because MGO1 is closer to 1 in the geographical location as shown in Figure 3, while MGO2 is closer to LA2. Therefore, MGO1 chooses to sell all surplus power to LA1 and MGO2 to LA2 to avoid large network losses. For MGO3, because neither MGO1 nor MGO2 can fully supply electricity to LA1 and LA2 all a day, MGO3 will provide part of the power to LA1 and LA2, respectively. Since MGO3 is closer to LA2, MGO3 will give higher priority to supply LA2 than LA1. After being sold to LA2, MGO3 does not have sufficient surplus electricity to supply LA1, so LA1 has to purchase power from the DNO as shown in Figure 8. Similarly, MGO1 cannot buy electricity from other MGOs to balance itself during several time slots for its geographical location; it can only buy power from the DNO.   does not trade with LA2. This is because MGO1 is closer to 1 in the geographical location as shown in Figure 3, while MGO2 is closer to LA2. Therefore, MGO1 chooses to sell all surplus power to LA1 and MGO2 to LA2 to avoid large network losses. For MGO3, because neither MGO1 nor MGO2 can fully supply electricity to LA1 and LA2 all a day, MGO3 will provide part of the power to LA1 and LA2, respectively. Since MGO3 is closer to LA2, MGO3 will give higher priority to supply LA2 than LA1. After being sold to LA2, MGO3 does not have sufficient surplus electricity to supply LA1, so LA1 has to purchase power from the DNO as shown in Figure 8. Similarly, MGO1 cannot buy electricity from other MGOs to balance itself during several time slots for its geographical location; it can only buy power from the DNO.    Figure 7 shows the capacity level of ESS. As it can be observed in Figure 7, dynamic changes in the ESS in each microgrid conforms to the strategy of discharging at peak periods of TOU tariff and charging at flat or valley periods of TOU tariff. Similar to the peak shaving and valley filling of loads adopted in MGOs, this strategy can also increase the surplus electricity of MGOs and thereby improve social welfare efficiency.   Figure 8 shows the electricity procurement by LA1 and MGO1 from the DNO and Figure 9 shows the electricity trading results between LAs and MGOs. It can be seen from Figure 8 that LA2 and MGOs 2 and 3 do not trade with the DNO, and the loads of LA2 are supplied by the MGOs 2 and 3 as depicted in Figure 9b, while MGOs 2 and 3 are self-sufficient in their own power generation. Thus, we can conclude that the coalition participants avoid trading with the DNO under P2P trading. Instead, they directly trade with each other to enhance the benefits of self and social welfare as depicted in Figure 9. It can be seen from Figure 9 that MGO2 does not trade with LA1 and MGO1 does not trade with LA2. This is because MGO1 is closer to 1 in the geographical location as shown in Figure 3, while MGO2 is closer to LA2. Therefore, MGO1 chooses to sell all surplus power to LA1 and MGO2 to LA2 to avoid large network losses. For MGO3, because neither MGO1 nor MGO2 can fully supply electricity to LA1 and LA2 all a day, MGO3 will provide part of the power to LA1 and LA2, respectively. Since MGO3 is closer to LA2, MGO3 will give higher priority to supply LA2 than LA1. After being sold to LA2, MGO3 does not have sufficient surplus electricity to supply LA1, so LA1 has to purchase power from the DNO as shown in Figure 8. Similarly, MGO1 cannot buy electricity from other MGOs to balance itself during several time slots for its geographical location; it can only buy power from the DNO.

Trading without Consideration of Network Losses
To illustrate the effectiveness of considering network loss for P2P electricity trading, Figure 10 depicts the P2P electricity trading between participants without considering network losses. It can be seen that the trading strategies of LAs and MGOs are different with/without considering network

Trading without Consideration of Network Losses
To illustrate the effectiveness of considering network loss for P2P electricity trading, Figure 10 depicts the P2P electricity trading between participants without considering network losses. It can be seen that the trading strategies of LAs and MGOs are different with/without considering network losses. Figure 10a illustrates that the overall charging and discharging trends of ESS in each microgrid

Trading without Consideration of Network Losses
To illustrate the effectiveness of considering network loss for P2P electricity trading, Figure 10 depicts the P2P electricity trading between participants without considering network losses. It can be seen that the trading strategies of LAs and MGOs are different with/without considering network losses. Figure 10a illustrates that the overall charging and discharging trends of ESS in each microgrid are identical. Without considering network loss, ESS lost its specificity for each microgrid when maximizing social benefits, which is equivalent to a large ESS participating in scheduling. Figure 10b,c shows that MGO2 now trades with LA1 and MGO1 now trades with LA2, and all MGOs trade with each other which confirms our analysis in Section 2.2. This is because LAs and MGOs ignore the influence of geographical location and only consider how to maximize social benefits. Our simulation results indicate that the benefit of ignoring network loss is 841,713 RMB, which is greater than that considering network loss. However, this trading strategy results in unreasonable results.

Conclusions
In this paper, we studied distributed P2P electricity trading between LAs and MGOs in the distribution network. Compared with existing P2P trading studies, this study took network loss into account in the proposed P2P trading model, which makes P2P trading more rational. In the proposed model, LAs and MGOs formulated a coalition to improve their own interests in the day-ahead electricity market. Their conflicts of interest were resolved by NBS theory which can bring them a fair and Pareto-efficient sharing outcome. The ADMM-based distributed algorithm, which can protect internal privacy, was used to solve a non-convex Nash bargaining problem which was decomposed into two sub-problems. In the case study, we analyzed electricity trading among coalition participants with and without considering network losses, respectively. The results showed that power flow is more reasonable, and benefits can be fairly shared among coalition participants after considering network loss, verifying the effectiveness of the proposed P2P electricity trading model.

Conclusions
In this paper, we studied distributed P2P electricity trading between LAs and MGOs in the distribution network. Compared with existing P2P trading studies, this study took network loss into account in the proposed P2P trading model, which makes P2P trading more rational. In the proposed model, LAs and MGOs formulated a coalition to improve their own interests in the day-ahead electricity market. Their conflicts of interest were resolved by NBS theory which can bring them a fair and Pareto-efficient sharing outcome. The ADMM-based distributed algorithm, which can protect internal privacy, was used to solve a non-convex Nash bargaining problem which was decomposed into two sub-problems. In the case study, we analyzed electricity trading among coalition participants with and without considering network losses, respectively. The results showed that power flow is more reasonable, and benefits can be fairly shared among coalition participants after considering network loss, verifying the effectiveness of the proposed P2P electricity trading model.

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

Appendix A
Assuming U t and cos δ t are constant and both P n,c t,loss and P n,n t,loss are single variable functions, for this single variable nonlinear function, the following method was used to linearize. participants with and without considering network losses, respectively. The results showed that power flow is more reasonable, and benefits can be fairly shared among coalition participants after considering network loss, verifying the effectiveness of the proposed P2P electricity trading model. In Figure A1, ( ) ( ) In Figure A1, (x 1 , f 1 ), · · · , (x 5 , f 5 ) are a number of points given on the curve of the original function and all of them are known quantities. We introduce a i (∀i ∈ {1, · · · , 5}) and d i (∀i ∈ {1, · · · , 4}), which are both limited to the range of {0, 1}, and their respective summation is equal to one. In this way, the function can be characterized by the mixed integer linear constraints as:

Appendix B
When the maximum value of Equation (28) is obtained, the following equation is satisfied [24]: