A Novel Scheme for P2P Energy Trading Considering Energy Congestion in Microgrid

The advancements in Renewable Energy Sources (RES), increasing trends of distributed generation and proliferation of prosumer community requires an affective utilization of energy in Microgrid (MG) paradigm. Peer-to-Peer (P2P) energy trading mechanism provides a platform where prosumers can participate in energy sharing which is beneficial for all users of MG. Meanwhile, due to the high penetration of RES and distributed generations in distribution system used in P2P energy trading concept, the control and operation of existing grid is lacking the required functionalities. In P2P energy trading, power congestion occurs on distribution system which can limit effective utilization of RES. As RES and power demands are increasing, congestion problem also tends to increase. Smart Metering (SM) infrastructure is used to handle Energy Congestion Problem (ECP) by more effective management of prosumer community in P2P energy trading mechanism. SM monitors power transactions, maintains status of the network and obtains power profiles of prosumers. In this paper, Normalized P2P (NP2P) energy trading scheme is proposed with objective to decrease load on main grid and cost minimization for all users. NP2P is centralized contracting scheme treats all users in Microgrid equal for energy flow and cost implementation. Three different cases are considered to validate efficiency of proposed P2P energy trading scheme. In this research work, ECP due to NP2P model is analyzed, modeled as Knapsack Problem (KP) and solved using Greedy and Simulated Annealing (SA) algorithms. In proposed research, Central Energy Management Unit (CEMU) is responsible for implementation of functions for NP2P model and energy congestion control. To improve the reliability of grid, some prosumers with surplus energy should be disconnected. The results of various considered cases for proposed NP2P scheme and algorithms for ECP are compared to verify effectiveness of the solution.


I. INTRODUCTION
The transition from conventional grid to smart grid enables distributed Microgrids (MG) which enhance the stability and quality of power system and reduce CO2 emission using green energy systems [1]. A Microgrid is single controllable entity which consists of sources and loads [2]. Sources can be classified as generation units and storage system, and loads are power demands. Microgrid concept reduces the transmission system losses and alleviates congestion by matching the demand and supply in distribution system. Microgrid can operate in grid connected and islanding modes [3].
Various techniques are implemented by research community for efficient utilization of Renewable Energy Resource (RES) in Microgrid paradigm. In [4], authors modeled stochastic behavior of wind energy to achieve the objectives of cost and risk level minimization. A review of optimization methods for stochastic programming was discussed in [5] to handle intermittent nature of RES. Multiobjective RES optimization problem was considered in [6], to minimize total cost and system losses and solved using robust stochastic approach. To improve the functionality of Microgrid, Prony analysis were performed in [7] by studying damping profile of smart distribution network.
The peer to peer electricity trading mechanism is expected to grow because awareness about the shared economy has developed in recent years and advantages of Microgrid have risen. Furthermore, the research and development in area of renewable and communication technology will give a boost to implementation of new system. Since P2P electricity trading is relatively at an early stage in business, studies are more attentive for development of new schemes to use it effectively.
In [8], authors presented a P2P energy trading system between two sets of electric vehicles (EVs), which decreases influence of charging process on power distribution system during business hours. An aggregator gathers all available supply and demand information from the vehicles to calculate an optimum P2P price. In [9], the authors also proposed an idea of locally purchasing and selling of energy among Hybrid Electric Vehicles in Smart Grids using localized P2P electricity trading model with Consortium Blockchain. In [10], authors presented two types of competitions w.r.t buyers and sellers, defines their roles and trading scenarios respectively. P2P energy trading is still an open area for many researchers and investors. This will be the future technology that can be implemented on large scale. In traditional grid system, power congestion occurs in transmission network. But the concept of P2P energy trading enables large penetrations of renewables and distributed generation in distribution system, which leads to congestion in distribution network. The solution of energy congestion problem is a challenge for effective utilization of RES and DGs. Congestion in distribution system results power surges in grid during low demands and intermittent nature of RES [11].

