Investigation of Electric Vehicles Contributions in an Optimized Peer-to-Peer Energy Trading System

The rapid increase in integration of Electric Vehicles (EVs) and Renewable Energy Sources (RESs) at the consumption level poses many challenges for network operators. Recently, Peer-to-Peer (P2P) energy trading has been considered as an effective approach for managing RESs, EVs, and providing market solutions. This paper investigates the effect of EVs and shiftable loads on P2P energy trading with enhanced Vehicle to Home (V2H) mode, and proposes an optimized Energy Management Systems aimed to reduce the net energy exchange with the grid. Mixed-integer linear programming (MILP) is used to find optimal energy scheduling for smart houses in a community. Results show that the V2H mode reduces the overall energy costs of each prosumer by up to 23% compared to operating without V2H mode (i.e., EVs act as a load only). It also reduces the overall energy costs of the community by 15% compared to the houses operating without the V2H mode. Moreover, it reduces the absolute net energy exchanged between the community and the grid by 3%, which enhances the energy independence of the community.

INDEX TERMS Electric vehicle, energy management system, local consumption, mixed-integer linear programming, peer-to-peer energy trading.

NOMENCLATURE n
The n th house.

N Houses
Number of houses in the community. Pair no.
Number of available pair.  VOLUME 11, 2023 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ P EV n (t) EV battery discharge/charge power (kW). P EV −rating n Maximum EV battery discharge/ charge power (kW). P EV −disch n (t) EV battery discharge power (kW). P EV −charg n (t) EV battery charge power (kW). B EV −capacity n (t) Estimated EV battery capacity (kWh). N EVcycle n EV battery life cycle. E EV n (t) EV energy at time t(kWh). E EV n (t-1) EV energy at time t-1 (kWh). I EV n (t) EV battery charge/discharge current (A). P PV −1 n (t) Forecasted PV generation for day-1 (kW). P L−1 n (t) Forecasted load demand for day-1 (kW). P PV −2 n (t) Forecasted PV generation for day-2 (kW). P L−2 n (t) Forecasted load demand for day-2 (kW). E Day−f n The sum of mid-peak and peak times energy forecast of day-2 (kWh). P G n (t) Power exchange between the house and the grid (kW). P Gmax−export n Maximum allowed exported power to the grid (kW). P Gmax−import n Maximum allowed imported power from the grid (kW). P G−export n (t) Exported power to the grid (kW). P G−import n (t) Imported power from the grid (kW). export n (t) Binary variable to indicate the house is exporting energy to the grid. import n (t) Binary variable to indicate the house is importing energy from the grid.     Price of exported energy to the grid (£/kWh). f sell (t) Tariff for selling energy to the grid (£/kWh). f buy (t) Tariff for buying energy from the grid (£/kWh). C house n Optimization cost function for the individual house (£).

C sum−P2P
Optimization cost function for the paired houses (£). C P2P n Cost of energy exchanged between the paired houses (£). f P2P−exp n (t) Export exchange tariff between the paired houses (£/kWh). f P2P−imp n (t) Import exchange tariff between the paired houses (£/kWh). P P2P x↔y (t) The power exchanged between the paired houses (kW). P P2 P,max n (t) Maximum power exchanged between the houses (kW).

