Framework for the Introduction of Vehicle-to-Grid Technology into the Polish Electricity Market

: Vehicle-to-grid (V2G) technology is one of the advanced solutions that uses electric vehicles (EV) to balance electricity demand in the power system. It can be particularly useful in analyzing and then mitigating the risk of not delivering electricity to the end user. Therefore, it is necessary to analyze the possibility of operation of this technology in the legal framework. The article presents the analysis of the legal status in Poland, referring to the documents of the European Union and domestic legislation. Potential changes in Polish energy law that could facilitate the implementation of V2G technology are also proposed. In addition, the authors suggested the principles for the use of this technology, formulating a mechanism called the V2G Program. Within this Program, the V2G Service was defined and a business model of its implementation by a participant of the V2G Program (uEV) was presented. In addition, an uEV selection algorithm is provided so that the mathematical model of the V2G Service can be validated. Based on the performed simulations, it can be concluded that the implementation of the V2G Program requires significant changes in the Polish energy law, but it is feasible from the technical point of view.


Introduction
The European Union's policy of emission neutrality introduces further restrictions on the use of internal combustion engine (ICE) passenger cars [1]. Importantly, the process of achieving carbon neutrality does not only apply to EU countries. It is a global trend that, apart from efforts in the transport sector, also affects other industry branches [2,3]. However, it should be kept in mind that the transport sector is a major source of carbon dioxide (CO2) emissions [4,5]. Therefore, the transformation of public and private transport to zero-emissions has been ongoing for several years. This can be achieved by popularizing electric vehicles (EV) [6,7]. The development of electromobility in recent years has significantly accelerated. Many factors have contributed to this, such as the introduction of incentives and benefits, restrictions on the entry of ICE vehicles into city centers imposed by the EU and local authorities, CO2 emission fees imposed on car companies, and increased public awareness of environmental issues [8][9][10]. With the introduction of electric vehicles into public space, new solutions could be observed, which will contribute to a more efficient use of these vehicles. One of such solutions is Vehicle-To-Grid (V2G) technology [11]. It involves using the energy stored in batteries of electric vehicles for the purposes of end users or even Distribution System Operator (DSO) or Transmission System Operator (TSO). Depending on the location of the EV, discharge service will take place. These needs may vary according to battery charge, grid status, or internal user preferences. There are many concepts for using EVs to supply different facilities. It can also take the form of Vehicle-to-anything also known as Vehicle-to-X (V2X) programs, where X stands for, e.g., building (V2B-Vehicle-to-Building), home (V2H-Vehicle-to-Home), general load (V2L-Vehicle-to-Load), especially used with industrial loads (V2I) [12,13]. Basic diagram of using V2X technology is presented in Figure 1. Considering the basics of V2G technology, it is possible to reflect on the essence of its use in modern power systems. From the DSO point of view, it would be desirable to use EV batteries to support operation of the grid, e.g., reducing demand, reducing loading on transformers, and power lines connecting substations and end users to the Main Supply Points. From the point of view of the end user (residential or commercial), discharging the battery of an electric vehicle could allow them to increase security of energy supply or, in the case of their own vehicles, also enable a form of demand reduction. The aforementioned actions can be classified as those undertaken by actors within the so-called consumer-led energy sector, i.e., one in which distributed consumers and producers actively participate in balancing the power system in a given area. Thus, a research problem can be formulated to check whether the V2G technology can have an impact on the development of such a form of community engagement. However, in order to measure it, firstly, certain principles of functioning of V2G technology in the electricity market should be established. For doing so, it is necessary to understand the problem of introducing new services into this market. This is a multidimensional problem, because it concerns the following areas: Technical, legal, economic, but also social. This article will discuss mainly legal and technical problems. Thus, the legal framework allowing or obstructing the implementation of V2G services in the European Union and Poland, as a special case, will be analyzed. Assuming adaptation to the existing legislation, the business and technical model of such V2G services should be built from the scratch. Therefore, this paper will present a description of such a service from the point of view of its implementation by the user of an electric vehicle, and then give an algorithm for the selection of such users who will provide the service. The results of the performed research are methods that can be used in the future by energy companies to implement the whole mechanism of V2G services in real conditions. The paper is organized as follows: Different variants of V2X technology will be presented in Section 2 of the article. In this paper, the authors have focused mainly on legal and economic aspects of V2G technology. The description of other V2X technologies is complementary to the knowledge that can be used for further research. In Section 3, the authors focused on presenting the legal framework for the functioning of V2G technology in European Union and Poland. Section 4 presents a proposal of the V2G Program concept as a comprehensive platform to implement V2G technology in Poland. A mathematical description of the business model of V2G service was also depicted alongside the algorithm for the selection of participants, that will provide V2G Service. Section 5 presents a case study in which models from Section 4 were implemented.

State-of-the-Art
Globally, research work on the implementation of V2X technology has been going on for several years. As mentioned earlier, the literature contains a number of solutions using the discharging process of electric vehicles for various purposes [12,14]. The most popular solution is to use electric vehicles to support the operation of the power grid (mainly distribution)-Vehicle-to-grid (V2G). In the literature, the main concept of V2G technology functioning is presented in detail. In general, there are two types of analysis-technical and economic. In the literature, the technical analyses of V2G technology implementation concern the methods of power system control using EV [15], frequency control services [16][17][18], and the use of electric vehicles as mobile generation sources [16,19]. Unfortunately, these analyses often concern the transmission system, which, according to the authors, does not allow for an accurate assessment of the effects of discharging EV vehicles. These approaches allow a quantitative assessment of the capacity potential resulting from EV; however, the number of vehicles assumed in these scenarios is extremely remote from the actual number of vehicles. An important element that should be addressed when discussing the V2G technology is also the degree of battery degradation that will occur with the use of EV in battery discharge for the grid [20,21]. The economic aspects of V2G technology mainly concern cost analysis [22,23], definition of the roles of individual actors in V2G technology [24], and proposals for pricing system services based on fuzzy logic algorithms [25]. Interesting aspects are addressed in [26]. The authors pointed out that the mode and method of charging depends on the moment and length of stopping. The authors also proposed a five-state model of electric vehicle operation. Based on this knowledge, a business model for V2G services was designed, taking into account the German power system. Assumptions for providing V2G services in car parks are also presented in [27]. It is worth noting that the authors rightly underlined that vehicle user behavior is random and the probability of incomplete or complete failure of the V2G service should be taken into account.
V2G technology is also being developed commercially. Table 1 presents the selection of commercial projects of V2G technology applications. Another solution is to use electric vehicles to meet the needs of a residential building, i.e., Vehicle-to-building (V2B). In the literature, one can also find this solution under the name Vehicle-to-home (V2H). Generally, the methods of analysis are similar to those concerning V2G. In a previous publication [29], one can find information about the model in which the batteries of electric vehicles are used to supply an office and residential building. During the research, a detailed technical concept of operation of such batteries in a microgrid consisting of the aforementioned buildings was presented. The material contained in [30] seems to be interesting. The authors created an extremely detailed state-ofart concept in the area of integration of buildings and electric vehicles. It has been pointed out that one of the basic problems discussed in the area of V2B is the assessment of such systems in terms of reducing energy demand in a building. In addition, the authors of many publications focus on the integration of not only EV and buildings, but also additional renewable energy sources (RES), which include photovoltaic power plants or micro wind turbines [30][31][32]. There were also analyses in the scope of improving the flexibility of operation of such installations, e.g., by using peak-shaving and valley-filling methods [33,34]. Economic aspects of using such installations were also analyzed [35].
In the literature, you can also find solutions for Vehicle-to-load (V2L). These solutions in some way simplify the issue of energy supply from electric vehicles to end users. In a previous study [12], the concept of using EV in the V2L technology is presented in terms of ensuring energy security, in particular providing an additional source of electricity during power outages.

