A Novel Strategy for Optimising Decentralised Energy Exchange for Prosumers

The realization of the Smart Grid vision will change the way of producing and distributing electrical energy. It paves the road for end-users to become pro-active in the distribution system and, equipped with renewable energy generators such as a photovoltaic panel, to become a so called “prosumer”. The prosumer is engaged in both energy production and consumption. Prosumers’ energy can be transmitted and exchanged as a commodity between end-users, disrupting the traditional utility model. The appeal of such scenario lies in the engagement of the end user, in facilitating the introduction and optimization of renewables, and in engaging the end-user in its energy management. To facilitate the transition to a prosumers’ governed grid, we propose a novel strategy for optimizing decentralized energy exchange in digitalized power grids, i.e., the Smart Grid. The strategy considers prosumer’s involvement, energy loss of delivery, network topology, and physical constraints of distribution networks. To evaluate the solution, we build a simulation program and design three meaningful evaluation cases according to different energy flow patterns. The simulation results indicate that, compared to traditional power distribution system, the maximum reduction of energy loss, energy costs, energy provided by the electric utility based using the proposed strategy can reach 51%, 66%, 97.5%, depending on the strategy. Moreover, the proportion of energy self-satisfaction approaches reaches 98%.


Introduction
The traditional way of producing and distributing electrical energy is undergoing major changes.From a hierarchical system where energy is centrally produced and 'pushed' down to the users, we currently experience more and more distributed generation with energy flows that become multi-directional.According to the US Department of Energy [1], the Smart Grid is a term used to illustrate the evolution of the Power Grid that adopts Information and Communication Technology (ICT) to improve its efficiency, reliability, economics, and environmental sustainability.Traditional power systems are centralised with respect to energy generation (i.e., thermal and nuclear power generation), energy providers (i.e., electric utility), and operate a hierarchical energy transmission and radial energy distribution networks.Its overall efficiency is about 30% [2].However, the Smart Grid introduces distributed energy generation (DEG) based on renewable energy sources (RESs) and decentralised energy exchange in distribution networks based on bidirectional flows of energy.Compared to the traditional power system, the Smart Grid with distributed energy generation providers a much higher efficiency that is estimated to approach a value of 70% [2].
In the present work, we assume a future scenario where renewable energy generators based on photovoltaic (PV) panels and small wind turbines enable end-users to produce electrical energy and to distribute it freely among each other.In other terms, all end-users are connected to local energy markets.After fulfilling their individual needs, their surplus energy can be transmitted to other end-users that need to buy energy.The motivation for the exchange is monetary.This means that there can be multiple energy providers supplying energy at various prices.The end-user engaged in both energy production and consumption is called a prosumer.We use the term decentralised energy exchange to express the trading of surplus energy among prosumers in the distribution network.By contrast, centralised energy exchange is that end-users buy energy from or send their surplus energy to a centralized operator.All of the features described above compose a Prosumer-involved Smart Grid.Achieved by encouraging distributed energy generation and decentralised energy exchange on a local scale (i.e., in the same distribution network), the Prosumer-involved Smart Grid offers two important advantages: reducing the consumption of energy sources based on fossil fuels; and improving independence from the centralised energy generation and central energy providers [1].In this paper, we consider the medium and low voltage grids as part of the distribution network, including the substations.With the term "local scale" we identify residential area that is covered by a sub-network of the distribution network running at low voltage without substations.
The present paper focuses on optimising decentralised energy exchange in the Prosumer-involved Smart Grid considering prosumer involvement, energy loss of delivery, topologies, energy flows, and physical constraints of the distribution network.The optimisation objectives are to reduce energy loss of delivery, to enhance independence from centralised energy generation and central energy providers, and to decrease energy costs for the end-users.To achieve these goals, we proposed a mathematical model of the optimisation problem and a peer-to-peer (P2P) model of the Prosumer-involved Smart Grid.The models are richer than purely topological ones in considering also basic power flows, while simpler than detailed power flow models.In other terms, one has to find a balance between adequate physical modelling and the scale at which a phenomenon can be observed.Given our interest in looking at possible alternative distribution alternatives, we chose an intermediate approach between a traditional precise power engineering modelling and a topological/statistical one.We propose novel algorithms for the energy routing.To compare routing strategies, we build a simulation tool and design three comparable test cases based on different energy flow patterns.The simulation results validate the effectiveness of the proposed solution.Compared to the traditional power system, the maximum reduction of energy loss, energy costs, energy provided by the electric utility based on our solution can achieve 51%, 66%, 97.5%, for each of the three cases.Moreover, the maximum proportion of energy self-satisfaction in the distribution network approaches the value of 98%.
The major contributions of this paper are: (i) an optimisation model of decentralised energy exchange considering energy loss of delivery, topology of the distribution network, ampacity of electric lines and directions of energy flows; (ii) algorithms based on P2P approaches and Graph Theory to solve the optimisation problem; (iii) a proposal for reducing energy loss in the distribution network and energy costs for end-users; and (iv) a model for improving the independence from centralised energy generation and energy providers.
The remainder of this paper is organised as follows.Section 2 discusses the related work.Section 3 presents a mathematical optimisation model of decentralised energy exchange.In Section 4, a solution with algorithms is illustrated and complexity of the algorithms is discussed.Approaches of building a simulation programme for evaluation is described in Section 5.The evaluation results are presented and discussed in Section 6. Section 7 concludes the paper.