A. BACKGROUND STUDIES OF P2P ENERGY TRADING
A detailed discussion on the role of prosumer (producer and consumer) in power distribution system was presented in [12]. The approach used in this paper was dual decomposition distributed optimization approach. The proposed framework gives security protecting system to prosumers in exchanging a dispersed way through a multispecialist framework.
Two different configuration for P2P energy trading dominant distribution system architectures were presented in [13]. The configurations were considered with respect to utility. In first configuration utility have to settle the interactions in a centralized manner. Second configuration is known as peer-centric, which means no involvement of utility. Another trading system for smart P2P energy trading was suggested in [14], which provides feasibility to perform trading based on participant's data like instantaneous active power demand, locations and maximum daily energy demand. The solution based on principle of First-Come-First-Served was implemented in an anonymous blockchain trading ledger.
In reference [15], authors proposed a micro energy market for smart domestic energy trading in low voltage distribution systems in the context of high penetration of photovoltaic systems and battery energy storage systems. In addition, a micro-balancing market was proposed to address the congestions due to unforeseen energy imbalance. Centralized and decentralized management strategies based on demand and generation forecast were simulated in real time.
The peak load demand based P2P energy trading scheme for prosumers in MG was presented in [16]. The producers of network were considered as parents while consumers as children. An algorithm was proposed to calculate available energy of a parent to sell in real-time and required energy of a child in a day-ahead considering objective to minimize peak load demand. The method provides facility of energy transactions between two agreed prosumers without third party involvements.
The concept of Active Energy Agent (AEA) community was presented in [17] to develop a two-stage "P2P Plus" mechanism for energy transactions. At first stage, a model was established for direct electricity trading among AEAs via P2P price bidding by adopting multi-dimensional willingness. At second "Plus" stage, the centralized coordination by distribution company (DisCo) was formulated as a constrained optimization problem with the objective of profit maximization.
In [18], a scheme for Automatic P2P energy trading was modeled as a Markov decision process using deep reinforcement learning. The authors presented the concept of prosumers with an energy storage system while considering objective of profit maximization through participation in P2P energy trading.
The architecture and analysis for system of Microgrids with P2P electricity sharing was presented in [19]. The paper presented various types of Microgrid which can be used, its hardware and software requirements along with results obtained using different methods. The authors deliberated development of energy trading technologies and its impact on the global socio-economic structure. Similarly, in [20] decentralized, secure protocols for localized energy trading and billing were presented which uses a bidding procedure centered on secure multiparty computations.
A fair energy trading system among a cluster of Microgrids was proposed in [21]. The system assumes a cluster of power buying/ selling Microgrids where a central buyer/ seller agent manages all power and financial transactions. Based on power demands of buyers, and grid selling and buying prices, buyer agent calculates the optimum bid price for purchase of energy.
Some hierarchical levels of P2P trading were introduced in [22] and [23]. In [22], hierarchical two-level electricity trading system was proposed, where at lower level a hierarchical coordination system considered for economic dispatch of energy within the country. At the higher level, a parallel coordination system was proposed for international electricity exchange. In [23], a hierarchical P2P energy trading structure was presented, which offered effective energy trading in Microgrid. A three-level hierarchy framework was proposed considering P2P among Nanogrids within the community Microgrid, P2P among the community Microgrids in a Multi MG system and P2P among the various Multi Microgrid system. The fundamental objective was to keep energy and power balance in each level and reduce dependency of Microgrid on the main grid.
In [24], the authors proposed Intelligent Priority Selection based Reinforcement Learning (IPS-RL) to cater cyberattacks in P2P energy trading focusing on online detection of False Data Injection Attack (FDIA). A scheme for optimal energy management in Microgrid was presented in [25] considering compressed air energy storage, RES and demand response programs with the objective of cost and emission minimization. Similarly, an energy scheduling approach considering thermal and electric reserve requirements was presented in [26] to minimize cost and carbon emissions using cuckoo optimization algorithm. An agent based strategy was presented in [27] for intelligent energy management in Microgrid using P2P energy transaction model considering an office building as test case. In [28], the authors presented hybrid demand response scheme for optimal energy trading in Microgrid using fuzzy clustering and Gaussian-based regularized particle swarm optimization techniques.

B. ENERGY CONGESTION MANAGEMENT (ECM) STUDIES
A lot of research work is proposed for solution of energy congestion problem in transmission and distribution network. A solution for energy congestion problem was presented in [29] for deregulated system considering wind energy penetrations. The approach was considering bus and generator sensitivity factors. Solution was proposed based on Honey Bee Colony Algorithm and Particle Swarm Optimization (PSO) to find optimal location for wind power generators.
A comprehensive review on power congestion in transmission system was presented in [30] considering conventional methods of congestion control, optimization tools and algorithms used to solve ECP, recent techniques, advancements and importance of topic for reliability of power system. A congestion management strategy for transmission network considering stability margins (transient and voltage) was modeled as multi-objective programming problem in [31] and solved using Normalized Normal Constraint (NNC) method.
The scheduling and planning of energy storage systems (ESS) to control congestion with renewable energy penetrations was discussed in [32]. The power from renewables was modeled as Gaussian PDF and Monto-Carlo simulations, and formulized as un-constrained optimization problem, which was solved using PSO for optimal charging/ discharging of ESS.
An approach for management of energy congestion through cooperation of DSO (Distribution System Operator) and TSO (Transmission System Operator) was presented in [33]. In this paper, various issues of grid and market operations in the context of system states and congestion control strategies were presented and concluded that DSO-TSO cooperation is required to manage structural congestions on the borders of systems.
Cost based congestion management strategy was presented in [34] to address renewable energy curtailment considering grid constraints. The authors developed program for power flow analysis and congestion management under high renewable penetrations. It was concluded that congestion control scheme based on economic criteria provides control on tradeoff between cost and curtailment.
In [35], two approaches were presented to identify transmission system congestion and optimal scheduling of DGs and ESS was developed with objective of congestion mitigation. Transmission congestion management by integration of thermal and electrical systems was presented in [36]. The concept of Combined-Heat-Power (CHP) was adopted and formulated as Mixed Integer Linear Programming (MILP). The results indicates significant cost reduction through implementation of CHP congestion management strategy.
A hierarchical distribution congestion control scheme considering two stage functionality with objective to minimize operational cost was presented in [37]. Another hierarchical scheme for transmission congestion management was proposed in [38], for optimal scheduling of loads and generators using Darwinian PSO as solution algorithm. Application of ESS to manage transmission congestion by modeling system as multi objective optimization problem was presented in [39], where Multi Objective Genetic Algorithm (MOGA) was used for optimal location of ESS and new lines.