Novelty
Based on the literature review, it can be observed that previous studies have mainly focused on the following aspects related to V2G technology and other research areas that are necessary to launch V2G services:
However, the authors of this paper have noted a knowledge gap in the form of integrating domestic legal frameworks with the rise of V2G business models. Therefore, the work on legal aspects presented in [39] was developed by discussing Polish legal acts concerning the operation of the power sector. Based on the analysis of European and domestic legal acts, the following solutions were provided: 1. Proposals for changes in domestic (Polish) legal acts were indicated; 2. The authors' concept of the V2G Program, i.e., the set of services that could be provided by owners of electric vehicles under the vehicle-to-anything technology, was developed.
Moreover, in the proposed concept of V2G Program, there were examples of services included, which would be compliant with current legal conditions, and a business model of V2G service was also developed. The aim of this paper is to develop the design of V2G service models taking into account random events on the part of EV users, as presented in [27]. Verification of this model was presented in the novel algorithm for searching and selection of vehicles that will provide the aforementioned services.

Status of Energy Storage Facilities
One of the fundamental problems in defining the legal framework for the operation of V2G technology is to define the position of battery energy storage systems (BESS) on local energy markets. This problem was pointed out by Forrester et al. [41], who mentioned the need to qualify BESS to the well-known power engineering sub-sectors. A significant problem is the lack of a clear definition of what is the energy storage [42]. According to the EU Directive 2019/944 of 5 June 2019 on common rules for the internal market for electricity, energy storage is "in the electricity system, deferring the final use of electricity to a moment later than when it was generated, or the conversion of electrical energy into a form of energy which can be stored, the storage of such energy, and the subsequent reconversion of such energy into electrical energy or use as another energy carrier", while an energy storage facility is understood to be an "facility in the electricity system where the energy storage occurs" [48]. However, it should be mentioned that, according to the aforementioned Directive 2019/944, DSOs and TSOs cannot own energy storage facilities. However, it is possible to obtain a derogation from the EU Directive requirements by fulfilling the following conditions [48]: • Storage facilities must be fully integrated into the power grid; • The national regulatory authority has given its approval for such actions; • Other parties were not permitted to set up or operate energy storage facilities; • Energy storage facilities are necessary for DSOs to fulfil their obligations and regulations under Directive 2019/944 in order to ensure safe operation of the power system; • Storage facilities must not be subject to market play and additional revenues for DSOs.
The regulation of energy storage is a fundamental part of the European sustainable development process for the use of alternative energy sources. Since V2G technology uses BESS installed in electric cars, it can be concluded that without appropriate regulations it will not be possible to implement it efficiently. It should also be stressed that no direct regulation of V2G technology is included in any EU documents concerning energy storage. Therefore, it should be understood that member states are free to decide on the implementation of V2G services, while maintaining the current framework for energy storage.

