Dynamic energy pricing considering agent specific losses in residential energy hubs

The rise of distributed energy generation and storage is creating new opportunities for energy consumers to actively engage with energy markets. Achieving these potential benefits will require the implementation of new business models to address limitations of existing market structures. One promising area of research involves the use of decentralised energy trading markets. These markets can increase renewable energy generation through improved infrastructure utilisation and financial returns. However, facilitating these markets is challenging due to the constraints of physical laws and energy losses. The model presented in this paper addresses these challenges by demonstrating an energy market structure for local energy trading that accounts for physical constraints and losses. It fairly allocates the gains of trade and incentivises agents to minimise distribution losses. This market structure can be implemented with existing metering data and approximate values of electrical distribution network properties.


Introduction
Electrical distribution networks have traditionally been built to accommodate large scale centrally located energy generation (Saboori et al. 2017).Markets that facilitate energy trading across these networks have therefore been designed with this physical structure in mind (Padmanaban et al. 2022).These physical and economic conditions have resulted in energy consumers having minimal control over their cost of energy (Sayyad and Kazem 2020).
This situation is changing due to the rise of distributed energy resources (DER).DER has enabled energy consumers to actively participate in the electricity market, as they can both consume and produce electrical energy.However, existing market structures limit the effectiveness of decentralised energy production business models (Eid et al. 2016).Therefore, investigating new market structures to facilitate energy trading between decentralised market participants is essential to the future viability of DER (Guerrero et al. 2020).
The potential benefits of DER for consumers and the operation of energy distribution networks is significant and well documented by researchers (Gough et al. 2020).
However, it is acknowledged that advanced control and optimisation techniques are required to achieve these benefits.As such, many operational techniques to control and co-ordinate the operation of DER have been proposed (Xu et al. 2022;Xia et al. 2023).Some proposed solutions focus on maximising the DER owners' financial objectives (Pollitt 2018), while others prioritise community and utility objectives (Mahmud et al. 2020).
One proposed solution to maximising a DER owners' financial benefit while improving boarder social outcomes is via a transactive energy market (TEM) (Xia et al. 2022).A TEM facilitates financial transactions between decentralised energy market participants.Such a system has the ability to unlock additional value from DER by enabling demand side participation and energy trading between participants (Yang et al. 2021).A well-designed TEM can facilitate DER's integration into the existing electrical energy system resulting in improved technical, economic and environmental outcomes (Khorasany et al. 2020).
Although TEM's can achieve significant financial benefits, they are subject to physical constraints of electrical infrastructure and the laws of physics (Kumar et al. 2022).A successful TEM should therefore optimise market outcomes while accounting for physical limitations and effects arising from their transactions (Sabillon et al. 2021).
One physical limitation TEM's must account for are energy losses incurred by the distribution system (Dudjak et al. 2021).These losses can be difficult to quantify.As such, any approximations of these losses should favour the distribution and energy market operators to ensure the financial market always clears.TEM's also encounter challenges in quantifying distribution infrastructure utilisation required for energy transactions (Faqiry et al. 2020).This also requires the use of approximations that favour the distribution network operators.
These factors make it difficult to trade energy directly between two individual market participants (Zhou and Lund 2023).This is because physical laws govern where energy imported into the network travels, and losses between two network locations can be difficult to quantify (Zhou et al. 2022).As such, a TEM structure that facilitates trades between distributed energy users and producers while accounting for physical factors is required (Jiang et al. 2022).
This paper presents a centrally coordinated virtual power plant (VPP) implementation of a TEM to address these limitations by accurately quantifying and fairly allocating distribution losses among participants within a residential energy hub (REH).A REH in the context of this paper is a group of energy market participants connected to the same low voltage distribution network.This physical structure reduces the complexity in quantifying distribution losses and network constraints.As such, it is possible for a REH system operator to facilitate energy trades within this network that accurately account for energy losses.Excess energy required to clear the REH market can be purchased from, or sold to, the utility grid via a virtual meter.The proposed REH TEM will always exactly clear and ensure that DER within the REH is scheduled to ensure network physical constraints are not violated.
In this paper, a brief discussion of DER scheduling approaches and optimisation techniques will be discussed to establish the current state of research in this space.The research gap and how this paper addresses it will then be discussed.Once the current state of research and research gaps have been established, the research methodology will be explained relating to the proposed market structure, electrical model and optimisation technique used.A case study will then be analysed whereby results can be derived from applying the simulation model to a situation indicative of a real world application.These results allow the financial benefit of such a market and optimisation approach to be quantified.The proposed markets impact on individual agents based on their DER configuration and the total network DER will also be assessed.

Background
The research presented in this paper covers the scheduling of DER within a REH and the associated TEM required to facilitate energy trades.A DC equivalent optimal power flow (OPF) model of a three phase AC distribution network is used to approximate energy losses.The OPF model is an intrinsic part of the operation of the TEM as it is used to dynamically adjust network tariffs for each agent.As such, it is important to consider the current state of DER scheduling and OPF modelling as applied to distributed energy trading systems.

DER scheduling approaches
There are three main approaches to consider when choosing a system to optimise DER operation, each with their own advantages and disadvantages.These are uncoordinated, centralised co-ordination and peer to peer approaches (Guerrero et al. 2020).

Uncoordinated approaches
An uncoordinated approach involves each DER operator making decisions to maximising their own benefit.Examples of this approach include home energy management systems.Their advantages include being simple to install and do not require services and costs associated with third party operators.However, they do not inherently account for factors impacting the energy distribution network or other market participants.This system provides no incentive to optimise social utility, thereby preventing any potential gains to the energy market or distribution system being realised.

Centrally coordinated
Centrally coordinated DER involves a third party operating DER assets of multiple agents.The aggregate sum of all DER is a VPP.A VPP operator schedules the operation of multiple DER within a network to collectively achieve an optimal outcome.This scheduling can account for distribution constraints and enable participation in energy market programs unavailable to individual DER operators.The additional benefits from such actions can be shared among all VPP participants.
A VPP can collectively achieve greater value than individual operators.However, such an approach favours collectively optimum outcomes over individually optimum outcomes.It also requires individual operators to give up control over their assets.As such, there is no guarantee that a VPP operator will fairly allocate the gains of trade among participants.There are also third party costs associated with the VPP operator.Therefore, any benefits achieved through central coordination must exceed third party costs and ensure fairness in the allocation of financial benefits.

Peer to peer
Peer to peer (P2P) energy trading systems combine benefits from both uncoordinated and centrally coordinated systems.P2P trading ensures DER owners maintain full control over their assets and does not require a trusted third-party operator with their associated overheads.It is also possible to achieve benefits of aggregation such as participation in ancillary energy markets.Achieving these aggregation benefits requires coordination, but unlike a VPP, this coordination is achieved via decentralised mechanisms, as opposed to a centralised system.
P2P energy trading systems have significant potential to facilitate energy trading within an energy market.However, research into this technology using block chain based financial systems is still in its early stages.Decentralised coordination cannot guarantee the optimum dispatch outcomes for the energy market or network operation, as individual traders prioritise their own objectives.VPP's also have the advantage of being easier for energy market operators to regulate and control.As such, P2P energy trading faces greater challenges to implement than VPP forms of DER aggregation.