I. INTRODUCTION
The demand for integration of Renewable Energy Sources (RESs) into micro/nano-grids (MGs/NGs) is increasing worldwide in order to reduce energy costs and carbon emissions [1], [2]. A similar trend is affecting Electric Vehicles (EVs), with governments encouraging EV use to achieve net-zero emission goals [3]. The integration of RESs is creating some challenges for network operators, including over-generation [4], [5]. For example, in 2019, Germany's electricity network could not cope with the excess energy generated from RESs, resulting in paying neighboring countries to consume the excess energy [6], a solution that may not exist in near future as the other countries are also increasingly integrating more renewables. The use of EVs could exacerbate the situation because EV charging/discharging activities can significantly increase generation demand, overloading transmission lines, and even damaging local distribution transformers [7], [8]. However, it is potentially possible to exploit EVs to mitigate some of these challenges. For example, EV batteries can be used to support grid frequency and voltage regulation [9], [10], [11], [12], [13] by enabling the Vehicle to Grid (V2G) mode as in Project Sciurus, a commercial V2G project commenced in the UK in 2018 [14]. In addition, EV batteries can also be used to reduce household energy costs [15], reduce peak load [16], supply a home during outages [17], and increase household self-consumption by enabling the Vehicle to Home (V2H) mode [8], [18]. Thus, to reduce the burden of developing new infrastructure, the self/local-consumption approach is encouraged by several countries, including the UK [19], [20]. One way to enhance self/local-consumption is to reduce the net energy exchange with the grid by utilizing the Demand Response (DR) program in the Energy Management System (EMS) by considering shiftable appliances, RES generation, Battery Storage Systems (BSSs), and EV charge/discharge cycles. The authors in [21] proposed a Mixed Integer Linear Programming (MILP)-based Home Energy Management System (HEMS) to determine optimal scheduling of shiftable appliances, EV, and the BSS. The main target is to compensate for reactive power while simultaneously reducing household energy costs by enabling both V2H and Home-to-Grid (H2G) modes. However, the authors in [21], to encourage exporting, assumed that energy purchased from the grid is cheaper than energy sold to the grid, which is not the case for many countries, such as the UK network. The authors in [18] proposed a rule-based EMS to control power flow in a MG, with the main target of reducing energy costs by using EVs as additional energy sources. Similarly, a rule-based HEMS to reduce energy costs by facilitating the V2H mode is proposed in [22]. The authors in [23]enabled both V2H and V2G modes in a MILP-based HEMS to limit peak power. Moreover, an EV charging/ discharging controller is proposed in [24]to reduce the peak demand. However, the authors in [18], [21], [22], [23], [24] do not consider the lifetimes of EV batteries and BSSs in their EMS decision-making processes. To overcome this shortcoming, further research investigated the maintenance cost of the EV battery and BSS in a MILP-based HEMS, aimed to reduce the overall operating costs [25]. Similarly, the authors in [20] and [26] included the degradation cost of the BSS in a MILP-based EMS. An alternative solution is proposed in [19] to use the battery charge/discharge cycles as an indication of the battery's state of health.
A HEMS to control EV charging time to reduce electricity bill and peak demand is proposed in [27]. However, their work considered the EVs as loads only. The authors in [7] investigated the effect of EV charge/discharge activities on three houses individually without considering RESs or BSSs, with the target of reducing the load on the local distribution transformer and minimizing operating costs by enabling the V2H mode. However, their system does not exchange excess energy between the three houses.
As Peer-to-Peer (P2P) trading gains popularity, prosumers can freely trade excess energy with neighbors to reduce their energy costs and the burden on the grid [28]. Several research platforms for P2P energy trading are currently operating worldwide, including; the Piclo project in the UK [29], SOLshare in Bangladesh [30], and the blockchain-based Enerchain Project in Europe [31].
P2P energy trading has the additional advantage that it can be controlled in a centralized and decentralized manner [32]. For example, it has been proposed that a central controller be used to select the optimal paired combination based on minimum distance and energy losses [33]. The main target is to reduce the peak load by supplying the excess energy from EV, BSS, and PV to a neighbor. However, the proposed system does not consider the degradation cost of either the EV batteries or BSSs. The authors in [34] proposed a decentralized P2P algorithm to share the excess energy between smart buildings to maximize social welfare. However, their work does not include the use of EV batteries to supply buildings; it considers EVs only as flexible loads. Similarly, authors in [32] proposed a P2P energy trading based on a bidding strategy to compensate at the community level for the uncertainties associated with PV generation. However, EVs are considered only as loads. In [28] the effect of P2P VOLUME 11, 2023 EMS on the use of unidirectional EV chargers (G2V) and bidirectional chargers that can discharge an EV battery to supply a home (V2H) and/or grid (V2G) are investigated. However, a significant limitation was that the use of the EV does not change with time of year. P2P energy trading between buildings and the EVs in the associated charging stations has been proposed in [35], but the system limited the SOC of the EVs' batteries to between 30%-85% to extend their lifetime. Although this simple approach may maintain battery health for a longer period, however, it does not make the best use of the batteries.
One advantage of a centralized structure is that conflicts during system operation are minimized because optimal control settings are determined at the decision-making level. However, to avoid system failure, a decentralized structure is preferred in some studies [36]. However, the decentralized structure may not guarantee finding the optimal solution for a whole community. As a compromise, this study proposes a hybrid structure using two levels of HEMS and a central controller to avoid an entire system failure.
Most recent works on P2P energy trading have focused on minimizing operating costs. This paper proposes a new approach that minimizes energy exchange between the community and the grid through P2P energy trading with V2H mode and shiftable loads. Additionally, this paper introduces the use of the two days-ahead energy forecast to reduce the energy exchange with the grid by storing the next day energy forecast. It worth to mention that the proposed system could be used in a more complex management strategy in the form of peer to system to peer trading architecture [37].
The main contributions of this work are: • Proposing a P2P EMS that: • Exploits the two days-ahead forecasts in a MILP-based optimization process that minimizes the net energy exchange between the community and the grid. This enhances the energy independence of the community, which in return reduces: ■ transmission/distribution losses (since the exchanged energy is reduced), and ■ the requirements for central generation/storage, transmission, and distribution capacity.
• Utilizes the V2H mode to use EVs as alternative energy storage, considering the uncertainty associated with the availability of EVs. The result is a reduction of system energy storage requirements and a higher local consumption (i.e., within the community) of PV generated energy.
• Considers the lifetime of the BSS and EV batteries by including their degradation costs in the optimization problem.
• Utilizes shiftable appliances to move peak load to off-peak/mid-peak times or to a time when PV generation provides a surplus, which reduces the peak load and net energy exchanged between the community and the grid.
The rest of the paper is organized as follows. Section II details the methodology of the work. Sections III and IV present the HEMS mathematical formulation and Central Controller, respectively. Section V describes the case study. Section VI presents the results and discussion. Finally, section VII concludes the work.