C. SOLUTION APPROACHES FOR KNAPSACK PROBLEM (KP)
In this research, ECP is modeled as Knapsack problem to connect/ disconnect prosumers from distributor in proposed P2P energy trading strategy. In the literature, various schemes and algorithms are used to solve KP. In [40], Binary PSO (BPSO) and Chaotic BPSO algorithms were used for the solution of multidimensional KP (MKP). The solution of 0-1 KP through monkey algorithm where greedy algorithm was used to strengthen ability of local search was presented in [41]. Another approach was presented in [42] to solve 0-1 KP by formulating as Integer linear programming (ILP) using CPLEX solver. In [43], author proposed artificial bee colony (ABC) algorithm for the solution of 0-1 KP. Solution approaches based on Differential Evolution Algorithms (DEA) were presented in [44], in which three differential algorithms were implemented to solve discounted 0-1 KP. Another algorithm based on Whale Optimization was proposed in [45] considering penalty and sigmoid functions to solve multidimensional and single dimensional KP. Metaheuristic algorithm based on Gray Wolf Optimization (GWO) was proposed in [46] to solve large scale MKP using evolutionary mechanism. The comparison of various meta heuristic algorithms was presented in [47], in which solution quality and computational time was considered to solve high and low dimensional 0-1 KP. In [48], KP was solved using combinatorial branch-and-bound method considering branching scheme and simulated using MILP solver. Binary equilibrium optimization (BEO) was proposed in [49] considering sigmoid, penalty and repair algorithm to solve small, medium and large scale Knapsack problems.

D. RESEARCH CONTRIBUTIONS
Despite many studies on P2P energy trading and congestion management are conducted separately, still a comprehensive strategy is required to address the problem through a combined system development considering all design parameters of P2P trading model and energy congestion management. To fill this gap, a novel scheme is proposed in this paper which initiates contracts among users in MG, monitors and controls power transactions, calculates penalties and energy cost for each user and solves energy congestion problem. Proposed NP2P model allows each user to access equal available surplus power in Microgrid. Similarly, same energy cost based on Dynamic Pricing Scheme (DPS) is charged for all users. The main novelties of research work are centralized contracting among users and energy congestion control in distribution network using P2P energy trading mechanism. The utilization of renewable energy sources is increased by implementing congestion control strategy. The summary of research contributions of this paper is follows:  In this paper, P2P energy trading and congestion problems are mathematically modeled to achieve objectives of energy cost minimization and load reduction on main grid.
 Energy Congestion Problem (ECP) is modeled as Knapsack Problem (KP) and solved using Greedy and Simulated Annealing Algorithms.
 Normalized P2P scheme, Greedy and Simulated Annealing Algorithms are implemented considering three different cases to solve energy trading and congestion problem in Microgrid.
 Elimination of competition between buyers is achieved through establishment of central contract in MG for fair energy distributions.
 Finally CEMU establishes contracts, manages power transactions, calculates penalties, calculates payments and manages energy congestion in Microgrid distribution network.
To implement NP2P energy trading scheme, three different cases are considered to confirm effectiveness. In Case-1, all users are considered as 'Consumers' with energy consumption from main grid. Case-2 is considered as prosumers to sell surplus energy to main grid and consumers buy energy from grid. The benefits of proposed NP2P energy trading scheme are confirmed using Case-3, where consumers buy energy from prosumers through centralized contracting inside Microgrid. The paper is structured as follows. Section II provides problem formulation for NP2P energy trading and congestion management schemes. Section III gives the proposed solution methodologies and algorithms. The results are presented and discussed in Section IV and conclusion are provided in Section V.

II. PROBLEM FORMULATION
In this section, mathematical model of NP2P energy trading and ECP will be discussed. The objectives of research are:  To minimize electricity cost for all users in Microgrid by implementing NP2P energy trading scheme.
 To minimize load on main grid through efficient utilization of distributed energy in Microgrid by implementing NP2P energy trading scheme.
 To maximize connected number of prosumers with surplus energy through energy congestion management schemes with Microgrid to minimize load on main grid.