Optimal power flow
OPF refers to the modelling and optimization of electricity transmission and distribution networks.Solving OPF models are fundamental to the operation of electric power grids to ensure their reliability and achieve an economically optimal dispatch of available energy.OPF modelling techniques can be broadly classified as either AC OPF or DC OPF.DC OPF models are usually simplified versions of AC OPF models with less variables and relaxed constraints.
This decision problem is classified as NP-hard and is commonly considered by researchers to be a difficult problem to solve (Shchetinin et al. 2018).Despite advances in Nonlinear Programming (NLP) techniques, locating a local optimum of the AC-OPF problem can still be challenging.This is primarily due to three factors (Capitanescu 2016).
• OPF requires non-linear and non-convex constraints for modeling power flows • Practical applications in electricity grids require many constraints and decision variables • Computational time windows are relatively short due to the dynamic nature of generation and demand.This inherent complexity and computational time constraints requires some form of decomposition to solve.
A brief summary of common decomposition techniques used by researchers are listed below.

Benders decomposition
Bender's decomposition is a classification of optimization techniques that utilizes a divide and conquer method by dividing the original problem into multiple subsets that are individually easier to solve.A master problem is initially defined that only requires a subset of all decision variables to be solved directly.Master problem solutions are then supplied to sub problems that solve for the remaining decision variables.If a sub problem is provided with infeasible solution space, a Benders cut is initiated whereby information is provided back to the master problem such that it can find a new solution.The optimization continues until no new cuts are required to solve the sub problem.Textbook forms of Benders decomposition are not usually viable for solving OPF due to their poor performance for non-convex problems.It has also been noted that linear Benders cuts when applied to OPF often converge on sub optimal solutions (Capitanescu 2016).Therefore, solving OPF requires a modified form of Benders composition.
Proposed solutions include convex relaxation combined with network partitions (Yuan and Hesamzadeh 2017), nested sub problems (Giuntoli et al. 2021) and generalized Benders decomposition (GBD) approach using linearized sub problems (Jamalzadeh and Hong 2018).These techniques improve the accuracy of Benders decomposition when applied to non-convex problems, but they still cannot guarantee optimal solutions (Jamalzadeh and Hong 2018).

Alternating direction method of multipliers
Alternating direction method of multipliers (ADMM) combines dual decomposition and augmented Lagrangian methods for constraint optimization.ADMM's ability to implement distributed convex optimization problems has made it one of the most widespread techniques used to solve OPF problems.The ADMM variants used by researchers differ based on the formulation of consensus algorithms used to co-ordinate sub problem variables (Biswas et al. 2022).ADMM is applied to OPF problems by decomposing it into local subproblems, which are solved in parallel for each agent.The solver IPOPT is commonly used to solve the NLP in both global and subproblems.ADMM requires a centralized system to coordinate variables in sub-problems, so it is not a completely parallel algorithm in its basic form Oh et al. (2022).To use ADMM as a fully parallel algorithm, a consensus algorithm is used to co-ordinate between local subproblem variables and their equivalents in the global problem (Nedic and Ozdaglar 2010).
Common ADMM algorithms proposed by researchers to solve OPF problems utilise Second Order Cone Programming and Semi Definite Programming.These ADMM techniques have been demonstrated to provide a closer to optimal solution compared to adaptive Bender's decomposition methods.However, adaptive Bender's decomposition method generally offers faster execution times relative to ADMM (Capitanescu 2016).

Interior point methods
Interior point methods (IPM) have commonly been applied to the analysis of electrical power systems due to their ability to solve non-linear and non-convex problems.IPM algorithms search for the optimal solution by adopting a sequence of points that are constrained to the interior of the feasible set by using a barrier parameter (Delgado et al. 2022).IPM has similarities to ADMM in that it can decompose the AC-OPF problem into a base case global problem and contingency case sub problems (Capitanescu 2016).
IPM's advantages relative to ADMM is that it scales well and can solve all subproblems fully parallel to each other (Sundermann et al. 2023).These advantages allow for fully decentralized applications of AC-OPF to be implemented with similar convergence performance and accuracy to its centralized implementation (Lu et al. 2017).
IPM also has some limitations that are being addressed by researchers when applied to AC-OPF.These include improved techniques to update the barrier parameter and regularizing the constraints.IPM also has a limited ability to implement infeasibility detection and the handling of discrete control variables (Delgado et al. 2022).

Research gap
There are two research gaps to be addressed in this paper.These are the use of an internal tariff structure within an REH that accounts for energy losses and ensures fairness in scheduling DER.The second research contribution is the derivation and implementation of an OPF model that does not require decomposition to solve.

Research contribution 1-dynamic energy loss tariffs
One research gap to be addressed in this research is that of clearing a REH's TEM such that energy losses are fairly accounted for.All proposed REH TEM models cited in this paper use some version of OPF when scheduling DER.However, the impact these OPF models have on agents energy prices is inferred, but not explicitly quantified on an agent's individual basis.Further research is needed to integrate the individual price agents pay for energy with losses they incur within a distribution network.
Improved loss allocation algorithms are required to account for energy losses incurred during electrical energy distribution, as opposed to simple approximation or equal sharing-based approaches.These energy loss algorithms result in a dynamically priced, agent specific tariff on energy purchased and sold within the REH.Energy traded between agents is prices such that the selling agent receives their scaled spot price and the buying agent pays their scaled spot price.These agent specific spot prices include distribution cost reflective tariffs that result in the sum cost of all energy sold being equal to the sum cost of all energy purchased.
Agent specific energy loss tariffs have the added benefit of incentivising the reduction of distribution losses.This aligns the globally optimal solution with the individual optimal solution for each agent, thereby justifying an agents requirement to relinquish control of their DER.

Research contribution 2-application specific OPF model
OPF modelling is computationally intensive when incorporating DER scheduling into the optimisation problem.Therefore, any reduction in computational complexity will assist the widespread adoption of centralised DER co-ordination.Distribution systems in REH's only consist of a minimal subset of utility distribution network components.This allows the use of approximations that can achieve significant reductions in computational complexity, with minimal reductions in accuracy.
Within an REH, it can be assumed there are no transformers or significant sources of reactive impedance.This allows a DC approximation of the OPF problem to be used and eliminates the need for complex optimisation variables.It is also possible to schedule DER loads that are either on or off without considering energy losses.These loads are less flexible than batteries and have less ability to respond to distribution loss price fluctuations.This allows binary decision variables to be set outside of OPF calculations.
Using a DC OPF model and removing binary decision variables allows OPF calculations to be performed without decomposition and linearization.This is achieved by formulating all equations and constraints of OPF with a maximum polynomial order of 2. By restricting optimization equations to second order polynomials, it is possible to use solvers optimized for quadratics such as IPOPT.Non-linear optimization constraints that would usually require a mixture of decomposition and linearization can be reformulated into separate linear and quadratic constraints.This allows a solver to find a solution with a single solver call without the need for decomposition.

