The V2G Process With the Predictive Model

The paper proposes using a predictive model to optimize the use of electricity in the V2G (vehicle to grid) service. The novelty of the mechanism as a kind of model predictive control (MPC) is that it seeks an effective way of managing electric energy in an Electric Vehicle (EV). Additionally, it proposes a new method of predicting the electricity consumption which allows the battery of an electric vehicle to reconcile two sides: both the system’s and the user’s demand will be met at the same time. The model allows for very precise determination of the vehicle’s demand for the energy related to the progressive movement, taking into account the parameters characteristic of a given vehicle model, its suspension structure and aerodynamics. In addition, the machine learning algorithm was proposed for the prediction model as a hybrid (offline and online) of supervised learning. As the first part of the research, by using Matlab/Simulink/dSpace software, a prediction of EV energy consumption was created on a selected route at different times of the day (offline data matrix). At the same time, the simulated route was travelled by a BMW i3 EV (online data matrix). Based on the developed machine learning algorithm the results of the electric energy consumption were compared. The research confirms that if the correct mechanism for prediction of energy consumption by the EV is used, it is possible to define the amount of energy needed for a V2G service. The measurement error was obtained at 0.5%. The added value is setting up the EV energy security of customers after the V2G service and a correct WIN-WIN relation between the Low Voltage grid and EV customers’ needs.


Symbol Decision variable description d offset term; E EVS
the prediction of future energy consumption by EV (kWh); E Id8 recuperation energy (kWh); E V 2G energy demand in the V2G service; F B braking force; L proportional element of the regulator; p brake pedal position; P DSR the active power value obtained at time t via Demand Side Response DSR (kW); P load the active power value for the V2G service at time t (kW); P V 2G the active power value available with EV at time t for the V2G service (kW); SOC + CH storage capacity available for the V2G service -charging to the grid; The associate editor coordinating the review of this manuscript and approving it for publication was Hailong Li . SOC − DCH storage capacity available for the V2G service -discharging to the grid; SOC V 2G n local storage capacity required for the V2G service; t the duration of the V2G and DSR service; t k ending time of the V2G service; t p starting time of the V2G service; x brake pedal depth; z, n, y, w the value of the argument (e.g. the contract number for i -iteration);