Flexibility
The action related to sustainable development in the area of power engineering is ensuring, by DSOs, the so-called flexibility of the grid. In the literature, it can be found that grid flexibility is a series of actions aimed at adjusting energy demand and generation according to planned and unplanned changes [49]. These actions can be achieved by using an appropriate control algorithm in distributed energy sources (DES) [50], in energy storage [42], in end users, e.g., in buildings [51,52], or also in the processes of charging and operation of electric vehicles [42,51,[53][54][55]. An important topic addressed in [55], in the context of V2G, is the EV trip chain model, which combines flexibility mechanisms with V2G services.
The topic of flexibility is not only addressed in the literature, but also has its real dimension. In the EU Directive 2019/944 of 5 June 2019 on common rules for the internal market for electricity [48], information on grid flexibility can be found in Article 32. In this article, it is stated that DSOs will provide flexibility services, which will consist of congestion management to increase the efficiency of the distribution grid. Such activities may be carried out with the help of distributed generation, energy storage, or demand side response services (DSR). Considering the aforementioned provisions it can be concluded that the use of energy storage in electric vehicles as an action related to grid flexibility is possible. Moreover, the conclusions (No. 42) of this Directive indicate that the use of electric vehicles (and more specifically their energy storage) is feasible and needed. However, there is still no solution for creating a market for flexibility. Studies carried out by organizations associating TSOs and DSOs and other energy companies indicate the necessity of creating such a market [56]. It is suggested that flexibility services can be traded, and the facilitators of this market would be system operators. It is also important that in the case of Poland, there are still no national regulations enabling the setting up of a market for flexibility services or provisions on how flexibility should be used.

Electromobility Status in EU
A key legal act regulating electromobility in the EU is the Directive of the European Parliament of 22 October 2014 on the deployment of alternative fuels infrastructure [57]. It introduces fundamental definitions of electro-mobility concepts. In particular, three definitions are worth emphasizing in the context of the analysis of the V2G Program [57]: 1. Electric vehicle-"a motor vehicle equipped with a powertrain containing at least one nonperipheral electric machine as energy converter with an electric rechargeable energy storage system, which can be recharged externally"; 2. Recharging point-"an interface that is capable of charging one electric vehicle at a time or exchanging a battery of one electric vehicle at a time"; 3. Recharging or refueling point accessible to the public-"a recharging or refueling point to supply an alternative fuel which provides Union-wide non-discriminatory access to users. Non-discriminatory access may include different terms of authentication, use and payment".
None of the aforementioned definitions mentions a bi-directional energy transmission between the electric vehicle and the charging point. Therefore, it should be asked whether the legislators, in establishing the regulations, considered the use of V2G technology at all. Of course, the definition of energy storage cited in Section 3.1 allows the use of V2G technology in practice, although there is a stronger correlation with the energy storage process than with the development of electromobility. In order to clarify the rules, a definition of bi-directional charging points should be considered. Another aspect is the use of publicly available charging points. In particular, the part of the definition concerning non-discriminatory access to these points should be analyzed. This implies that the implementation of V2G technology has to be done at other than publicly accessible charging points, as it is not possible to give priority to vehicles that will discharge into the power grid. This aspect is discussed in detail in Section 4, when the V2G Program is proposed.
Further references to electromobility in EU legislation can be found in the EU Directive 2019/944 of 5 June 2019 on common rules for the internal market for electricity [48]. In principle, it defines a set of rules that must be respected in the operation of European local electricity markets. However, it also sets out principles for the integration of electromobility into the electricity grid-Article 33. On its basis, it can be concluded that a key role in the development of electromobility is the cooperation between the Operators of Charging Points Accessible to the Public (OCPAP) and DSOs. However, it is not possible for DSOs to take over a role of OCPAP, due to the provisions of Article 33 (2) of the Directive [48]. A DSO cannot own or manage charging stations, except for its own use. According to the aforementioned interpretations of Directive [48], own use is to be understood as the use of charging points for charging the fleet of DSOs' business vehicles. As in the case of energy storage, there are possibilities to obtain derogations for DSOs to manage charging points. These conditions are as follows: • Other parties were not permitted to set up or operate charging points, • The national regulatory authority has given its approval for such action, • DSOs apply the principle of third-party access, while operating the charging points, and do not discriminate against other companies, in particular in favor of companies with capital connections to DSO.
It follows that for the V2G Program it would be impossible for DSO to obtain derogations due to the fact that V2G Program users must be prioritized.

Current Legal Framework in Poland
For the introduction of the V2G technology in Poland, the regulations contained in the Act on Energy Law [58], the Act on Renewable Energy Sources [59], and the Act on Electromobility [60] have to be respected. These are three basic legal acts, which in an imperfect way regulate the use of bi-directional energy flow. Each of these acts must comply with the EU Directives presented in Section 3.3. Nevertheless, it can be stated from the very beginning that the Polish legislation is not ready to introduce V2G technology. In this section, the authors shall present provisions that may help to create a legal framework for the V2G technology and suggest changes in the law to make its implementation easier.
The first problem observed is the lack of legal possibility for DSOs to use energy from electric vehicles for grid purposes. As mentioned in Section 3.3 under EU law, DSOs may not manage charging points or energy storage facilities unless it is justified by the conditions described in the previous chapter. So, the certain option is to treat vehicles as mobile energy storage; however, the legal framework for energy storage is not fully defined either.
First of all, analysis should begin with Polish definitions of energy storage facilities. According to Article 3 (10k) of the current Energy Law, an energy storage facility is "an installation for storing energy, connected to the grid and capable of supplying electricity to the grid" [58]. Unfortunately, a completely different definition can be found in Article 2 (17) of the Act on Renewable Energy Sources, where an energy storage facility is defined as "a separate device or set of devices used to store energy in any form that does not cause emissions that are a burden to the environment, in a way that allows at least partial recovery" [59]. As it can be seen from the aforementioned definitions, the problem relates to their lack of coherence. However, analyzing the provisions of the draft amendment to the Energy Law, which in May 2021 is in the final stage before its implementation, it can be concluded that the definitions of energy storage have been clarified [61]. Article 7 (1c) of the amendment to the Energy Law also changes the Act on Renewable Energy Sources. According to the aforementioned article, the only definition of an energy storage facility that should be used is the amended definition in Article 3 (10k) of the Energy Law, i.e., "an installation enabling the storing of electric energy and its injection into the grid". Nevertheless, it should be mentioned that in the first versions of the amendment, these definitions were not coherent. According to the authors, it is important that the definition of energy storage will include a reference to mobile energy storage, so that V2G technology is explicitly treated as an energy storage type. Unfortunately, a definition of mobile energy storage was not included in the final version of the act.
Amendments to the definition of an energy storage facility in the Energy Law were made on the occasion of the adoption of the Act on Electromobility and Alternative Fuels in 2018 [60]. Its introduction also brought about a number of other changes, such as the recognition of publicly accessible charging stations in the Energy Law. However, focusing on the provisions of the Act on Electromobility and Alternative Fuels, the definitions concerning charging infrastructure for electric vehicles should be analyzed. It introduces concepts already known from the European Parliament Directive 2014/94 on the development of alternative fuel infrastructure. In addition to the term of recharging point, which was mentioned in Section 3.3, the following definitions are also included [57,60]: 1. Normal power recharging point-"a recharging point that allows for a transfer of electricity to an electric vehicle with a power less than or equal to 22 kW, excluding devices with a power less than or equal to 3.7 kW, which are installed in private households or the primary purpose of which is not recharging electric vehicles, and which are not accessible to the public"; 2. High power recharging point-"a recharging point that allows for a transfer of electricity to an electric vehicle with a power of more than 22 kW".
Unfortunately, there are no provisions in the entire text of the current Act on Electromobility (as of October 2020) allowing the use of V2G technology. The relevant provisions introducing the definition of a bi-directional charging point have been included in the draft amendment of the Energy Law [62]. According to the Polish government's proposal (January 2020), a bi-directional charging point is "a charging point which allows electric energy to be absorbed from an electric or hybrid vehicle" [62]. However, according to the latest government proposals, the definition of a bi-directional charging point has been removed from the amendment of the Electromobility Act and the Energy Law (May 2021) [61]. However, it should be noted that if the Energy Law is amended, this would be a beneficial step that would undoubtedly unlock the potential for developing and exploiting V2G technology. Nevertheless, it should be remembered that acknowledgment of a bi-directional charging point would not solve the problem of V2G Program implementation. Furthermore, the division of roles in the establishment and operation of a wide-access network of bi-directional charging points is an unsolved problem. The Act on Electromobility carries over the provisions from both previously discussed Directives of the European Parliament [48,57]. They concern, in particular, equal access to publicly accessible charging points and the introduction of a market for energy storage services.
It should also be mentioned that the current Polish Energy Law significantly complicates the provision of ancillary services by energy storage facilities [58]. As part of the strategic changes, it should be possible for energy storage facilities and mobile energy storage facilities to provide such services. The introduction of the V2G technology is nothing else than a new type of ancillary service that may, and even has to, be provided at the level of distribution grid. According to the current regulations, DSO mainly deals with the coordination of traffic in the distribution grid, but is excluded from the process of balancing the system concerning the balancing of current demand and generation. However, it should be mentioned that DSOs may dispatch generation units smaller than 50 MW connected to the distribution grid. In addition, the purchase of ancillary services is solely the responsibility of the TSO. The most similar services in the current pool of ancillary services in Poland are: Operational Capacity Reserve, Hot Reserve, or Demand Side Reduction [58]. However, it should be emphasized that as of 18 December 2020, the services Operational Capacity Reserve and Hot Reserve will be decommissioned due to the introduction of the Capacity Market. It should be considered whether the Capacity Market will be one of the future considerations of the V2G technology, especially in the context of not subsidizing units with significant CO2 emissions.
Therefore, the authors proposed their own V2G Program model, which is discussed in detail in Section 4 of the article. Also, based on the analysis of the aforementioned legal acts, Table 2 is presented. It presents the missing domestic legislative aspects, as well as a priority of their introduction in order to reach the full potential of V2G technology.

Model of V2G Program
It is also important to define the practical use of V2G technology. It should be determined whether the discharge of an electric vehicle for the purposes of the distribution network is an ancillary service or service provided by a third party for the sole purpose of making a profit. The following definitions are proposed: 1. V2G Service is a defined action, which is undertaken by the V2G Program Participant, aimed at the improvement of the power system operation, or ensuring sufficient capacity for end-user.

V2G Program Participant (uEV) is the owner of an electric vehicle or fleet of electric vehicles, who provides services by offering battery capacity to end-users or Distribution System
Operator. 3. End User (EndUs) is the energy consumer, who has decided to use electric vehicles for reserve power supply, within the V2G Program. 4. The V2G Program is understood as the activity of a power company involving the use of electric vehicles to improve the operation of the power grid or/and to improve the security (assurance) of supply. 5. V2G Service Provider (V2Gsp) is the party managing the V2G Program in a given area. Figure 2 shows the block diagram of V2G Program operation. It is important to ensure that the full potential of the V2G program can be fully achieved by allowing a given uEV to provide multiple V2G services simultaneously. Regardless of the number of services provided, the V2G Program should be based on the mutual relations between the participants. Figure 3 shows a scheme of relations between key actors and their role in the V2G Program. Considering the legal framework described in Section 3, it should be stressed that DSO is not allowed to be fully actively involved in shaping the V2G Program, especially using publicly available charging points. Therefore, it is necessary that a dedicated company, a so-called V2G Service Provider (V2Gsp), would be the operator of V2G technology. However, the legislation does not limit whether V2Gsp can perform other roles in the electricity market, that do not directly concern the operation of the distribution grid, as provided for in Articles 6 and 33 of the EU Directive 2019/944 of 5 June 2019 on common rules for the internal market for electricity [48]. In Poland, it seems obvious that a local retailer would be obliged to become a Charging System Operator (CSO) within its competence, in accordance with the Polish Act on Electromobility [60], and therefore also a V2G Service Provider. However, the role of DSOs cannot be neglected in the process of creating V2G Program. It was concluded that the DSO not only should but rather must be a party to the implementation of the V2G Program, but not as a managing party.
The discussed proposal considers two main cases of V2G Program implementation. Case 1 concerns securing of end-user electricity demand during scheduled and unscheduled outages or constraints in access to energy resulting from the operation of the power system. The introduction of V2G technology would make it possible to secure such needs by recalling V2G participants (uEV) to a selected user and discharging the batteries to a specified level. Settlement and coordination of the program would remain within the V2G Service Provider (V2Gsp). However, the DSO should also be party to the agreement between the uEV and V2Gsp. This is related to the fact that the DSO must be aware of the network traffic, e.g., during maintenance. In order to comply with EU legislation, a solution to the problem of installing bi-directional EV charging station (EVSE-V2G), in Case 1, is building this station by the end user. This means that it is the responsibility of the end user to ensure that the service can be carried out-e.g., providing a parking space. In fact, it seems that the end customer would sign a contract with the V2Gsp for an additional V2G service, whereas the DSO would only be an agent between V2Gsp and the end customer-DSO will not take any commission. This would result in there being no need to define a new ancillary service, which would imply an amendment to the Act on Energy Law.
Contrary to Case 1, Case 2 concerns the securing of the electricity demand of the entire power system. The V2G technology can serve as a support mechanism for balancing the distribution network, obviously with all proportions. It should be remembered that in the case of overloading power lines, energy from EV can be used to supply end users in a relevant region. While further coordination of V2G Program and chargers would be handled by V2Gsp, the key role in Case 2 is played by DSO. Only the DSO is able to detect and identify a disturbance in the power system and then set up the appropriate coordination of network traffic. V2G services would be provided at publicly accessible V2G points belonging to V2Gsp; however, the possibility of using private end-user points is not excluded if the situation in the power system requires it. However, in Case 2, there could be a legal problem in regard to the ancillary service provided by DSOs to V2Gsp. The most important issue properly defines such a service, so that the rules set out in the Energy Law would be fulfilled. Therefore, it is possible to amend the regulations allowing DSOs to participate in the purchase of ancillary services, and thus create a portfolio of such services at the level of distribution grid. Another solution is close cooperation between the TSO and the DSO in the implementation of a V2G Program. It seems that V2Gsp would have to report the performance of discharging services to both TSO and DSO. In that case, it is important to regulate cash flow between these entities for providing such services.
The V2G Program is intended to enable owners of electric vehicles to participate in two basic modes-Mandatory Mode and Optional Mode. In Mandatory Mode, uEV will receive a fixed payment for its availability to provide services; however, it will be forced to do so upon the request of V2Gsp. Otherwise, it will receive a fine proportional to its participation in V2G Program. This is a mechanism borrowed from the capacity markets, where the power generators receive payments for their availability to deliver capacity to the power system. The Optional mode is intended for more mobile users, who are expected to want to benefit from the V2G Program, but after receiving an appropriate economic incentive. The uEV users providing V2G Services in the Optional Mode will be able to receive more remuneration for more challenging services, and the uEV performing its obligations in the Mandatory Mode will receive a relatively equal payment, but more often.

Model of Basic V2G Service
The V2G service was previously presented as "defined action, which is undertaken by the V2G Program Participant, aimed at the improvement of the power system operation or ensuring sufficient capacity for end-user". Therefore, the mathematical description of business model of such an action should be discussed in order to present the implementation of such a service from both the uEV and the V2G Service Provider.
The first step is to define the energy flows during charging (Grid-to-vehicle: G2V) and discharging (Vehicle-to-grid: V2G). These are shown in Formula (1).
where: eV2G-energy flow injected or consumed by 1 electric vehicle; C-capacity of the electric vehicle battery pack, in kWh; SOCex-expected battery State-of-Charge (SOC) at the end of the charging process; SOCt-current State-of-Charge (SOC) in the time t; SOCf-State-of-Charge required for the next journey; SOC0-minimal State-of-Charge limited by technical constraints; R-a reserve, which considers the possible lengthening of the route, e.g., to avoid a congestion; ηd-efficiency of discharging process; ηc-efficiency of charging process. The aforementioned SOCt, SOC0, SOCex must fulfil the following condition (2): Understanding the value of electrical energy that an electric vehicle can deliver to the power grid, one should proceed to the next step, i.e., to design the proper V2G service. This paper considers Case 1, discussed in Section 4.1-providing an additional energy supply for the EndUs. In this paper, the name of the aforementioned V2G service is: Emergency work for the energy consumer. According to V2G Program Case 1, the energy consumer will own its bi-directional EV charging point. As part of the contract between the parties, EndUs will have to specify the value of the energy that they want to collect from EVs. Let Ed denotes the end user's electricity demand from V2G Program at time t and Edmax denotes maximum end user's electricity demand from V2G Program, which can be obtained from end-users V2G charging points. Its value will be calculated according to Formula (3).
where: Edmax-maximum end user's electricity demand from V2G Program, which can be obtained from V2G charging points, in kWh; nCS-number of bi-directional charging points owned by EndUs; PEVSE,i-rated power of bi-directional charging point, in kW.
The end user will provide V2Gsp with data on the amount of energy in advance, so that V2Gsp is able to inform uEVs. The authors estimate that in the case of scheduled power outages for the end user, time t will be about 8 h, and in the case of unscheduled outages, energy should be enough for about 12 h. Given the relatively tight constraints on the transmission of power and energy from the charging point, the EndUs should choose its reserved energy demand wisely. However, the end user must not forget to possibly oversize their facility, so that more cars are able to provide V2G service.
Let denote the number of vehicles needed for providing the V2G service. Equation (4) describes the correlation between the demand of EndUs and the number of participants in the V2G Program.
where: Ed-end user's electricity demand from V2G Program, in kWh; eV2G+,n-energy flow injected by n-th electric vehicle; -required number of electric vehicles for provision of V2G Service for end user.
Knowing that the maximum demand covered by V2G Program participants is determined by the number of V2G points in a location, the ratio between Edmax and Ed can be determined.

= (5)
where: Ed-end user's electricity demand from V2G Program, in kWh; Edmax-maximum end user's electricity demand from V2G Program, which can be obtained from V2G charging points, in kWh; k-reserve level; the authors suggest that k-factor should be limited: 1 < k < 1.1. Taking into account that not every uEV participant will perform the V2G service by arriving at EndUs and discharging its vehicle, the probability of performing such a service P(A) should be considered. Therefore, the energy delivered by the uEV to the EndUs can be determined as follows: where: P(A)-total probability of providing V2G service; EV2G,t+-expected energy delivered to the end-user in time t. Thus, it can be concluded that: , ≤ E The problem that needs to be solved in this V2G service model is to find a number of uEV , such that the energy delivered to the consumer is not less than that specified by the EndUs.
where: Ed-end user's electricity demand from V2G Program, in kWh; -estimated number of electric vehicles expected to be involved in establishing V2G Service provision, considering the probability of service provision; P(A)-total probability of providing V2G service; eV2G+,n-energy flow injected by n-th electric vehicle; E'V2G,t+-expected energy delivered to the end-user in time t, which covers the reserve resulting from the probability of service provision P(A) < 1.
In theory, it can be stated that the number of bi-directional charging points should be equal to the number of EV. That would mean that every car that provides V2G service at the moment t should have its own dedicated charging station and additional facilities should be provided in case of a temporary increase in electricity demand. However, the data on the number of EVs to provide the V2G service are not sufficient to determine how much actual energy can be delivered to the EndUs. The probability of providing such a V2G service should be taken into account. This probability will depend on three simultaneous random events-on the side of the customer P(EndUs), on the side of the operator P(V2Gsp), and on the user EV P(uEV). This is defined by Formula (10).
where: P(A)-total probability of providing V2G service; P(EndUs)-probability of providing V2G service by end-user; P(V2Gsp)-probability of providing V2G service by V2G Service Provider; P(uEV)-probability of providing V2G service by V2G Participant. Each of these events contains different elements specific to the type of V2G Program Participant. Individual probabilities for given users have been defined by Equations (11)- (13). It should be stressed that in this article, the authors have attempted to develop a concept of mathematical notation of the V2G Service; however, the aim of this article is not to define specific values of the described probabilities.
where: P(FEVSE)-probability of failure of a bi-directional charging point; P(DPL)-probability of the availability of V2G charging point at the place of service delivery.
( 2 ) = 1 − ( ) where: P(FS)-probability of failure of a metering and billing system. It should be noted that the metering and billing system has to be designed for operational reliability, so that the P(V2Gsp) function is approximately equal to 1.
where: P(EC)-probability of the user's reaction to providing the service at a given time-e.g., receiving an economic incentive; P(USEV)-probability of using the electric vehicle; P(INT)-probability of service interruption. The most extended is the probability function of the service execution by a V2G (uEV) participant. This is due to many variable factors, whether the user of the electric vehicle will want to perform such a service. The most important element in Equation (13) is the probability of the user's reaction, e.g., after receiving an appropriate economic incentive (P(EC)). This will mainly depend on whether the uEV will discharge its vehicle. Determining this value will be key to assessing whether V2G services may become potential future ancillary services and should be estimated for local conditions and continuously improved in the course of the V2G Program operation.
Based on the aforementioned equations, the number of vehicles that will be needed to cover EndUs demand can be determined. The service is then considered to be provided if and only if , is not less than Ed. Alternatively, fuzzy logic can be used to evaluate the performance of the service. Thus, the execution of V2G Service can be defined as EXV2G, which could be further treated as a fuzzy number. A fuzzy logic triangular membership function was used to describe this problem. The membership function µ(EV2G,t+) is defined by Formula (14).
From Equation (14), it can be concluded that a V2G service can be performed: • Not at all (when EV2G,t+ < EV2Gmin); • Completely (when Ed = EV2G,t+); • Partially (when EV2G,t+ < Ed); • Excessively (when EV2G,t+ > Ed), but it will be limited by the value of Edmax, which is the maximum energy that can be delivered from bi-directional charging points.

Search for Vehicles to Provide V2G Services
This section of the article describes the algorithm for the implementation of a V2G Service from the moment of obtaining information about such a service to the arrival of the vehicle and monitoring its discharge, from the point of view of V2Gsp. First, the energy needs of the customer to whom the service will be provided should be determined according to the Formulas (4)- (9). The next step is to place the location where the V2G Service will be provided on a map. For this purpose, it is necessary to define an area that will be described by certain geometrical coordinates. Let G denote the area in which the V2Gsp operator works. In this area, points can be distinguished such that: where: xG and yG are the geometric coordinates of the selected point g.
In order to represent the location on the map, a grid of 1 km squares must be created. The area can therefore be described as consisting of NG squares, which can be described by the following relation: knowing that: and: where: xGmax and yGmax are the boundary values of the area. Then, it is necessary to define the location of the facility where the service will be provided. Let L denote the point in area G where the V2G service should be provided. Thus, it can be described by the coordinates ( , ) ∈ . The next step is to describe each V2G Program Participant (uEVi) in the area G. Each participant is assumed to have a single unique electric vehicle. Let be the set of vehicles that are part of the V2G Program in the area of operation of V2Gsp. Therefore, each uEVi must fulfil the following relation: From the V2Gsp point of view, the most important information that should be submitted by an electric vehicle via a remote communication system is: The search for vehicles to be used for the provision of the service will take place in particular zones Zn. Successive search areas will consist of NG1 squares, according to the following equation: In addition, the zone Zn will be defined by the following number of grid squares: knowing that ≤ and ∈ . While running the algorithm, it should be assumed that the first square i.e., n = 1 contains the point ( , ). In case the number of EVs in this square is not sufficient, one moves to the next zone i.e., adding one square to the point of each vertex of the first square. If one square is outside the area G, this square should be ignored in the calculation of the number of EVs. A sufficient number of EVs should be understood as the number of vehicles , which will allow to supply the demand of the EndUs customer at point L, considering the probability of service provision. Figure 4 shows an example of the determination of three zones for the tested algorithm. The next step of the algorithm is to assign the number of EVs that are in a given zone. Assume that the number of vehicles in a given zone is . Thus, it is necessary to make a check whether the energy provided by vehicles is sufficient to meet the demand Ed. If the energy delivered by a certain number of vehicles in a zone is less than that is estimated to cover the demand, one should proceed to search in the next zone Zn while increasing the number of grid squares in the search area. If, in subsequent iterations of the algorithm, one of the grid squares is outside the area G, assign it a value of = 0, which implies an energy delivered by a vehicle equal to 0. This process can be written in the following pseudo-code: The result of this part of the algorithm should be the obtained number of electric vehicles that can potentially provide V2G service to the end user . Figure 5 shows the first part of the algorithm for finding uEV participants to provide V2G service.

Selection of Vehicles to Provide V2G Services
The next step is to create the set of vehicles that was identified after the operation of the first part of the algorithm. Let denotes such a set of vehicles. The relation between the number of vehicles that can potentially provide V2G services , and the set can be represented as follows: Therefore, it can be concluded that the set of electric vehicles that can potentially provide a V2G service to a customer will be a matrix (24) with the number of rows equal to and 11 columns, which is derived from the vector .
Afterwards, a ranking of the users that are in the search zone of the operator should be created. Each record in the aforementioned ranking will be described by the following vector: whereby: Maximum discharge power: , . Considering the assumptions of the presented V2G Program, which are described in Section 4.1, the participants that have chosen the service delivery mode as mandatory-uEVman-must be selected first. These users must be identified first to provide the service, since their remuneration depends not only on the service itself, but also on their availability to provide the service. Users who have chosen the optional mode-uEVop-will be considered in second order. Therefore, in the matrix , the first rows from the top (symbolizing the highest-ranking position) will be held by vehicles with parameter , = 2. In each user group ( , = 2 or , = 1), the following sorting rules will be applied: 1. DIST : min → max; 2. C , : max → min; 3. ts : max → min; 4. P , : max → min.
The next step involves finding the appropriate number of uEVRi to whom the request for V2G service will be sent. Let , denote the number of vehicles/participants in the matrix . The general relation that must be fulfilled to proceed the algorithm is: where: -estimated number of electric vehicles expected to provide a V2G service to an end user, considering the probability of service provision.
The key process at this point is to determine the number of uEVman, since by definition these users must be available to provide the service. It is worth noting that it may be the case that all users providing V2G service belong to the Mandatory mode. In that case, the highest guarantee of service performance is obtained, due to the potential penalties that non-performance of the service may bring. An example of such a situation is shown by the Equations (27) whereby: < < < and = , however , > , . In case the number of uEVman will be less than the number of vehicles required by the end user to provide the service (N REQ EV), participants that belong to the Optional mode should be involved. Due to the voluntary nature of V2G services in the Optional mode, V2Gsp should send a request to more uEVs than required. This relation was described by the probability of providing the service by uEV-Equation (13). An example of this situation is shown with the Formulas (29) whereby: < < < and = , however , > , . V2Gsp therefore sends a request to uEVop and a call to uEVman so that the total number of vehicles queried is equal to . After sending a service request to uEVop and a call to uEVman, V2Gsp waits for the response from the program participants and then receives the number of accepted requests and calls. Let this number be denoted by , . The next step is to check the relation: If relation (31) is fulfilled, then the process of selecting vehicles for providing V2G services ends. Two more cases need to be considered, when the number of accepted requests is less than the required number of vehicles (a) and when the number of accepted users is more than the required number (b).
For case (a) i.e., when , < , one should return to the matrix and then send a request to the next participants uEVRi. The activity should be repeated until the relation (31) is met.
A slightly different course of events occurs for case (b) i.e., when , > . In this case, a ranking should be arranged for uEVop only (uEVman must provide the service) according to the criteria as for the matrix . Then, participants who accepted but ranked in a way that does not classify them for service provision should be paid a remuneration or provided with some other form of benefit. The amount of this remuneration will not be given in this paper. The output of the second part of the algorithm is the validation if the energy supplied by the , of the electric vehicles ∑ , , is at least equal to the demand of the end user Ed. If yes, then one proceeds to the next part of the algorithm related to monitoring the arrival of uEVs at the facility. If not, a search for additional EVs is undertaken by creating a new ranking of vehicles again. Figure 6 shows part two of the operation of the algorithm for finding uEV participants to provide the V2G service.
After the selection process of the uEVs that have accepted to provide the service, the service delivery process follows. However, before the energy flows from the EV battery to the customer's power system, it is necessary to check whether the EVs have arrived at the location. If the indicated uEVs have arrived at the discharge point it is necessary to monitor the execution of the service, i.e., to monitor the electrical parameters of the discharge (power, voltage, remaining SOC). In case not all uEVs have arrived at the site, the repair procedure should be started. The first step is to determine the number of participants that did not arrive at the service delivery point N1NA. Then it is necessary to check how many of the participants belong to the group uEVman ( ) and uEVop ( ). For uEVman participants, one needs to calculate the fines that the participants will have to pay for not performing the service. It should be remembered that for these participants, the performance of the service is mandatory. After calculating the numbers and , it is necessary to summon the uEVop participants that have previously accepted the offer to provide the service. If such a participant decides to provide the service, then the compensation for their willingness to excessively provide the service is withdrawn. However, it is worth noting that the price of providing the service in the second iteration of the search is larger than in step 1. The authors suggest that this price should be larger by 10-20%. Next, V2Gsp checks again if the number of participants who accepted the ser-vice provision is sufficient. If so, V2Gsp monitors the uEV's arrival at the facility. Otherwise, V2Gsp has to create a new uEV ranking with the purpose of finding the missing number of vehicles . The ranking creation should follow the rules described in Section 4.3.2, with the variable replaced by in the Equations (23)-(30).

Case Study
This section will present a case study of V2G Program implementation within a sample V2Gsp operator area. It contains an area divided into a 6 km × 6 km square grid, in which 618 vehicles providing V2G services are randomly placed. The simulations assume that of the 618 EVs, 482 of them will be uEVop (optional mode) vehicles and 136 will belong to the uEVman group (mandatory mode). The random deployment is based on the fact that each grid square has a random number of vehicles assigned to it. In a real implementation, it can be assumed that the selected area may be an urban area with different population densities and locations of electric vehicles. The grid squares with a higher number of vehicles represent more urbanized areas, e.g., city centers, or areas with supermarkets or motorways. It should be emphasized that in the case of the analysis of real urban areas, maps should be created with the assigned number of vehicles for different times of the day when services will be provided. In this chapter, the implementation of the algorithm from Section 4.3 regarding the selection of vehicles for the service will be presented. It should be emphasized that the purpose of this case study is to validate the algorithm and is not to indicate specific values of EVs for actual locations. For such activities, it is necessary to analyze the movement of vehicles in a given city, every hour of the day. Figure 8 shows the V2Gsp operational area, with the square grid plotted in the coordinate system. Each square contains the assigned number of EVs participating in the V2G Program and indicates the service provision point L. Based on Figure 8, the location of the EndUs can be described by the following point L (2.9; 3.1). Next, it is necessary to determine the energy demand of the EndUs to be secured and to define the boundary conditions to determine the energy flux from one EV. Let us assume that the EndUs facility under consideration will be a food-driven shopping center with a Gross Leasable Area (GLA) of 80,000 m 2 . Based on the study in [63], it can be concluded that an average unit energy consumption value of Eavg = 272 kWh/m 2 a GLA is assumed for European countries. The same study also states that 20% of the energy consumption of such shopping centers is for air conditioning and heating (HVAC) [63].
The assumption of the case study is to find out how many electric vehicles will be needed to power the HVAC needs for 3 h per day-i.e., the peak demand days in summer between 12:00 and 15:00. Therefore, based on the aforementioned assumptions, the energy demanded by EndUs under the V2G Program Ed can be calculated: where: S-area of shopping center, in m 2 ; -annual energy demand for shopping center, in kWh; -hourly energy demand for shopping center, in kWh; -hourly energy demand for HVAC in shopping center, in kWh; -demand requested by EndUs, in kWh. = In order to calculate the number of vehicles required, it is first necessary to calculate the average value of the energy delivered by one electric vehicle. It has been found that the average value will be the best representation to estimate the number , because throughout the execution of the algorithm, at the end of each step, the relation is checked whether the energy delivered by the vehicles will be at least equal to the energy requested by the EndUs. In real applications, a prediction system consisting of real-time data collection from vehicles within a certain proximity to the location of the facility ordering energy from the V2G Program should be considered. Nevertheless, for simulation purposes, a formula considering average values has been used: where: -number of vehicles in the V2Gsp area; , -the average value of the energy delivered by 1 electric vehicle, in kWh.
Therefore, the values of energy injected into the grid eV2G+ were calculated according to Equation (1). Those amounts of energy will allow the V2Gsp estimate the energy potential of the uEVs in the searching area). The parameters SOCt,i, SOCf,i, and Ci were randomly selected for the whole set of EVs, taking into account previous research. The minimum capacity due to technical constraints was also selected based on previous global studies. A summary of the ranges of each value is shown in Table 3. Table 3. Parameters used in simulation of the proposed algorithm.