Market structure
The market structure for this trading system involves all energy transactions being traded via a single common market.The market has a single spot price that is applied to all energy purchased and sold.This spot price is scaled at each individual agents location to ensure the financial market always clears.Excess energy can either be bought or sold to the grid via a virtual common meter that is responsible for setting the market price.This market structure is graphically shown in Fig. 1.
This market can be implemented via P2P trading or via an aggregator.In P2P configuration, the selling agent decides how much energy to export and can choose to trade directly with another agent.A selling agent will receive the market price scaled by their loss factor and the buying agent will pay the market price scaled by their loss factor.As both agents know their voltage, they can calculate their respective loss factor without third party intervention.Although some of the traded energy will be lost in distribution, the discrepancy between the buying and selling price will compensate for the energy shortfall needed from the utility grid.Excess funds required for each transaction will be paid to the utility grid by whichever agent has the highest price scaling factor.
Operating the market in aggregator configuration requires all energy transaction to occur between each agent and the aggregator.Agents are assigned the market price scaled by their loss factor by the aggregator, which constitutes a centrally cleared tariff.The aggregator's central coordination ensures energy trades are optimised to minimise energy losses.As such, the centrally coordinated application of this market structure will be analysed in this research.In Fig. 1, at time interval t the market price C t market is set by the marginal cost of importing extra energy into the REH via the virtual grid meter.If energy is being imported from the grid into the REH, this marginal cost will be the grid buy price C t grid,buy , otherwise the marginal cost will be the grid sell price C t grid,sell .This relationship is mathematically described in (1) where µ t,exp grid is a Boolean variable that equals 1 if the grid is exporting energy into the REH during time interval t.
Each agent will trade energy with the REH energy market at a buy and sell price of C t a where a is the agent number.This price is the market price that has been scaled by a loss factor P t a to ensure the sum of all financial transactions is zero as described by (2).
Equation 2 describes the variable agent pricing that is the key innovation of the proposed TEM.A variable energy price at each agent is used to ensure the fair allocation of costs incurred by distribution energy losses.When distribution losses to transfer energy to an agent are high, the price at the agent will increase.This will create incentives for the agent to reduce load or to supply energy to the network.Both options will result in lower distribution losses with the benefit provided to the agent that adjusts it operation to reduce network losses.
All DER within the energy market will be operated via a third party VPP operator that will be optimising to achieve the lowest total grid energy costs.This optimisation strategy favours global rather than individual optimal outcomes.It is therefore necessary for individual agents to relinquish control of their individual DER assets.This loss of control can be justified as the TEM pricing structure rewards agents contributing to improved global outcomes.It will therefore be demonstrated in this paper that relinquishing control over DER assets in order to participate in the REH will provide a greater benefit to all agents irrespective of their DER configuration.

Loss factor derivation
The value of P t a from (2) requires knowledge of the electrical infrastructure and a simulation model to compute distribution losses.This would traditionally be achieved using an AC OPF electrical model.However, implementing such a model would require detailed knowledge of existing infrastructure and may be infeasible to to incorporate into a solver that also optimises the value of energy trades.Much of this complexity can be avoided by using a simplified electrical distribution system model that can produce sufficiently accurate results while being incorporated into a solver that is optimising energy trades.Such an outcome is possible as the local level distribution network incorporates less complexity than the entire utility grid.
It can be assumed that interconnecting cables have a mostly resistive impedance that can be estimated based on geographical meter locations and commonly used cable gauges.Based on these interconnection resistance estimates and energy metering data, it is possible to build an electrical model to approximate energy losses. (1) To develop an electrical model that would be valid under these conditions, consider a simple DC circuit in which energy is transferred from a source to a load as depicted in Fig. 2.
Figure 2 depicts a simple electrical circuit where energy is transferred from a source to a load with resistive losses due to the interconnecting resistance.The source voltage is V t s , load voltage is V t l and a current of I t passes through the source and load via a resistor of resistance R at time index t.Over time interval t , the energy supplied by the source E t s and load E t l to this simple distribution network is given by ( 3) and ( 4).
As energy is lost in the distribution network, more energy will be supplied to the network by the source than received by the load as E s > −E L .To ensure this energy market balances, the load will need to pay a higher price for energy than that received by the source.If C t s is the energy price at the source and C t l is the energy price at the load, the market will clear provided (5) is satisfied.Substituting (3) and ( 4) into (5) results in the ( 6) price required at the load to clear this energy market.Therefore, operating this energy market requires a reference price and voltage (in this case C t s and V t s ) to be determined.Equation 6 is solved at the load location using the load voltage V t l to determine its energy price.Although (6) was derived using a simple case, it is valid for any DC distribution network.This can be proved by considering a multi agent energy network with an unknown interconnection structure and electrical properties as shown in Fig. 3.
The energy market in Fig. 3 will balance if the sum of all energy trades as described by (7) equals zero.In ( 7), X a is the set of all agents in the network and C t a is the energy price at agent a. (3) The (6) energy price C t l can be substituted into the (7) energy price C t a .Simplifying the result of this substitution allows (8) to be derived as the reference voltage V t s , reference energy price C t s and time interval t are constants for all time intervals.
Equation 8 describes Kirchhoff 's current law.This result demonstrates that if Kirchhoff 's current law is valid for the entire distribution network, ( 6) can be used to set the energy price at each agent.It also means that any agent can provide the reference voltage and price, provided that both values are derived from the same agent.For the model simulated in this paper, the value of V t s will be set as the grid connection voltage where the virtual meter is connected to the distribution network.
Although this section only demonstrated the proposed pricing technique as valid for DC distribution networks, it will be used for a three phase AC network.The DC network model is a close approximation of an AC three phase network as a balanced phase load will result in no neutral current.It will also be assumed that reactive power is a minimal component of the total agent power requirements.Using these assumptions, it is possible to estimate network losses using a DC equivalent circuit and interval energy meter data.

OPF simplifications
OPF is a common example of a non-linear optimization problem.Due to its non-convex nature, there is no efficient method to locate its optimal solution.Finding a global optimum for this type of optimization problem in acceptable computational time is a major challenge under investigation by optimization theory researchers (Asghari et al. 2022).One reason for the inherent non-linear nature of OPF is the requirement to multiply decision variables.This occurs as energy traded is the product of voltage and current, both of which are decision variables subject to constraints.The per unit cost of energy and energy traded are also decision variables that must be multiplied, thereby resulting in even greater complexity.
As stated in Background section of this paper, some form of decomposition and linearization of the OPF problem is required to find a solution in acceptable times.However, ( 7) I t a = 0 if all binary decision variables can be removed from the OPF problem and decision variable multiplication is replaced by quadratic constraints, it is possible to solve the OPF problem in a single stage using a quadratic programming solver.
To represent the product of two decision variables as a quadratic constraint, consider the expansion of ( 9) that contains two decision variables A and B and a scalar term D. The scalar term D is required such that A and the product BD have the same units.
Rearranging ( 9) results in a quadratic expression for the product of A and B as described by ( 10).
The scalar term D is only required to ensure quantities of the same units are added together.As such, it can be set to any real number.Choosing a value of D = 1 allows (10) to be simplified.Applying this substitution allows the product of decision variables A and B to be expressed as ( 11) subject to the (12) constraint.Substituting all decision variable products with quadratic equations as per (11) allows quadratic programming solvers to find the optimal solution of the OPF problem without decomposition.This technique, combined with a simplified DC distribution model is the key innovation presented in this research to solve the OPF problem.

Optimisation model description
Scheduling DER within the REH requires two optimisation stages due to the computational complexity in implementing the electrical model.As such, two stage decomposition with constraint relaxation will be used to schedule DER and compute the value of energy trades.The first optimisation stage involves scheduling the DER while not accounting for energy losses.The second optimisation stage will calculate prices and energy transfers between agents accounting for losses.During the first optimisation stage, all DER operation states will be dependant variables.The first optimisation stage values of schedulable loads and net grid imported energy will then be passed to the second optimisation stage as constants.During the second optimisation stage, all battery parameters will be set accounting for distribution losses and constraints.Agent prices will also be determined during the second optimisation stage.
Scheduling DER during the first optimisation stage will be achieved using a discrete time, model predictive control simulation with a finite time horizon.This simulation will determine the optimum DER operational state for the first time slot.The second optimisation stage will then determine energy prices and trades during this first time slot.This process (9) will then be repeated for the second time slot by incrementing the time horizon by one time slot.