I. INTRODUCTION
The growing awareness of the dangers to our civilization based on fossil fuels is causing the generators of electricity to switch from the conventional sources to the renewable ones which do not degrade the natural environment. The European Council has approved and proposed a complete decarbonization process in all EU Member States by 2050 [1]. The indicated process will be subject to additional arrangements and clarification in mid-2020 (f.ex. in conjunction with the position of the Polish authorities), but key regulations will be developed in 2020 (European Commission incentive) [2]. VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ At the same time, the global technological transformation forces customers to respect electricity, offering access to production taking into account environmental conditions. Therefore, the customer's future value local chain will be based on the energy generation, storage and consumption. Currently, the energy efficiency for customers is beginning to take on a different meaning, the more conscious among them already using renewable energy sources in the form of e.g. solar panels. Thus, the customer is technically able to cover the daily energy demand through own production. However, the potential local electricity shortages encourage customers to connect with the electricity grid, where the prosumer profile is balanced.
Simultaneously, there is a slow technological retreat from the use of fossil fuels in transport. Electromobility allows customers to store up electricity from their own generation sources or from the electricity network and to shift the peak of the power system load to the night hours when the electric vehicle (EV) is charging [3]. This concept defines the new function of an electric vehicle as a mobile energy storage, which with the support of appropriate procedures can significantly contribute to improving the energy system balance. The specificity of the use of EVs use by customers imposes significant restrictions on the amount of energy that can be transferred from the vehicle to the energy system, because it always involves limiting the maximum range of the vehicle.
Vehicle-to-Grid (V2G) is a technology that enables the mobile supply of electricity at electric car charging points, primarily in the low voltage power networks [4]. It is implemented through a bidirectional energy transfer using an isolated AC/DC converter and a buck-boost DC/DC converter [5].
Recently, the V2G technology has been applied to the market mechanism for stabilising the electricity demand and smoothing the peak demand [6]. The technology allows diversification and balances the local demand of customers in another part of the power grid without distribution losses. From the point of view of the consumer, it is possible to use the electrical energy stored in an electric vehicle for transport or inject it in any part of the low voltage network.
Reasonable and effective management of electricity by customers in the technology of bidirectional energy exchange constitutes a new approach to building a central electricity power grid and the value of the available power consumption. This is a change in the direction of production and consumption of energy in one area of customer activity [7]. It limits the costs of maintaining a centrally managed system and effectively uses the technologies available locally. In addition, technology can be a support system for the local reconstruction of the energy distribution system [8]. Due to the short-circuit conditions and the power available from electric vehicles, this technology can be used exclusively in some part of the installation, e.g. a building in the island operation mode. The current literature presents the examples of the V2G algorithms for low voltage networks [9], however, they lack the examples of how to calculate the energy needs of EV users in this service process.
The authors of the article assumed that the effectiveness of the V2G process is possible (effective) when the EV user is sure that theirs as well as the grid demand will be met at the moment. The authors' motivation for the research was to find an effective way of managing the electric energy available in the electric vehicle battery and reconcile two sides: the system's demand for energy and the demands of EV users. There are currently scientific articles presenting the ways of managing the V2G technology from the point of providers, the so-called aggregators [10]. For the whole process to be efficient one should still take into account the needs of customers who provide their infrastructure (as much as possible to achieve the destination target).
The purpose of the research is to point out: The purpose of the research is to point out: • developing a process for the V2G service supplemented with the EV demand (chapter II.B); • developing a mechanism for predicting energy consumption in the process of providing V2G services including a machine learning algorithm (chapter III); • developing an EV kinetic model to build the X vector database to teach the offline algorithm [chapter III.A]; • developing a proposal of machine learning algorithms for predicting energy mechanism in the process V2G [chapter IV.C]; additionally: • the relation between the external conditions (environmental, traffic volume, driving style), the EV's technical parameters of a EV, as well as demonstrate the possibility of reconstructing these quantities by a computer simulation [chapter V];

II. IDEA OF THE V2G PROCESS WITH PREDICTION
The key to using the V2G technology is to look for the low voltage grid flexibility mechanisms. There is a reasonable possibility of sharing the energy resources between the transport and the energy system [11].

A. V2G IDEA
The stability of the power system is permanently balancing between power generation with energy system restriction and load demand in real time t. The idea of V2G is available as scattered energy storage system that would support this process of service [12]. The availability of active power P for aggregates is crucial as an element of network flexibility in the form of a V2G or Demand Side Response (DSR) service [13]. This means that both parties (e.g. V2G Operator & Customer) of a V2G contract must know their technical capabilities available to the service, according to the following formula: Therefore, based on Equation 1, it becomes important to look for the technical solutions to improve the energy balancing efficiency in the power grid, and the V2G service is potentially available for use and would be support the power system. The challenge for the future is to ensure an increase in the use of V2G services by EV users and thus by aggregators of such systems.

B. THE V2G PROCESS WITH THE PREDICTIVE MODEL
The starting point for the conducted research is to develop a proposal for the process of relationship in the V2G service between the V2G Operator (e.g. aggregator) and the EV user. The new process idea includes an element supporting the matching of the EV user needs and the needs of the energy system. This element is a module for predicting the energy consumption of the described EV vehicle before starting the service (predictive model). This is a first step to describe a mechanism for predicting the energy consumption in the V2G service provision process, proposed in Figure 1. It can be assumed that the calculation engine for predicting the EV demand (future energy consumption by EV) can be implemented on both sides of the service [14]; however, it seems rational to locate it with the V2G service provider because: -the customer will not incur additional costs for the on-board EV equipment; -the model needs to be updated with new data; -the maintaining solution is independent of the customer. Thus, according to Figure 1, having a prediction of future energy consumption by EV (E EVs ), the process of cooperation and assessment of the contract potential can be described by the following equations [15]: 1. E V 2G = E EVs , when a single V2G service form n balances the demand 2. E V 2G > E EVs , when a single V2G service form n does not balance the demand Other services, such as DSR [16], must be run to achieve power balance in time t (t p : t k ).
3. E V 2G < E EVs , when a single V2G service form n balances the demand and there is an excess of energy that can be transferred as part of the service In the most favorable situation, there is a balance and the second direction of energy transfer is launched, i.e. the possibility of transferring a temporary surplus of energy from the electricity system.