Parameter
Values Remarks Battery capacity Ci (kWh) [30; 60] Based on technical data of EV [64][65][66][67] and also [46] SOCt,i-current State-of-Charge (SOC) in the time t (%) [50; 90] Upper limit is defined by maximum SOC based on [46,68] SOCf,i-State-of-Charge required for the next journey (%) [35; 50] Estimated values that provide a range of EV at least 50 km, assuming that the average energy consumption of an EV is equal to 0.2 kWh/km [ Based on the values from the Table 3, the values of energy injected by electric vehicles in the area of V2Gsp 2 +,n were calculated. Then, according to the introduced assumptions, the average value of injected energy by 1 EV was calculated: According to the V2G service model presented in Section 4, the expected energy delivered to the customer 2 +, should include the probability of such a service. This means that sending a request to 82 V2G Program participants may result in not covering the demand requested by EndUs. It is therefore necessary to find the number of Program participants to whom the query must be sent in order to consider the probability of service provision. Table 4 shows the assumed aggregated values of the probabilities, as defined by Equations (11)- (13). Due to the lack of availability of widespread data, the expected probability values were assumed for the simulation of this case study. In the process of operation of the V2G Program in a certain area, V2Gsp should continuously collect data on individual random events, e.g., triggering of the service by uEVop. In the process of V2G Program implementation, this will be one of the biggest challenges for V2Gsp. Transforming Formulas (6) and (9), the estimated number of electric vehicles that will participate in the process of setting up and delivering the V2G service to the EndUs customer was determined: Based on the information obtained above, it is possible to proceed to the identification of the zones in which the search for vehicles will take place. According to Equations (21) and (22), successive zones will consist of a number of squares equal to Zn. Furthermore, according to the assumptions of the algorithm, the zone Zn = 1 will be located in a square with an assigned point of EndUs. In the case of area G from Figure 8, the zone Zn = 1 will be described by a square with coordinates [(2,3); (2,4); (3,3); (3,4)]. Further, based on Equations (21) and (22), the second zone Zn = 2 will be determined. Figure 9 shows the determined zones Zn = 1 and Zn = 2 in the area of operation V2Gsp.
As it is presented in Figure 9, the number of electric vehicles providing V2G services in zone Zn = 1 is equal to 38. Then, according to the presented algorithm, it is necessary to check how much energy the vehicles located in zone 1 are able to offer. Thus, using Formula (1), the total energy available from each vehicle in zone 1 was calculated: , = 763.20 kWh Therefore, the condition is not fulfilled: ∑ , ≥ as = 1500 kWh. Thus, it is necessary to proceed to check the number of vehicles in the next zone Zn = 2 and calculate the energy available from their batteries. In zone Zn = 2, there are 102 vehicles providing V2G services, which are able to provide 1934.91 kWh of energy. Therefore, the condition is met: ∑ 2 +,n =1 ≥ .
Next, one must assign the number of electric vehicles that can provide the service-N1EV. This number will be: The next step is to establish a set of electric vehicles, the number of which is determined by the N1EV parameter. The vector defining each vehicle is represented by Formula (20).
Hence it is possible to create a matrix : In the matrix , records that belong to Zone 1 and Zone 2 are separated by a black line. The next step is to create a ranking of vehicles that will be selected to provide the service . According to Formula (25), each record in the ranking will be described by the following vector: For example, a vehicle with ID EV167 and EV337 were identified: = EV167: Keeping in mind the established sorting order presented in Section 4, the ranking of electric vehicles is created. The matrix representing the ranking will have 140 rows, which results from the total number of uEVs in zones 1 and 2. Interestingly, there can be a situation when vehicles located in zone 2 will be higher in the ranking than in zone 1. There can be two reasons for this-the first one is related to the mode of service i.e., mandatory, and the second one is when the distance between EndUs and uEVs will be smaller for vehicles from zone 2, because the EndUs facility is located close to the border of zone 1. Equation (39) shows the arranged ranking of vehicles . Red indicates vehicles from zone 1 and blue indicates vehicles from zone 2.
By having the uEV ranking sorted, V2Gsp then sends a request to uEVop and a call to uEVman. It is known that the number of requests and calls sent must be equal to , i.e., V2Gsp should send a query to the first 116 uEVs in the ranking. Based on the input analysis, there are 35 vehicles in the uEVman group and 81 vehicles in the uEVop group. It is known that the required number of vehicles needed for the service is equal to 82, according to Equation (37). This means that out of the 82 vehicles in optional mode, only 47 vehicles are needed for the service. It was assumed that in the simulations, it will not happen that the number of vehicles that accept the service will be greater than the required number of vehicles i.e., 1 , > . Thus, in the simulation, uEVop vehicles were randomly selected without repetition, so that the condition in Equation (31) The final part of the algorithm's operation is to check that the number of vehicles that have been selected to provide the service is able to provide sufficient energy requested by EndUs: This means that the algorithm found the correct number of UEVs to provide the service to EndUs. It further calculated that the average service availability time is 5 h and 15 min and the average discharge power that is available for EndUs is 35.87 kW.
This case study excludes consideration of estimating the number of vehicles that did not arrive at the location indicated by EndUs. This means that a situation is assumed where all vehicles whose users have accepted the offer have arrived at the site. Monitoring activities should be implemented during the piloting of the V2G Program, during which surveys of how many vehicles have not arrived at the facility would be conducted. No financial penalties should be imposed during such inspections, only a reminder should be sent out for missed service.

Conclusions and Discussion
The paper presents an in-depth analysis of the state of development of the V2G technology, with particular emphasis on the possibility of its implementation in Polish legal conditions. It focuses on two areas that are necessary for the appropriate functioning of V2G or V2X technology in the power sector.
The first of these areas concerns legal conditions. Based on the information presented, it can be concluded that V2G technology in the context of legal regulations is still at an early stage of development. In order to effectively implement this technology, a significant modification of legislation will be necessary. In this paper, a number of modifications to the regulations that should be included in domestic legal acts were proposed. Nevertheless, the further research in this area should be done, due to the noted problem of the lack of legal and formal regulations regarding the billing of end users as well as V2G Program participants. Unfortunately, the forthcoming amendments to the Polish Energy Law do not contain adequate legal provisions for the implementation of the V2G Program. Therefore, it should be suspected that the possibility of implementation will have to wait, at least until the development of flexibility services. Then, perhaps, it will provide an incentive not only for current users of electric vehicles, but also for other people experiencing sustainable lifestyles, who will want to further expand their portfolio of measures to pursue climate neutrality.
The second area of the V2G technology presented in this paper is related to the author's concept of market mechanism based on the provision of ancillary services by EV users to end users. The aim of such approach is related to decrease of the risk of not delivering electricity to the end user. Bearing in mind that, according to the current legislation, DSOs are not allowed to provide ancillary services, a model was developed, in which the role of a broker between the end customer and the DSO is taken by another independent entity-the V2G Service Provider. It should be noted, however, that the planned changes at the European level will enable DSOs to order ancillary services or flexibility services. The DSO will then be able to take over the role of V2G Service Provider. While developing the concept of V2G Program, the novel business model of V2G service provision was proposed and an algorithm for vehicle selection from the V2G service provider perspective was designed. Considering the knowledge from previous literature studies, one of the biggest problems in the implementation of V2G or V2X technology is the high uncertainty in its execution. It is caused by the inability to predict the behavior of EV users, which are inherently random. The proposed model of the V2G service includes the probability of execution of such a service. Further work in this area should focus on the development of a correct method for obtaining data on random user behavior. It is also worth mentioning that in the algorithm, several mechanisms to ensure the full execution of the V2G service and mitigating the risk of undelivered electricity to the end user were proposed. Current research in the area of V2G technology should focus on developing economic viability analyses of the solution from the perspective of the end user, the V2G Program participant, and the V2G service provider.
To sum up, the concept of V2X technology is worth considering when Smart Grid technology emerges. It is a robust solution that can certainly help in the development of a newly designed catalogue of ancillary services available to both Transmission System Operators and Distribution System Operators. Setting aside the energy sector, V2G technology could become crucial in achieving the climate goals set by the EU. With the introduction of an appropriate legal framework, it will be possible to significantly accelerate the electrification of private transport, but also to stimulate citizens to create and develop energy communities aimed at sustainable development. V2X technology may be an ideal example of one of the ways to develop such communities, as well as an impulse for more efficient use of electric vehicles. Additionally, for many, it can serve as an additional source of income, as many companies providing services related to V2G technology can be expected to develop in the future, offering ever more innovative business models.
Funding: This research received no external funding.

Institutional Review Board Statement: Not applicable
Informed Consent Statement: Not applicable Data Availability Statement: No new data were created or analyzed in this study. Data sharing is not applicable to this article.

Conflicts of Interest:
The authors declare no conflict of interest