II. METHODOLOGY
The proposed EMS in our previous work in [36] is developed further by including EVs and shiftable appliances to the system. Fig. 1 presents the system configuration of the residential community. It should be noted that the proposed strategy is applicable to any residential community regardless of the number of houses. For the sake of simplicity, this study includes six houses. The EMS approach is divided into three stages as shown in Fig. 2: 1-Data collection: the inputs for the HEMS and P2P EMS are: A) Data from the household: initial SOC of the BSS (SOC B n ) and EV (SOC EV n ), travel distance (T D n ), EV arrival time (EV A n ), EV departure time (EV D n ), desired SOC of the EV for the second trip (SOC EVdesired n ), appliance start time (T start n (i)), appliance maximum waiting time (T wait n (i)), where n and i are referred to the house number and the appliance. If i is equal 1 it is the washing machine and if i is equal 2 it is the dishwasher. B) Two days-ahead forecasted data are assumed to be provided from the forecaster (i.e., forecast company): day-1 PV generation (P PV −1 n ), day-1 load demand (P L−1 n ), day-2 PV generation (P PV −2 n ), and day-2 load demand (P L−2 n ) of each house within the community. 2-Home Energy Management System: HEMS is launched at each house to minimize the daily energy exchanged with the grid while reducing the energy cost by scheduling BSS, EV battery, and shiftable appliances. The optimal setting for BSS is achieved by considering the sum of peak and mid-peak energy forecast of day − 2 (E Day−f n ) as in (1): After finding the optimal system settings the energy costs and parameters of each house are uploaded into the Central Controller to carry out the P2P EMS optimization. 3-Central Controller: this level consists of two stages: A) P2P EMS where all possible pairs of the 6 houses are created. The number of house pairs (Pair no. ) for 6 houses is 15 and calculated as: where N houses is the number of houses in the community.
B) Selection level where the pairs are selected based on cost reduction percentage of each house. After the optimal settings are attained from the selected house pairs, the reference values are delivered to each house.