Related Work
Many studies have investigated topics related to the optimisation of the Smart Grid.Some of them focus on modelling and optimising involvement of distributed energy generation [3][4][5][6][7][8][9].Others propose strategies for auction and bidding based on the Smart Grid vision [10][11][12][13].Recent research considers the theme of local energy exchange.This concept is one of the most significant innovations that the Smart Grid concept can bring to energy distribution.A prominent example is the PowerMatcher [14][15][16][17] which is an agent based architecture and related physical deployment demonstrating the feasibility of local energy exchange.Mocanu et al. [18] model the interaction between the Smart Grid and Building Energy Management Systems (BEMS) to optimise energy scheduling and energy costs of buildings.The model of the interaction involves energy exchange among neighbour buildings equipped with BEMS.Han et al. [19] present a model of energy exchange among base stations (BSs) of mobile networks for minimising energy bought from the electric utility for the BSs.In this model, each BS is equipped with a renewable energy generator and acts like a prosumer.It consumes the energy produced by itself and transmits surplus energy to other BSs that need energy without charging any cost.We share the vision of local energy exchange with these previous approaches, though focus less on the coordination mechanism, but rather on the energy flow for energy exchange and energy loss of delivery in the distribution network.In other terms, less on the prosumers choices, and more on the topology of the energy flows.
Another line of research is that on optimal power flow (OPF) problems in the Power Systems.Kim et al. [20] optimise power flows for sharing energy among battery storage systems installed in buildings.The proposed solution is based on the multiple travelling salesmen problem solved via a genetic algorithm.Chaudhuri et al. [21] propose a market-based method of OPF in the Smart Grid to minimise overall costs of energy production for the end-users.Although these studies consider power flows and energy loss of delivery, the prosumers were not modelled in the optimisation problem.Moreover, Gemine et al. [22] and Hauswirth et al. [23] focus on providing methods or computational tools to solve multi-period OPF problems for the distribution network.Their work did not consider the prosumers either.
The topology of the network has an important influence on the distribution and might need to change altogether in the new model for power systems [24].In [24] Pagani et al., we analysed the topologies of samples from the medium and low voltage power grids in the Netherlands.This analysis evaluated how topologies influence local energy exchange.The results indicate that the small-world model of the topology with average degree k ≈ 4 can provide a balance between the performance and the cost of deployment and operation of local energy exchange.Brown [25] argues for the necessity for non-radial distribution networks to support distributed energy generation in the Smart Grid.This is further emphasized in Dugan et al. [26].This study indicates that adopting the meshed distribution network in the Smart Grid provides the potential for reducing energy loss and improving the support for distributed energy generation.Based on this evolution trend of power system infrastructure, in [27] we analyse the lower layers of the distribution network from a static topological point of view.That previous study evaluated several graph models (e. g., small-worlds vs. random graphs) using approaches from Complex Network Analysis (CNA).The goal was to assess which topological models are most appropriate for supporting decentralised energy exchange and how topology models influence the costs of electrical energy transit in the Smart Grid.The contribution of Pagani et al. [27] highlighted the importance of topological models for enabling decentralised energy exchange in the Smart Grid.In this study, we go beyond a statical topological analysis and look into the actual power flows.

Decentralised Energy Exchange Optimisation
In the Prosumer-involved Smart Grid, end-users include electricity consumers and prosumers.By decentralized energy exchange, we mean a model in which any party connected to the grid can trade energy with anyone else.Next we provide details of the model we propose and on the definition of optimal power flow.

Assumptions and Mathematical Model
Some end-users without any (renewable) energy generators are simply consumers.Other end-users equipped with (renewable) energy generators are prosumers.The prosumer produces energy and consumes it directly.It also can sell its surplus energy at variable prices to anybody on the network.The electric utility is seen as a seller with infinite capacity.In a given time slot, a prosumer acts as a provider selling energy to consumers, if its energy production exceeds its energy consumption.In the opposite case, a prosumer becomes a consumer buying energy from providers or the electric utility.The distribution network delivers energy from the providers to the consumers with possible energy losses and under the governing physical constraints.End-users are connected via a local energy market to sell and buy energy negotiating on real-time prices.Energy prices in the local energy market fluctuate depending on tariffs offered by the providers.Our model is based on the following assumptions.
1.The actions of buying and selling energy are considered by the system as random discrete events.2. The actions of buying and selling energy are independent.They only are related to the energy production and consumption of the individual prosumer.3.All the actions, including trading (buying and selling) energy and transmitting energy, at any two different time slots are independent.4. At one time slot, a prosumer can be either a consumer or a provider.5.The provider prefers selling energy to the consumers.The provider sells energy to the electric utility only if it has energy that cannot be sold to the consumers.The consumer also prefers buying energy from the providers.6.There is energy loss in electric lines when delivering electrical energy in the distribution network.7. The costs of energy loss of delivery are paid by the consumer.8.We do not consider how to compensate energy losses of delivery.9. Energy loss only happens in electric lines.10.We only consider the active power in the distribution network.The reactive power is not considered.11.There is no voltage instability in electric lines.12.All the end-users are connected to the distribution network.
As a point of notation, we consider a system with EU = {eu 1 , eu 2 , ..., eu N } end-users of cardinality N. The set of time slot is represented by ∆T = {∆t 1 , ∆t 2 , ...} and ∆t i = ∆t j (i = j) and common to all users.A set of energy consumers at ∆t is defined as EC(t) = {ec 1 , ec 2 , ..., ec n }.A set of energy providers at ∆t is defined as EP(t) = {ep 1 , ep 2 , ..., ep m }, where n + m ≤ N.For each provider, we have ep i = (p i , v i ), in which p i denotes the energy price (EUR per kWh) of ep i and v i denotes the amount of energy provided by ep i .The energy amount that ec i buys from ep j is denoted by b i,j ∈ (0, v j ].
The energy produced and consumed by eu i are denoted by G i and C i respectively.Thus, we have Q i = G i − C i .It denotes the amount of energy that eu i can sell or it needs to buy.If Q i > 0, there is surplus energy for eu i to sell.If Q i < 0, eu i needs to buy energy to meet its demand.If Q i = 0, eu i is self-satisfied.It is neither a provider nor a consumer.