Various operating conditions considering objectives and constraints are elaborated in following sub-sections.

A. SIMPLIFIED SYSTEM ARCHITECTURE
A simplified system model is shown in Fig. 1, representing the required components for NP2P energy trading in MG.
The system defines prosumer community with some surplus energy and power demands, Smart Metering (SM) infrastructure, and connectivity of all components. Central Energy Management Unit (CEMU) monitors and records the power transactions, creates contract, implements DPS, calculates bills, payments and penalties in prosumer community and controls energy congestion on distributor.
The system is to monitor APTC continuously, which requires information of demands in P2P connected prosumer community. Based on information of surplus energy, demand, connectivity status and contractual limits of prosumers, CEMU performs the operations of energy trading and congestion control in MG. By implementing centralized contracting through CEMU, each user have equal access to available surplus power in MG and have equal price for per unit energy consumption.
In proposed system formulation, we consider N prosumers, which have power generation using solar or diesel generator, and their power consumptions, where each prosumer is expressed by n where n = 1, 2,3, … N. The prosumer n can buy/sell energy from/to Microgrid. Each prosumer n may have some surplus power S p,n , that can be shared using NP2P mechanism or it needs more power than its generation (negative surplus) D p,n . In selection procedure, we only consider the prosumers which have positive surplus power. The capacity of distribution line is considered as nonnegative integer APTC. The variations in demands and surplus are managed through Energy Management Unit (EMU) and SM in home area network. Disconnection/ reconnection process can be done by CEMU using SM communication. Power losses and other system constraints, such as reactive and active powers in terms of phase, frequency and voltage, are not considered.
Proposed NP2P scheme utilizes existing power distribution network of utility/ distribution company Karachi Electric (KE). The distribution company operates, manages and monitors entire P2P network and CEMU.

B. NP2P ENERGY TRADING MATHEMATICAL MODEL
This research assumes a network of 'N' prosumers connected together in a Microgrid to exchange power among them. Microgrid is connected to main grid and all the power sources of Microgrid are synchronized with main grid. Any additional requirement of power that Microgrid cannot fulfill, will be provided by the main grid. All prosumers have SM network which monitors the connection of prosumers to grid and measures the actual power transactions in Microgrid. The prosumers are also equipped with a Data Monitor which receives data serially from SM and performs energy calculations. It establishes communication with CEMU to provide information about prosumer connection status and power exchange with Microgrid. The Data Monitor has a GUI to display all the parameters and has several options to check daily power contract, bill and payment status. The CEMU also has a GUI to display and controls the power trading autonomously. The system model shown in Fig. 1 presents system architecture of proposed scheme.
Each prosumer on the Microgrid is assigned a unique ID and IP Address which is used by CEMU to exchange data and commands. It is assumed that each seller can control their power output. Each seller has a power generation controller installed with their source.
If a user chooses to be a seller, he enters the maximum and the minimum surplus power . The user will also provide information of power generation source (solar or diesel generator) and selling rate of energy ( ). If a user chooses to be a buyer, he enters the power required from the Microgrid . The maximum power available to each buyer is equal to the total surplus power available by sellers divided by number of buyers.
Assume is the current power produced by and is the current power consumed by . The total current power generated by sellers is: And the total current power consumed by buyers is: The maximum power available by sellers is given as: Where is equal to '0', if seller is disconnected from the system to manage congestion. The available power in pool is Maximum Power available to each buyer: Unlike other P2P energy trading mechanisms where buyers and sellers agree to a common power rate, no power rate agreement is made between the buyers and sellers in this model. This model uses an algorithm of DPS to calculate hourly energy rate in MG. The CEMU calculates current energy rate based on current available surplus power of sellers. This algorithm eliminates the need of competition and requirement of any matching algorithm between sellers and buyers. Each buyer has an equal opportunity to the power available in Microgrid. At the end of day, CEMU will calculate bills for buyers and payments for sellers. All these functions of the CEMU are elaborated in following subsections.

1) DYNAMIC PRICING SCHEME (DPS)
The proposed NP2P model uses DPS to calculate the current rate of energy, based on seller's available surplus power, which is then utilized to calculate bills for buyers. Algorithm utilizes the information about surplus power generated by each sellers and rate set by sellers during formation of initial daily/ monthly contracts. Equation (6) gives current rate of energy: The DPS algorithm is dependent upon current power generated by sellers. A seller having more surplus power, will have higher influence on the rate. In order to keep the rate as low as possible, CEMU has to accommodate more power of solar powered sources.