III. HEMS MATHMATICAL FORMULATION
The problem is formulated as MILP to find the optimal settings for each house in the community as a stand-alone system. The main target of the cost function of the HEMS (C house n ) in (3) is to minimize the net energy exchanged with the grid by including the absoluteenergy costs of the energy imported from and exported to the grid. In addition, the BSS and EV battery degradation costs are considered. It is worth mentioning that the EV battery degradation cost is considered only when the EV is on V2H mode, i.e., when the EV battery discharges to supply a house.
where n refers to the house number (here, total number of houses is 6). C buy n and C sell n represent the cost of the energy imported from and exported to the grid (£), respectively. C BSS n and C EV n represent the degradation cost of the BSS and EV battery (£), respectively. The time of day starting at 12 AM is t 0 , T is the day duration of 24 hours, T (hr) is the sampling time, f buy (t) is the tariff for the energy imported from the grid (£/kWh), f sell (t) is the tariff for energy exported to the grid (£/kWh), and P G n (t) is the grid power (kW). CC B n represents the cost of a new BSS (£), B capacity n (t) is estimated BSS capacity, N Bcycle n is the number of BSS life cycles, η conv n is BSS converter efficiency (%), P B−disch n is the BSS discharge power (kW), P B−charg n is the BSS charge power (kW), η d n is the discharging efficiency of the BSS (%), and η c n is the charging efficiency of the BSS (%), B EV −capacity n (t) is the estimated EV battery capacity,CC EV n is the cost of a new EV battery (£), N EVcycle n is the number of EV battery life cycles,η EV n is the EV converter efficiency (%), η EVd n is the discharging efficiency of the EV battery (%), and P EV −disch n is the EV discharge power (kW). Note that P G n (t) is positive when the house (n) is importing from the grid and is negative when it is exporting to the grid. P B−disch n has a positive value and P B−charg n has a negative value. The power balance equation of the system is represented by (8): where P EV n (t), P B n (t), and P L−sh n (i, t) represent the EV charge/discharge power, BSS charge/discharge power and the power required for the shiftable appliance of i at time t (kW), respectively. It is worth noting that the P EV n (t) is equal to zero when the EV is not connected.

A. DEMAND-SIDE MANAGEMENT
Residential load scheduling encourages consumers/ prosumers to change their daily consumption by considering several factors such as the price of electricity, and the level of available local generation and storage. This study considers two types of home loads: shiftable appliances, and fixed appliances. The shiftable appliances such as washing machines and dishwashers, can be time-shifted to the off-peak/ mid-peak times or when the PV energy is surplus to reduce energy cost and make the best use of PV energy. On other hand, the fixed appliances such as TV, refrigerator and lights cannot be scheduled. The following steps are taken to schedule the shiftable appliances: • HEMS receives the ON state from appliance i. • Then HEMS schedules the start time of the appliance.
• The appliance waits till it receives the turn ON state.
• Once it starts, it will stop when it finishes its cycle. In this study the maximum waiting time varies between 1 to 8 hours based on householder preference to ensure a high user comfort level. Zero waiting time indicates that the appliance i must operate immediately once it is switched ON.
Constraint (9) is used to ensure that the appliance i does not exceed the waiting time [26]: where T wait n (i) is the maximum time that appliance (i) can wait (hr). T start n (i) is the time when EMS receives an ON state for appliance i (hr). L n (i,t) is a binary variable that indicates the operation status of a shiftable appliance. L n (i,t) equals 1 if the appliance is ON otherwise, it equals 0. Constraints (10) is introduced to starting up the appliance i [26].
where startup n (i,t) is a binary variable that indicates the starting up of an appliance. startup n (i,t) equals 1 when the status of an appliance has changed from OFF to ON and equals 0 otherwise.
To keep the appliance i in continuous operation without sudden interruption (i.e., switch OFF), constraint (11) is introduced [26]: where T cycle n (i) is the operation time needed for the appliance i (hr), T end n (i) is the finishing time of the appliance operation. To ensure that the appliance is started only when it is requested and switches OFF after completing its operation cycle, L n (i,t) is set to 0 before the HEMS receives the start signal and after the operation cycle has been completed [26].
The power required for the shiftable appliance i in any period is represented by (13) [26].
where P rate−L n (i) is the rated power of the appliance i (kW).