Objective Function
The proposed model considers energy losses due, for instance, to resistance.Since energy can have different routes depending on pairwise agreements, energy losses can vary per transaction.For saving energy costs, the consumer decides from which providers to buy energy and which delivery paths are used to transmit energy.In this scenario, the optimisation problems we propose to solve is concerned with "how to search the cheapest energy providers considering energy prices and energy loss, and how to organise delivery paths with minimum energy loss".
For the consumer ec i , the cost of buying an amount of x of energy is denoted by CoB(x).Energy loss of delivering x energy to the consumer is denoted by LoD(x).The delivery path from ep j to ec i , consisting of electric lines, is PATH(j, i) = {e 1 , e 2 , ...}.Energy loss in e ∈ PATH(j, i) is denoted by L e .Thus, when Q i < 0, the objective function of optimising energy costs for ec i at any given time slot is the following.

Production and Consumption Constraints
Based on the assumptions in Section 3.1, a prosumer can only be a consumer or a provider at the same time slot.
The set of prosumers is a subset of the set of end-users.It is also possible that some end-users are self-satisfied in a time slot.
The total amount of energy consumption and the total supply at each time slot has to be in balance.
In general, renewable energy sources are not stable.Outputs of renewable energy generators depend on weather conditions.To solve this problem, we introduce a super agent (i.e., electric utility or balancing agent) in our model.The super agent sells energy at a fixed price when the total outputs of renewable energy generators do not satisfy the total consumption needs.On the contrary, the super agent buys energy at another fixed price when the total outputs of renewable energy generators exceed the total consumption.The amount of energy provided by the super agent at ∆t is denoted by ES(t).If ES(t) > 0, the super agent sells energy to the consumers.If ES(t) < 0, the super agent buys the surplus energy from the providers.If ES(t) = 0, there is no energy trading between the end-users (including consumers and providers) and the super agent.Thus, the constraints on energy balance are given by:

Constraints on Ampacity and Energy Flow Direction
We consider two physical constraints of the distribution network.One is ampacity that is the maximum current-carrying capacity of an electric line [28].The other one is the direction of the energy flow (i.e., electric current) in the electric line.Because several energy flows can go through the same electric line only in the same direction at a given time slot.For example, if there is an energy flow in an electric line from point A to B at ∆t, another energy flow in this electric line from point B to A at ∆t is not allowed.
The ampacity of electric line e k is denoted by and the energy capacity of electric line is I max e k × V e k × ∆t where V e k is the voltage of electric line.The energy flow that starts from ep j going through e k is denoted by f (e k ,ep j ) .The direction of f (e k ,ep j ) is denoted by The constraints on ampacity and energy flow directions are described as follows. ∑ ∑

Energy Loss Calculation
Energy loss is computed by state information of each electric line.In the distribution network, electric power is delivered as alternating current (AC).In the AC system, the value of electric current and voltage can be expressed in the form of root mean square (RMS).The RMS value is the effective value of alternating current or voltage.It is equivalent to the value of the direct current (DC) that provides the same effect in a resistive load [29].Therefore, we applied RMS values of alternating current and voltage to the energy loss calculation.The symbols for the calculation are defined in Table 1 as follows.Based on the definition of Electric Power, electrical energy transmitted in a conductor is: Adopted from Equation ( 9), we can compute the electric current I by Equation ( 10) and the calculation of energy loss L in the conductor is represented as Equation (11).
Being L i the energy loss of an electric line in a delivery path, then the total energy loss in the delivery path PATH(a, b) is denoted by LOSS ab .

Peer-to-Peer Model of Prosumer-Involved Smart Grid
In our proposed model, thus, end-users are represented as nodes/peers; electric lines with electrical resistance are arcs with weights; produced energy has varying/dynamic prices for given finite amounts, while buffering and replication do not exist.The significant differences between this model and other graph-based models are that arc directions can change in different time slots, as they represent flows, and are finite in capacity.

Arc Dynamic Direction Matrix
To address the constraints of ampacity and energy flow directionality (Section 3.4), we design a data structure called Arc Dynamic Direction Matrix (M ADD ).In M ADD , each element denotes an arc and represents the state of the arc including its energy capacity, the amount of energy that it carries and its energy flow direction.The value of energy capacity of the arc (i, j) is fixed and it is represented by M ADD (i, j).AMP.The information relating to the energy flow is described by the value of M ADD (i, j), and defined next.
The value of the M ADD (i, j) is the value of the energy flow; = 0, M ADD (j, i) = 0 There are no energy flows; = N A, M ADD (j, i) > 0 It is not available to pass an energy flow from i to j; = N IL, M ADD (j, i) = N IL There is no connection between i and j.
(13) If M ADD (i, j) > 0, there is an energy flow in the arc (i, j) (from i to j).The value of M ADD (i, j) is the amount of energy carried by the energy flow.For the value of M ADD (j, i), it has to be N A (Not Available).On the contrary, if M ADD (i, j) = N A, there has to be an energy flow in the arc (j, i).Hence M ADD (j, i) > 0. If M ADD (i, j) = 0, there are no energy flows in (i, j) and the value of M ADD (j, i) has to be 0 too.Moreover, M ADD (i, j) = N IL means that there are no arcs between i and j (i and j are disconnected).The initial value of each element in M ADD is 0 or N IL according to the topology of the distribution network.
The purpose of designing M ADD is to check whether an arc is available to transmit electrical energy.Electrical energy is able to transmitted from the node i to the node j, only if i and j are connected; and there are no energy flows from j to i in the arc (i, j); and the value of M ADD (i, j) is less than M ADD (i, j).AMP.This function is the key step when optimising delivery paths for decentralised energy exchange in the distribution network.Then, Algorithm 1 for checking whether a node is available to transmit electrical energy is represented as follows.