2) CALCULATING MAIN GRID POWER
During the day if power consumed by buyers exceeds surplus power produced by sellers, Microgrid will start to accept power from main grid to fulfill power deficiency. Equation (7) gives additional power calculation: The main grid's power can either be positive or negative. It will be positive if more power is being consumed by buyers than surplus available in MG. Similarly, it will be negative if surplus power available in MG exceeds consumption of buyers. In case of negative power, sellers will be asked to reduce their power outputs even if they are operating under the maximum limit to minimize energy congestion. In the other case, if the main grid's power is positive, CEMU will calculate the extra power used by buyers greater than defined for that day. This is defined as excess power for that buyer ( ). If the combined excess power of all the buyers is equal to the main grid's power, CEMU will not send any power raise request to sellers. Even if all the sellers are working under maximum surplus power available. But if total excess power ( ) of buyers is less than the main grid's power, a power raise request will be sent to sellers. If the main grid's power is greater than the excess power of the grid, CEMU will identify which sellers ( ) are operating under the maximum power ( < ).
The CEMU will generate power raise request to sellers, which will continue until total excess power of buyers becomes equal to . The algorithm for power raise request is presented in (8).

3) CALCULATING PENALTIES
Penalties are imposed on all prosumers in Microgrid when they do not comply with contract of the current day. These are calculated in terms of power and charged at 10% of main grid's rate. The penalty is imposed on a seller if it is producing surplus power less than the minimum power ( ) agreed as per contract of the day. It is given as: If any seller in the Microgrid is producing power less than the minimum surplus, the deficit power ( ) is calculated. This is used to calculate penalty to be imposed at the 10% of rate of main grid rate ( ). In this case other sellers would be requested to raise their power to fulfill deficiency of energy.
Similarly, if a buyer consumes more power than defined amount of power as per contract, excess amount is charged as penalty ( ℎ ), at 10% more on rate of main grid.

4) CALCULATING BILLS AND PAYMENTS
Bills and payment calculations are important aspect of proposed NP2P model. CEMU performs bills and payments calculation on per minute basis and sums the result at the end of day. Calculations are performed on per minute basis because of continuous change in the rate of energy as mentioned in (5). Bills are calculated of buyers for actual surplus power used. The per-minute energy consumed by each buyer is stored in a database called 'Power Database'. Let 0 be the total energy consumed by a buyer at time 0 and 1 be the total energy consumed at time 1 (one minute later). The algorithm for per minute energy consumed by buyers is given in (11).
The power utilized from Microgrid is first calculated. Then energy is calculated from that power. The current rate of energy is multiplied with this difference energy ( ) to calculate the bill of that particular minute. This bill is stored in the database for time 0 . Similarly, bills are calculated on per minute basis for the entire day. These are summed at end of the day according to (12).
The payments to sellers are calculated simply by multiplying the rate set by the seller ( )/ rate of main grid and total energy exported by seller to the grid during whole day. Penalties are added/ subtracted in/from the bills/payments. All the information is communicated to respective users at the end of day.

C. ECP MATHEMATICAL MODEL
In distribution network, distributer has a limit of power transfer which is called Available Power Transfer Capability (APTC). From each prosumer, a surplus power is being transferred to distributer. The sum of all surplus powers should not exceed APTC limit. Based on this phenomena, energy congestion problem in distribution network can be considered as Knapsack (KP) problem where we have to determine which prosumer should be disconnected to eradicate congestion or it may remain connected. Hence it can be considered 0/1 Knapsack problem where is 1 if unit remain connected and 0 if unit should be disconnected.
Mathematically, it can be modeled as = ∑ ∈ (13) Where is the total number of connected prosumers and is set of units having positive power surplus.
can be 0 or 1, so it is Binary Integer Programming problem. The objective is to maximize connected surplus power by maximizing total number of connected users with surplus power.
By increasing connected users, from communication point of view, data traffic for disconnection process will be reduced and from power point of view, as many units are connected, their energy can be utilized in P2P trading.
To remove congestion, the surplus power of any prosumer can be decreased by increasing its own demand while keeping capacity under considerations. It can be defined as demand objective.
It should be considered that the prosumer with higher energy efficiency should not be disconnected. The energy efficiency of prosumer can be defined as the ratio of , and , .
Where ή is the energy efficiency of prosumer . Similarly, overall energy efficiency can be defined as the ratio of cumulated demands and cumulated surpluses.
By considering energy efficiency, the prosumers with low energy efficiency can be encouraged to increase power utilization during solar hours.
From the above formulation, it is clear that ECP is a standard 0-1 Knapsack problem, which can be defined using following equation. Where is Profit of item , is Weight of item and is Weight capacity of bag.

III. PROPOSED SOLUTION APPROACHES
A scheme for P2P energy trading based on equal-opportunity based solution is proposed where all consumers are treated equally for power flows and pricing of consumed energy. Proposed scheme manages and controls the power transfer, creates monthly contracts between buyers and sellers, calculates bills based on dynamic pricing scheme, imposes penalties and records all the power transactions in prosumer community. The energy congestion caused due to P2P power transactions is managed through solving ECP. Greedy and Simulated Annealing algorithms are proposed to solve ECP in Microgrid. The solution approaches are elaborated in following sub-sections.