III. PREDICTIVE MODEL
The predictive model of the sought-after value of EV consumption is based on the iterative optimization at three-time intervals: t -1: the past tense, first prediction based only on simulation data without experience E EVS0 ; t: the present, the decision on the V2G process, where: -for the first iteration: E EVS = E EVS0 ; -for the next one iteration base on experiences; t + 1: future prediction time, E' EVS estimate based on real measurement and simulation data. The mechanism coincides with the Model Predictive Control solution [18], [19].
The purpose of the prediction model is to evaluate the E EVS value at the boundary conditions declared by the user (e.g. travel time, route, type of EV vehicle, etc.) and based on the iterative E EVR value of measuring the real object. The comparison of the estimated value with the real value through iteration allows for a precise definition of the value attributes -I d . The model assumes the repeatability of selected I d attributes for the given states. The mechanism has the possibility of simple learning based on the experience gathered in iteration. The output prediction of consumption EV dynamics is then governed by the following form equation [19]: The diagram of the prediction model seeking optimal future electricity consumption by EV is presented in Figure 3.
There are one basic deviations from a typical MPC: -control dynamics, the value sought is estimated once for the requirements of the V2G process. As in MPC, the J cost function [20] will still be used for optimization the values of the I d attributes.

A. ELEMENTS OF THE PAST
In order to formulate the element of ''PAST'', the dSPACE Automotive Simulation Model -(ASM) element is used along with a database matrix (look-up table) [21]. The range of configuration options for the EV energy prediction is shown in Figure 4 [22]. The value of electricity available from an EV is influenced by many I d attributes, such as [23]: • I d1 -route to be travelled by the EV user after completing the V2G service (length, height); • I d2 -technical parameters of the EV storage (e.g. kWh); • I d3 -technical parameters of the EV (weight, drag attributes, vehicle dimensions, etc.); • I d4 -environmental conditions (surface condition, temperature); • I d5 -time of day when the route is travelled (possibility of reaching the nominal electric motor rated torque); • I d6 -number of passengers; • I d7 -system efficiency: electric engine, inverter, battery, charging-discharging; • I d8 -recuperation value; • I dn -n-th arbitrary attributes. In addition, the Vehicle dynamics system was modified in terms of brake pedal operation as a recuperative element in the simulation in accordance with the following equation: Implementation of dependency equation 8 was added to ASM as Figure 5 [24], [25]. The task of ASM is to develop a matrix of potential solutions in accordance with the following equation: Knowing how to correctly parameterize the I d value attributes is key to developing a matrix of potential solutions.

B. ELEMENTS OF THE PRESENT TIME
At this stage, the potential solutions for E EVS are already prepared for the defined I d attributes, which can be divided into two groups. The first, by far the largest group are the attributes, the value of which known, I d1 → I d6 (user declaration in the V2G process). The second group comprises of the attributes values of which are unknown and their uncertainty results comes from the inability to describe the physical phenomenon dependent on many variables, is I d7 , I d8 . Thus, at time t, E EVS is predicted with potential offsetd, as shown in Figure 3.

C. ELEMENTS OF FUTURE TIME
In order to optimize the prediction model for the V2G service, the first iteration is followed by the correction of the I d7 , I d8 attributes in regard to the actual value of the E EVR measurement. The algorithm selects, looks for new values of I d7 , I d8 for which the value of E EVS is within the limit of the assumed offset d. The historical values in subsequent iterations of the scenarios are the starting point for other predictions. In this way the V2G process with the predictive model is capable of learning. This solution allows improvement in regard to the efficiency of the V2G process, working closer to the limits of the technical constraints.