Delivery Path Optimisation
We extend Dijkstra's algorithm [30] to find a shortest path from the provider node i to the consumer node j.In this algorithm, when visiting a node, the key step is to find its connected nodes that are available to transmit electrical energy using the Arc Dynamic Direction Matrix (M ADD ).To measure the weight of an arc, we use R/V 2 .Because V and R are the parameters that reflect the characteristics of the electric line, Equation (11).The resulting algorithm for finding the shortest-path in a weighted graph is Algorithm 2.
Algorithm 1 Find nodes that are available to transmit electrical energy for the node i.The node j is available for the node i, only if i and j are connected; and there are no energy flows from j to i; and the arc (i, j) has sufficient energy capacity.
1: procedure FIND-AVAILABLE-NODES(i) 2: Global variable: M ADD 3: Output: a set of nodes 5: for each node j in M ADD and j = i do 6: if M ADD (i, j) = N IL and M ADD (i, j) = N A and M ADD (i, j) < M ADD (i, j).AMP then return path 24: end procedure Algorithm 3 is used to plan multiple delivery paths with energy flows.After finding the shortest path from the provider node i to the consumer node j, Algorithm 3 checks whether this path has sufficient energy capacity to transmit the electrical energy injected by the provider.The energy capacity of a path is determined by the arc with the minimum energy capacity.If the capacity is sufficient, the algorithm ends with the identified delivery path.Otherwise, the algorithm calculates the amount of energy that cannot be transmitted among the path and finds alternative available delivery paths from i to j to transmit the rest of energy.This process continues until all the energy injected by the provider can be transmitted or there are no more paths from i to j, Algorithm 3.

Algorithm 3
Plan energy flows from a provider to a consumer.The algorithm plans one or multiple paths to transmit energy from the provider to the consumer considering the energy capacity of each electric line.Output: amount of energy that cannot be transmitted from the source to the destination capacity ← calculate energy capacity of (path) if capacity ≥ E then 10: f lows ← path with E a f low is a path with the energy it transmits.return f lows and rest 21: end procedure

Optimisation Step
Since one consumer's need is not necessarily satisfied by a single provider, then the computation of energy loss needs special attention.If multiple providers transmit different amounts of energy to one consumer, comparing the values of energy loss is not applicable.We define the proportion of loss (loss%) as the percentage of energy loss in all delivery paths.For each provider, we calculate the cost based on transmitting the same amount of energy to the consumer.This is the estimated cost that is only used for comparing providers.Algorithm 4 identifies the optimal providers for a specific consumer.
If the demand of consumers exceed the productions of prosumers, then the utility has to intervene.The consumer has to buy the rest of energy from the electric utility at a fixed price.We assume that the electric utility injects energy to the distribution network at a fixed node.Then, calculating energy loss of buying energy from the electric utility is the same as calculating the energy loss of delivering energy from the fixed node to the consumer.Algorithm 5 considers this case.

Example of Optimisation
To illustrate the working of the proposed algorithms, we provide a small and representative example of their execution.Consider the network shown in Figure 1.It consists of five nodes and six arcs.To simplify the example, we assume that the electrical resistance of each arc is 3 ohm and the voltage of each arc is 1 kV.Arc < A, B >, < B, C >, < C, D > and < A, D > have the same energy capacity that is 10 kWh.Arc < A, E > and < D, E > have the same energy capacity that is 20 kWh.The time slot for this example is 1 h, i.e., ∆t = 1 h.We start with Node A being a consumer.Its energy demand is 20 kWh.Node C and Node D are providers.Each of them provides 20 kWh with the price of EUR 0.15 per kWh.
Algorithm 4 Find optimal providers for a consumer 1: procedure FIND-OPTIMAL-PROVIDERS(consumer, E)

2:
Global variable: M ADD

3:
Global variable: all providers in ∆t that is EP(t)

4:
Input: consumer node 5: Input: amount of energy to buy 6: Output: one provider or a set of providers selected to buy energy 7: Output: amount of energy that cannot be supplied by the providers return cost 15: end procedure The procedure starts from Algorithm 5 that is launched by Node A. At the beginning of Algorithm 5, Algorithm 4 is called to find providers and get their energy costs for the consumer.Algorithm 4 calls Algorithm 3 to organise energy flows for Node C and Node D that are providers.Algorithm 3 calls Algorithm 2 to find the shortest paths for Provider C and Provider D and Algorithm 1 is called by Algorithm 2 to get adjacent nodes.In this example, we assume that Provider C is processed before Provider D. Firstly, Algorithm 2 returns a shortest path f 1 : C → B → A for Provider C. Then Algorithm 3 checks whether the energy capacity of this path is sufficient to transmit the energy required by Node A. Since the capacity of f 1 is 10 kWh that is insufficient, Algorithm 3 calls Algorithm 2 again to get another path f 2 : C → D → A for Provider C.After checking the capacity by Algorithm 3, f 1 and f 2 are able to fulfil the demand of Node A. When processing Node D, the arc < A, D > is not available.Because f 2 : C → D → A has taken all the capacity of < A, D >.Therefore, Algorithm 2 returns the path f 3 : D → E → A for Node D. After checking the capacity by Algorithm 3, this path has the sufficient capacity for transmitting 20 kWh to Node A. When Algorithm 3 returns, energy loss is calculated by Equation ( 12) in Algorithm 4 and energy costs are calculated in the same algorithm.For f 1 : C → B → A, the energy loss in C → B and B → A are 0.3 kWh and 0.28 kWh respectively.The total energy loss of f 1 is 0.3 + 0.28 = 0.58 kWh.For f 2 : C → D → A, its energy loss is same as f 1.Thus, Provider C has loss% = (0.58 × 2)/20 = 5.8% and the energy cost (20 + 0.58 × 2) × 0.15 = 3.17 EUR.For f 3 : D → E → A, the energy loss in D → E and E → A are 1.2 kWh and 1.1 kWh respectively.For Provider D, the total energy loss is 2.3 kWh with loss% = 11.5% and the energy cost is (20 + 2.3) × 0.15 = 3.35 EUR.Then, Provider C is selected to buy energy and the delivery paths are f 1 : C → B → A and f 2 : C → D → A. Finally, Algorithm 5 gets that the energy cost of Node A is 3.17 EUR and the procedure ends.