Optimisation stage 1
The objective of the first optimisation stage is to determine a close to optimal solution for all DER scheduling decision variables.This approximation is achieved by not accounting for distribution losses within the network.Ignoring distribution losses allows DER to be scheduled without the need for quadratic constrained decision variables.As such, a mixed integer programming solver can be used to schedule DER.In optimisation stage 1, the solver to be used is the GLPK solver.
Electrical distribution is implemented using three AC phases, with each agent connected to a single phase.Agents will be grouped together based on their connected phase during the first optimisation stage.This prevents agents on different phases trading with each other.Agents on different phases can affect each other's price as the market price is set at the marginal cost of net imported energy from the grid.Therefore, the market price in the REH could be set at the grid buy price even if one phase is exporting energy to the grid, provided that the REH has a net import of energy.
Figure 4 shows a single phase of the grid connection and the energy flows associated with each agent.
Each grid phase will have a net amount of energy imported into the REH given by the variable X t grid,phase , where the variable phase is the phase number.Grid energy must be separated into two components, one for imported and another for exported energy to compute energy costs as described by (13).
The (13) values must also be bound by physical limits as described by ( 14).In ( 14), the γ variables are maximum energy transfers per time interval.A Boolean variable µ t,imp grid,phase is also used to prevent energy being imported and exported simultaneously and will equal 1 when grid energy is being imported into the REH.
(13) X t grid,phase = X Fig. 4 High level model of a single grid phase X t a from Fig. 4 can be positive or negative depending on whether the agent is importing or exporting energy.This variable must be separated into two components, one for energy imported and another for energy exported as described by (15).Energy import and export variables from (15) are bounded by a maximum limit as represented by the γ variable in (16).A boolean variable µ t,imp a is used to ensure an agent does not simultaneously import and export energy and will be set to equal 1 when the agent is importing energy.
Each agent is comprised of a fixed load that is not a function of any decision variables and a schedulable load.The schedulable load is modelled on a hot water service that is either turned on or off during each time interval.An agent can also contain a battery and a solar photovoltaic system.These agent components and their associated discrete time energy flows are depicted in Fig. 5.
Energy imported into each agent X t a is the sum of all internal energy transfers as described by ( 17).
Energy flows required for the solar X t a,pv and fixed loads X t a,load_f are predetermined constants and are therefore not functions of decision variables.The only decision variables from Fig. 5 are battery and schedulable load energy flows.
Battery charging and discharging variables are bound by a limiting constraint represented by the γ variables in (18).A boolean variable µ t,ch a,batt is used to ensure a battery does not simultaneously import and export energy and will equal 1 when the battery is charging. (15) 0 ≤ X t,ch a,batt ≤ γ max,ch a,batt µ t,ch a,batt 0 ≤ X t,dis a,batt ≤ γ max,dis a,batt (1 − µ t,ch a,batt )

Fig. 5 Internal components and energy flows of each agent
Energy stored in the battery must be updated after each discrete time step as described by ( 19).This update must account for charging and discharging efficiency factors represented by the η labelled variables.
The battery state of charge variable e t,SoC a,batt is also subject to constraints.These constraints are that it must be greater than or equal to zero and cannot exceed a maximum value.It must also be set such that its value at the end of the time horizon is equal to or greater than its initial value.These constraints are described by (20).
The schedulable load requires a fixed amount of energy during the optimisation window and is either on or off at any individual time interval.When the schedulable load is on, its energy consumption for that time interval will be γ max a,load_s , otherwise its energy consumption will be zero.This can be achieved by using the (21) constraint where µ t a,load_s is a boolean variable.
The total amount of energy required by the schedulable load over the finite horizon is defined by γ total a,load_s .This value will be set as an integer multiple of γ max a,load_s , thereby allowing the (22) constraint to set the total energy used by the schedulable load.
The cost of energy imported from the grid is C t grid,buy and the cost of energy sold to the grid is C t grid,sell .Therefore, the total cost of energy over the finite horizon is determined by (23).
The objective function is to minimise the total cost of imported energy as described by (24) for all agents and time slots.
Solving for (24) over the finite horizon window allows the schedulable loads and battery operation variables to be optimally set to minimise grid energy costs.