IV. STUDIES OF PREDICTION MECHANISM
In order to verify the purpose of the research, sequences of actions were carried out to confirm the idea of electricity prediction for the V2G process.

A. INPUT DATA FOR PREDICTIVE MODEL
The BMW i3 electric car was selected for testing as a plant (Figure 3), the basic technical parameters of which are presented in Table 1. The vehicle decides about the attributes: I d2 I d3 . The course of the EV passage route was selected to achieve the urban driving conditions including short and long travel sections. In addition, the selection of a route allowed achievement of nominal torque M for the HSM BMWi3 synchronous motor which, depending on the scenario, should improve the efficiency of the energy consumption by the EV.
The height profile of the route was developed using the Geocontext application, implemented in the ASM model of the dSPaceModelDesc environment.
On the basis of the above-mentioned technical parameters within the chosen real route, prediction of energy consumption E EVS was developed using the ASM. At this stage, only the information regarding ASM is missing I d7 & I d8 . Therefore, according to the prediction model (Figure 3), a database of potential solutions E EVS was built. It was assumed that: • I d1 , I d2 , I d3 , I d4 , I d6 -known data; • I d7 -controlled in the range (57.5-65) %; • I d8 -controlled in the range (5-30) %. At this moment, the prediction model enables data to be built for the first t-1 interval.
In order to start the first iteration as the second interval t, select the initial values I d07 and I d08 . When the predictive model has no historical data, the assessment is subjective. The learning element allows choosing the initial values correctly based on several iterations.

B. VEHICLE & MEASUREMENT
Due to the limited accuracy of the vehicle's on-board measurement systems, the measuring equipment was used to determine the amount of energy consumed by the vehicle on the route.
For measuring the E EVR values, two recorders were applied. The first one was a C.A 8336 CHAUVIN ARNOUX IP53, accuracy class B, power and quality analyser; the second -a PQ Box 150 a -Eberle, accuracy class A (Fig. 7). The BMW i3 was charged by means of a 230 VAC, 16 A on-board charger.  Each time before the start of the EV BMW i3 (Fig. 8) driving route, Fig. 6, it was charged to the full battery capacity SOC = 18.8 kWh -I d3 . After completing the route, the BMW VOLUME 8, 2020 i3 EV's on-board energy storage was again charged to the maximum SOC. The above-mentioned measurements took place on November 15 th and 16 th , 2018.
It is calculated, that the maximum permissible error was p X = 0.005. Therefore, the prediction model assumes the same error value d as p X .

C. ALGORITHM MACHINE LEARNING
As shown in Figure 3, the algorithm machine learning (AML) after the first iteration determines the new value of the EV's energy consumption as E EVS (formula 6). Therefore, the structure of AML, supported by the kinetic model of the EV, becomes indispensable for supervised learning. Figure 10 shows the AML sequences. From step 1-9, these are tasks to determine the predictive values of I d7 and I d8 . AML has features of offline learning algorithms (data is downloaded from dSpace) and online too (real object EV). Thus, AML is hybrid (offline + online) for correct prediction with an acceptable error. • 2'nd step 1. According to Fig. 1, the AML loads data form the V2G process. 2. According to Fig. 3, the AML loads initial values for Id 7 -Id 8 from dSpace. The values are stored according to the driver ID.
• 3'rd step For each j iteration, the z value is determined, in accordance with the following equation: where: X -input value matrix based on I d attributes. • 4'th step 1. The activation function φ(z) is selected and must be continuous, e.g type: ReLU [27]. 2. Using the activation function φ(z) to calculate the net output in the class.
• 5'th step Each on iteration j presents its own set of I d7 -I d8 assigned to a class. The first machine prediction.  • 6'th step E EVS is calculated by dSpace using the vehicle's kinetic model ( fig. 4) for j and I d7 -I d8 (step 5).
E EVR is taken from the environment, real measurement. The machine database (E EVR ) for the real object is completed each time the EV passes for the driver ID.
• 7'th step Calculation of the value of error -δ, in accordance with the following equation: • 8'th step Use of the cost function, in accordance with the following equation: • 9'th step The learning gradient for step j: where: η -the learning rate;

