“Peer-to-Peer Plus” Electricity Transaction within Community of Active Energy Agents Regarding Distribution Network Constraints

: This paper proposes the concept “active energy agent (AEA)” to characterize the autonomous and interactive entities of power system. The future distribution network is a peer-to-peer (P2P) community based on numbers of AEAs. A two-stage “P2P Plus” mechanism is developed to address the electricity transaction within AEA community. In the ﬁrst “P2P” stage, electricity is directly traded among AEAs via P2P price bidding. The model of P2P transaction is established, and the method of multi-dimensional willingness is adopted in price bidding. In the second “Plus” stage, the centralized coordination by distribution company (DisCo) is formulated as a constrained optimization problem, in which the objective is to maximize proﬁt and the constraints are the basic rights of AEAs and line ratings of distribution network. A 30-bus test system including 29 AEAs and main grid is investigated. Numeric simulation results verify the e ﬀ ectiveness of the proposed models and methods regarding ﬂow constraint. Comparative study reveals the economic motivations of AEAs to participate in P2P transaction, the e ﬃ ciency of combined search, and the beneﬁt of DisCo from pricing control.


Introduction
The future distribution network is a peer-to-peer (P2P) community based on distributed energy resources (DERs) and distributed intelligence. On the one hand, the boundaries between electricity producers and consumers are blurring fast, leading to the emergence of prosumers. A prosumer can play a time-variant dual-role in electricity transaction, as either a buyer or a seller at different times. On the other hand, advanced information technologies make prosumers capable of active perception, comprehension, decision, and interaction in terms of various energy behaviors, such as production, consumption, and storage. This paper proposes the concept of active energy agent (AEA) to characterize the autonomous interactive entities in electricity market. Numbers of AEAs form a P2P community and each AEA is an equivalent peer of the community, regardless of physical implementations. An AEA in reality can be a smart appliance, a rooftop photovoltaic, an electric vehicle, a household energy management system, a microgrid, a virtual power plant, etc.
The P2P transaction is generally adopted among entities that are organized in a P2P manner, due to the advantages with respect to renewable energy use and economic benefit. Reference [1,2] developed the P2P transactions between renewable energy modules and electric vehicles. The use of renewable energy is significantly improved, since electric vehicles can charge batteries to consume the excess output of renewable energy modules which would, otherwise, be curtailed to avoid over-voltage issues.
DisCo is the dual-role participant in the electricity transaction. On the one hand, DisCo is a self-interested market player that maximizes profit from electricity transactions, on the other hand, DisCo is the system operator responsible for ensuring the basic rights of users and the safety of the distribution network [24]. In this context, this paper proposes a two-stage "P2P Plus" mechanism of transaction that is a hybrid of the decentralized P2P transaction with centralized coordination. The mechanism takes full account of the willingness of the AEA and guarantees the energy supply and the safety of the distribution network. The innovative contributions of this article can be outlined as follows: (1). The concept of the "active energy agent" is proposed to characterize any autonomous entity exhibiting active energy behavior in electricity transaction, regardless of their specific physical appearance. (2). The two-stage "P2P Plus" mechanism is developed, which integrates the decentralized transaction and centralized coordination or intervention by considering the benefits of all parties in electricity transaction. (3). Realistic constraints, such as users' basic rights and line ratings, are incorporated in the optimization model. The tailoring algorithm based on power transfer distribution factor is designed to locate and tailor orders causing congestion. (4). This study is performed in the context of setting up electricity market in China. The proposed methodology and the results obtained can provide a reference for accelerating the local energy transaction and distributed renewable energy use.
The remainder of this paper is organized as follows: Section 2 presents the structure and process of the "P2P Plus" transaction mechanism. Sections 3 and 4 establish the mathematical models and performs a numeric case study, respectively. The concluding remarks are drawn in Section 5.

Structure of AEA Community
The AEA is a unified behavioral model of the entities that exhibit active energy behavior in electricity transaction. An AEA may have various physical implementations: a smart appliance, a rooftop photovoltaic, an electric vehicle, a household energy management system, a microgrid, a virtual power plant, etc. As illustrated in Figure 1, several AEAs connecting to distribution network form a community, and perform decentralized electricity transactions in P2P manner. The distribution company (DisCo) is responsible for the basic rights of AEAs and the safety of distribution network. To implement the electricity transaction within an AEA community, this paper proposes the "peer-to-peer plus (P2P Plus)" mechanism that consists of two stages as follows: (i). The "P2P" stage is the decentralized matchmaking of transaction orders among multiple AEAs; (ii). The "Plus" stage is the centralized coordination by DisCo to solve the unaddressed orders and congested lines.

Process of Electricity Transaction
In the "P2P Plus" transaction, each AEA is an autonomous peer that accesses the distribution network, and interacts with peers in the AEA community. The AEAs with electricity shortage and surplus are electricity buyers and sellers, respectively. Notice that the role of an AEA can vary with time, since the internal production and consumption are both time-variant. However, it is assumed that the role of an AEA is invariant in each hour, i.e., given a specific hour, an AEA can be either a buyer or a seller in electricity transaction.
Considering the day-ahead market, the process of the "P2P Plus" electricity transaction can be expressed as follows:

Process of Electricity Transaction
In the "P2P Plus" transaction, each AEA is an autonomous peer that accesses the distribution network, and interacts with peers in the AEA community. The AEAs with electricity shortage and surplus are electricity buyers and sellers, respectively. Notice that the role of an AEA can vary with time, since the internal production and consumption are both time-variant. However, it is assumed that the role of an AEA is invariant in each hour, i.e., given a specific hour, an AEA can be either a buyer or a seller in electricity transaction.
Considering the day-ahead market, the process of the "P2P Plus" electricity transaction can be expressed as follows: Step 1 Each AEA initializes its transaction order (including bid quantity and bid price) of t-th hour and publishes in community.
Step 2 Each AEA searches for counterparties to form bidding pairs Step 3 Each bidding pair performs price bidding for H bouts, unless the bid quantity of any party is cleared.
Step 4 Each AEA repeats Step 2-3 for R rounds, unless its bid quantity is cleared.
Step 5 All AEAs repeat Step 1-4 for 24 h of a day.

{"Plus" stage}
Step 6 DisCo optimizes pricing control to solve the undealt quantities.
Step 7 DisCo computes power flows and quantities to be tailored to solve line congestions.

Initialization of Transaction Orders
For the electricity buyer i , its transaction order can be expressed as of the r-th round. As a sequel, the initial order is  , and the initial bid price of i is set as follows: ( ) where  is a small positive number, and rand (

Initialization of Transaction Orders
For the electricity buyer A i , its transaction order can be expressed as Q i t,r , λ i t,r(h) , and can be simplified as Q i r , λ i r(h) since P2P order matching is independent in different hours. Q i r represents the Energies 2020, 13, 2408 5 of 23 electricity shortage of A i in r-th round of bidding, λ i r(h) is the bid price of A i at the h-th bout of the r-th round. As a sequel, the initial order is Q i 1 , λ i 1 (1) , and the initial bid price of A i is set as follows: where ε is a small positive number, and rand(1) is a random number for simulating individual diversity among different buyers. Given the feed-in price µ, i.e., the price at which DisCo buys electricity from AEAs, the rational buyer A i cannot expect to buy electricity at a price that is lower than µ.
Similarly, for the electricity seller A j , its transaction order is denoted by Q j r , λ j r(h) , where Q j r and λ j r(h) are the electricity surplus of A j in r-th round and the bid price at h-th bout of r-th round, respectively. The initial bid price of A j is set as follows: Given the retail price µ, i.e., the price at which DisCo sells electricity to AEAs, the rational seller A j cannot expect to sell electricity at a price that is higher than µ.
All transaction orders are published on the P2P transaction platform of the AEA community for retrieval and matchmaking.

Search of Transaction Counterparties
Each buyer retrieves transaction orders on the P2P transaction platform and searches for qualified sellers as its transaction counterparties. Once a bidding pair is formed, the two parties negotiate price for a maximum of H bouts. We consider two strategies for buyers to search for qualified sellers: price-based search and quantity-based search. As shown in Figure 3, the buyers search for sellers that offer the lowest bid price, and that can satisfy all its electricity shortage, respectively.

Search of Transaction Counterparties
Each buyer retrieves transaction orders on the P2P transaction platform and searches for qualified sellers as its transaction counterparties. Once a bidding pair is formed, the two parties negotiate price for a maximum of H bouts. We consider two strategies for buyers to search for qualified sellers: price-based search and quantity-based search. As shown in Figure 3, the buyers search for sellers that offer the lowest bid price, and that can satisfy all its electricity shortage, respectively.  where r  represents a set of all seller AEAs in r-th round. In quantity-based search, the candidate set could be an empty set if there is no seller can satisfy all shortage of i  .
In the following sections, we assume that buyers apply the combined search, which is the union of price-based search and quantity-based search. As long as r ≠ ∅  , Buyer i  must has one transaction counterparty from price-based search; and may have one more counterparty from quantity-based search.

Negotiation of Deal Prices
Once the transaction counterparties are determined, the buyer and the seller start the procedure Where S r represents a set of all seller AEAs in r-th round. In quantity-based search, the candidate set could be an empty set if there is no seller can satisfy all shortage of A i .
In the following sections, we assume that buyers apply the combined search, which is the union of price-based search and quantity-based search. As long as S r ∅, Buyer A j must has Energies 2020, 13, 2408 6 of 23 one transaction counterparty from price-based search; and may have one more counterparty from quantity-based search.

Negotiation of Deal Prices
Once the transaction counterparties are determined, the buyer and the seller start the procedure of price negotiation in each bidding pair. Notice that all the negotiations are in parallel, i.e., multiple buyers may choose a seller, and the same seller/buyer may simultaneously negotiates price with different counterparties in different bidding pairs. Once the price agreement is reached in a bidding pair, the involved orders of the two parties of the bidding pair immediately update, and price games of other related pairs can be affected or even be terminated if some orders are cleared. A bidding round ends if a deal is made in the bidding pair or the deadline is reached (h = H). AEAs can reselect counterparties and form new bidding pairs in a new bidding round. The maximum round of price bidding in each hour is R.
Consider a bidding pair in the r-th round including Buyer A i and Seller A j ; the bidding price of and the bid price of A j at h-th bout is: where w (1) . B r is a set that contains all buyer AEAs in r-th round. S i r and B j r are candidate set for A i and A j , respectively.
Notice that w i,j r(h) is proportional to the urgency of A i to buy electricity. A high willingness implies that A i would like to make a deal as soon as possible, while a low willingness indicates that A i would like to wait for more favorable prices. This paper adopts the concept of multi-dimensional willingness, which comprehensively integrates multiple factors including the gap of initial supply demand situation of market, the transaction history of an individual AEA, the time pressure of transaction, the matching degree of two parties in a bidding pair, etc.
(a) δ r is the basic step of price adjustment, and is proportional to the difference between the two initial prices of the seller and the buyer in a bidding pair, (b) SD describes the supply demand situation of the whole market in the AEA community, 0.75 < SD < 1.25 (8) SD = 1 if supply and demand are balanced, SD > 1 and SD < 1 indicate that the AEA community is globally oversupplied and undersupplied respectively. Notice that the function of arctangent is used to map SD into a symmetric bounded interval (0.75, 1.25) centered at 1. In the case of an oversupplied market, buyers take the advantages in price game since it is easy to buy electricity. The sellers have higher willingness and are more active to decrease the bid prices so as to sell their surplus electricity. On the contrary, in the case of an undersupplied market, sellers possess an advantage due to the overall shortage of electricity. Consequently, buyers actively increase the transaction willingness and tend to bid higher prices to satisfy the electricity shortage.
(c) NR i r is the transaction record of Buyer A i , and is related to the undealt quantity Q i r and the basic value b 0 . Larger undealt quantity results in higher transaction record.
where b i r is a Boolean value. b i r is 1 if a deal is made in the r-th round, and otherwise 0.
Similarly, we can also define NR j r as the transaction record of Seller A j .
(d) TP i r(h) is the time pressure due to the approaching deadline of the current bidding round, Obviously, closer to deadline and more undealt electricity cause larger time pressure.
(e) MD i,j r is the matching degree of Buyer A i with its transaction counterparty (Seller A j ) in r-th round, where S i r is the set of sellers forming a bidding pair with buyer A i in r-th bidding round. MD i,j r = 1 if all the electricity shortage of A i can be satisfied by the electricity surplus of A j through a single deal, and otherwise MD i,j r < 1.
Similarly, we can also define MD j,i r , the matching degree of Seller A j , with its counterparty (buyer A i ) in r-th round.
where B j r is the set of buyers forming a bidding pair with Seller A j in r-th bidding round.

Match and Update of Transaction Orders
In each bidding pair, Buyer A i and Seller A j repeatedly adjust their bid prices according to Equations (6) and (7), respectively. A deal is made once the two bid prices intersect. Assume the deal is made at h * -th bout of bidding, where λ i,j r(h) is the price of A i bids to A j at h-th bout of r-th round.
Energies 2020, 13, 2408 8 of 23 Then the deal price is (15) and the deal quantity is q Once a deal is made, the bid quantities of both two parties of the bidding pair immediately update.
The buyer/seller, whose bid quantity is cleared, will terminate price games with other counterparties and withdraw from the relevant bidding pairs. All the other buyers/sellers will continue the price game until the end of R rounds or a bid quantity of zero.

Model of "Plus" Stage
The centralized coordination of the "Plus" stage can be formulated as a constrained optimization problem, through which DisCo maximizes its profit by satisfying constraints of basic rights of AEAs and line ratings of distribution network. Hereafter, we analyze the net incomes of market participants, build the pricing control model, develop the tailoring algorithm, and finally derive the problem formulation.

Economics Analysis
The future distribution network is a decentralized community based on numbers of autonomous AEAs. However, the decentralized P2P negotiation among AEAs can neither ensure that all transaction orders are matched nor guarantee that all deals are feasible as far as the physical constraints are concerned. It is required for DisCo to perform the centralized coordination. The DisCo plays a dual role in the AEA community: on the one hand, an independent market participant that maximizes the profit; on the other hand, the system operator that is responsible for ensuring the basic rights AEAs and the safety of distribution network.
From the perspective of an AEA, there are two options to handle the undealt quantities.
(i). Abandon transactions. The renewable energies, such as wind and solar, can be curtailed, the interruptible load can be switched off, and the flexible load may be translated to other periods. All the above operations may obtain economic compensation from DisCo. The compensation rate is dynamically set according to supply demand factor in the community. (ii). Direct transaction with DisCo. Buyers can also retail electricity from DisCo at the retail price to satisfy the electricity shortage, and sellers can feed electricity back to DisCo at the feed-in price to clear the electricity surplus. Both the retail and feed-in prices are dynamically set by DisCo.
From the perspective of DisCo, there are also two options of the centralized coordination.
(i). Incentive measures. In the context of market-oriented reform, it is expected for DisCo to take economic approaches (prices, compensation rate, import/export electricity, etc.) to affect the energy behaviors of AEAs. (ii). Mandatory measures. In the case of unsatisfied hard constraints (line congestion, basic living conditions, etc.), it is also required for DisCo to tailor some already-dealt quantities.
The net income of AEAs and DisCo can be computed over the whole process of "P2P Plus" electricity transaction.
The net income of Buyer A i in t-th hour includes the payment of P2P transaction, the payment of retailed electricity from DisCo, and the revenue of compensation for tailoring dealt quantities.
The pricing control is applied on A i when DisCo handles its undealt electricity in a P2P transaction, which is denoted byQ i t . ∆µ t is the variation of retail price in the t-th hour.q i t and q i t are the corresponding quantity for pricing control and tailored quantity in the case of line congestion, respectively. ρ is the compensation rate for tailoring quantities. Notice that the intervention of DisCo on P2P transaction results is financially constrained since large amount of tailoring implies high expense of compensation.
The net income of Seller A j in the t-th hour includes the revenue of P2P transaction, the revenue of feeding electricity to DisCo, and the revenue of compensation for tailoring dealt quantities.
For Seller A j ,Q j t and q j t are its undealt electricity in the P2P transaction and the tailored quantity in "Plus" stage, respectively.
The net income of DisCo in t-th hour includes the revenues of retailing electricity to AEAs and exporting electricity to main grid, and the expenses of purchasing feed-in electricity from AEAs, importing electricity from the main grid, and compensating with tailored quantities.

Pricing Control
DisCo applies pricing control to handle the undealt electricity in P2P transaction. DisCo initiates variable price on AEAs as incentives, and AEAs actively respond with variable output profiles. The mechanism can be modeled as a generalized version of demand response. The elasticity is defined to quantitatively describe the impact of price variation on demand variation, The elasticity matrix can be computed, where each element on the main diagonal e tt is the self-elasticity that shows the impact of price on quantity in the same time unit t; each off-diagonal element e tt is the cross-elasticity that shows the impact of price on quantity of a different time unit. The self-elasticity and cross-elasticity are negative and nonnegative numbers, respectively. Taking Buyer A i , for example, the quantity variation can be computed as follows, whereQ andq are the undealt quantity after P2P stage and responded quantity in Plus stage, respectively. ∆µ is the variation of retail price. The update undealt quantity after applying pricing control isQ i 1 +q i 1 .

Tailoring Algorithm
DisCo carries out the safety check in distribution network to ensure that the power flow through any line l not exceed the transmission rating. In the case of line congestion, DisCo is authorized to mandatorily tailor the deals that cause the congestion. Given one transmission line l, and two nodes i and j, the power transfer distribution factor (PTDF) Φ ij l presents the impact of the power injections of Node i and Node j on the power flow through Line l. Based on the concept of PTDF, this paper proposes a method of tailoring dealt quantities that cause line congestion. The procedure is shown in Figure 4. where each element on the main diagonal tt e is the self-elasticity that shows the impact of price on quantity in the same time unit t; each off-diagonal element tt e ′ is the cross-elasticity that shows the impact of price on quantity of a different time unit. The self-elasticity and cross-elasticity are negative and nonnegative numbers, respectively. Taking Buyer i  , for example, the quantity variation can be computed as follows, where Q and q are the undealt quantity after P2P stage and responded quantity in Plus stage, respectively. μ Δ is the variation of retail price. The update undealt quantity after applying pricing control is 1 1î

Tailoring Algorithm
DisCo carries out the safety check in distribution network to ensure that the power flow through any line l not exceed the transmission rating. In the case of line congestion, DisCo is authorized to mandatorily tailor the deals that cause the congestion. Given one transmission line l, and two nodes i and j, the power transfer distribution factor (PTDF) ij l Φ presents the impact of the power injections of Node i and Node j on the power flow through Line l. Based on the concept of PTDF, this paper proposes a method of tailoring dealt quantities that cause line congestion. The procedure is shown in Figure 4. where N and L are the total numbers of lines and nodes in the distribution network, respectively. ,   Where N and L are the total numbers of lines and nodes in the distribution network, respectively. g i,l is the power transmission factor which presents the impact of the power injections of Node i on the power flow through Line l. Please refer to the Appendix A for more details of the calculation of transfer factor.
Based on the descending sort of φ ij l , DisCo tailors dealt quantities of relevant AEAs that contribute on the congestion. Finally, it computes the economic compensation for the tailored quantities.
Notice that the AEA output may include the decentralized deals made in "P2P" stage and the direct transactions with DisCo in "Plus" stage. The priority of tailoring should be definitely determined in the case of line congestion. In this paper, the transactions with DisCo are first tailored, and secondly the P2P deals if necessary.

Constrained Optimization
Based on the aforementioned analyses, we can establish the model of the centralized coordination of DisCo on AEAs, which can be formulated as a constrained optimization problem. The objective is to maximize the 24-h profit. The constraints are the basic rights of AEAs and the safety of distribution network. The controlled variables are the elastic demand. The decision variables are the price signals, and the import/export quantities. max where Equation (36)

Simulation Setup
In this section, we perform a case study to verify the effectiveness of the proposed model and method. Figure 5 depicts the 30-bus test system that is modified from the IEEE 30-bus network: on each node connects one and only one AEA, and Node 30 represents the substation integrating to main grid. In the "P2P stage", 29 AEAs exchange the electricity surplus and shortage within the distribution network. In the "Plus stage", DisCo handles the undealt electricity through centralized coordination on 29 AEAs and exchange (import or export) with the main grid. Open access data from Energinet, which include a 3-year record of electricity production and consumption in a region of Denmark, are adopted as the 24-h output profiles of 29 AEAs [25]. As shown in Figure 6, the electricity surplus and shortage electricity of AEAs are presented by positive and the negative output, respectively. Three AEAs,  Open access data from Energinet, which include a 3-year record of electricity production and consumption in a region of Denmark, are adopted as the 24-h output profiles of 29 AEAs [25]. As shown in Figure 6 Open access data from Energinet, which include a 3-year record of electricity production and consumption in a region of Denmark, are adopted as the 24-h output profiles of 29 AEAs [25]. As shown in Figure 6, the electricity surplus and shortage electricity of AEAs are presented by positive and the negative output, respectively. Three AEAs,  It is reasonable to assume µ < µ, and otherwise there is no profit space for DisCo to survive in the electricity market. The simulation environment is MATLAB-2018a, CPLEX12.8, Intel (R) Core (TM) i7-7700 @ 3.6 GHz, and 8 GB DDR3 RAM.

Results of P2P Price Bidding
Since the P2P transaction is independent of time, without loss of generality, the 8th hour (t = 8) is taken as an example to demonstrate the mechanism and process of P2P transaction in details. In this hour, the supply demand factor defined by Equation (10) is 1.15, which indicates the oversupplied market. Table 1 lists the transaction information of 19 deals among 29 AEAs in 8th hour. The first column is the deal index; the second and third columns present the two parties of each deal; the fourth and fifth columns respectively show the quantity and price of each deal. Notice that the same buyer may make deals with different sellers due to multiple bidding rounds, e.g., Buyer A 1 with Sellers A 2 , A 28 , and A 17 . Similarly, the same seller may also make deals with different buyers in different bidding rounds, e.g., Seller A 20 with Buyers A 13 and A 3 . Three typical groups are investigated to further analyze the price bidding process of the P2P stage. In each group, the buyer has two sellers as the counterparties and simultaneously participates in two price games. Figure 7 depicts the whole processes of price bidding in the 8th hour, and Table 2 lists the specific parameters. The solid and dashed lines illustrate the bidding processes between a buyer and the two sellers, which are from price-based search and quantity-based search, respectively. counterparties are independent of each other, 25  will reach an agreement on price with 11  and 6  in 26th and 27th bout, respectively. Therefore, 25  makes a deal with 11  in reality.   (a) The buyer is A 25 , and its counterparties are A 6 from price-based search and A 11 from quantity-based search, respectively. Assume the price games between A 25 and two counterparties are independent of each other, A 25 will reach an agreement on price with A 11 and A 6 in 26th and 27th bout, respectively. Therefore, A 25 makes a deal with A 11 in reality. Although the two bidding pairs have the same transaction record, there is a significant difference in the matching degree, from the perspective of A 25 , the matching degree with A 6 is 0.607, indicating that the surplus electricity of A 6 cannot satisfy its shortage. The higher matching degree with A 11 results in higher willingness of A 25 to make a deal and earlier agreement on price. (b) The buyer A 7 has very similar price bidding strategies to its two counterparties, since they have little difference. The deal is mainly determined by the strategies of sellers. It is demonstrated that the bid curve of A 23 declines much faster than that of A 17 , since A 23 has a higher matching degree with A 7 and stronger willingness to make a deal. (c) Both sellers have made deals in previous rounds and the transaction records A 18 of A 19 and are 0.351 and 0.763, respectively. Due to the higher ratio of sold to the total tradable, A 18 shows lower willingness than A 19 to make a deal and tend to wait for more favorable prices. In this round, A 19 finally makes a deal with A 8 , while A 18 fails in reaching an agreement with A 8 before deadline.
It can be summarized that the transaction records, matching degree, and supply demand factor determine the price bidding strategy significantly and then affect the results of the bidding round. Besides, the impact of time pressure on bidding process can be observed from the slopes of price bidding curves of both buyers and sellers: the slopes increase as the deadline is approaching.
As a global parameter of the electricity market, the supply demand ratio simultaneously affects the price bidding strategies of both two parties (buyer and seller) in a bidding round. Although the deal prices may vary significantly with different bidding pairs due to individual diversities, the overall trend can be witnessed. Figure 8 demonstrates that the average deal price positively correlates to the corresponding supply demand ratios on the 24-h horizon. All deal prices are bounded within the interval [µ, µ], and the average deal price is approximately below/above the interval median during the undersupplied/oversupplied periods.
Energies 2020, 13, x FOR PEER REVIEW 16 of 25 to the corresponding supply demand ratios on the 24-h horizon. All deal prices are bounded within the interval [ , ] μ μ , and the average deal price is approximately below/above the interval median during the undersupplied/oversupplied periods.

Results of Pricing Control
According to the transaction mechanism of "P2P Plus", the undealt electricity in the decentralized P2P stage will be handled by DisCo in the centralized "Plus" stage. DisCo applies timevariant price on AEAs, and AEAs make response by actively changing their output profiles. For the

Results of Pricing Control
According to the transaction mechanism of "P2P Plus", the undealt electricity in the decentralized P2P stage will be handled by DisCo in the centralized "Plus" stage. DisCo applies time-variant price on AEAs, and AEAs make response by actively changing their output profiles. For the ease of demonstration, the internal demands of all buyer AEAs are accumulated in the entire AEA community. Figure 9 shows 24-h retail price and its impact on the accumulated demand. It is observed that the retail price and demand are positively correlated, and the peak-to-valley difference of demand is reduced by applying pricing control. Figure 8. The relationship between deal prices and supply demand ratio of market.

Results of Pricing Control
According to the transaction mechanism of "P2P Plus", the undealt electricity in entralized P2P stage will be handled by DisCo in the centralized "Plus" stage. DisCo applies ti iant price on AEAs, and AEAs make response by actively changing their output profiles. For e of demonstration, the internal demands of all buyer AEAs are accumulated in the entire A munity. Figure 9 shows 24-h retail price and its impact on the accumulated demand. I erved that the retail price and demand are positively correlated, and the peak-to-valley differe emand is reduced by applying pricing control.

Results of Tailoring Transaction
The transmission line rating is a hard constraint of electricity transaction. The power flows of the distribution network are physically determined by the power injections on all nodes, and are economically affected by three factors: P2P deals among AEAs, direct transactions between AEA and DisCo, and import/export with main grid. The power flows on all lines are computed by applying the DC power flow method. Table 3 takes 9 lines for example and lists the relevant PTDFs. Without loss of generality, we assume that Line 13 and Line 22 are congested; the data are shown in Table 4.

Results of Tailoring Transaction
The transmission line rating is a hard constraint of electricity transaction. The power flows of the distribution network are physically determined by the power injections on all nodes, and are economically affected by three factors: P2P deals among AEAs, direct transactions between AEA and DisCo, and import/export with main grid. The power flows on all lines are computed by applying the DC power flow method. Table 3 takes 9 lines for example and lists the relevant PTDFs. Without loss of generality, we assume that Line 13 and Line 22 are congested; the data are shown in Table 4. Figure 5 shows that Line 13 links A 11 and A 9 , and Line 22 links A 15 and A 18 . Table 3 further reveals that the flow on Line 13 is mainly affected by Deal#1, and Deal #2, #5, and #7 are the top three that have the largest impact on the flow on Line 22. Table 5 presents the solution of tailoring transaction. It can be observed that the transactions with DisCo is firstly tailored in case of congestion, and the P2P deals may be tailored if the congestion still exists after all transactions with DisCo having been canceled. The above described the P2P transaction and DR optimized scheduling scheme at t = 8 in detail, and demonstrated the results of each stage through simulation. We enumerated the bidding strategies in P2P transactions, and demonstrated the optimization scheme that the distribution network adopted for internal resources and the benefits the DSO received in the power grid. The safety check is a necessary action taken to ensure the safety of the system. Generally, most of the power transmission in the power grid meet the requirements, and only in extreme cases needs adjustment. During the tidal current safety inspection, 471.9 kW of power which is traded with DSO was mainly reduced.

Advantages of P2P transaction
The following figure shows the specific benefits of AEAs. To demonstrate the motivations of AEA to participate in P2P transaction, we compute the net income of AEAs under two mechanisms of electricity transaction: (i). Sole centralized coordination (ii). "P2P Plus" proposed in this article Figure 10 illustrates the net revenues/expenses of 29 AEAs under the two transaction mechanisms. It can be observed that all AEAs, no matter whether as buyers or sellers, can benefit from participating in P2P transaction since the deal prices are always between the retail price and the feed-in price. As a result, buyers and sellers can respectively save expenses and expand revenues, as compared to the direct transaction with DisCo. As for all AEAs, the P2P transaction is more attractive to than the sole centralized coordination due to the economic advantages.

Efficiency of Counterparty Search Strategies
In the previous sections, each buyer applies the combined search to determine its transaction counterparties: one from price-based search and one (at most) from quantity-based search. This subsection performs a comparative study on the three strategies: (i) sole price-based search, (ii) sole quantity-based search, and (iii) combined search, and verifies the superiority of the combined search over the former two. Dozens of runs of simulation are conducted under the same conditions, and computational results are averaged to avoid the experimental contingency.
Since the P2P transaction relies on the independent decision-making of a large number of AEAs, not all orders can be successfully matched in the P2P stage and there can be some tradable electricity remaining undealt. Figure 11 shows the total undealt electricity in the distribution network by applying the three search strategies, and Table 6 lists the convergence performances in details. It is observed that the combined search has the highest ratio of dealt quantity to the total tradable electricity, and the fastest convergence. The price-based search has slightly inferior performance compared to the combined search, and the quantity-based search rapidly stagnates in the 2nd bidding round and a large amount of electricity is left undealt. These phenomena can be interpreted as the former two search strategies (combined and price-based) providing more opportunities for buyers to find a qualified seller as the transaction counterparty, while the quantity-based search only accepts sellers with enough surplus electricity.

Efficiency of Counterparty Search Strategies
In the previous sections, each buyer applies the combined search to determine its transaction counterparties: one from price-based search and one (at most) from quantity-based search. This subsection performs a comparative study on the three strategies: (i) sole price-based search, (ii) sole quantity-based search, and (iii) combined search, and verifies the superiority of the combined search over the former two. Dozens of runs of simulation are conducted under the same conditions, and computational results are averaged to avoid the experimental contingency.
Since the P2P transaction relies on the independent decision-making of a large number of AEAs, not all orders can be successfully matched in the P2P stage and there can be some tradable electricity remaining undealt. Figure 11 shows the total undealt electricity in the distribution network by applying the three search strategies, and Table 6 lists the convergence performances in details. It is observed that the combined search has the highest ratio of dealt quantity to the total tradable electricity, and the fastest convergence. The price-based search has slightly inferior performance compared to the combined search, and the quantity-based search rapidly stagnates in the 2nd bidding round and a large amount of electricity is left undealt. These phenomena can be interpreted as the former two search strategies (combined and price-based) providing more opportunities for buyers to find a qualified seller as the transaction counterparty, while the quantity-based search only accepts sellers with enough surplus electricity. electricity, and the fastest convergence. The price-based search has slightly inferior performance compared to the combined search, and the quantity-based search rapidly stagnates in the 2nd bidding round and a large amount of electricity is left undealt. These phenomena can be interpreted as the former two search strategies (combined and price-based) providing more opportunities for buyers to find a qualified seller as the transaction counterparty, while the quantity-based search only accepts sellers with enough surplus electricity.   Price-based 1332.6 10 3 Quantity-based 4283. 9 2 Hereinafter we further compare the performances of the combined search and the price-based search. For the ease of comparison, we assume that there are 15 sellers and 14 buyers in the community and the initial price of each seller is proportional to the tradable quantity. Figure 12 shows three scenarios which are designed to present three different market conditions in the AEA community.  Price-based 1332.6 10 3 Quantity-based 4283. 9 2 Hereinafter we further compare the performances of the combined search and the price-based search. For the ease of comparison, we assume that there are 15 sellers and 14 buyers in the community and the initial price of each seller is proportional to the tradable quantity. Figure 12 shows three scenarios which are designed to present three different market conditions in the AEA community. The performances are quantitatively investigated in terms of the total undealt electricity and the average effective bidding rounds. The former is the total quantity of unmatched orders of all AEAs in the community, and the latter is the average of the effective bidding rounds in which deals are made. These two indexes present the completion ratio and convergence speed of P2P transaction, respectively. Figure 13 shows that the combined search can always enable AEAs to achieve the Pareto The performances are quantitatively investigated in terms of the total undealt electricity and the average effective bidding rounds. The former is the total quantity of unmatched orders of all AEAs in the community, and the latter is the average of the effective bidding rounds in which deals are made. These two indexes present the completion ratio and convergence speed of P2P transaction, respectively. Figure 13 shows that the combined search can always enable AEAs to achieve the Pareto optima, i.e., non-inferior in the total undealt electricity and the average effective bidding rounds as compared to the price-based search. Notice that the two search strategies have almost the same performance of total undealt electricity in Scenario C and Scenario B but they show an advantage in the number of effective bidding round. In summary, the combined search can achieve the highest efficiency in P2P transaction among the three strategies as far as the completion ratio and convergence speed are concerned.

Benefit from Pricing Control
Hereinafter we analyze the impact of pricing control on the profit of DisCo. Six different AEA communities are investigated, of which the AEA number varies from 9 to 59, and it is assumed that the average demand of AEAs is constant. Figure 14 compares the profit of DisCo before and after pricing control. It is revealed that DisCo can always benefit from applying pricing control, and larger accumulated demand can result in higher profit increment. In summary, the combined search can achieve the highest efficiency in P2P transaction among the three strategies as far as the completion ratio and convergence speed are concerned.

Benefit from Pricing Control
Hereinafter we analyze the impact of pricing control on the profit of DisCo. Six different AEA communities are investigated, of which the AEA number varies from 9 to 59, and it is assumed that the average demand of AEAs is constant. Figure 14 compares the profit of DisCo before and after pricing control. It is revealed that DisCo can always benefit from applying pricing control, and larger accumulated demand can result in higher profit increment.
In summary, the "P2P Plus" two-stage transaction mechanism is both economically favorable and environmentally friendly, since it can improve of the net income of market players and promote the market-based use of renewable energies in the distribution network. In the first stage, the P2P transaction breaks down market barriers, provides the opportunity for market players to participate in electricity market, and fully considers the willingness of each market participant. In the second stage, a centralized coordination is adopted. The DisCo uses price incentives to affect AEAs' electricity consumption behaviors. Since the proposed "P2P Plus" transaction can provide more opportunities and possibilities for AEAs to exchange the internal electricity surplus and shortage, the overall use of renewable energies can be significantly promoted through consuming the surplus electricity of neighbored AEAs rather than retailing from DisCo or importing from main grid.
Hereinafter we analyze the impact of pricing control on the profit of DisCo. Six different AEA communities are investigated, of which the AEA number varies from 9 to 59, and it is assumed that the average demand of AEAs is constant. Figure 14 compares the profit of DisCo before and after pricing control. It is revealed that DisCo can always benefit from applying pricing control, and larger accumulated demand can result in higher profit increment. In summary, the "P2P Plus" two-stage transaction mechanism is both economically favorable and environmentally friendly, since it can improve of the net income of market players and promote the market-based use of renewable energies in the distribution network. In the first stage, the P2P transaction breaks down market barriers, provides the opportunity for market players to participate in electricity market, and fully considers the willingness of each market participant. In the second stage, a centralized coordination is adopted. The DisCo uses price incentives to affect AEAs' electricity consumption behaviors. Since the proposed "P2P Plus" transaction can provide more opportunities and possibilities for AEAs to exchange the internal electricity surplus and shortage, the

Conclusions
This paper proposes the concept of AEA and the "P2P Plus" mechanism for the electricity transactions within AEA community. In the first "P2P stage", all AEAs perform decentralized matchmaking of transaction orders through multiple rounds of price bidding. The procedure of P2P matchmaking is developed and the strategy of multi-dimensional willingness is adopted, which comprehensively considers overall and individual factors, such as supply demand factor, transaction record, time pressure, and matching degree. In the second "Plus stage", DisCo conducts the centralized coordination to handle the undealt electricity and congested lines. The centralized coordination is formulated as a constrained optimization problem. DisCo can benefit from applying pricing control in plus stage though it subject to constraints of distribution network power flow and basic rights of AEAs.
Numeric study is performed on a 30-bus test system, which includes 29 AEAs on 29 nodes and connects to main grid on 30th node. The multi-bout convergence processes of price bidding among three representative bidding pairs are demonstrated and analyzed. It is revealed that the deal price is positively correlated with the supply demand ratio of the market. In addition, it is illustrated that the peak-shaving impact of retail price on the accumulated demand. The deals causing congestion can be accurately located by computing the network PTDFs and then tailored by solving the constrained optimization problem of DisCo.
Comparative discussion validates the advantage of P2P transaction over centralized methodology as all AEAs can improve net incomes by participating in P2P transaction, the combined search for counterparty can achieve faster convergence and higher transaction quantity than the search solely based on price or quantity, and DisCo can always benefit from applying pricing control in various scales of AEA communities.
It is verified that the proposed "P2P Plus" transaction is equitable and mutually beneficial for market players, as well as flexible and reliable for the system operator. This contribution provides a reference for the establishment of future distribution network and the implementation of power market reform in China.  index of buyer, seller AEA, generally used as the superscript of a variable in this paper t index of time unit of electricity transaction, generally used as the subscript of a variable in this paper t = 1, · · · , 24 ∆t time unit of electricity transaction, ∆t = 1 h in this paper r index of round of price bidding in a time unit, generally used as the subscript of a variable in this paper, r = 1, · · · , R h index of bout in a single round of P2P price bidding, generally used in a bracket as the subscript of a variable in this paper, h = 1, · · · , H Q P2P bid quantity of an AEA (unit: kWh) q P2P deal quantity of a bidding pair (unit: kWh) Q undealt quantity of an AEA after P2P stage (unit: kWh) q responded quantity of an AEA in Plus stage (unit: kWh) q tailored quantity of an AEA (unit: kWh) λ P2P price of an AEA (unit: ¥/kWh) µ feed-in price, the price at which AEAs sell electricity to DisCo (unit: ¥/kWh) µ retail price, the price at which AEAs buy electricity from DisCo (unit: ¥/kWh) rand(1) a random number following the uniform distribution on interval [0,1] ε a small positive number w willingness of an AEA to make a deal with to its counterparty (unit: ¥/kWh) δ basic step of price adjustment (unit: ¥/kWh) SD supply demand factor of electricity market NR transaction record of an AEA TP time pressure of an AEA MD matching degree of an AEA with its counterparty u, v, z revenue, expense, net income of a buyer/seller AEA U, V, Z revenue, expense, net income of DisCo ω price at which DisCo exports electricity to main grid (unit: ¥/kWh) ω price at which DisCo imports electricity from main grid (unit: ¥/kWh) ρ compensation rate for tailoring quantities of AEAs (unit: ¥/kWh) e, E elasticity, elasticity matrix P electric power flow (unit: kW) l index of transmission line, generally used as the superscript of a variable in this paper g, G transfer factor, transfer factor matrix ∅ power transfer distribution factors (PTDF) of two nodes on a line N number of nodes in distribution network L number of lines in distribution network k, k lower, upper limit

Appendix A
The power transfer distribution factor (PTDF) can be calculated as follows: Step 2 Calculate the admittance matrix where each element γ l on the main diagonal is the susceptance of Line l.
Step 3 Calculate the injection transfer matrix where each element g n,l describes the impact of the power change on Node n to Line l.
Step 4 Calculate PTDFs by using the two corresponding elements of the injection transfer matrix φ i j l = g i,l − g j,l (A5)