B. EV BATTERY MODEL
At the beginning of each day, the EV user leaves its house with a fully-charged battery on its first trip using (14): where SOC EV −max n and EV D n are the maximum SOC limit of the EV battery and the EV departure time (hr), respectively.
For simulation purposes, when the EV returns and is plugged at home, a new SOC EV n (t=EV A n ) is determined based on the energy consumed during the journey assuming no charging occurred during the journey using (15) [7]. Otherwise, exact information of the battery charge is determined once it is plugged into home charging/discharging control unit. The estimated energy reduced during the journey (E reduce n ) represented by (16).
The battery degradation is taking into consideration using (17) to estimate the current capacity of EV battery.
where EV A n is the EV arrival time (hr), B EV −capacity n is the estimated EV battery capacity, E cons n is energy consumption per km (kWh/km), and T D n is the travel distance (km), I EV n (t) is the battery charge/discharge current (A), SOC EV n (t α ) is the battery SOC at time t α (%), and SOC EV n (t β ) is the battery SOC at time t β (%).
For the second trip at same day, the user estimates the needed minimum charge before conducting the trip (SOC EV − desired n ). Constraint (18) is used to ensure that the EV battery is maintained the required energy before departure.

SOC EV
Equations (19) and (20) are used to estimate the stored energy and SOC of the EV battery, respectively.
where E EV n (t) is EV energy at time t, and E EV n (t-1) is the EV energy at time t-1, η EVc n is the charging efficiency of the EV (%), and P EV −charg n is the EV charge power (kW).
Constraint (21) is used to ensure that the SOC of the EV battery does not exceed its allowable limits: where SOC EV −min n is the minimum SOC limit of the EV battery.
The EV instantaneous power and its limits are represented in (22) and (23), respectively.
where P EV −rating n is the rated charge/discharge power of the EV battery (kW).

C. BSS MODEL
Constraint (24) is used for mid-peak and peak times,to allow the BSS to discharge to its minimum limit if needed to reduce the energy purchased from the grid at a higher tariff.
where SOC B−max n and SOC B−min n are the maximum and the minimum SOC limits of BSS, respectively.
Constraint (25) is used for off-peak times, to ensure that the energy required for the next day is stored in the BSS (i.e., E Day−f n ).
Equations (26)-(28) are used to estimate the current capacity, stored energy, and SOC of the BSS, respectively.
where E B n (t) is energy stored in the BSS at time t(kWh), E B n (t-1) is the energy in the BSS at time t-1, B capacity n (t) is estimated BSS capacity, and I B n (t) is the BSS charge/discharge current (A).
Equations (29) and (30) represent the BSS power and the power limits, respectively.
where P B−rating n is the rated charge/discharge power of the BSS.

D. SYSTEM CONSTRAINTS
Four binary variables are created for EV and house batteries which are EV −disch n , EV −charg n , B−disch n , and B−charg n to represent their discharge and charge modes. In addition, another two binary variables are created, namely import n and export n , to represent grid power. To ensure that the BSS is not in charged and discharged mode at the same instant, constraint (31) is used.
Similarly, to ensure that the EV battery is not in charged and discharged mode at the same instant, constraint (32) is used.
where B−disch n (t)/ EV −disch n (t) is equal to 1 when the BSS/ EV battery is discharging, otherwise, are equal to 0. The Constraints (33) and (34) are used to avoid charging the BSS and EV battery from each other.
Constraints (35)- (38) are used to ensure BSS and EV battery are charged/discharged within allowable limits.
where import n (t) is equal to 1 when the system imports power from the grid, otherwise, equals 0. export n (t) is equal to 1 when the system exports power to the grid, otherwise, equals 0.
Constraints (40)-(42) that limit the grid power to its permitted maximum, if in place.
where the P G−export n (t) and P G−import n (t) are exported and imported power to and from the grid, respectively. P Gmax−export n (t) and P Gmax−import n (t) values are set to infinity unless specified.
To ensure that the BSS and EV battery do not export energy to the grid constraints (43) and (44), respectively, are used.  • All parameters are entered to the HEMS to minimize the cost function of (3), which are subjected to (4)-(8).
• Then the system will check if the appliances are turned on, if yes constraints (9)-(13) must be satisfied. • Next the system will check if the EV is connected, if yes constraints (14)-(23) must be satisfied.
• Then the system will check if the battery has sufficient energy for next peak hours, during the off-peak time by satisfying constraint (25), else (24) must be satisfied. Then, constraints (26)-(30) must be satisfied for all times.
• Finally, after satisfying system constraints (31)-(44) the output parameters for the house are uploaded into the Central Controller.