Optimisation stage 2
In the second optimisation stage, all electrical parameters are determined based on first optimisation stage results.This will require quadratic decision variable terms in the (19) e t,SoC a,batt = e t−� t ,SoC a,batt (24) Minimise C total , ∀t ∈ T ∀phase ∈ X p objective function that were not possible to implement in the first optimisation stage.As such, the IPOPT solver will be used to solve for the second optimisation stage.The IPOPT solver cannot solve for binary decision variables.Therefore, the schedulable load states as determined by the stage 1 optimisation will be passed to the stage 2 optimisation as constants.Batteries are the only DER to be scheduled during the second optimisation stage.
The electrical network in the second optimisation stage is modelled as an interconnected mesh of resistance elements subject to basic circuit laws.Figure 6 illustrates this network with labelled nodes and current flows.
In the second optimisation stage electrical model, agents are connected to one of three phases.All agents are connected to the neutral conductor that will be simulated as having a voltage of 0 V. Solving electrical rules around this model will allow voltages and currents to be determined.These values will in turn will be used to compute energy trades and nodal prices.
Modelling electrical parameters is achieved by solving Kirchhoff's current law at each node and solving Ohm's law for currents between each node.Each node in Fig. 6 as represented by a dot on the conductor will have a set of connected nodes given by the set X c n where n is the node number.The sum of these currents must equal zero for the set of all nodes X n as per (25) where x is the currents destination node number.
Electric current in each conductor is also constrained by a maximum limit.This limit for each conductor between nodes n and nodes x is given by the parameter I max n,x .Defining this parameter allows the (26) constraint to be defined.Each node on the active conductors also has an associated voltage given by the variable V n where n is the node number.Solving Ohms law at each node is achieved as per ( 27) where X a n is the set of all nodes on active conductors, R n,x is the resistance between node n and x and I n,x is the current flowing from node n to x.
Active voltages must also be constrained within a certain range as defined by utility regulations.This will result in a maximum and minimum allowable voltage defined to be the variables V max n and V min n respectively.Applying these constraints to all active node voltages is achieved using the (28) constraint.
For the purposes of this simulation it will be assumed the voltage on the neutral conductor will be zero.This will be the case for a balanced three phase circuit and will therefore be a close approximation in the network as shown in Fig 6 .Therefore, the agent energy consumption will be the product of V a , I a and the time interval.As the time interval is a constant, only the product of voltage and current is required to be set by the solver.Calculating the product of voltage and current can be achieved using the decision variable multiplication technique referred to in section OPF simplifications.Using this technique, the product of V a and I a can be expressed as the ( 29) and ( 30) constraints.
Over a discrete time interval of t , the energy received by agent a will be t V a I a .Setting this value to equal the net imported energy into an agent allows the agent power constraint to be set as per (31).In (31), V a is agent a voltage, I a is current flowing into agent a and C is defined in (30).
The electrical model is only required for the second optimisation stage, which is restricted to the finite horizon's first interval.Therefore, only X t=1 a is required to be computed using voltages and currents.
All currents entering agents on a phase must also equal the current supplied by the grid to that phase.This is achieved by the (32) constraint where X p is the set of all phases and X phase is the set of all agents connected to the phase specified by the subscript variable phase. (27 It is also necessary to equate the grid imported energy to the grid currents and voltages.Grid imported energy during the second optimisation stage for each phase is represented by the variable X grid,phase as described by the (33) constraint.
It can be assumed that the grid connected node voltage is known and represented by the variable V grid,phase in (33), where phase is the respective phase number.Therefore, ( 33) is a linear constraint with the only decision variables being X grid,phase and I grid,phase .
The value of grid imported energy as described by X grid,phase in (33) was determined during the first optimisation stage to be X 1 grid,phase .Due to the inflexible nature of the schedulable loads, their optimisation stage 1 values will be used for stage 2 optimisation.That leaves the battery charge and discharge variables X t=1,ch a,batt and X t=1,dis a,batt for time interval 1 from (17) as optimisation stage 2 decision variables.
The values of battery charge and discharge decision variables can be set by the second optimisation stage solver to ensure no internal distribution constraints are violated.However, an unfeasible solution space can be provided to the second optimisation stage via the total grid import or export energy as determined by the first optimisation stage.This may arise as the first optimisation stage does not account for energy losses and can therefore overestimate the maximum amount of energy that can be imported or exported from the grid.Therefore, the (33) value of total grid imported energy X grid,phase can be set using the first optimisation stage value of X 1 grid,phase and two fine tuning variables X extra_in grid,phase and X extra_out grid,phase as described by (34).
The value of grid imported energy as determined by the second stage variable X grid,phase is bound by the (35) constraints.
To ensure the (35) constraint is not violated, the values of X extra_in grid,phase and X extra_out grid,phase are bound by the (36) constraints.
It is important that the variables X extra_in grid,phase and X extra_out grid,phase are only assigned non-zero values when no other solution is available.Therefore, these values will be multiplied by a penalty cost C p in the objective function that is sufficiently high enough to achieve this outcome.
The objective function for the second optimisation stage is required to determine all network voltages such that each agents energy price can be calculated as per (6).This is achieved by finding the minimal distribution network loss subject to all agent energy requirements and electrical parameter constraints.Distribution losses are (33) X grid,phase = V grid,phase I grid,phase t ∀phase ∈ X p (34) X grid,phase = X 1 grid,phase + X extra_in grid,phase − X extra_out grid,phase 0 ≤ X extra_out grid,phase ≤ γ exp grid,phase calculated using basic electrical circuit laws whereby the energy loss of each conductor is its current squared multiplied by its resistance.The stage 2 optimisation objective function can therefore be derived as (37).In (37), all node currents and voltages variables and battery charge and discharge variables are optimisation variables.
Solving for (37) allows the final value of battery charging and discharging parameters to be set and all agent energy prices to be determined.Once a valid second stage optimisation has been achieved, all parameters are recorded and the first stage optimisation is repeated with the finite horizon window incremented by one.

Case study
To assess the proposed optimisation models ability to schedule DER and facilitate financial transactions within a REH, a model has been built using the equations and constraints described in the previous section.Energy transactions with the grid are priced using 2022 NEM energy spot prices and tariffs based on energy purchased in the Australian state of Victoria.Network tariffs will be set to their City Power 2022-2023 values while environmental and market charges will be set to their average residential rates for 2022.Peak time network tariffs are applied from 7 AM to 11 PM weekdays with all other times being off peak tariffs.Table 1 breaks down the prices used for grid energy imports and exports.
A discrete time interval t will equal 5 min and the finite horizon will be set to 24 h.This is due to metering interval data being recorded in 5 min intervals.The set of all discrete time intervals will therefore be T = {1, 2, . . ., 288}.
This model will include 24 residential houses connected to a three-phase electrical distribution system participating in a REH enabled TEM.All houses contain fixed loads and a single schedulable load that represents a hot water system.A select group of houses will also have a solar PV and some will have batteries.The internal REH distribution network is comprised of nodes where individual agents connect to.This REH distribution network is shown below in Fig. 7 All agents have a schedulable load that requires 10 kWh per day with a power rating of 2.5 kW.The network is also configured such that each phase contains two agents with batteries.Each agent connected battery has the following properties.
• Battery Size: 10 kWh • Battery maximum charging power: 4.8 kW • Battery maximum discharge power: 4.8 kW • Battery charge efficiency: 96% • Battery discharge efficiency: 94% Network nodes and interconnections have the following properties.The REH distribution network consists of interconnected nodes as depicted by blue dots in Fig. 7.A three-phase connection exists between each node and a single-phase connection exists between an agent and a node.Table 2 lists each agents' specific properties as only some agents have solar and batteries and each agent can only be connected to a single phase.
Agents with solar are simulated with solar energy generation taken from the National Renewable Energy Laboratory database for a solar installation in Melbourne.This data is scaled to match the output of a DC rated solar PV system with a size specified in Table 2.All agents have fixed loads with seasonal variation based on data taken from the CSIRO report "The Evaluation of the 5-Star Energy Efficiency Standard for Residential Buildings", for households in Victoria.This data was scaled such that it has a standard deviation of 10% of its mean value between agents.
To quantify the economic benefits of participating in the REH, two DER optimisations models were used.The first model requires each agent to schedules its own DER and purchases energy as a single agent from the utility grid.Agents will therefore pay the residential network tariff to purchase energy and energy exported from each agent will be sold at the NEM spot price.
The second model implements the two stage decomposition optimisation described previously, with all agents participating in the REH.Energy can be traded between agents at a reference price determined by the marginal cost of purchasing more energy from the grid.Excess energy required to be purchased from the grid is purchased via a virtual meter.Surplus energy from the REH is sold to the grid at the NEM energy spot price.
The REH consists of 12 agents that have only fixed and schedulable loads, 6 agents have fixed loads, schedulable loads and solar while 6 agents have fixed loads, schedulable loads, solar and batteries.Quantifying the average agent energy price based on its DER configuration allows the economic benefit of DER to be determined.DER will also be excluded from some simulations.This will allow the marginal benefit of including DER within the network to be determined.The following list describes the DER modelled states.

Table 2 Agent specific properties
• No DER: In this state, all DER for all agents will be disabled.All schedulable loads will operate from 12:00 AM until they reach their maximum daily energy transfer • Only Schedulable Load: In this state, schedulable loads will be set for their lowest operational cost time.All solar and batteries in the network will be disabled.• Schedulable Load + Solar: In this state, schedulable loads will be set for their lowest operational cost time and all solar systems will be enabled.Only batteries in the network will be disabled.• All DER: In this state, all DER including schedulable loads, solar and batteries will be enabled.
A total of 8 optimisation models will be used to quantify energy costs based on the above list of DER states.For each DER state, all agents costs will be recorded when participating in the REH and when trading individually.In each DER state, agent energy costs will be averaged and grouped into three categories.These are agents without solar and batteries, agents with only solar, and agents with both solar and batteries.

DER parameter analysis
A simulation was conducted using the model parameters stated in Case study section.
Based on these results the yearly average energy cost for each agent category for all states is listed in Table 3. Table 3 lists the average yearly energy cost for agents without solar and batteries, agents with only solar and agents with both solar and batteries.REH results were achieved using the two stage decomposition method described in the preceding two sections for 1 year of operation.Individual results are average values achieved by agents when optimising their DER individually without any peer to peer trading or being network aware.
The first row of Table 3 is the average cost of energy for these three agents' groups when no agent has solar or batteries and when all schedulable load turn on at 12:00 AM.This row sets the benchmark against which other DER configurations can be assessed against.It can be seen form this first row that there is a benefit of establishing the REH even without DER due to the changes in network tariffs.The second row of Table 3 are energy costs when the schedulable load is optimally set.Optimising the schedulable load benefits agents within the REH or operating individually.However, it is still advantageous for agents with schedulable loads to participate in the REH.
Row 3 of Table 3 are agents energy cost when some agents have solar.It can be seen from the first column that agents without solar will receive no benefit from other agents solar when trading individually.However, when participating in the REH, the average energy cost for agents without solar decreases from $1652.83 to $1584.60.This is because these agents have the ability to purchase solar at a lower rate than grid energy.However, most of the financial benefit of solar is achieved by agents with the solar generation.
The final row in Table 3 is the average energy cost when all DER, including batteries, are operating.Most of the financial benefit of batteries is obtained by the agents with solar and batteries.However, agents with only solar also receive a financial benefit from other agents' batteries.This is because batteries have the ability to increase the REH energy price to the grid purchase price when it would have otherwise been set at the grid sell price.This has a small financial penalty on agents without solar or batteries, however these agents are still incentivised to participate in the REH.
It can be observed from Table 3 that all DER configurations result in lower energy prices for agents participating within the REH.Even agents with no solar or batteries have an absolute advantage of participating in the REH relative to individually trading.
Another way to quantify the benefit of participating in the REH is to quantify the average price each agent pays to import energy.This value is calculated by dividing the total imported energy cost by the total imported energy per agent and is listed in Table 4.
Table 4 demonstrates that agents will always pay a lower average price to import energy when participating in the REH relative to trading individually.The average import energy price for agents with solar increases compared to when they only had a schedulable load.However, this is due to a reduction in energy imports during the middle of the day when the NEM spot price is low.The average price received for exported energy can also be quantified using the same technique.This results in Table 5 value of average energy export prices.As only agents with solar or batteries can export, Table 5 contains results when these DER are enabled.
Agents without solar or batteries do not export energy and therefore have no export energy price.Table 5 demonstrates that agents with only solar have an absolute advantage in export price received when participating in the REH.Agents with batteries receive a higher energy export price compared to agents with only solar.However, they receive a lower average export price in the REH relative to if they were trading individually.This result is influenced by the increased energy traded by agents with batteries participating in the REH.When all DER are enabled, agents with batteries import on average 9892 kWh per agent per year when trading in a REH, but only 4851 kWh when trading individually.This 103.9% increase in exported energy agents with batteries achieve when trading in the REH results in higher battery utilisation and greater financial returns.
The marginal benefit of the schedulable load relative to a simple fixed operational time load is quantified in Table 6 on a per kWh basis.
Table 6 states that for every 1 kWh of additional schedulable load, the net benefit across all agents is $27.71 when participating in the REH and $17.90 when trading individually.This marginal benefit is approximately the same for all agent DER configurations, which indicates most of the schedulable load marginal benefit is obtained by the agent with the schedulable load.
The marginal cost of installing solar can also be derived from the same simulation results and is displayed in Table 7.
Table 7 states that for every 1 kW of solar capacity added to an agent, the marginal benefit to all agents is $143.67 when participating in the REH and $150.65 when trading individually.This confirms that a greater solar marginal benefit is achieved when trading individually.The cause of this reduction in marginal benefit is likely the lower average energy price in the REH relative to directly purchasing from the grid.It is also noteworthy that for each 1 kW of solar added to an agent, a $10.90 marginal benefit is achieved by agents without solar.This incentivises agents to participate in the REH even if they cannot afford solar, or are unable to install solar due to being tenants.
Based on an average installed solar cost of $925.38/kW, the simple payback time for agents with solar participating in the REH or trading individually is listed below.• REH solar payback time: 6.44 years • Individual solar payback time: 6.14 years.
Although participating in the REH results in a longer payback time for solar, this increase is only 0.3 years and should have minimal impact on the decision to install solar.The marginal benefit of installing batteries on a per kWh basis can also be quantified and is stated in Table 8.
Table 8 states that for every 1 kWh increase in battery capacity, the total marginal benefit to all agents is $121.53 when participating in a REH or $107.01 when trading individually.Of the additional value achieved from batteries in the REH, most is allocated to the agent with the battery with some additional financial benefit to agents with only solar.There is a slight decrease in marginal benefit for agents without solar or batteries when increasing energy storage capacity in the REH.As agents with batteries have a higher marginal benefit from their batteries from participating in the REH, they have incentives to remain in the REH and increase their energy storage capacity.
Based on a subsidised installed battery cost of $1260/kWh, the simple payback time for a battery trading in the REH or individually is listed below.
Both options have a simple payback time greater than 10 years, which does not make this an attractive investment.However, a reduction of 1.4 years in payback time will bring forward the future date at when batteries become a viable investment relative to alternatives.
Based on the optimisation results, energy traded in the REH can be summarised as per the following data.When agents were trading individually, they collectively had the following energy imports and exports.Therefore, by participating in the REH, the net energy imported and exported to the grid was reduced by the quantity listed below.
The significant reduction in grid export energy was due to energy exported from agents being consumed locally.This feature, combined with tariff reductions due to bulk energy purchases results in the net energy savings as described in this section.

Internal distribution tariff analysis
The optimisation model demonstrated that agents trading energy within the REH have an absolute advantage compared to agents trading energy directly with the utility grid.One significant factor for this advantage is the lower network tariff paid to the electricity distributor for grid energy imported into the REH relative to an individual agent purchasing directly from the grid.The underlying reason for lower network tariffs for larger energy consumers is due to the economies of scale of electricity distribution.It is more expensive to build a distribution network for a large number of small consumers than for a small number of large consumers.A REH operator may therefore be required to pay an additional tariff to the electricity distributor to account for this.
There are two possible REH distribution network configurations that must be considered when deciding an additional tariff to be paid by agents when trading in an REH.The first situation is where all agents share the same connection to the utility grid and the REH distribution network is on private property.This occurs if all trading agents exist within a group of units or flats on the same property title.This situation is depicted in Fig. 8 where four units are on the same property title.
Figure 8 depicts 4 units on a single property title.In this configuration, the distribution network built on private property is paid for, and maintained by the property owner despite not being on the consumer side of the electricity meter.This private distribution Fig. 8 Units with a privately build distribution network network is connected to the utility grid at a service pit for an underground connection or at a mains box for an overhead supply.Therefore, if the virtual meter is set to the service pit location in Fig. 8, all internally traded energy uses the privately funded and operated distribution network.
In this configuration it should be possible to trade within the REH with no additional distribution tariff as internally traded energy does not require the utility network.The utility distributor is only required to build a network up to the service pit location shown in Fig. 8.At this location the utility network sees the combined load of all units and is therefore the same as a connection to a large energy consumer.This justifies the use of large costumer tariffs at the virtual meter location.Another situation can arise where energy can be traded in a REH.This involves agents on different properties trading energy via the utility distribution network as shown in Fig. 9.
In Fig. 9, four houses are connected to each other via the utility distribution network.The utility distribution network is shown in black and enclosed by the dotted red lines.This distribution network is not on private property and is built and maintained by the utility electricity distributor.Therefore, a REH incorporating parts of the utility distribution network will require some form of financial compensation to this third party for the use of their assets.
The residential network tariff used in this analysis has a peak time charge of 14.7c/ kWh and an off-peak charge of 3.67c/kWh.The large low voltage tariff used to purchase energy for the REH via the virtual meter has a peak time charge of 3.55c/kWh and an off-peak charge of 2.57c/kWh.The difference in tariff prices is only 1.1c/kWh for off peak times, but 11.15c/kWh for peak times.One reason for this discrepancy is that a distribution network capacity must be capable of supplying the maximum demand of all connected agents.The high degree of correlation between residential maximum demand times and the large amount of cables required relative to load size for residential distribution results in high peak time tariff.
A REH has the ability to schedule loads and batteries to maximise the utilisation of the available infrastructure.This reduces the cost of building a residential distribution network.As such, a tariff for energy traded internally within the REH should be close to the network off peak tariff.
To determine the maximum viable tariff on internally traded energy within an REH, a new optimisation model was built based on the network used in this section.In this model, a network tariff to be paid as compensation to the utility distributor is charged Fig. 9 Houses connected via the utility distribution network for energy imported into each agent.The average yearly energy cost per agent based on their DER configuration was recorded as a function of network tariff.This data is displayed in Fig. 10, where the dot on each line is the break even price compared to each agent trading individually.
Based on the data displayed in Fig. 10, the maximum REH internal distribution tariff that can be charged before it becomes more financially viable to trade individually are listed Table 9.
Table 9 reveals that different agent configurations result in different break even REH internal distribution tariffs.Agents with both solar and batteries are impacted the most be REH internal distribution tariffs.This is because batteries in agents trading individually can charge on network off peak times at a price of only 1.1c/kWh more than importing energy into the REH at off peak times.The REH internal network tariff will decrease the batteries profitability, resulting in less energy traded and lower returns for battery operators.Agents with solar have the highest break even internal distribution tariff price.This is due to the additional value received by selling excess energy to other agents instead of the grid.
It is also possible to compute the average energy purchase price for agents in the REH as a function of internal distribution tariff.This is shown in Fig. 11 based on agents DER configuration.
Figure 11 shows that agents with no solar or batteries and agents with only solar experience similar changes to their energy purchase price due to increases in the REH internal distribution tariff.However, agents with batteries and solar experience a  greater increase in energy purchase price.This results in agents with solar and batteries to have a higher average energy purchase price compared to agents with only solar at an internal distribution tariff above 2.8c/kWh.Another useful metric to consider is that of total energy traded per agent.Agents without batteries have a fixed total energy consumption.However, agents with batteries will change their total energy imports and exports based on battery cycling.As the internal distribution tariff increases, battery cycling should decrease due to reduced returns from energy trading.This effect can be quantified using this section's model.The total yearly average energy imports per agent with a battery and solar in this model is shown in Fig. 12.
Figure 12 demonstrates that energy imports and exports of agents with batteries decrease as the internal distribution tariff increases.It can also be stated that the rate of change of energy transfers decreases with increasing internal distribution tariff.Therefore, battery operation is most sensitive to changes in internal distribution tariffs when these tariff values are low.The difference between the energy import and export curve is the total energy consumed by the agent.This value should be a constant.

Energy storage variations
It was determined in Table 8 that batteries result in a greater marginal benefit when agents participate in the REH relative to trading individually with the grid.Therefore, establishing REH trading systems could be an effective way to incentivise the greater uptake of distributed energy storage.Achieving this would require the changes in financial outcomes when agent's energy storage characteristics are varied to be analysed in greater detail.
To quantify the effect of changing the network energy storage, a new DER optimisation model was used where the number of agents with batteries was varied between 0 and 21.Each agent with a battery had 10 kWh of energy storage as per the previous model.All battery properties will be the same as previously analysed.When the network has 12 or less batteries, each battery will be allocated to agents with solar, as these agents benefit the most from batteries.When there are between 13 and 21 batteries in the network, the number of batteries that exceeds 12 will be allocated to agents without solar.Each agent will be allocated a maximum of one battery.When there are 21 batteries in the network, there will be one agent per phase without a battery.
Optimising DER operation within the network with different numbers of batteries over 1 year results in the Fig. 13 value of total grid energy costs.Figure 13 demonstrates that a net reduction in energy costs is achieved when the number of batteries in the REH increases.It is also discernible that the relationship between total energy cost and the number of batteries is not linear.Figure 13 demonstrates a diminishing marginal return of increasing the number of batteries based on the existing number of batteries.This relationship can be seen from the REH marginal cost of energy shown in Fig. 14.
Figure 14 shows that the marginal cost of energy decreases less with each additional battery added to the REH.The addition of the first battery to the REH results in a $1350 reduction in total energy costs, while the 21st battery reduces total energy costs by $684 .The marginal benefit of a 10 kWh battery for an agent trading individually according to Table 8 is $1070.1 , which falls between the marginal cost of 6 and 7 bat- teries in Fig. 14.It is therefore optimal to install 6, 10 kWh batteries in the REH modelled in this analysis.
Figure 14 demonstrates that participating in the REH can result in greater returns for agents investing in batteries compared to trading individually.However, these benefits reduce with increasing energy storage within the REH.The diminishing marginal benefit of energy storage does not effect agents trading individually with the grid.This is because standard residential tariffs are not dynamically priced to reflect the true cost of network access at specific instances in time.Such a dichotomy will always result in an upper limit to maximum viable energy storage within a REH, as REH prices dynamically reflect network congestion and constraints.
It would also be beneficial to gain insights into the effect of varying the total energy storage capacity at each agent.This allows the difference to be observed between adding more distributed storage vs having storage at only a few locations.To achieve this comparison, the REH model with 6 agents with batteries will be used.However, the storage capacity of these 6 agents will be scaled such that the total network storage varies between 0 kWh and 210 kWh.This is the same variation in total REH storage as depicted in Fig. 13, although the storage is only at 6 locations within the REH.Each of the 6 agents with batteries will have the same amount of storage.
Simulating the REH over 1 year and recording the total REH grid imported energy cost as a function of total REH storage results in the "Fixed Number of Batteries" data The benefits of distributing storage in the network can be observed from Fig. 15.For network energy storage values less than 60 kWh, the fixed battery size network will contain less batteries than the fixed number of batteries network.In this region, the network with the greater number of batteries will result in a lower total energy cost.Above 60 kWh of REH energy storage, the fixed battery size network will have the greater number of batteries.In this region the network with the greater number of batteries also has the lowest total energy costs.Therefore, Fig. 15 demonstrates that for a given amount of energy storage, the lowest total cost is always achieved by the network with the greater number of batteries.This difference can be attributed to more distributed batteries having a greater ability to minimise distribution losses and are less impacted by localised network constraints.
Advantages of distributed storage can also be observed by analysing the marginal cost of energy due to changes in network energy storage.Figure 16 shows the marginal cost of grid energy imported into the REH as a function of network storage.Figure 16 demonstrates that a fixed number of batteries results in a lower marginal reduction in energy costs compared to fixed battery sizes distributed throughout the network for total energy storage values of 20 kWh and above.The beneficial effect of distributing storage throughout the network can also be observed through the aggregate sum of all energy imported by agents in the REH.This value is shown in Fig. 17 for one year of simulated data.
For network storage of less than 60 kWh, the fixed battery size model will have less than 6 batteries.Above 60 kWh, the number of batteries in the fixed battery size model will be greater than the 6 batteries in the fixed number of batteries model.Therefore, Fig. 17 demonstrates that the network configuration with the greatest number of batteries results in the largest total amount of imported energy into each agent.
A similar trend can be observed with aggregate agent energy exported energy as shown in Fig. 18.
As was observed with aggregate agent energy imported energy, the REH with the most batteries results in the largest amount of aggregate agent energy exported energy for a given total network energy storage.Any differences in agent imported and exported energy between simulations with the same total network energy storage can only be explained through differences in battery cycling.This is because total energy consumption and generation was constant for all simulations.Therefore, the more distributed batteries are within the network, the more cycling they are subject to.As demonstrated by Fig. 15, this greater battery cycling results in lower yearly grid energy import costs.

Solar capacity variations
The previous section demonstrated how a batteries impact on the REH depends on the total storage and distribution of batteries within the network.As total solar generation is also a factor that impacts energy prices within the REH, quantifying these effects on a per agent basis would also have merit.
Variations in solar generation should exhibit a different impact on grid imported energy compared to variations in network energy storage.This is because the amount of solar generation is not an optimisation decision variable.Therefore, fluctuations in energy prices within the REH will not change solar generation.However, greater solar Fig. 18 Aggregate agent yearly exported energy vs network energy storage generation will result in more energy exported to the utility grid, thereby lowering energy prices within the REH.
To quantify the effect of solar generation variations, a new DER optimisation model was used where the number of agents with solar was varied between 0 and 24 agents.Each agent with a solar installation had a peak DC solar generation capacity of 6.25 kW.This configuration results in changing the network solar generation capacity between 0 kWh and 150 kW.
Optimising DER operation within the network with different numbers of solar installations over 1 year results in Fig. 19 value of total grid energy costs.
Figure 19 shows a net reduction in energy costs occurs when the total number of solar installations within the REH is increased.A diminishing marginal return is also discernible from Fig. 19 as the relationship between energy costs and solar installations is nonlinear.REH marginal costs from the data displayed in Fig. 19 can be quantified and are depicted in Fig. 20.
Figure 20 shows that the marginal grid energy costs decreases with each additional solar installation.The first solar installation results in a $1002 reduction in total energy costs.At a price of $925.38/kW , the simple payback time for the first 6.25 kW As the lifetime of a solar installation is usually considered to be 25 years, these payback times should result in the investment being cash flow positive within its operational life.However, some investors require a simple payback time of 7 years or below.In this case, the maximum number of solar installations would be limited to 12.
Another useful metric to consider when planning solar installations is the effect of distributing the generation capacity throughout the network relative to more concentrated generation locations.The data displayed in Fig. 19 was the result of distributing new generation capacity throughout the network.This result can be compared to that obtained by fixing the number of agents with solar and adjusting their solar capacity to change total network solar generation capacity.To achieve this, the number of agents with solar will be fixed at 12.These 12 agents will all have the same solar generation capacity that will be scaled with each successive simulation.
Optimising DER operation within the network with a fixed number of solar installations, but varying total solar capacity over 1 year results in Fig. 21 value of total grid energy costs.This data is also shown with the Fig. 19 values obtained by fixing the solar system size and varying the number of agents with solar.
Figure 21 reveals that there is no significant effect on total energy costs within the REH due to the distribution of solar generation within the network.This result could be due to the inability to control solar generation as it is not an optimisation decision variable.Total solar generation is also less that total energy consumption.As such, it is unlikely that any network constraints will result in solar generation curtailment.
Changing the solar generation capacity will also impact the energy imported into each agent per year.The aggregate sum of all energy imported into each agent when the number of agents with solar is fixed is shown in Fig. 22.
Total agent imported energy is approximately linear with solar generation capacity.The square of the linear regression correlation coefficient is 0.9975 for the data in Fig. 22.This indicates that almost all of the variations in total agent imported energy are due to changes in solar generation capacity.Therefore, distribution losses and

Discussion
Results obtained from analysing the case study used in this paper revealed that financial savings could be achieved through load aggregation and active network management.This can be achieved using dynamic and cost reflective tariffs to incentivise distribution loss reduction and maximise network utilisation.However, as shown in Fig. 10, there is a point where existing flat rate energy market tariffs prevent the proposed market structure being viable.This is because existing flat rate tariffs do not reflect the dynamic costs of consuming energy on the distribution network.It is therefore advisable to increase the time and network traffic dependence of current energy market tariffs.
It was also observed that lowering energy prices within a REH has the effect of increasing the payback time of energy generation systems.However, it was also noted that solar generation does not result in any significant energy loss reductions when evenly distributed throughout the network.It is therefore possible to benefit from economies of scale by building larger shared solar generation assets as opposed to many agent based solar installations.
Batteries were found to result in significant cost savings and reductions in energy losses.However, they were also very sensitive to internal distribution tariffs.This suggests that battery specific tariffs would be required to ensure the benefit they provide to other agents and the distribution network is sufficiently compensated for.
Results in this paper are unique among current literature in the assessment and allocation of distribution energy losses.Most research reviewed and cited in this paper mentions the use of OPF in scheduling DER, although the effect that energy losses derived using OPF have on agent energy costs are implied, but not quantified.This is because OPF and its associated losses rarely contain the key research contributions when discussing REH and TEM.The authors of Faqiry et al. (2020) provide the closest research into quantifying distribution energy losses to the model in this paper.However, even this level of detail is insufficient to make a direct compression to the research findings in this paper.The distribution model described in Jiang et al. (2022) provides a similar level of complexity and quantifying of distribution losses.However, the model used works at 48V and incorporates features specific to this small scale application.As such, its findings are not directly comparable to those presented in this papers.Due to these factors, more research is required to make OPF a key feature and source of innovation in REH models.

Conclusion
Results presented in this paper demonstrated that savings can be achieved by energy consumers in a VPP utilising existing tariff structures and DER configurations.These financial benefits exceed those achievable by agents with DER trading individually with the utility grid.Agents must relinquish control of their DER assets to achieve these benefits, but unlock greater value from their energy flexibility.This is evident by their higher average energy selling prices within the REH.Agents without DER also achieve financial benefits through aggregated energy purchasing.
Energy savings of the proposed business model varied based on DER configuration.When all DER within the REH was enabled, agents without solar or batteries reduced their energy costs by 29.2% compared to having no DER enabled and purchasing energy individually.Agents with DER also achieved energy cost reductions by participating in the REH relative to trading individually.In the REH, agents with solar achieved a energy cost reduction of 64.8% and agents with batteries and solar achieved a cost reduction of 118.2% relative to having no DER.
It was also observed that including an internal distribution tariff within the REH had a significant impact on financial outcomes.These internal tariffs may be necessary to compensate electricity distributors for the use of their network and to pay for DER aggregation and control services.Agents with batteries were especially sensitive to these internal distribution tariffs.As such, further research may be needed into internal tariff structures to incentivise battery participation.
It was also observed that VPP implementations accounting for distribution losses and constraints can achieve savings relative to agents trading individually with the utility grid.However, there is a point where fixed rate tariffs incentivise agents to leave the VPP.This is due to existing distribution tariffs not accurately reflecting time specific distribution costs in high DER penetration networks.
The model presented in this paper contrasts with existing research relating to REH's as the OPF model became a key feature of agent specific energy pricing.Using this methodology, pricing systems can be used to incentivise and reward agents for minimising distribution losses.The OPF model presented does not require decomposition or linearization to solve.As such, computational time constraints were not required to be considered in this research.
Overall, results presented in this paper demonstrated that load aggregation and centralised DER coordination can result in financial savings in the current regulatory environment.

Fig. 6
Fig. 6 Second stage optimisation electrical model

•
Grid connection voltage: 230 V • Maximum node voltage: 253 V • Minimum node voltage: 207 V • Node to node maximum current: 320 A • Node to agent maximum current: 50 A • Node to node resistance: 12.5 m • Node to agent resistance: 12.5 m

Fig. 10
Fig. 10 Yearly agent energy cost vs internal distribution tariff

Fig. 11
Fig. 11 Yearly agent energy price vs internal distribution tariff

Fig. 13
Fig. 13 Total yearly REH energy cost vs number of batteries

Fig. 15
Fig. 15 Total yearly REH energy cost vs number of batteries

Fig. 16
Fig. 16 Total yearly REH energy marginal cost vs number of batteries

Fig. 19
Fig. 19 Total yearly REH energy cost vs number of solar installations

Fig. 21
Fig. 21 Total yearly REH energy cost vs network solar capacity

Fig. 22
Fig. 22 Aggregate agent yearly imported energy vs network solar capacity .

Table 4
Average energy import price (c/kWh)

Table 5
Average energy export price (c/kWh)

Table 9
Break even distribution tariffs

Table 11 Nomenclature
True if energy is exported to the grid during time t True if agent a schedulable load is on during time t a Agent a price scalar during time tR n,xResistance between node n and xR aResistance between agent a and connected node l Load voltage at time t