A. NORMALIZED P2P ENERGY TRADING SCHEME
A normalized scheme for the development of P2P energy trading in prosumers community is proposed in this paper. Central Energy Management Unit has the ability to initiate contracts and manage power transactions in Microgrid. Each prosumer can decide to be producer (with surplus energy) or consumer (with power demand) on hourly basis to cater intermittent nature of renewable energy resources. Each producer provides information of available min/max surplus energy with per unit price. Similarly, consumer provides their demand profiles. Based on all information from prosumers, CEMU establishes the contracts, monitors power flows, imposes penalties, calculates bills and sends information to all stakeholders at the end of the day. To ensure that surplus power is available to all buyers on Microgrid, the competition between buyers for cheap electricity is eliminated. The rate of power for buyers is calculated by CEMU based on the current generation. If a user does not want to change any of the information, data of previous day is used. Once roles have been decided along with its parameters, CEMU will store these parameters in a database and create a contract between sellers and buyers. CEMU will also continuously monitor the exchange of power from prosumers to Microgrid. It will calculate maximum available power from all sellers, power available in pool and the total current power consumed by buyers.
The proposed scheme for P2P energy trading based on mathematical model provided in previous section, can be summarized in following steps: 1. Initiation of contract creation by CEMU.
2. User definition as producer or consumer.
3. If user is power producer with surplus energy go to next step. Else goto step-7.
4. Definition of minimum and maximum surplus power limits, by each producer.
5. Definition of power source as solar or diesel generator.
6. Definition of per unit energy cost by each producer.
7. Definition of power requirements by each consumer. 8. CEMU saves all the information of prosumers and initiates power transactions.
9. CEMU calculates energy requirements from main grid (if any).
10. CEMU implements Dynamic Pricing Scheme for energy cost calculations in Microgrid.
12. CEMU manages energy congestion on power distributor according to algorithms proposed in next sub-section.
In NP2P scheme, users can define their parameters on hourly basis and contracts are managed based on user definitions. It provided an opportunity to prosumers to manage their power generations accordingly. In this scheme, DPS provides equal opportunity to all users for power consumption at normalized rate. Imposition of penalties demotivates the users to violate contractual obligations and helps CEMU to forecast power demand accordingly.

B. ECP SOLUTION ALGORITHMS
As formulated in the previous section, ECP is 0/1 knapsack problem. Different algorithms and solution techniques are available for the solution of 0/1 knapsack such as genetic algorithm, dynamic programming, backtracking and particle swarm optimization algorithm. In this sub-section, greedy approach and simulated annealing based algorithms are discussed and proposed for the solution of ECP in P2P energy trading.

1) SOLVING ECP USING GREEDY ALGORITHM
Greedy algorithm works for the local optimal solution. It makes the choice of best solution so far and this provides solution to sub-problem. The decision made by greedy algorithm depends on previous choices. By extending the solution through this manner, it achieves global optimal solution.
For ECP in NP2P mechanism, it is assumed that the information of power demands and generated power from each prosumer is received on CEMU through SM. The prosumers with positive surplus power are considered for connection/disconnection process. The distribution feeder overload should be monitored at every instant. VOLUME XX, 2017 9 If is greater than 0, the feeder is overloaded and algorithm must start work for congestion management. If overloaded than after sorting surpluses in descending order, algorithm will start disconnecting houses from distribution feeder. It will connect the units up to limit and check power overflow again. If overflow occur, some connected units with less power efficiency must be disconnected and some units from the remaining with higher power efficiency must be connected such that the total surplus of connected units remain inside the limits. It is a very good approach and maximizes total number of connected units. The step by step explanation of Greedy algorithm to solve congestion problem is provided in Algorithm 1.

2) SOLVING ECP USING SIMULATED ANNEALING ALGORITHM
Simulated Annealing algorithm provides a strategy for solution of combinatorial optimization problem and avoids to fall the solution in local minima/maxima. Annealing is a process of cooling red hot metals in specified steps and energy decrease at every step is considered. Annealing process is used in metallurgy where metals are heated and then controlled cooling is provided for better structure formation of crystals and defects elimination. On the basis of annealing process, SAA achieves global optimal solution in iterative fashion. Simulated Annealing algorithm decides probabilistically from one solution to the neighboring new solution. The probabilities of movement leads algorithm to move towards final low energy state. These movements are repeated until system achieves final best solution. The probability at each step is calculated and it depends on change in energy and temperature. It can be formulated as Boltzmann Probability.
where ∆ is Change in Energy, ĸ is Boltzmann constant and T is Temperature at which change in energy occurs. Energy Congestion Problem can be modeled and solved using SAA through following steps: 1. Calculation of energy efficiency of each prosumer present in P2P energy trading mechanism.
2. Connection of prosumers with distribution network until total connected surplus power reached to limit.
3. Initialization of SAA parameters, limit, available total surplus power (S_Total) and best total surplus power (S_Total_Best) in MG. 4. Picking a random prosumer i which is not connected with distributor.
5. Connect prosumer i with distributor. If sum of connected surplus is less then then go to next step. Else jump to step 10.
6. Pick any other prosumer j which is not connected with distributor. If sum of connected surplus is less then then go to next step. Else jump to step 9.
7. Calculate difference of surplus power (∇ = , − , ) of both considered prosumers. 8. If ∇ is negative, select prosumer j to connect with distributor and add , in S_Total. Else go to next step.
9. Select prosumer i for connection and add , in S_Total.
10. Pick any random prosumer k which is connected with distributor.
11. Disconnect prosumer k. If S_Total is less then then go to next step. Else go to step 14.
14. Select prosumer k to remain connected and add , in S_Total. 15. If S_Total is greater then S_Total_Best, then assign it as new best value of surplus power. 16. Go to step 4 and continue till achievement of defined SAA parameters (e.g. Target temperature).
17. Obtain final value of S_Total_Best and terminate.