IV. CENTRAL CONTROLLER
The P2P EMS and selection of house pairs take place in the Central Controller.

A. P2P PROPLEM FORMULATION
The cost function for paired houses x and y is represented in (45). The exchange tariff between the paired houses is represented in (46): where n refers to houses x and y, C P2P n is the cost of the energy transferred between the paired houses per day. f P2P−exp n (t) and f P2P−imp n (t) are the export and import tariffs between the paired houses (£/kWh), respectively. P P2P x↔y (t) is the power transferred between houses x and y (kW). Note that P P2P x↔y is negative and positive when the house n is importing from and exporting to the neighbor, respectively.
The system balance equations for houses x and y and when they are paired are: For house x: For house y: For houses x and y: n=x ,y P G n (t) + P B n (t) + P EV n (t) The equations presented in section III-A are used here for the appliances in houses x and y.

C. BSS AND EV BATTERY MODELS
The equations presented in sections III-B and III-C are used here for the EV battery and BSS battery of house x and y.

D. SYSTEM CONSTRAINTS
In addition to the constraints in section III-D, the following constraints are defined: Constraint (50) is used to ensure that the power flow between the houses x and y flows in only one direction at a time: where export n (t) equals 1 if house n is exporting energy to its neighbor and equals 0 otherwise. The binary variable import n (t) is equal to 1 if, the house n is importing energy to from neighbor and equals 0 otherwise.
The binary variables and power exchanged between houses are linked using (51) and (52): x ↔ y (t) ≤ export n (t) × P P2P−max n (t) (51) where P P2P−max n (t) is the maximum limit of the power exchanged between the houses x and y, this value is infinity unless otherwise specified. Despite the P P2P−max n (t) is relaxed to infinity, the exchange limit peers can be restricted according to the specific constituency's requirements/ standards, which are still undefined.
Constraint (53) is used to avoid importing power from the grid whilst simultaneously exporting power to the paired house [1]: where import n (t) is 1 if house n is importing power from the grid otherwise, it is equal to 0. Constraint (54) is used to avoid exporting power to the grid whilst simultaneously importing power from the paired house [1]: To ensure that P2P operational cost for houses x and y is lower than when the house operates individually, constraints (55)-(57) are used: where C house−cost individual(n) is the operational cost for houses x and y when they are operating individually and C house−cost P2P(n) is the operational cost for houses x and y when they are operating as a pair. Figure. 4 presents the flowchart illustrating the above constraints for P2P EMS and follows the steps below: • All parameters are entered to the P2P EMS along with energy costs of the house being operating individually from HEMS to minimize the cost function of (45), subject to (4)- (7) and (46)- (49).
• Then the system will check if the appliances are turned on, if yes constraints (9)-(13) must be satisfied. • Next the system will check if the EV is connected, if yes constraints (14)-(23) must be satisfied.
• Then the system will check if the battery has sufficient energy for the next peak hours, during off-peak time by satisfying constraint (25), else (24) must be satisfied. Then, constraints (26)-(30) must be satisfied for all times.
• Finally, after satisfying the system level constrains of (31)- (44) and (50)-(57), the output parameters are uploaded into the Selection level. Figure. 5 presents the flowchart which shows the process whereby the pairs of houses are selected from the P2P results, which can be explained as follows:  (1) Obtain the operating costs for each house individually from HEMS. Delete all other entries, for these and the other houses, to avoid unwanted repetitions. (5) Repeat step (4) until optimal P2Ps have been found, then transmit the optimal settings to every house.