Performance Analysis
We use N to denote the number of nodes and use K to denote the number of arcs.The number of providers at a time slot is denoted by S. The distribution network of the Prosumer-involved Smart Grid is a connected graph, Section 3.1.This means that there are no disconnected end-users in the distribution network.
In Algorithm 1, the for loop checks all nodes in the graph.Its running time is O(N).The running time of Algorithm 2 depends on how we implement the distance[] that contains the values of weight in Line 5. Because this decides the performance of searching the minimum value in Line 9 of Algorithm 2. Numbering the nodes from 0 to N − 1 and we store the values of weight in the elements of an array indexed by the node number.Therefore, the performance of Line 9 in Algorithm 2 is O(N).In the main for loop starts from Line 8 of Algorithm 2, the running time of Lines 9 and 13 are both O(N).The running time of the for loop starts from Line 14 of Algorithm 2 is O(K).Then, the performance in the main for loop is O(N + N + K) = O(N + K).Since the main for loop runs N − 1 times, the overall performance of Algorithm 2 is O((N − 1) × (N + K)) = O(N 2 ).
In Algorithm 3, Line 8 compares all the arcs in a path to find the arc with the minimum energy capacity.Its running time is O(K).Updating elements in Lines 12 and 17 both run N times.The performance of Line 7 is O(N 2 ) as discussed above.How many times the while loop runs is difficult to measure.Because it is decided by the number of paths from the source node to the destination node and the energy capacity of these paths.Considering the number of paths between two nodes is no more than the number of arcs in a graph, we estimated that the while loop runs no more than K times.Thus, the complexity of Algorithm 3 is In Algorithm 4, the for loop in Line 8 and the while loop in Line 15 both run S times.The performance of Line 10 is O(N 2 + K 2 ) as discussed above.Based on Equation ( 12), the worst case complexity of calculating energy loss in a delivery path is O(K 2 ).In Line 16, the time consumed by selecting the provider with minimum estimated cost is O(S).Outside of the loops, the running time of updating EP(t) is O(S).Thus, the overall performance of Algorithm 4 is O(N 2 + K 2 + S 2 ).Since S ≤ N, the performance is given by O(N 2 + K 2 ).
The complexity of Algorithm 5 is decided by Algorithm 4 (in Line 5).Therefore, the overall performance of the whole solution is O(N 2 + K 2 ).In practice, the distribution network is normally not a complete graph because of the high construction costs of the infrastructure.Therefore, there are only a few paths between two nodes.In Algorithm 3, the times of running while loop should be T while K.In this case, the performance of the proposed solution is O(N 2 ).It is beyond the scope of the present treatment to identify whether the given complexity is an upper or a lower bound to the problem at hand.

Simulation
To verify the solution developed in Section 4, we build a simulation programme to represent the Prosumer-involved Smart Grid.This simulation programme involves end-users, prosumers, dynamic pricing, energy production, energy consumption, energy loss of delivery and a distribution network based on an IEEE test feeder.To make the simulation realistic, relevant data are generated according to open datasets available on-line [31][32][33][34].
The simulation programme was written in Java.It ran on a standard desktop computer with Intel Core i3-4160T CPU at 3.10 GHz, 8.0 GB installed memory (RAM), Windows 7 Enterprise 64 bit Operating System and Java Version 8 Update 73.

Distribution Test Feeder
For the simulation we use the standard IEEE Distribution Test Feeder consisting of 13 nodes and three phases.The original test feeder is presented in [35].Its complete data can be downloaded at http://ewh.ieee.org/soc/pes/dsacom/testfeeders.We made some modifications to adapt this test feeder for our simulation.We closed the switch; substituted the in-line transformer for a line; removed the regulator.We used the desired voltage on a 120 volt base as the voltage for all lines in the test feeder.We focused on the active power and assumed that all of the nodes in this test feeder are end-users.
Another assumption was that distributed loads of different phases are balanced.Meaning that all phases in this test feeder have the same behaviour in terms of the distributed load.The topology of this modified test feeder is shown in Figure 2.

