Closest Energy Matching: Improving peer‐to‐peer energy trading auctions for EV owners

EPSRC; EP/R513039/1 Abstract Herein, a novel approach to conduct peer‐to‐peer energy auctions for electric vehicles (EVs) to benefit both buyers and sellers is presented. It considers a scenario where households can sell their surplus solar energy to visiting EVs that make use of the households' vacant charge points during the day. The aim of the energy trading is to maximise the amount of charge EVs receive from the solar energy, and increase the revenue for sellers. The novel Closest EnergyMatching (CEM) double auctionmechanism is proposed and it is comparedwith four other mechanisms. CEMallows the auction to take into account current energy requests as well as the potential future demand without requiring additional information. Anovel algorithm,MARMES (MAtrix Ranking forMaximisingElement Selection), is also presented to solve the optimisation problem that forms the basis of the CEM mechanism. The CEM mechanism on average results in 21.5% more solar energy used, lower cost to the consumer, a 24.9% increase in profits for sellers and a 71.4% reduction in required grid energy compared with the traditional double auction mechanism.


| INTRODUCTION
The electric vehicle (EV) revolution is gathering pace, and technology and infrastructure development must adapt quickly to keep up. The availability of charging points and EV range are still among customers' top concerns [1]; as of May 2020, there are approximately 18,000 public charge points available across the UK, however, many of these are 'slow' and provide insufficient range from short charges, or often suffer technical issues and are out of service [2]. Around 80% of EV charging takes place at home, with approximately 90% of EV owners having access to a private charge point [3,4]. These charge points are often vacant during the day and there is an emerging market for EVs to utilise them, solving many issues that EV drivers currently face. As existing public chargers cannot be booked, introducing a reservation system for private charge points would alleviate EV owners' concerns over charge-point availability, especially when travelling to a new location. In addition, private charge points could provide parking for visiting EVs, thus helping to reduce parking and congestion difficulties and guarantee charging.
The surge in EV numbers is creating new challenges for power networks and energy systems, which must support the ever-increasing demand. The industry is undergoing rapid evolution, with increasing use of distributed energy resources (DERs) such as solar photovoltaic (PV) panels and private energy storage, as well as the creation of smart grids and additional load from EVs [5]. Peer-to-peer (P2P) energy trading is emerging as a key technology for power networks and smart grids [6][7][8][9][10][11][12][13][14][15] as it facilitates the trading of smaller quantities of intermittent renewable energy among a local grid, whilst avoiding many of the challenges of selling energy back to the main grid. A common issue addressed through P2P trading is the economic dispatch [8,9], where the trading of energy is used in conjunction with the control of loads and generation to minimise overall cost for a micro or smart grid. P2P trading can result in economic benefits for energy prosumers (i.e. households that are both consumers and producers of energy). For instance, while E.ON Energy offer just 3 pence per kWh (p/kWh) to purchase energy from producers through a Smart Export Guarantee (SEG), compared with their standard selling rate to consumers of 16.5 p/kWh [16], a P2P trade can be agreed at a price that is beneficial to both parties. P2P trading can be conducted in a centralised (e.g. [8,17]) or distributed [6,7,[18][19][20] procedure. Wang et al. [8] develop a centralised blockchain-based approach to P2P trading, where sellers and buyers send energy supply or demand requests for day-ahead trading to the utility, which then solves an optimal power flow problem to minimise the generator cost function. A real-time optimisation is also used to balance out fluctuations and forecast errors. Smart contracts are implemented by the utility to control the energy trades. In [17], the ECO-Trade algorithm is presented to coordinate P2P energy trading among households to solve an energy cost optimisation problem whilst ensuring fairness amongst participants. A Stackelberg Game approach is considered by [6,7,18] to coordinate P2P trading in a distributed manner. In [7], buyers and sellers in a community microgrid act on non-cooperative and Stackelberg Game frameworks to select the trade to maximise their welfare, with buyers iteratively selecting a seller to trade with based on submitted energy costs. A distributed iterative algorithm is used to achieve equilibrium in the game. Liu et al. [6] consider a microgrid operator (MGO) which optimises energy sharing between solar PV prosumers. The MGO sets internal prices for energy trading, and prosumers act as followers to determine their energy consumption. Prosumers and the MGO choose strategies to maximise profit for the MGO and utility for prosumers. The authors of [18] also consider a game theory relationship between microgrids for distributed P2P trading. An iterative non-cooperative game is played among the energy sellers as they attempt to maximise their profits by selling energy to buyers. The relationship between buyers and sellers is then modelled as a Stackelberg Game to achieve equilibrium to determine the optimal pairing of buyers and sellers, and quantity of energy sold by the sellers. A contract-based approach for energy trading is considered in [19]. Forward and real-time markets are considered, where agents can buy and sell energy contracts in the forward market based on predictions of cost and demand, the agents must then meet their obligations in the real-time market. At each iteration of the market, each agent is offered a set of contracts by its neighbours. The objective of the market is to ensure that the agents choose a set of contracts that they do not wish to alter, through a distributed price adjustment process. Khorasany et al. [20] present a distributed approach to maximise the welfare of all participants in the market. The market clearing problem is decomposed into local subproblems, which can be solved with limited information using the primal-dual gradient method. This maintains the privacy of participants and, by each participant solving their own welfare maximisation problem, the social welfare of the entire market can also be maximised.
EVs can also utilise P2P networks for the trading of energy. EVs with surplus energy in their batteries can sell energy directly to other EVs that require charging (V2V) [21,22]. The energy stored in EV batteries can also be sold to the grid (V2G), for instance in [23] EVs act as either buyers or sellers of energy with the grid, with the aim of regulating voltage deviations. The EVs submit both bids and asks, with an auctioneer choosing which offer to accept. Most relevant to this study is P2P EV charging, where EVs can purchase energy to charge their batteries directly from energy producers. Smart charging of EVs is considered in [24], where contracts are negotiated between EVs and aggregators to coordinate EV charging in a way that is beneficial to the grid. The aggregator attempts to maximise profits and, with the cost set as a function of the base load, it also results in flattening of the total grid load. A multi-agent system is proposed in [13], where buyers and sellers can negotiate temporary contracts for the sale and purchase of energy, including the ability to renegotiate the price.
Auctions are a popular method of facilitating P2P energy trading, as they give prosumers the ability to set their desired bid and ask prices, quantity of energy traded and participation. The Vickrey sealed bid mechanism [25,26] can facilitate truthful bids, as the highest bidder wins the auction but pays second highest bid price. A common auction structure is the double auction where buyers and sellers submit bid and ask prices, respectively [9,12,14,21,22,26,27]. The submitted bids and asks can be used to form demand and supply curves based on price and quantity. The intersection point of these curves determines the quantity sold and the market clearing price [9,22]. Buyers and sellers are typically matched according to price, where the highest bidder trades with the seller with the lowest ask [12,14]. An adaptation on this is considered in [11], where the difference between bid prices and market price is calculated, with the smaller the difference the higher the priority to trade. This rewards buyers who bid truthfully at market price. There are also other mechanisms for matching buyers and sellers: the authors of [21] determine trades through a combination of cost and the percentage of EV's energy need fulfilled, whereas [27] use a day-ahead auction with the goal of minimising impact on the grid through charging and discharging EVs. An Average Price Mechanism is compared with trading at the market clearing price in [26], where the authors conclude that the Average Price Mechanism allows more participants to trade. The authors of [28] consider auction matching mechanisms for P2P energy trading among EVs (V2V). They focus on a cloud-based server for communication between EVs, and consider the amount of energy each EV has initially when determining the matching through a value known as the aspiration rate. The auction matching mechanism aims for greater profit for all participants, and the matching of EVs is found to be optimal if the sum of the gain (difference between bid and asks) is maximised.
P2P trading of surplus solar energy is covered in [10,25,29]. The price of the solar energy in [10,25] is calculated from the supply and demand ratio (SDR) in the energy market. The uncertainty in solar production is considered in [29]. PV owners make asks as they attempt to sell their surplus energy. The market mechanism aims to maximise the PV revenue, taking into account the revenue from energy sold, positive deviation sold and reducing the costs of negative deviation. The PV offers are ranked low to high, and loads are matched with PV owners until there is no unmatched load remaining.
In many of these energy auctions, a seller is able to provide energy to multiple buyers, or a buyer is able to purchase energy from multiple sellers, simultaneously. However, in certain trading circumstances, the resources available do not cater to this. For instance, [30] deals with the limited availability of onstreet charging for EVs through incentivising cooperative handovers to encourage better utilisation of charging points. The limited availability of parking spaces is also considered in [31,32]. Both use auction mechanisms with a limitation on the number of winners to match the available resources (number of parking spots and charge points). In [32,33] the amount of energy available to a buyer is also limited. The energy available to each buyer is determined by the total energy available minus the amount requested by buyers offering a higher bid price. A blockchain-based auction system is presented in [25], where sellers offer a block of energy for sale via a blockchain platform. The highest bid wins the block of energy, matching a trade for the respective buyer and seller. In these works, the priority of obtaining the desired resource is based upon the bid price, with a higher bid price increasing the likelihood of trading the desired quantity of the resource.

| NOVEL CONTRIBUTION
Herein, a scenario is considered where a household or smallbusiness, etc. (hereafter referred to as a household), wishes to sell surplus solar energy produced by their solar PV panels to a visiting EV that requires charging. It is assumed that the household owns their own EV and has a vacant EV charging point during the day. A double auction platform is considered where households can submit asks to sell their surplus solar energy and visiting EVs can submit bids to purchase this energy. In the auction, the winning households will provide the winning EVs with a guaranteed parking space, EV charging point and the agreed amount of solar energy in exchange for the price determined from the bid and ask prices. Each EV can only trade with a single household as it is assumed that an EV would not want to relocate during the day, and as a household only has a single charging point, each household can only charge one EV at any given time. In line with existing work, our auction ensures that participants are no worse off through participation in the auction, and buyers and sellers are free to individually determine their own bid and ask prices based on their own preferences. The primary contributions of this work are as follows: 1. Unlike many existing pieces of work that assume that there is sufficient energy to ensure all EVs are able to fully charge, our study examines the scenario where there may be insufficient energy to complete all EV charging demands, and explores auction matching mechanisms that aim to maximise the amount of charge all EVs receive. 2. Electricity produced by household solar panels is fed directly to the household's charge point to charge the EV, rather than sold and distributed through the grid. This reduces system complexity and power issues resulting from the charging of EVs or injection of DER-produced energy.
It also ensures that the study is relevant and valid, as it can be implemented in real life with existing technologies. By focusing on increasing the EV charge, and hence the amount of solar energy consumed, important environmental challenges are tackled, aiding in the process of decarbonisation. 3. One-to-one matching of EVs and households is enforced to explore the effectiveness of different auction mechanisms for EV energy auctions under the scenario of limited solar energy and imperfect online information regarding the future needs of EVs. One-to-one matching is chosen because most households have only a single EV charge point, meaning they can charge only one EV at a time, and in addition, household PV arrays may not generate sufficient energy to fully charge one EV, and are unlikely to have sufficient surplus solar energy to trade with multiple EVs. The procedure used and findings of this work regarding the one-to-one matching of households and EVs could also be extended to other scenarios that can only facilitate one-toone matchings.

A novel double auction mechanism, Closest Energy
Matching (CEM), is proposed, which aims to maximise the amount of charge EVs receive from solar energy, reduce the grid energy required for charging, reduce the EV's cost to charge and increase the profit made by sellers. The proposed CEM mechanism is described along with four other mechanisms in Section 3. 5. A novel algorithm, MARMES (MAtrix Ranking for Maximising Element Selection), is presented in Section 4 to solve the optimisation problem that forms the basis of the CEM mechanism. Section 5 explains the case study used and the performance results for each of the presented auction mechanisms, showing that the CEM mechanism results in higher solar consumption, greater EV charge, increased revenue for households, lower costs for EVs and a significant reduction in grid energy required to fully charge all EVs.

| DOUBLE AUCTION MATCHING MECHANISMS
The auction mechanisms presented here are based on the double auction premise: buyers submit a bid consisting of the price in p/kWh (1p = £0.01) that they are willing to pay for the energy, along with their departure time and amount of energy requested in kWh; sellers submit an ask price in p/kWh and their predicted surplus energy available to sell throughout the day. The purpose of the auction matching mechanism is to match bids with asks to determine which buyers and sellers trade together. The mechanism should satisfy individual rationality (the participants are no worse off through participation in the auction), achieve a strong balanced budget (the auctioneer neither gains nor loses money as a result of a matching), and attempt to satisfy economic efficiency (maximise total social welfare) [34]. A major factor of the auction used in this scenario is that each buyer wishes to acquire a certain quantity of energy and each seller has a different amount of finite energy available. In addition, each buyer THOMAS ET AL.
-447 (seller) is only able to trade with a single seller(buyer). As a result, the sellers are non-homogeneous-the choice of seller affects both trade price and energy quantity-so the auction mechanism must take both price and energy quantity into account during the matching. In all of the tested mechanisms, the auction runs every 15 min. If the EV owner requires energy and is not already charging, they will submit their bid price and quantity of energy required. Similarly, if the household has surplus energy available and is not currently charging another EV, they can submit an ask price and their predicted surplus energy profile. Privacy issues are an important consideration with P2P trading systems for EVs. Buyers and sellers must submit private information relating to their energy demand and supply profiles, EV energy needs and driving patterns. The auction mechanisms presented here utilise a sealed-bid system, where the private information regarding the EVs and households (energy profiles, departure times) is only visible to the auctioneer that conducts the matching mechanism. In addition, each buyer and seller are identified by a unique ID number which preserves privacy during the auction process. Once the auction matching process is complete, the private information of a household's location or EV information can be communicated directly with the matched buyer and seller, respectively. Although not within the scope of this work, the auction mechanism can be combined with a blockchain implementation, such as in [14,21,35]. Public-key encryption and the blockchain consensus procedure are used in [14] to validate transactions and discard any transactions created by dishonest partners within the network. Smart contracts are also used to deal with discrepancies between energy awarded in the auction and energy actually traded. A consortium blockchain is used in [21] to allow permitted aggregators to verify the energy trades. Public/private key encryption is again used to mask real identities and ensure all messages and transactions are legitimate. The authors of [35] present a privacy-preserving algorithm through the encryption of bids, with matching taking place over the blockchain through a smart contract and the masking of the identities of participants.
PV production and the household's energy requirement are assumed to be predictable, and therefore the household is able to broadcast their profile of surplus solar energy over the day to all buyers. A further assumption is that an EV owner would not wish to move their EV during the day. Therefore, a buyer can only match with at most one seller, regardless of whether or not that seller is able to provide sufficient energy to fully charge the EV. Most households only have a single EV charging point so, until an EV departs from a seller, no other EVs can be charged. If a seller has insufficient solar energy production to meet the EV's demand, grid energy can be used to make up the shortfall.

| Determining the bid and ask price
Each buyer and seller has their own private valuation of the energy, which is the equivalent of the highest price they are willing to pay per kWh (denoted v i ) or lowest price they are willing to receive (v j ), respectively. This valuation is known only to the individual participant and is determined individually through a variety of factors. A buyer who requires a large quantity of energy may value it more highly than a buyer who requires less energy, but the valuation is also a factor of their own personal and economic situation-if the buyer has other EV charging alternatives they would likely the value energy lower than a buyer who relies heavily on the energy they are bidding for. Likewise, a seller with a large quantity of energy may value it lower than a seller with less energy to sell. However, if battery storage is available to them, they may prefer to store the energy rather than sell it and would therefore value the energy they sell in the auction more highly.
It is logical for a buyer to wish to trade at a price considerably lower than their valuation and a seller to wish to trade at a price higher than their valuation. The gain that a buyer receives from the auction matching is defined as the difference between their valuation and the price they pay for the energy, and the gain a seller receives is the difference between the price they receive for the energy and their private valuation [22,36]. If buyers bid lower than their true valuation they risk not receiving the full amount of energy they request if the only seller with sufficient energy has an ask price π bid i < π ask j < v i . However, because sellers are free to set their own ask price, and the award of energy through the auction mechanisms considered here is not directly proportional to the bid price, it is an appropriate assumption for the buyer and seller to choose their optimal bid and ask prices solely based on their expected gain per kWh.
If a buyer and seller are matched by the auction mechanism with bid and ask prices of π bid i and π ask j and trade at price , then the gain the buyer receives is given by The maximum gain that a buyer can receive is which occurs when v j ¼ π ask j and π bid i ¼ v j , that is, when the seller asks for their true value and the buyer bids the same value.
If both parties bid truthfully-π bid i ¼ v i and π ask j ¼ v jthe gain the buyer receives is given by Therefore, the gain they have sacrificed between their maximum possible gain and the gain from bidding truthfully is given by The same is true in reverse for a seller, so a seller would ask for more than their true value v j to try to increase their gain, in the same way that a buyer could increase theirs by bidding closer to the seller's true value. Therefore, π ask j > v j , and G max i < v i − v j . Therefore, bidding truthfully is not a dominant strategy in the auction and, as such, the buyers and sellers must choose their bid and ask prices in order to try and maximise their gain. The optimal bid price for a buyer is derived as follows: The buyers do not know the sellers' ask prices or other bid prices, hence the auction operates in sealed bid manner. It could be assumed that the asks are normally distributed as it is likely that participants will have past knowledge of the average trade price [37]. The majority of bids/asks will be focused around the average price, with fewer offers at prices further from the average price. Herein, the past data have been estimated with μ = 11.5 p and σ = 1. The buyer wishes to choose their bid price to maximise their gain against the expected ask price, but if they bid lower than the ask price then they will receive 0 gain.
The expected gain that a buyer would expect to achieve based on their bid price, G exp i , is given by where f(x) represents the normal distribution probability density function: Figure 1 shows the value of the buyer's expected gain calculated from solving (5) for a range of bid prices for three different valuations (v i ). It shows that the buyer can expect to obtain a higher gain by bidding a value lower than their true valuation, as expected from (4), but it also shows that their expected gain decreases if they bid too low as the probability of trading decreases. The optimal bid price ðπ � bid i Þ to maximise the expected gain for each valuation is shown on the graph by the dotted lines corresponding to the maximum value.
In order to maximise the expected gain, the buyer must choose a bid price that maximises the value of Equation (5). To simplify the calculation, this integral is approximated as a Riemann sum using the midpoint rule, and the optimisation problem is presented as follows: where n is the number of intervals, m k is the midpoint of interval k in the integration and Δx k is the width of each interval. Each buyer can calculate their optimal bid price π � bid i by finding the value of π bid i that maximises the objective function (7).
The derivation of the optimal ask price for a seller π � ask j � � is not shown here, but it can be obtained using the same procedure as above and is given by

| Auction matching mechanisms
Five mechanisms are explored below, each with a different strategy for matching buyers and sellers. The overall aims of the buyers are to maximise the amount of charge they receive for their EVs and reduce the cost, whereas sellers wish to maximise the amount of their surplus energy sold and increase their profit. In each mechanism, the trade price is calculated as the mean of the matched bid and ask prices, resulting in buyers always paying the bid price or less, and sellers always receiving their ask price or greater.

Mechanism 1 Cheapest ask
This is the classic double auction mechanism, as in [12,14]. Once buyers and sellers have submitted bids and asks, they are ordered according to natural ordering-bids are sorted from high-to-low, and asks from low-to-high. Each bid is taken in this order and matched with the lowest available ask. The corresponding household and EV are then matched and can trade. This mechanism only considers the bid and ask prices and not the amount of available energy. THOMAS ET AL.
-449 Mechanism 2 Sufficient energy/cheapest ask Mechanism 2 is an adaptation of Mechanism 1. Because the first mechanism only considers the prices and not the energy requirements, it is possible that an EV will be matched to a household that is unable to provide the desired quantity of energy, when there may be an alternate household that could supply sufficient energy with little difference in price. This mechanism makes the following adjustments to the algorithm used in Mechanism 1: Once the bids and asks have been sorted, each bid is taken in order. However, sellers that have insufficient energy to meet the EV's energy need are first removed from the list of asks before the cheapest ask remaining is matched. If there are no sellers available with sufficient energy, then the mechanism picks the cheapest ask, as per Mechanism 1. Mechanisms 1 and 2 reward buyers who have bid the most by giving them priority in the matching, as in [32,33].

Mechanism 3 Minimise cost
This mechanism attempts to minimise the total cost to buyers through solving the following optimisation problem. Similar cost minimisation strategies are popular in energy auctions, and can be found in [10,11,23] and [38].
π bid i > π ask j ð9dÞ where I, J are the number of buyers and sellers, respectively, π trade ij is the agreed trade price, E trade ij is the amount of solar energy traded, π grid is the price to purchase energy from the grid, E grid ij is the amount of energy that must be purchased from the grid to ensure EV i receives a full charge if trading with seller j. T D i and E req i are the departure time of, and amount of energy required by EV i, respectively. E t av j is the amount of surplus energy seller j available at time t, and π bid i ; π ask j are the bid and ask prices of the buyer i and the seller j, respectively. The decision variable is X-a matrix with I rows and J columns, and x ij is the value of X at position (i, j), where x ij = 1 if buyer i trades with seller j, or else equals 0. Constraints (9e), (9f) and (9g) ensure that matrix X contains only 0s and 1s and has at most a single 1 in every row and column.
The problem considers both the cost to a buyer of purchasing solar energy from a seller and also the cost of any additional energy that would be needed from the grid to enable the EV to depart with its required energy. If buyer i's bid price is not greater than seller j's ask price, they are unable to trade and x ij = 0.
By attempting to minimise the total cost, the mechanism encourages trading of renewable energy, as it is assumed that π trade ij < π grid . This increases the quantity of surplus energy sold, and thus the amount of charge received by the EVs, whilst also reducing the cost to the consumer.

Mechanism 4 Buyer/seller utility
To ensure that the auction mechanism is beneficial to both buyers and sellers, Mechanism 4 considers the satisfaction of both buyers and sellers through a quantity known as the buyer's or seller's utility, which has been based on the work in [21]. A good matching for a buyer meets the following criteria: � Low cost-a buyer wishes to pay as little as possible for the energy � High charge-a buyer wishes to receive all of their required energy Whereas, sellers aim for: � Maximised income-a seller prefers to sell surplus energy at a higher price, as this increases their income � High energy utilisation-a seller aims to sell as much surplus energy as they can Despite each buyer and seller having two aims there is inherent equivalence, allowing them to be expressed as a single aim for a buyer and for a seller. Buyers wish to increase the amount of charge received and by doing so will also help the seller's aim of increasing the amount of solar energy sold. Introducing the term 'cost benefit' allows the second point for each participant to also be met [22,32,33]. The cost benefits for buyer i and seller j trading are defined as the difference between the trade price and the bid or ask price, respectively, as given in (10) and (11): Whilst similar, it is important to note the differences between the cost benefit ðB buy ij Þ here, and the gain (G i ) used in the calculation of the optimal bid and ask prices earlier in this section. The cost benefit is the difference between the bid price and trade price, whereas the gain is the difference between the buyer's private valuation and the trade price, such that G i ≥ ðB buy ij Þ. As the trade price is equal to the mean of the matched bid and ask prices, (12) always holds. Therefore, increasing either the buyer or seller cost benefit also results in an increase to the other. As a result, all aims for buyers and sellers can be realised through the buyer and seller utility expressions in (13) and (14), respectively: where w is a unitless constant. The use of subscript ij denotes the value from buyer i's point of view, and subscript ji is a value from seller j's view. For instance B buy ij is the benefit buyer i receives if trading with seller j, whereas B sell ji is the benefit seller j receives if trading with buyer i. The total utility of buyer i trading with seller j is The utility that would be achieved for every combination of buyer and seller trading can be calculated using the information submitted with the bids and asks at every time step. If a buyer and seller cannot trade, that is they are already partaking in a different trade, or the buyer's bid does not exceed the seller's ask, the total utility for that combination can be set to −∞. Mechanism 4 matches buyers and sellers by solving optimisation problem (16) to maximise the total utility. The optimisation outputs matrix X which contains a 1 at position (i, j) if buyer and seller i and j should trade, or 0 otherwise. This is very similar to the approach used in [28], however, there it is assumed that the EVs will reach a full charge so the matching mechanism only includes (14) and not (13).

Mechanism 5 Closest Energy Matching
A disadvantage of Mechanisms 3 and 4 can be demonstrated through the following simple example: There are two households selling energy and two EVs wishing to charge, arriving at different times: Household A has a total of 20 kWh of energy available to trade and asks for 11 p/kWh, and Household B can offer a total of 50 kWh at a price of 10 p/kWh. EV 1 arrives at 11 AM, requiring 15 kWh with a bid price of 12 p/kWh. Under mechanisms 3 and 4, EV 1 would trade with Household B. However, if EV 2 then arrives an hour later at 12 PM, requiring 30 kWh and offering the same price, Household A is its only option to trade, resulting in EV 2 not receiving a full charge. It should be apparent that if EV 1 had instead matched with Household A, then EV 2 would be able to trade with Household B, resulting in both EVs receiving a full charge.
The concept of CEM attempts to rectify this problem by matching each buyer with the seller whose available surplus energy is closest to the amount requested by the buyer. In this context, the seller j with the closest available energy to buyer i is the seller for whom their total available surplus energy minus THOMAS ET AL.
-451 the buyer's requested energy results in a positive value closest to zero as follows: If there are no sellers for which this calculation results in a positive value, the seller with the closest energy is the one which has the highest negative value.
The energy difference is weighted with the constant w in (19a) or (19b) depending on whether the energy difference is positive or negative. This weighting ensures that the energy difference has the greatest contribution to the optimisation function. Two other terms are included in the optimisation (19): the proportion of the EV's energy that can be supplied from charging with each household and the cost benefit (10) achieved by participants. This ensures that the aims of both buyers and sellers are represented and result in a better outcome for all parties. The CEM mechanism matches buyers and sellers so that their energy difference is minimised, and the energy purchased/sold and cost benefit are maximised. Matching buyers and sellers by minimising the difference between the buyer's need and seller's surplus energy should result in a matching that not only meets the buyer's energy needs but also considers potential future EV charging requests as it keeps households with greater available surplus energy in reserve for the event that an EV with a greater energy requirement arrives.
The optimisation problem solved at time t by Mechanism 5 is where where E D ij is a function of E diff ij : the difference between seller j's available energy and buyer i's required energy; E A ij is the proportion of buyer i's energy need that can be satisfied by seller j, and w, a are unitless constants.

| MARMES
The optimisation problems in Mechanisms 3-5 are from the class of integer linear programming problems, as the optimisation variable, X, only contains zeros and ones. The problem being solved is to place ones in the matrix X to maximise the sum of the elements in U* = X ⋅ U, where U is a matrix containing the utility values from Mechanism 4, the inverse of the cost function in (9), or the energy difference function from (19), calculated for each combination of buyer i and seller j. U* is a matrix containing the chosen elements from U. The constraints (9f) and (9g) enforce that matrix X can contain at most one 1 in any row or column as each EV is only able to trade with a single household and each household can only trade with a single EV, all other values must be 0. The problem can be generalised as follows: where A is a M � N matrix containing a set of real numbers and X is a matrix of equal size to A containing the output from the maximisation. MATLAB supports the solving of this type of problem through its 'intlinprog' solver, however a new algorithm named MARMES (MAtrix Ranking for Maximising Element Selection) specifically designed for solving this problem is proposed here. MARMES solves the problem faster than MATLAB's solver and does not rely on MATLAB functionality, making it more appropriate for use in a realworld application. Find location n of number with rank = 1 in row m and put a 1 in corresponding location m, n in X (iter) end for while there exists a column n where P x

Algorithm 1 MARMES Algorithm for maximising the sum of chosen elements in a matrix
if Higher rank value not allocated in line 15 then Move 1 in X (iter) from current position in row to position corresponding to next highest rankcolumn n* end if end for end for end while return X (iter) The MARMES algorithm begins by ranking numbers in each row of the matrix A, with the highest number given the rank 1, the second highest rank 2, etc. Once all numbers have been ranked, it begins by selecting the highest number (rank = 1) in each row, by placing a 1 in the corresponding field in matrix X. Given that there can be, at most, one 1 in each column, the columns that contain more than one 1 are found. While there are any columns that contain more than a single 1, the following is repeated: for each of these columns (denoted by set Ω n ), the rows that contain the 1s are found (set Ω m ). In each of these rows the algorithm looks to see if the location of 1 in that row of X corresponds to the highest rank (1). If not, it then checks to see if the higher ranked values in that row fall in columns of X that contain all zeros. If so, the location of the 1 in that row of X is moved from the current column to the empty column corresponding to the highest rank. If this is not possible, the difference between the values of the number in A in the current rank (position currently selected by 1), and the number in the next highest rank is calculated (A diff m2Ωm ). The row from set Ω m containing the greatest difference is left unchanged, and in all other rows from this set, the location of the 1 in matrix X is moved to the position corresponding to the next highest rank. If there are still columns containing more than a single 1, then the iteration number increases and the algorithm repeats. Once a solution has been found that results in at most a single 1 in each row and column, the algorithm stops and outputs the current iteration of X. The locations of 1s in this matrix show the chosen values that maximise the sum of A, subject to the imposed constraints. The algorithm does not place a 1 in every row if there is no feasible solution-if there is no next highest rank available in line 23 of the algorithm, then this row would be left blank instead. If A contains negative numbers or other unwanted values, then these can be ignored by adjusting the ranking criteria in line 3, for example by only ranking positive numbers.
The performance of this algorithm is measured against that of the intlinprog solver in MATLAB, which is assumed to be reliable in providing the optimum selection of values resulting in the highest possible total sum. The algorithm is compared with MATLAB's solver through computation time-the time taken to find the optimum selection of values, and the solution accuracy-the ratio of the sum of values achieved by the proposed algorithm, with the true maximum value. To evaluate the performance, 1000 repeats are taken using a 50 � 50 matrix filled with a random selection of numbers between 1 and 20 for input A. The accuracy and the average time (ms) to compute the solution with each algorithm is shown in Table 1.
The proposed algorithm solves the problem on average 93.5% faster than MATLAB's intlinprog solver, whilst maintaining an average accuracy of 99.4%. For reference, an average accuracy of 100% would mean that the proposed algorithm reaches the exact same solution as MATLAB's solver on every repeat. As it is assumed that MATLAB's solver provides the optimum solution, it is not possible to exceed an accuracy of 100%. Because of the success of this algorithm in reducing computation time without sacrificing result, this algorithm is used in the CEM mechanism to compute the optimal matching of buyers and sellers.

| One-to-one matching versus many-tomany matching
A one-to-one auction matching mechanism is proposed, where each buyer is only able to match with a single seller and vice versa. One-to-one matching has been chosen as the most suitable auction type in our scenario for the following reasons. First, such a system can be easily implemented with existing hardware and technology, and is less computationally complex than a many-to-many matching system, making it more appropriate for use within the low-powered hardware as may be used in an EV charging point. Secondly, it enables the household's charge point and solar panels to be isolated from the grid, enabling EV charging and use of DERs without concerns around transformer load and line voltage deviation issues. Thirdly, EV energy requirements are high in comparison with the energy generated from domestic PV panels. A single household is unlikely to have sufficient surplus solar energy to charge multiple EVs and most households only have a single charge point, so trading amongst multiple households and EVs is not greatly beneficial in the scenario considered here. By enforcing one-to-one matching, the auction mechanism must determine which household should charge each EV to ensure best consumption of household solar energy and EVs achieving the greatest percentage of their required energy, without any information about future demand. Alternatively, many current studies consider many-to-many matching, where each household can charge multiple EVs, and each EV can purchase energy from multiple households [7,13,21,27]. In certain scenarios, such a system could result in greater utilisation of renewable energy, or cheaper prices for consumers. Although this is beyond the scope of this study, it is possible to adapt the MARMES algorithm presented in the previous section to conduct many-to-many matching auctions. The auction can be conducted in two rounds, with the first round using MARMES and CEM to match each EV with a household where the EV can park and charge. The second round would be an energy-only round where, if an EV is unable to fulfil its charging requirements from the household that it has been matched with in the first round, it can make an energy bid to other households for its energy shortfall. If a household has additional surplus energy not already promised to a charging EV, they can submit an energy ask to sell this energy to another EV through the grid. This requires another round of communication to the auction and is therefore more computationally complex, but could result in more EVs achieving a full charge and households selling more of their surplus solar energy. However, if a household that is not charging an EV opts to sell energy in the second round, it could reduce the chance of that household winning a more profitable future first-round auction, as it has already committed some of its energy. A comparison between the two auction types is beyond the scope of this work.

| Case study
The case study centres around the simulation of a 24-h period, beginning and ending at midnight, using the parameters in Table 2. Eighty EVs randomly arrive between 6 AM and 2 PM and will make a request for the energy they require to fully recharge, a randomly selected value between 3 and 30 kWh. The EV will also announce its planned departure time, which will be no sooner than the earliest time that the EV could receive all of its required energy at the standard home charging rate of 7.2 kW. There are eighty households equipped with EV charging points and rooftop solar PV panels ranging between 5 and 20 kWp capacity. Households can sell their surplus solar energy (the difference between generation and the household's baseload consumption) to visiting EV drivers who require charging. The EVs can park at the household and use their charging point to recharge with the surplus solar energy. The information about EV arrivals/departures and energy needs are considered 'online' information, and are therefore not known ahead of their arrival.
If there are EVs that need to charge, prior to the auction each EV will each submit a bid consisting of their energy requirement, departure time and bid price. If a household is not currently charging an EV and has surplus solar energy available to trade, they can broadcast their available surplus energy profile for the day with an ask price they want to receive for their energy. It is assumed that a household can predict its solar energy generation and baseload consumption on a daily basis, but the procedure for this prediction is beyond the scope of this study. The amount of energy that a household has available for trading is the minimum of either the available surplus solar energy, or the amount of energy that can be charged at a rate of 7.2 kW (maximum EV charger rate).
The energy trading auction takes place every 15 min using the EV bids and household asks that have been submitted in the prior quarter hour. The auction mechanism under study is used to match the bids and asks to determine which EVs and households trade, and therefore where the EVs will go to park and charge. Once a household and EV have matched, the household will feed its surplus solar energy generated by its PV panels directly to its EV charge point, allowing the visiting EV to charge. Whilst the EV is parked at the household, the household is unable to partake in any further trades as its charging point is occupied.
It is assumed that EVs will account for the charging efficiency during the trade-for instance if they require 18 kWh to fully recharge and the charging efficiency is 90%, then the EV will request 20 kWh.
As there is significant inherent variation in the selection of the random parameters, the simulation is repeated 1000 times for each of the five auction mechanisms studied here. This ensures accuracy and reliability in the results and enables comparisons between the five mechanisms to be made unaffected by the randomness of the simulation parameters.
The described case study is shown schematically in Figure 2. It displays the process of households submitting asks containing their surplus solar energy profile and EVs submitting their bid prices and energy requirements to the auction system, and the outcome of the matching algorithm confirming which household and EVs are matched.

| Results
In an EV charging scenario, the amount of charge received by the EVs is of primary importance, as it is necessary to ensure that EVs receive sufficient charge to meet their energy needs for subsequent journeys. Increasing the amount of charge EVs receive from the solar energy can reduce the cost to the buyer, increase seller profits, assist with decarbonisation objectives and reduce the load on the grid, enabling a higher penetration of EVs to charge. It also enables communities to become more self-reliant, as is necessary in the case of islanded microgrids, by reducing the amount of additional energy that must be imported. Increasing the consumption of the solar energy is an incentive for further investment in new renewable energy sources and expands capacity for further DER integration and decarbonisation in the grid. However, it should be acknowledged that given the relative size of EV batteries to domestic PV installations, there is unlikely to be sufficient surplus energy produced by a single household to fully meet the needs of an EV. Therefore, it is important that the auction matching mechanism can make optimal usage of the available solar energy to ensure that EVs are allocated to charge in the most efficient way. Figure 3 shows the distribution of the percentage of the EV's requested charge that has been fulfilled from solar energy by their departure, for all five auction mechanisms. Each bar in a group of 6 represents a range of EV state of charge (SoC) at departure, and the height of the bar signifies the percentage of EVs that depart with SoC in that range. SoC is defined in (21): Table 3 displays the average charge achieved by EVs with each mechanism and the final three columns display the percentage of EVs departing with SoC specified by the three criteria. The percentage of EVs departing with less than 20% of requested charge is low for all five mechanisms (max 0.4% -Mechanism 2). The mechanisms based on the standard double auction mechanism (1 and 2) result in lower SoCs than are achieved through other mechanisms: 15.2% of EVs depart with 50% or less of their requested energy with Mechanism 1, whereas Mechanisms 3-5 see a significant improvement, with 7.5% of EVs departing with 50% or less with Mechanism 3, and just 3.7% with CEM (Mechanism 5). Mechanisms 3 and 4 both perform similarly; however, there are clear improvements with the proposed CEM mechanism. There is a 16% improvement in the number of EVs that depart with full charge compared with Mechanisms 2-4, with all other departure charge ranges seeing a decrease in the percentage of EVs departing with that range of charge. Only 13.4% of EVs depart with less than 90% of their requested charge, compared with over 20% of EVs using any of the other four mechanisms. The CEM mechanism also results in the highest average charge at departure, with EVs departing with on average 94.8% of their requested energy, with Mechanism 4 achieving the next highest average charge of 91.4%. Figure 4 quantifies the amount of grid energy that is required to fully charge all EVs in each mechanism. Despite there only being a 3% difference between the mean charge from solar energy of Mechanisms 3-5, this equates to a 36% reduction in required grid energy between Mechanisms 4 and 5, and a 71.4% reduction in grid energy between Mechanism 1 and the CEM mechanism. This means that the proposed CEM mechanism can reduce the load on the grid by over onethird, essential to increasing the penetration of EVs within existing grid limits. Because Mechanism 5 is designed to prioritise the charge received over cost benefit, it does result in higher trade prices ( Figure 5), and therefore lower buyer/seller cost benefit.
A higher trade price would appear to be more advantageous to sellers as selling surplus energy at a higher price will increase their profit, but would be detrimental to buyers as it means that they pay more per kWh than under a different mechanism. However, if it is assumed that the buyers would purchase the additional energy they require to ensure full EV charge by departure at grid prices, then the total cost incurred to buyers is not just the cost of buying the surplus solar energy from the household but also the additional cost of the grid energy. Figure 6 shows the average cost per buyer and average profit per seller for each of the auction mechanisms. Mechanisms 3-5 result in a very similar average cost per buyer, with the CEM mechanism resulting in just 0.6% lower costs than Mechanism 3, and is only 7.9 pence (4.3%) cheaper than the most expensive mechanism (Mechanism 1). Despite the highest trade price, Mechanism 5 results in the lowest cost per buyer because of the significant reduction in required grid energy. Similarly, Mechanism 1 provides the lowest trade price, and greatest cost benefit, but results in higher costs to buyers and lower seller profits because of the lower solar energy consumption and subsequent increase in grid energy. Mechanisms 3 and 4 are a clear improvement over the first two mechanisms for seller profit, both averaging around 21 pence greater profit than Mechanism 1. Again, the CEM mechanism provides the greatest profit for sellers, with a 31.6 pence (24.4%) improvement over Mechanism 1, and a 10.2 pence improvement over Mechanisms 3 and 4. THOMAS ET AL. -455 The average buyer cost and seller profit using CEM (Mechanism 5) are compared with a household that does not partake in P2P trading in Table 4. Instead of selling energy to other EVs, the household instead sells all produced solar energy to the grid at SEG price, and the EV must purchase all required energy at grid price. To make this a fair comparison, the household partaking in P2P trading is also able to sell its un-traded solar energy to the grid at SEG price, resulting in a seller profit greater than displayed in Figure 6.
As the trade price is much lower than the standard grid electricity rate, the cost to a buyer using P2P trading with the CEM mechanism is around 24% lower on average than if purchasing energy directly from the grid. In addition, the price received through exporting energy to the grid through the SEG is significantly lower than can be obtained through P2P trading, with sellers able to achieve a 132% increase in income if using the CEM mechanism and P2P trading. To ensure fairness amongst sellers, the number of sellers selected by the F I G U R E 2 Schematic representation of the case study F I G U R E 3 Grid energy required at each repeat to satisfy all electric vehicle charging requests 456mechanism to trade must also be considered. Despite the fact that there are the same number of sellers as buyers, and every buyer is receiving charge, it is possible for a single seller to sell to more than one buyer during the day, if the first buyer arrives and departs early. As a result, not every seller is guaranteed to sell energy through the auction. Mechanism 1 results in the highest percentage of sellers trading, with a median value of 73 sellers, Mechanisms 2 and 5 have almost identical results with a median of 71 sellers, and Mechanisms 3 and 4 are similar, with a median of 70 sellers trading. The differences between these results are too small for a conclusion that the choice of mechanism significantly affects the likelihood of a seller trading. Figure 7 shows the results of a sensitivity analysis exploring the impact of incorrect solar prediction and a varying ratio of EVs to households on the mean solar energy charge (mean SoC) of EVs. Whereas the previous results have used equal numbers of EVs and households, this figure shows how varying the ratio of the number of EVs to households from 1:4 (20 EVs, 80 households) to 4:1 (80 EVs, 20 households) affects the mean SoC at departure. In addition, the percentage error in solar energy prediction is also varied to evaluate the robustness of the CEM mechanism and its reliance on accurate solar predictions. The solar energy is predicted by the households and this prediction is used in the auction matching, however, the actual solar energy that can be sold to the EV is varied between 20% greater (+20%) and 20% lower (−20%) than the prediction. Under-predicting solar energy (percentage error +5%-+20%) results in a very slight increase in the mean departure charge (0.8%-4%); as although the additional solar energy theoretically enables the EVs to depart with greater charge, the charge they can receive is limited by the availability of households with sufficient energy to meet every EV's requirement. If the solar energy is over-predicted by the household, and the actual solar energy that is traded is less than declared by the household during the auction process (percentage error: −5% to −20%), there is a greater decrease in average charge. Over-predicting solar energy by 20% results in a decrease in SoC of between 8% and 9% compared with accurate solar predictions. This is not a huge decrease however, and shows the CEM auction mechanism to be fairly robust against deviations between predicted and actual solar energy production. Decreasing the ratio of EVs to households also results in slight increases in mean SoC as there are more options for each EV, however, similarly to -457 under-prediction of solar energy, there is a limit to the increase in mean SoC as there are inevitably EVs with energy requirements greater than can be fulfilled by household solar energy. Increasing the number of EVs relative to the number of households shows a more significant drop in the mean SoC. A ratio of four EVs to three households still F I G U R E 5 Average trade price agreed under each mechanism F I G U R E 6 Average cost per buyer to fully charge EV, and average profit per seller with each auction mechanism 458results in a relatively high SoC (89.2% compared with 94.8%), likely because there will be enough EVs departing fully charged early enough in the day to enable another EV to charge at the same household after it leaves. However, with double the number of EVs as households or above, there is a significant reduction in the mean charge as there are increasing numbers of EVs that are unable to trade with any household as the demand greatly exceeds supply, and depart with a SoC of 0%. For the above results, the value of w in Mechanism 5 was chosen to be w = 5. A value of 5 was found to maximise the amount of EV charge received from solar energy, which is the purpose of this study. Decreasing the value of w results in a lower trade price, thus a higher buyer/seller benefit, but at the expense of reduced EV charging. As additional grid energy is required in this instance, there is no financial benefit to the buyer despite a lower trade price. Increasing the value of w beyond 5 offers no additional benefits.

| CONCLUSION
Herein, five different auction mechanisms are presented and compared for matching buyers and sellers in a P2P energy double auction. The specific scenario considered was where households were able to utilise their vacant EV charge points during the day to sell surplus solar energy produced by the household's PV panels to the visiting EV owners. It is in the interests of the EV owners to receive as much energy from the surplus solar energy sold as possible and reduce their costs to charge, and it is in the interests of the sellers to sell as much surplus solar energy as they can, and to receive the maximum amount of income. To help solve the integer linear programming problem in the optimisation stage of the auction mechanisms, a novel algorithm 'MARMES' is proposed. MARMES is benchmarked against MATLAB's 'intlinprog' solver, and demonstrates an equivalent level of accuracy, but with much faster computation time, making it more suitable for use in a real-world auction application. The proposed CEM algorithm (Mechanism 5) can be seen to offer the best performance of all the auction mechanisms considered. It increases the percentage of EV charging from solar energy by considering not only current EV charge requests but also potential future demand, benefiting both buyers and sellers. It therefore reduces the amount of grid energy required, facilitating higher EV F I G U R E 7 Sensitivity analysis showing the effect of incorrect solar energy prediction and varying the ratio of EVs to households on the average solar charge gained by EVs

Trade w/Grid Mechanism 5 % Improvement
Avg. cost per buyer 233 p 177 p 24.0% Avg. seller profit 101.9 p 237 p 132.6% THOMAS ET AL.