V. CASE STUDY
This study uses data for six houses located in London, UK as a case study for four months (June to September 2014), with a sample time ( T ) of 10 minutes [38]. Each house is equipped with a BSS of 4 kWh, a PV panel and home appliances (some of which are shiftable) connected to the grid, as shown in Fig. 1. The rated charge/discharge power (P B−rating n ) and the number of the life cycle (N Bcycle n ) of the BSS are 2.7 kW and 5,000, respectively [39]. The capital cost of the BSS is assumed to be £3,000 [40]. The maximum SOC (SOC B−max n ) and the minimum SOC (SOC B−min n ) limits of BSS are set to 98% and 20%, respectively [19]. The PV rating   [1]. and the total energy consumption for four months (June to September 2014) for each house are represented in Table 1. This study considered two shiftable appliances: washing machine and dishwasher. Table 2 represents the ratings for the shiftable appliances in each house. In addition, it is assumed that all houses use EV, and are equipped with a bidirectional charger to enhance the V2H mode. The charge/discharge efficiencies and the life cycle (N EVcycle n ) of all EV battery types are assumed to be 90% and 5,000, respectively [7]. The maximum SOC (SOC EV −max n ) and the minimum SOC (SOC EV −min n ) limits of the EV battery are set to 90% and 10%, respectively [41]. This study used two types of EVs which are Nissan Leaf and Tesla. The battery costs of Nissan Leaf and Tesla are equivalent to 110£/kWh and 100£/kWh, respectively [42]. Table 3 represents the EV parameters.
The forecasting methodology for PV and demand are outside the scope of this paper. Instead, a normally distributed random numbers are applied to the historical data to represent the forecasted data [20], [43]. The mean absolute percentage error of the forecasted energy is 30% over the four months. The probability distribution function of EV arrival

×100%
(58) , and (d-3) represent shiftable appliance scheduling of houses 1, 2, and 3, respectively. The dashed red and dashed blue represent the scheduled operation for the dishwasher P D n and the washing machine P W n , respectively. The solid red and solid blue lines represent the users' requested operation for the dishwasher P D−Sh n and the washing machine P W −Sh n , respectively. and departure times are obtained from National Household Travel Survey data [44].
This study uses the Time of Use (TOU) tariff, as shown in Table 4 [1]. The cost of selling energy to the grid is currently 3.79 p/kWh [45].The maximum export power from the house to the grid is limited to 3.68kW [46]. The cost of the energy exchanged between the paired prosumers is chosen as 4 p/kWh, which is higher than the sell tariff to the utility and lower than the purchase price from them to promote the local-consumption approach.

VI. RESULTS AND DISCUSSION
The proposed energy system is implemented in MATLAB software to investigate the effect of V2H mode and shiftable appliances on its performance.