A. ASSUMPTIONS
1. No energy storage system available in Microgrid.
3. Each prosumer can update his information on hourly basis. 4. All generation units are operating at rated power. 5. Fixed energy rate is considered from main grid. 6. Prosumers with solar power provides minimum/ maximum surplus value during solar hours. 7. Calculations are performed for 24 hours and same algorithm will repeat for other days of month with different prosumer parameters. 8. The load of consumers is considered as domestic load to operate their home appliances. 9. The prosumers have Photo-Voltaic and diesel based energy generating units. 10. ECP is considered for affective solar hours to manage congestion due to high Photo-Voltaic (PV) penetrations.

B. NP2P ENERGY TRADING -VARIOUS CASES
Various outcomes of proposed NP2P energy trading scheme will be discussed in this section considering three different cases in power distribution network. In Case-1, all Analysis are performed to find various parameters of users i.e. load on main grid, energy cost, prosumers surplus power and benefits etc. for all cases.

1) CASE-1: ALL USERS CONSIDERED AS CONSUMERS
As mentioned earlier, this case considers that all users are consuming energy from main grid and no distributed generation available in distribution network. In this regard, Fig. 2 presents a power loading on main grid during 24 hours of a day. A maximum peak was observed at 2200 hours with power demand of 193KW, as shown in Fig. 3. On the contrast, minimum power demand from main grid occurs at 0500 hours with 128.5KW.
The energy consumed by all users and their daily cost in Case-1 is presented in Fig. 3

2) CASE-2: PRODUCERS SELL ENERGY DIRECTLY TO MAIN GRID
Microgrid with distributed generation is considered in Case-2, where 11 users are considered as prosumers and 19 users are consumers. Prosumers have their energy requirements, as well as, power generation capabilities. The surplus power profile of prosumers is provided in Fig. 4, including energy source and energy cost (PKR/KWH). It indicates that 6 users have solar based generation and 5 have diesel generating stations.
The surplus power profile of prosumers is presented in Fig. 5, which clearly indicates that surplus energy is high during effective solar hours. It is assumed that diesel generator operates for 24 hours, while solar power generation works only during affective solar hours. It is observed that maximum surplus energy is available in Microgrid at 1200 hours (66KW), as shown in Fig. 6. The surplus power also depends on power demands of prosumers, In this case, prosumers sell surplus energy to main grid during light load periods. Other users can buy energy from main grid to meet their power demand for whole day. The net cost (consumed energy costsurplus energy cost) of energy for prosumers is presented in Fig. 7, which indicates that P-18 have maximum bill (1089 PKR) and P-22 have minimum bill (-925 PKR) for 24 hours. The net cost of prosumers is decreased significantly in Case-2. A negative bill indicates profit of consumer by selling surplus power. Daily energy cost of all users is presented in Fig. 8, indicates that consumers have same cost as in Case-1 but prosumers have reduced energy cost because of distributed generation.
A significant decrease is observed in load on main grid in Case-2. Due to distributed generation, prosumers reduced their power consumption from grid and provide surplus to grid, which reduces overall power demand from main grid as shown in Fig. 9. The maximum main grid loading reduced to 136KW and minimum power requirements approaches to 74.5KW.