V. RESULTS OF RESEARCH
The vehicle's energy consumption depends on many factors that are independent of each other. The basic factors are: terrain, weather conditions, types of manoeuvres and driving style of the driver. Including all these factors in the mathematical model is extremely difficult and prompts that the calculation algorithms be equipped with an element that can fine-tune the algorithm to these parameters. To assess the impact of traffic intensity and driving style on the amount of energy consumed, a series of experiments were carried out on an electric vehicle traveling the same route under different conditions.  As part of the research work, three scenarios for measuring the E EVR were designed in order to verify the correctness of the predicted EV model BMW i3 with the E EVs measurement. The starting point of the research is the common route for the passage of Figure 6, but at different times of the day. The simulations and real measurements were performed for the following scenarios where: Scenario I -morning drive on November 16 th , 2018y; Scenario II -noontime drive on November 15 th , 2018y; Scenario III -evening drive on November 15 th , 2018y; The summary of the values obtained from the simulation measurements and the real measurements for the abovementioned scenarios is presented below.

A. SCENARIO I
The ride was interrupted with numerous stops due to the inability to synchronise with the traffic lights. At least two longer stops along with driving in a stop-go manner.
An example of the simulation energy consumption for the creation of the E EVS matrix, scenario I is presented below. VOLUME 8, 2020     Based on the measurements and calculations, it can be seen that with properly selected I dn parameters, the calculated and real values are very similar. It has been shown that by appropriate selection of parameters in the calculation model, it is possible to fine-tune the parameters of the prediction model using AML. This allows accurate prediction of the amount energy for EV user demand.

VI. APPLICATION OF THE SOLUTION
The algorithm developed allows a precise determination of the vehicle range, taking into account its technical parameters as well as the weather conditions and those related to the anticipated traffic volume. Its considerable complexity makes it difficult to directly implement in the EV and EVSE (Electric Vehicle Supply Equipment) management systems. It was assumed that high-level communication protocols (ex ISO151818) are able to mediate between EV and EVSE and the central server on which the solution developed will ultimately function. An example of the IT architecture for  the implementation of the mechanism is shown below in Figure No. 17 [28], [29].

VII. CONCLUSION
The effectiveness and popularity among the EV users of the V2G service will depend on the correct definition of the demand for EV electricity after implementation. The correctness of prediction on the V2G service engine side is a function of many I d variables, which should be collected and processed on a current basis to establish a favorable balance for P V 2G at the service point. Regarding the way of simulating the calculations and energy consumption measurements in real urban traffic, it can be stated that the electric vehicle model developed reflects well the energy phenomena occurring in it while driving under various environmental conditions (E EVR: the morning = 2.163 kWh, the noontime = 1.98 kWh, the eventing = 2.06 kWh). There is a clear correlation between coverage and system efficiency, environmental conditions and traffic (correctly defined or calculated Id attributes). This makes it necessary to use such a tool when calculating the parameters of the V2G process.
Relieving the user from the necessity to define the abstract energy value that can be given away from theirs simplifies the use of the V2G technique, contributing to its popularisation and consequently to improving the balance of the power grid. It should be emphasized that the travel time has a small influence on the prediction of the energy consumption of the forward EV motion and due to the random events during the actual crossing, it is burdened with the error in the simulation.
The simulations of the computational model and verification of the actual measurements of energy consumption on a given route of passage indicate that it is possible to predict it at the level of the determination of error d by using a predictive model. In this study the value of d was less than 0.5%, confirmed on the three scenarios.
The case-by-case studies indicate the need to conduct further research using other EV vehicles and other additional external factors that may be relevant in a different environment than the one being studied.