A. SYSTEM BEHAVIOR
This subsection shows the effect of V2H mode on the system shown in Fig. 1 for 17 th and 18 th June 2014. Since it will take too much space to depict the results of all six houses, here houses no. 1, 2, and 3 are chosen to be discussed.
Figs. 6 (a-1), (a-2), and (a-3) represent the PV and demand for houses no. 1, 2 and 3, respectively. The red and black lines represent P PV n and P L n , respectively, where n refers to the house number. Figs. 6 (b-1), (b-2), and (b-3) represent the SOC of the EV battery, departure time, arrival time of the EV, and BSS of the houses no. 1, 2, and 3, respectively. The red and blue lines are SOC EV n andSOC B n , respectively. The first and second dashed black lines represent EV departure time EV D n and arrival time EV A n , respectively. Figs. 6 (c-1), (c-2), and (c-3) represent the power exchanged with the neighbors and the grid. The red and dashed blue lines represent P P2P n and P G n , respectively. Figs. 6 (d-1), (d-2), and (d-3) represent shiftable appliance scheduling of houses no. 1, 2, and 3, respectively. The dashed red and dashed blue represent the scheduled operation of the dishwasher P D n and the washing machine P W n , respectively. The solid red and solid blue lines represent the users' requested operation of the dishwasher P D−Sh n and the washing machine P W −Sh n , respectively.
It can be observed from Fig. 6 (a-1) and (a-2) that the demand of houses no. 1 and 2 are greater than the PV generation most of the time during the two days. However, for the house no. 3 the generation is greater than the demand most of the time during both days, as shown in Figure. 6 (a-3). Fig. 6 (b-1), (b-2), and (b-3) show that the EVs in houses no. 1 and 3 travel only once during days 1 and 2, while the EV associated with house no. 2 travelled twice on day 1 and once on day 2. In addition, as can be seen, all EVs are charged to full during the off-peak time to reduce purchasing power at a high tariff and to be prepared for the first trip. It can be notice that the BSSs of houses no. 1 and 3 are not fully charged during both days, while BSS of house no. 2 is fully charged during day 2 from neighbor as illustrated in the square black box in Fig. 6 (c-2). This is because the forecasted energy for the next day (E Day−f ) indicates that more energy is required. Please note that the next day is day 3, which is illustrated in   respectively. However, house no. 3 during day 1 didn't exchange power with its neighbor. As shown in Figs. 6 (d-1), (d-2), and (d-3), the on times of the appliances of each house are shifted to the time where PV powers are surplus or when the house can import power from a neighbor to reduce the peak load, energy cost and the exchanged energy with the grid. As can be seen from Figs. 6 (c-1) and (d-1), the dishwasher in house no.1 is requested to start at 8:00 AM on day 1; however, the EMS shifted the start time to 11:40 AM to be supplied by the neighbor at a lower tariff. Similarly, as shown in Figs. 6 (c-2) and (d-2), the washing machine in house no. 2 is requested to start at 5:10 PM on day 1; however, the EMS shifted the start time to 8:30 PM to be supplied by the neighbor.
For house no. 3 on day 1, the EMS shifted the dishwasher to times when there is PV surplus energy, as shown in  Figs. 6 (a-3) and (d-3). One also sees the washing machine load of house no. 3 on day 1 is shifted to be supplied by BSS and EV batteries. Figures 7 and 8 show the peak time energy exchange of houses no. 1 and 3 in day 2. The dashed red, black, and blue lines represent P P2P n , P L n -P PV n , and P EV n , respectively, where n refers to house numbers 1 and 3. As can be seen from Figs. 7 and 8 around 3:50 PM, the EV of house no.1 discharged power to supply house no. 3 as pointed to by the black arrows. In addition, around 4:45 PM, the EV of house no.1 supplied power to help meet the demands of its own house and house no. 3. However, at 5:30, the EV of house no. 3 was plugged in and started to supply its energy to house no. 1. Table 5 presents the energy costs with and without V2H mode for the four months from June to September 2014. Table 5   TABLE 5. Energy costs for the community with and without V2H Mode for Four months. shows that the V2H mode reduces the overall energy costs of the community up to 15% compared to the houses operating without the V2H mode. In addition, the V2H mode reduces each house's energy cost by up to 23%. Table 6 shows the absolute net energy exchanged between the grid and the community with and without V2H mode for the same four months. As shown, the utilization of the V2H mode reduces the absolute net energy exchanged between the community and the grid by 3%.

VII. CONCLUSION
This paper proposed P2P EMS considering the V2H mode, which enhances the local-consumption within the community, which in turn (1) reduces the burden on the grid and losses of distribution/transmission networks by reducing the energy exchanged with the grid, (2) reduces operating costs by using the EV battery as additional energy storage, and (3) reduces the need for new infrastructure, more charging stations and central storage.
In addition, the proposed EMS utilizes the 2-days ahead forecasted data in an MILP optimization problem, considering the load scheduling, which reduces the energy cost and make the best use of PV energy by shifting appliances to the times where the PV energy is surplus or to the off-peak/ mid-peak times.
An economic analysis of the proposed EMS needs to be conducted, taking into account the overall system component costs and profitability. Future studies will also consider the use of different tariff schemes.