Wind Energy Production
We applied two types of renewable energy generators, small wind turbines and PV panels.For a prosumer, we randomly chose one of them for energy production at the beginning of the simulation.
A prosumer can only have one wind turbine.Wind power flowing through a wind turbine depends on the length of its rotor blades, air density and wind speed.The height of the wind turbine also influences the wind power, due to the different wind speed [36].In our simulation, we chose a small wind turbine mounted on a residential building.The total height of the installed wind turbine is limited.Therefore, we neglect the influence of the height.The formulas of producing electric power P w and electrical energy E w by a wind turbine are derived from [36] and shown in Equation (14).
The unit of P w is Watt and the unit of E w is Joule.The area swept by the blades (m 2 ), air density (kg/m 2 ) and wind speed (m/s) are denoted by A, ρ and v respectively.We used C w ∈ (0, 1) to denote the efficiency of a wind turbine.A wind turbine has the maximum power output P max (watt).
In the simulation, we used the data of a small wind turbine Evance R9000 (WindPower (accessed on 8 April 2016): www.wind-power-program.com/small_turbines.htm) where A = π × (5.5/2) 2 , C w = 0.35 and P max = 5200.For air density, we used ρ = 1.225 that is the typical air density value.
To simulate the wind speed, we obtained wind speed data of Eelde [31].Eelde is an airport near Groningen in the Netherlands.These data are provided by Koninklijk Nederlands Meteorologisch Instituut (http://www.knmi.nl/home)(Royal Netherlands Meteorological Institute).These data provide the minimum hourly mean wind speed vmin and the maximum hourly mean wind speed vmax from 1st January 1906.We only used the data of year 2015 for the simulation.
In the process of the simulation, we produced a random boolean value to indicate whether there was wind blowing at that time slot.If the wind existed, we randomly selected one day D r in a year and converted current time slot to the hour in a day.Then, we were able to obtain vmin and vmax of this hour in D r .Finally, we randomly generated a value between vmin and vmax as the wind speed and calculated the wind energy production.

Solar Energy Production
For the Photo-Voltaic panels we resorted to the Photovoltaic Software (Photovoltaic Software: http://photovoltaic-software.com/PV-solar-energy-calculation.php).The number of PV panels installed for a prosumer was randomly selected between 4 to 22 at the beginning of the simulation.Then, we summed the production of each PV panel to obtain the total energy production of the whole installation.
The unit of P s is Watt and the unit of E s is Joule.The surface area of a solar panel (m 2 ) and solar radiation (W/m 2 ) are denoted by A and r respectively.We used C p ∈ (0, 1) to denote the efficiency of a PV panel.We used Q ∈ [0.5, 0.9] to denote the Quality Factor (Performance Ratio) that includes all loss relating to the solar power production of the PV panel.The peak power output of the PV panel is P peak (watt).
In the simulation, the PV panel that we chose was LG315N1C-G4 (Product page (accessed on 8 April 2016): http://www.lg-solar.com/global/products/index.jsp)where C p = 0.192, A = 1.65 and P peak = 315.For the Quality Factor, we used Q = 0.75.
To simulate the solar power, we got solar radiation data in 2015 of Eelde [31].We obtained sunshine duration H (hour), global radiation G (J/m 2 ) and percentage of maximum potential sunshine duration SP ∈ [0, 1].The time of sunrise and sunset in 2015 are provided at "www.timeanddate.com".We selected time of sunrise and sunset in Groningen [32] which is about 10 Km from Eelde.
In the process of the simulation, we randomly selected one day D r in a year and converted the current time slot to the hour T in the day.If T was out of the duration from sunrise to sunset, there was no sun light in T and the output of solar energy was 0. If T was in daylight hours, there was still a possibility of no sunshine in this hour (because of clouds).Therefore, we produced a random boolean value to indicate whether there was sunshine in T. The possibility of "true" for this value was SP.If it was "true", we used G with a random fluctuation of ±20% and H to calculate the solar energy production in T.

Energy Consumption and Price
We simulated hourly electrical energy consumption of end-users based on the dataset provided by Liander [33].This dataset records the hourly electricity consumption of small customers (connection ≤ 3 × 25 amperes) in the Netherlands in 2009.In the process of the simulation, we randomly selected one day D r in a year and converted current time slot to the hour T in a day.Then, we obtained the value of average hourly consumption for an end-user from the dataset according to T and D r .We adjusted the value by a random fluctuation of ±20% as the hourly electrical energy consumption of this end-user.
We used three types of energy prices.One is a fixed tariff offered by the electric utility for selling its energy to consumers.We simply use EUR 0.25 per kWh that was offered by Energiedirect.nl (http://www.energiedirect.nl) in 2015.This price includes taxes, grid fees, accounting risks, structuring of profiles, etc.Another type of price is also a fixed one, the one offered by the electric utility for buying energy from prosumers.This price ranges from EUR 0.03 per kWh to EUR 0.1 per kWh in the Netherlands [34].We use 0.065 per kWh that is the middle value of this range.The last one is the dynamic price decided by prosumers for selling their energy to consumers.At a time slot, a prosumer offers the same price to all consumers.When running at the next time slot, the same prosumer is able to offer energy at a new price.Price formation is beyond the scope of the present treatment.Thus we do not consider grid fees, accounting risks, structuring of profiles and taxes for the dynamic price.We simply assume that, in order to be attractive for consumers, the prices offered by prosumers are lower than the fixed selling price of the electric utility.Moreover, these prices are higher than the fixed buying price of the electric utility.In the process of the simulation, we randomly generated a value in the range [0.1, 0.2] for each prosumer at each time slot.

Evaluation Cases
We consider three evaluation cases based on different energy flow patterns.The first one is a Radial-flow Case that simulates the traditional energy distribution flow.Electrical energy goes from the electric utility (central provider) to all end-users in the test feeder.In this case, there are no prosumers.All end-users are consumers and all energy consumption in the test feeder is supplied by the electric utility.The electric utility injects energy into the test feeder via Node 650 in Figure 2. The energy is delivered to other end-users from this node.Node 650 is also an end-user but energy loss of delivering energy to this node is 0.
The second evaluation case is the Optimal-flow Case.It simulates the model and solution of the Prosumer-involved Smart Grid proposed in this paper.Some of end-users are prosumers; energy production and decentralised energy exchange are involved.The optimisation strategy of decentralised energy exchange in this case is based on Section 4.
The last case is the Closest-flow Case.It is based on the Optimal-flow Case with a minor adjustment to the energy flow pattern.In this case, prosumers, energy production and decentralised energy exchange are involved as the Optimal-flow Case.Though there is a difference in the optimisation strategy.When finding the optimal providers in Algorithm 4, we select the providers that offer the lowest price without considering the cost of energy loss.These providers are the contract providers that actually receive the payments from the consumer.When planning energy flows, we select the providers with the shortest distance to the consumer.These selected providers are the transit providers that actually transmit electrical energy to the consumer but they do not get any payment.The shortest distance means the minimum number of electric lines from a source node to a destination node.This energy flow pattern is close to the realistic situation when transmitting electrical energy in the test feeder.Thus, the step of getting weight in Line 15 of Algorithm 2 is modified.We set the weight of each arc (u, adj) to 1 instead of R/V 2 .The contract provider and the transit provider can be the same node or can be two different nodes.Therefore, it is possible that some providers are paid without exporting their energy and some providers export their energy without any payment.

Assessment Metrics, Baseline and Simulation Setting
To verify the effectiveness of the proposed solution, we design five assessment metrics.These are energy loss of delivery, energy provided by the electric utility, proportion of energy self-satisfaction in the test feeder, excess energy sent to the electric utility, and average energy costs per end-user.We used the Radial-flow Case (traditional power system) as a baseline to assess other two evaluation cases based on our solution.
To assess the influence of the prosumer, we set various number of prosumers for the Optimal-flow Case and the Closest-flow Case in the simulation.The number of prosumers is M = 0, 1, 2, 3, 6, 10, 13.This means that 0%, 5%, 10%, 20%, 50%, 75%, 100% of the end-users are prosumers.When the number of prosumers is M = 0, the Optimal-flow Case and the Closest-flow Case equal the Radial-flow Case.For the Radial-flow Case, the number of prosumers is always 0 that dose not influence the simulation results.
In order to analyse simulation data, we ran multiple instances of the simulation and calculated the mean values of all outputs for the metrics [37].We set the number of simulation runs per configuration to 10.000.That is, we ran the simulation for 10.000 days and calculated the mean values for all outputs of these days for each evaluation metric.In these 10.000 days, each day was randomly selected from four seasons in a year.Therefore, the seasonal effects are represented in our simulation.In each iteration, each case run once.Three evaluation cases share same generated data of energy consumption and energy prices offered by the electric utility.The Optimal-flow Case and the Closest-flow Case share the same generated data for energy production and energy prices offered by prosumers.In each iteration, the number of time slot was T = 24 and ∆t = 1 h.To avoid conflicts that several consumers buy energy from one provider at the same time, the running of each end-user is isolated, independent and sequential.The sequence of running end-users was random at different each time slot.But at the same time slot, the sequences of running end-users for three evaluation cases were the same.

Discussion
One aim of our study is to decrease energy loss of delivery in the test feeder.The performance of energy loss reduction is shown in Figure 3.For the Optimal-flow Case and the Closest-flow Case, the overall trend of energy loss is decreasing with the increase of the number of prosumers.Energy loss in this figure is based on transmitting the same amount of energy in the three evaluation cases.For the Optimal-flow Case and the Closest-flow Case, the loss of buying energy from prosumers and the loss of buying energy from the electric utility are both counted.With the rising number of prosumers, the amount of energy transmitted from the electric utility decreases (shown in Figures 4 and 5) and the amount of energy flowing as the proposed solution increases.Then, the efficiency of energy loss reduction in the test feeder is improved.This finding means that the solution proposed in this study outperform the baseline (traditional power system) in reducing energy loss of delivery.
In Figure 3, there are peaks of energy loss for both the Optimal-flow Case and the Closest-flow Case and the peaks are beyond the baseline.This happens when the number of prosumers, denoted by M, is 2.This can be explained with the consumers' preference to buy energy from prosumers in our simulation.Consumers still would buy energy from prosumers when the energy loss of buying energy from prosumers is greater than the cost of buying energy from the electric utility.When M = 2, the influence of the case mentioned above is significant.This can cause the increase of energy loss.For example, if we assume that the prosumers are Node 634 and Node 646, and one of consumers is Node 611; that energy from the electric utility is injected via Node 650, then for Node 611, buying energy from Node 634 or Node 646 obviously has more energy losses than from the electric utility.When M = 1, there is only about 12% of energy in the test feeder provided by the prosumer (shown in Figure 4).Compared to 50% of energy provided by the prosumers when M = 2, the influence of the case mentioned above is limited.When M ≥ 3, there are more choices for consumers to select prosumers.Therefore, the consumers are able to buy energy from the prosumers with lower energy loss than the situation of M = 2. Comparing to the traditional power system, the Prosumer-involved Smart Grid has a considerable advantage in terms of improving independence from centralised energy generation and central energy providers, Figure 4.The upward trend in proportion of energy self-satisfaction is shown in Figure 4.In this figure, the proportion of energy that provided by prosumers to the total energy consumption increases with the rising number of prosumers in both cases of the Optimal-flow and the Closest-flow.Because the increasing number of prosumers causes the increase of distributed energy generation and decentralised energy exchange among end-users.For the Radial-flow Case (i.e., baseline), the energy self-satisfaction is always 0, overlapping with the X axis.On the contrary, energy provided by the electric utility decreases when we add prosumers.This can be observed in Figure 5.The reason of this descending trend is the same as the reason of the ascending trend of energy self-satisfaction.Moreover, the results of the Optimal-flow Case and the Closest-flow Case are lower than the baseline.This finding supports that the solution improves independence from centralised energy generation and central energy providers.
We also measured the excess energy that is sent to the electric utility.The excess energy shown in Figure 6 is prosumers' energy that is not sold or transmitted to other end-users.For the Radial-flow Case (i.e., baseline), the excess energy is always 0, overlapping with the X axis.For other two cases, it significantly increases with the number of prosumers.The reason of this ascending trend is similar to the one of energy self-satisfaction.Besides, most parts of the two curves in Figure 6 overlap.It means that different patterns of energy flows have no influence on this metric.Another aim of our study is to save energy costs for end-users.The energy cost is the total amount of money paid by the end-user for buying energy over a day.The results in Figure 7 show a dropping trend of average energy costs per end-user with the rising number of prosumers.The results of the Optimal-flow Case and the Closest-flow Case are both lower than the baseline.Since the price formation is beyond the scope of this paper, we simply consider that the renewable energy produced by prosumers has different prices from the energy provided by the electric utility; grid fees, accounting risks, structuring of profiles and taxes are considered to be fixed.Thus, renewable energy produced by prosumers is sold with lower price than energy provided by the electric utility in the Prosumer-involved Smart Grid.Therefore, energy costs of end-users are reduced when more prosumers are involved in the test feeder and more renewable energy is exchanged among end-users.Compared to the baseline, the maximum reduction of energy loss is 51% achieved by the Closest-flow Case.The Optimal-flow Case maximumly reduces energy provided by the electric utility by 97.5%.It also obtains the maximum proportion of energy self-satisfaction that is 98%.The maximum reduction of average energy costs per end-user is 66% achieved in both cases.To compare the Optimal-flow Case with the Closest-flow Case, based to the data in Table 2, we design Figure 8.The figure highlights how these two evaluation cases have the same performance in the maximum reduction of average energy costs per end-user.They also have very close performance in the maximum reduction of energy provided by the electric utility and the maximum proportion of energy self-satisfaction.However, the Optimal-flow Case slightly exceeds the Closest-flow Case in these two metrics.On the other hand, the Closest-flow Case significantly outperforms the Optimal-flow Case in energy loss of delivery.For energy loss of delivery, the Closest-flow Case obviously outperforms the Optimal-flow Case in Figures 3 and 8.The reason of this outcome is linked to the use of a radial test feeder to test the solution.As described in Section 6.1, the energy flow pattern of the Closest-flow Case approximates to the realistic situation when delivering energy in the test feeder.In the realistic situation, the test feeder has the radial topology.Thus, the Closest-flow Case is designed for the radial test feeder.It may therefore have better performance than the Optimal-flow Case in this test feeder.However, the ideal test platform for the Optimal-flow Case is a test feeder with a more meshed topology.In the radial network, there is only one path between each pair of nodes.This negatively influences the optimisation of delivery paths proposed in Section 4.3.For example, if in Figure 2 Node 634 transmits energy to Node 611, the energy flow travels on the longest path in the test feeder and blocks energy transit between other nodes.The blocked consumers have to buy energy from the electric utility.This may increase energy loss of delivery.When the number of prosumers rises, the number of nodes involved in decentralised energy exchange increases.Then, the negative influence of the radial topology may therefore become apparent.

Conclusions
We proposed a novel strategy for optimising decentralised energy exchange based on the Prosumer-involved Smart Grid.The optimisation strategy considers renewable energy production of prosumers, energy loss of delivery, topology of the distribution network, and physical constraints including ampacity of electric lines and directions of energy flows.A mathematical model of the optimisation problem and a P2P model of the Prosumer-involved Smart Grid are central to the present study.We designed algorithms and evaluated them by building a simulation programme and running it on three representative cases.The simulation results prove the effectiveness of our solution.Compared with the traditional power system, the maximum reduction of energy loss, energy costs, and energy provided by the electric utility based on the proposed solution can achieve 51%, 66%, and 97.5%, in each case.Besides, the maximum proportion of energy self-satisfaction in the test feeder approaches 98% and there is large amount of excess energy sent to the electric utility.The study does provide further evidence to the potential of having an open energy market for prosumers, as this is more efficient and it makes become a prosumer economically more attractive than the current model where the utilities buy back the produced energy.
The proposed algorithms are based on heuristic methods.The final results provided by our solution are near-optimal.However, the focus of this paper is not on the optimality of energy flows, but on the comparison of distribution solutions.In the future work, it is our intention to analyse the optimality of the solution and the influence of the topology with respect to the proposed model.
In the open energy market mentioned above, transaction costs for buying and selling energy should be considered.The transaction costs could be significantly reduced if the number of transactions is very high and thus result in micropayment per transaction.This is for instance the case in the domain of Cloud Computing and Service-Oriented Architectures [38,39].Our current study focuses on the distribution costs which are additive to the transaction costs.A further study of the transaction costs is left for future work.
To gain further insights in attractive future Smart Grid models, we will consider introducing distributed energy storage systems (DESS, such as home batteries and electric vehicles) and adding the optimisation of the charge/discharge cycle to the model.Because there is large amount of excess energy sent to the electric utility (Figure 6).With DESS, prosumers are enabled to decide whether the excess energy should be sold for an immediate profit or stored for later use.

1 :
procedure PLAN-ENERGY-FLOWS(source, dest, E) one energy flow or a set of energy flows 6:

Figure 1 .
Figure 1.A simple example to describe the procedure of the algorithms proposed in this section.

Figure 3 .
Figure 3. Energy loss of delivery in the test feeder.

Figure 5 .
Figure 5. Energy provided by the electric utility.

Figure 6 .
Figure 6.Excess energy sent to the electric utility.

Figure 7 .
Figure 7. Average energy costs per end-user per day.

Figure 8 .
Figure 8.Comparison with assessment metrics of Optimal-flow Case and Closest-flow Case.

Table 1 .
The symbols used in energy loss description.
Find the shortest path from a source node to a destination node based on a weighted graph and the Arc Dynamic Direction Matrix.
1: procedure FIND-SHORTEST-PATH(source, dest) 6: previous[] ← N IL Initiate all elements.7: distance[source] ← 0 8: for all nodes in the graph do 9: u ← extract unvisited node of minimum distance[u] 10: if u is dest then nodes ← FIND-AVAILABLE-NODES(u) Refer to Algorithm 1. 14: for each adj in nodes do 15: alternative ← distance[u]+ get weight by R/V 2 of arc (u, adj) 16: if alternative < distance[adj] then A shorter path to v has been found.17: distance[adj] ← alternative path ← get the nodes of the shortest path in previous[] 23: , rest i ← PLAN-ENERGY-FLOWS(consumer, ep i , buy i )loss i % ← loss i /(buy i − rest i ) × 100% 13: estimate i ← E × (1 + loss i %) × ep i .priceEstimatecost of buying E with loss i from ep i .costu ← price u × (rest + loss u ) price u is the price offered by the electric utility.
providers ← ep i with minimum estimate i in EP(t) update states of selected ep i in EP(t) p ← ∑ cost i of all ep i in providers 7: if rest > 0 then 8: loss u ← calculate energy loss of transmitting rest energy from electric utility to consumer 9: cost ← cost u + cost p 14:

Table 2 .
Performance comparison with the evaluation cases.