3) CASE-3: NP2P ENERGY TRADING WITHIN MICROGRID
The efficiency and benefits of proposed NP2P energy trading strategy are verified through simulation results provided in this sub-section. In Case-3, surplus energy of prosumers is used to meet power demands in Microgrid, and remaining surplus sent to main grid. In NP2P model, prosumers have more reduced net energy cost by sharing surplus power in Microgrid. In Fig. 10, the cost of prosumers is presented which indicated a considerable reduction.
To calculate energy cost for all users, Dynamic Pricing Scheme is used, which provides same rate of available surplus energy in Microgrid for each user. As shown in Fig.  11, the maximum price is 15.4 PKR/KWH at 2100 hours. It is noteworthy that selling rates of prosumers are same as considered for Case-2. This strategy omits First-Come-First-Serve based pricing schemes which charge higher energy cost to users who are late in bidding system. The overall cost of all users, calculated based on DRC algorithm is presented in Fig. 12.
Implemented NP2P energy trading strategy have much decreased load on main grid as shown in Fig. 13, as compared to Case-2. The peak demand from main grid reduced to 131KW at 2200 hours and minimum power requirement approached to 17.5KW at 1100 hours.
NP2P also imposed penalties on users upon violations of contract agreements. If a consumer consumes more energy than defined in agreement, penalty is imposed for excess power consumption at rate defined in Section II. Fig. 14 presents penalty calculations of User-5, which indicates contract violations at 0200, 1100 and 2000 hours by consuming more power (4KW, 6KW and 4KW respectively) than defined in contract. The cost of energy in both scenarios is also shown in same figure. Total cost of energy consumed as per contract is 1860 PKR and cost of actual consumed power is 2130 PKR for 24 hours. Original price of consumed energy is 2100 PKR and imposed penalty for contract violations is 30 PKR. Same method was implemented for penalty calculations on producers, if they produce less energy than defined in contract.

4) COMPARISON OF SIMULATION RESULTS FOR ALL CASES
The implementation of NP2P model have two major objectives: i) Cost Minimization and ii) Decrease in load of main grid. The results indicates significant achievement of both objectives. The comparison of energy price is presented in Fig. 15, which confirms a total cost reduction of 44% and 13% as compared to Case-1 and Case-2 respectively. For the second objective, a comparison of load on main grid is provided in Fig. 16, indicates load reduction of main grid by 52% and 27% as compared to Case-1 and Case-2, respectively.

C. ECP SIMULATION RESULTS
The problem of energy congestion arises as distributed generation penetrates in Microgrid. It is observed in previous sub-section that high energy penetrations are present at distribution network during peak solar hours. The trends of utilizing RES is increasing day by day, which can lead a serious energy congestion problem in distribution system. It is assumed that total power carrying capability of distributor is 200KW and real time is calculated by considering loading of power distributor at each hour. Greedy and Simulated Annealing algorithms are used to solve ECP in distribution network. Simulation results are discussed in the following:

1) SOLVING ECP USING GREEDY ALGORITHM
The simulation results of Greedy Algorithm are provided in Fig. 17, where different parameters indicating algorithm efficiency are presented. The objective of ECP is to connect maximum available surplus with Microgrid to utilized P2P energy trading concept effectively. Simulation results indicates that maximum surplus power connected with Microgrid is 58.5 KWH at 1100 hours and total surplus power in Greedy algorithm for 24 hours is 496.5KW.

2) SOLVING ECP USING SAA
Simulated Annealing Algorithm operates on basis of annealing process in metallurgy engineering to develop specific structure of molecules by step by step change in temperature and energy. Simulation results of SA algorithm to solve ECP modeled as Knapsack problem is provided in

3) COMPARISON OF PROPOSED ALGORITHMS FOR ECP
A comparison of simulation results for both algorithms is provided in Fig. 19, which indicates that SAA is 2.7% more efficient than Greedy Algorithm when compared with respect to connected surplus power. On the other hand, Greedy Algorithm outperforms SAA by 8% when compared w.r.t number of connected prosumers as shown in Fig. 20. It is noteworthy that there are always tradeoff for the solution of combinatorial problems.
More surplus power connected with distribution network have benefits to Microgrid and load on main grid will be decreased. Moreover, distributed generation and renewable energy can be utilized more affectively by connection with distribution network. On the other hand, benefits of more connected number of prosumers are decreased communication system requirements for disconnecting prosumers from distributor. In complex networks, communication requirements plays a vital role for transfer of information between users, Microgrid and main grid.
In proposed NP2P model, surplus power of prosumers is more important consideration as it decreases overall load on main grid and cost of all users in Microgrid. The performance of SAA is 2.7% better while considering surplus power of connected prosumers.

V. CONCLUSION
P2P energy trading enables affective and enhanced penetration of RES in Microgrid. In this paper, the effectiveness of proposed NP2P energy trading was verified through implementation on small scale Microgrid distribution network. Simulation results proves that proposed scheme achieves objectives of energy cost reduction and load reduction on main grid. The energy congestion, which occurs during peak solar hours was managed through Greedy and SA algorithms, where SAA outperforms by connecting Although proposed scheme acquired good results, still there are some potential limitations to be discussed. Due to the application of energy storage systems, demand-supply scenarios may be changing dynamically. Moreover, modeling of stochastic behavior of wind power generation is necessary for affective utilization of RES. The proposed research work can be extended in future by introducing wind power generation, energy storage applications and multilevel energy trading mechanism considering multiple Microgrid networks.