Adopting the Game Theory Approach in the Blockchain-Driven Pricing Optimization of Standalone Distributed Energy Generations

The importance of the distributed generations cannot be overemphasized. This ranges from the contribution to resilience down to the energy cost efficiency advantage at the consumers’ end. The distributed generations in some localities, however, lack connection to the utility grid due to the remoteness of the generation site. Certain benefits are, however, threatened. Thus, where there is no energy price regulation policy, fluctuations in energy prices could be the order of the day. This paper, thus, focuses on the transaction price optimization of the standalone distributed generations using the game theory approach. First, blockchain technology is incorporated in the energy transaction arena to bind prosumers and their energy transactions to a common platform. Next, for electricity price prediction, the linear regression algorithm is used to obtain the fitting equation from the current transaction data stored by the blockchain network. Using the fitting equation as the objective function, the particle swarm optimization (PSO) algorithm is used to achieve the proposed energy transaction price minimization and profit maximization. Finally, the individual hourly optimization results are fitted by a decision tree algorithm for instant referencing purposes in making energy best price transaction decisions. The individual results show that it is capable of constantly updating the optimized energy price in real-time based on the subsequent transaction records updated by the blockchain network.


I. INTRODUCTION
The optimal distribution and sale of generated electric energy is an important factor to both the prosumers and consumers. The consumers on the other hand primarily focus on receiving the generated energy at the most favorable cost while meeting the dynamic demands of the loads. Conventionally, the localized generations, ranging from the distributed generations to the coordinated microgrid system are connected to the main grid [1]. This allows seamless and bidirectional energy exchange between the utility grid and the localized generations. It, thus, enables a symbiotic relationship between the two generation entities. The localized generations help in supporting the resiliency and reliability of the utility grid during sudden supply disruption and supply shortfall, respectively [2], [3]. Also, it focuses on meeting the energy needs of consumers' loads as well as at their desired costs [4]. Thus, The associate editor coordinating the review of this manuscript and approving it for publication was Fabio Mottola . to achieve this, local operators design consumers' schedule which is intelligently managed by the electronic management system. Hence, time-varying energy tariffs in the conventional grid are consistently monitored and energies are mainly purchased and stored by the generation-deficient local operators at the off-peak tariffs. This is subsequently sold to the local consumers at lower costs during the peak demand intervals thereby meeting their price preferences. Purchases are also made by the local operators when the local generation cost exceeds the buying cost from the utility. This buying and selling of energy prompt diminished cost of local generations. The collective symbiotic benefits are tailored towards adequately meeting consumers' load demands [5]- [7] and friendly price preferences [8], [9].
The aforementioned benefits emanate from the symbiotic relationship between the local operators and the utility operators. This is due to the successful transactive nexus between the two entities. However, there are events leading to the possibilities of finding the standalone operation of localized generations in which case some of such benefits would consequently cease to apply.

A. LOCALIZED STANDALONE GENERATIONS
The standalone operation of the local generating sources could be ignited by two major factors. An unforeseen disruption could be experienced in the utility supply leading to an unforeseen blackout in the power supply task. The duration of such a blackout depends on the weight of the cause of the disruption, the affected power component, and the severity of the damage. For example, the Hurricane Maria disaster in Puerto Rico, in October 2017, threw Americans in shock leaving a collapsed energy grid and communication system [9], [10]. This led to unforeseen extensive darkness which lasted for an extended period. A connected local generation in such circumstance would be disconnected from the affected grid thereby operating in islanded mode to guarantee resilience to its local loads. Another factor that results in a standalone operation of localized generation is when its generation site is remote and thus too far away to accommodate the long distance to the utility site [11]. To evade extreme transmission costs and losses, local generations independently serve the residing loads in a coordinated fashion. In such a situation, such lost benefits due to standalone operation pose the local energy producers as apparent monopolists. It exposes prosumers to sole dependence on the local energy policy of the microgrids as well as individual policies among the individually owned and managed distributed generations. This affects the local consumers as they are mainly left with anxieties about energy transaction price control.

B. TRANSACTION PRICE CONTROL IN LOCALIZED STANDALONE GENERATIONS
The standalone operation mode of local generations introduces unshared energy transaction attention from the local prosumers. Consequently, in a locality with little or no energy-transaction-and-cost policy, prosumers and consumers would be susceptible to energy purchases at prices that are solely dependent on the individual producers' policy relative to other colleagues. Sometimes, where producers are quite limited, they could engage in group monopolistic practices which peg energy purchases at a common undesired price. Also, the time-varying energy prices as a result of peak and off-peak demands could remain largely unequal amongst producers. Similarly, season-varying generation costs could amount to undulating energy prices as a result of inconsistencies in individual producers' price decisions. Furthermore, due to uncertainties in the generation volume of renewable sources [12], different energy sources are combined, as well as energy storage systems, to boost supply reliability [13]. Each source, however, has a different generation cost, hence, arriving at a unified energy selling cost could be difficult due to lack of regulation policy. The collective resultant effect is that energy price fluctuations could be the order of the day. It requires bargaining expertise and experience in consumers to be able to achieve their load demand purchases at a fair price. Such a price would always be controlled by the real-time changes in the energy market price. Hence, a game theory approach is strongly required. This is to ensure that changes and irregularities in the real-time and future energy prices amongst sellers are constantly accommodated in the buyers' subsequent pricing decisions. This would require a chronological track record of the time-varying and seasonvarying energy prices in order to make accurate price-friendly decisions in the current and future energy purchases. Therefore, it becomes a huge task for individuals and needs to be addressed.

C. CONTRIBUTIONS OF THIS PAPER
Various researchers have contributed largely to the improvement and optimization of the supportive grids leading to the resiliency contributions to the main grid. Haider Jouma Touma et al [14] introduced the use of pricing techniques in the microgrid as an alternative to improve the grid resiliency using the demand side management. Its purpose however focused on improving the resilience of the microgrid. Hence, it instead considered the microgrid as connected to the main grid rather than standalone. Bishwajit Dey et al [15] proposed the use of electricity market pricing for optimal scheduling of distributed generations. Several hybrid optimization algorithms were employed, namely, The Grey Wolf Optimizer (GWO), population-based Sine Cosine Algorithm (SCA), etc. The work, however, is based on a reference with a connected parent grid. The standalone operation scenario was not covered. The improvement in the operation of islanded microgrid was considered in [16] but instead focused on the energy management system (EMS) optimization. The pricing system optimization was not considered. The method of making electricity price decisions in shore-side electricity price variations on an all-electric ship (AES) is given in [17]. A different method was rather proposed which entails the use of deep learning technic for electricity price prediction and a hybrid multiobjective algorithm for selecting the lowest prices. Various previous researchers have not given satisfactory attention to the price optimization in the standalone distributed electric energy generation.
This paper proposes an optimal electricity pricing system in the standalone operation of distributed energy generations for consumers' best price-making decisions. Taking advantage of the characteristic transaction data records offered by blockchain technology, this paper proposes blockchain technology as the energy transaction platform in the distributed generation arena. This presents the required energy transaction data with which the transaction model simulation and subsequent optimizations are performed. Blockchain technology was used to capture the transaction data (electricity buying and selling prices) among the participants in the transaction platform. Using this data, the electricity prices are modeled in hourly intervals for the 24 hours of the day. This is achieved using the linear regression algorithm, thus, the fitting equation is obtained for each of the 24 intervals of the day. The particle swarm optimization (PSO) is thereafter used VOLUME 10, 2022 to optimize each of the fitting equations to obtain the least buying price and maximum selling price. Finally, the decision tree algorithm is used to fit the best electricity prices for references. Hence, Section II comprises a brief introduction of blockchain technology and its purpose in the electricity trading platform. The three simulations of the three algorithms are performed in section III. Section IV contains the discussion of the results obtained in section III, while the conclusion is presented in section V.

II. BLOCKCHAIN AND THE DISTRIBUTED GENERATIONS A. BLOCKCHAIN TECHNOLOGY AND THE TRANSACTION FEATURES
Blockchain technology, which is initially applied in the financial sector, offers users a transactive platform under which decentralized communication takes place [18]. This is one of the promising features of the technology that accounts for the greater percentage of its admissibility in various sectors of the economy. It typically annuls the use of intermediaries in transactive communications amongst participants [19]- [21] such as those found in the centralized platform. This is as shown in Fig. 1. Fig. 1(a) represents the traditional transaction network in the centralized platform and Fig. 1(b) represents the decentralized transaction platform proposed by the blockchain technology. Here, each participant has direct communication access with everyone as shown in the green communication lines.
With Fig. 1(b), several bottlenecks associated with the use of intermediaries are evaded. For instance, the inherent transaction latency in the centralized transaction platform, as a result of the presence of an intermediary, is eliminated. Hence, transaction time amongst blockchain participants becomes shortened. Also, the gross security threat associated with gaining unauthorized access to the middleman is eliminated since there is no middleman.
First introduced in the year 2009 in the cryptocurrency domain for financial transactions, blockchain application has currently gained vast attention in several other fields of the economy. This ranges from the health sector [22], aviation industry [23], power sector [24], manufacturing industry [25], down to the private peer-to-peer transaction platform [26]. Several other benefits are tied to the wide admissibility of blockchain. The high level of security, transparency, and trust offered by the technology [27], [28] is quite promising. Various residing features account for such a remarkable achievement. For instance, an alphanumeric string, commonly known as a hash, is used to chain blocks of transactive data to one another [29]. Here, each block contains two hash keys in which one is shared with the immediately preceding block while the other is shared with the immediately subsequent block. This is as shown in Fig. 2(a). An unsuccessful attempt was made by an adversary to change the hash key of block 2 from 6BQ1 to H62Y in Fig. 2(b). It was consequently resisted by block 3 due to the hash mismatch in its block. Hence, to gain unauthorized access into each block means to gain access to the entire blocks since they are all chained together. This is almost impossible, hence, security is guaranteed in this manner. The transparency characteristic is achieved by the use of a consensus mechanism for transaction approvals. This generally entails the use of elected members to validate every transaction before they are stored in the blocks [30], [31]. Hence, every initiated transaction is treated equally. Furthermore, every completed transaction in the block is stored by every member of the consortium. This implies that each member possesses a copy of each completed transaction block as shown in Fig. 3. The transaction details of every transaction are also contained in each block. This accounts for the increased popularity and acceptability of blockchain technology in various sectors as its data cannot be tampered with even by its participants. This increases the trust amongst each participant knowing that every participant has the same transaction detail which cannot be altered.

B. ENERGY TRANSACTION IN DISTRIBUTED GENERATION ARENA
In this paper, the introduction of blockchain technology in the distributed generation arena is motivated by the inherent transaction data records feature of blockchain technology. This is to capture the stored data which would be used as simulation data in modeling the distributed   generation environment. The kind of detail recorded in each block depends on the type of transaction and the purpose of use [32], [33]. In the distributed energy generation arena, the generated electric energy is transacted amongst the individuals. Hence, the transaction data would contain details such as the cost and quantity of energy purchased, its seller and buyer, as well as the date and time of transaction. This is as shown in Fig. 4. In our paper, the buying and selling data of transacted electric energies are collated and subsequently used to perform simulations in section 3.

III. TRANSACTION DATA AND SIMULATIONS IN THE DISTRIBUTED GENERATIONS
We consider the peer-to-peer energy transactions amongst participants of the blockchain network in the standalone distributed generation platform. We consider nonintegrated distributed generations. Since the facilities are individually owned and managed, and there is no local control policy, price regulations are almost nonexistent. Also, since there is no supply from the utility grid to regulate electricity prices amongst local producers, producers would sell according to the cost of generation and the preferred profit margin. Hence, different producers would transact at different prices at different time intervals. Consequently, fluctuations in electricity prices would rather be the order of the day. Hence, we propose a model to achieve a minimum buying price among the market prices and maximize profit. This is achieved by the use of a game theory approach whereby the outcome of the price minimization depends on the varying transaction prices. Because energy prices vary depending on the time interval of the day, we perform the modeling in each hourly interval of the day. Thus, this amounts to 24 different simulations representing 24 hours of a day. Therefore, energy demands and the corresponding trading prices recorded by the blockchain network are used to simulate the transaction model of the platform.

A. TRANSACTION DATA PROFILING
To demonstrate our method, an hourly sample data of 24-interval energy demand and the corresponding trading prices in South Korea as contained in [34] is used to perform  our simulation. This represents data in each of the 24 hours of the day as shown in Table 1.
This has 3 fields made up of hourly time intervals, t; electric energy selling prices, P sell ; and quantities sold, Q sell . To generate different instances of transactions, say 15 instances for each of the 24-time intervals, random numbers are used to generate each of P sell and Q sell . The instances are made up to 15 so as to generate adequate transaction data with which regression analyses would be performed. This is to obtain the underlying relationships among the transaction data. The random numbers are introduced to model the following: (i) the stochasticity in producers' price variations in energy prices and (ii) the stochasticity of consumers' decisions in making energy purchase demands. For P sell , the selected lower and upper range of its random values are P sell − 1 and P sell + 1, respectively. This is as shown in Table 2(a), column 3. Similarly, for Q sell , since 15 instances of transactions are considered (rather than 1), each of the values is divided into 15 (Q sell /15). These represent 15 energy transactions. It is denoted as Q sell in Table 2(b), column 3. The price of energy would conversely remain unaffected no matter the number of times it is purchased, i.e., it is not cumulative. To generate different random values of Q for each of the 24-time intervals, the lower and upper ranges are selected as Q sell − 1 and Q sell + 1, respectively. Its generated values thus lie within these bounds as shown in Table 2(b), column 4.
Furthermore, random values of the buying price and quantity bought are generated in a similar suite. The same values as in Table 1 are used. The values are however distinguished from the selling price values using the random number seed. Thus, for each of the 24-time intervals, different seed values of same-range random numbers are used to generate the buying and selling values of energy. This is done at 15 instances of transactions.
For each of the 24 intervals, the random number generation seed values for the electric energy buying and selling prices and their corresponding quantities bought and sold are given in Table 3. For example, to generate the energy selling prices at interval-1 (1:00 hr) in 15 instances (in 2-decimal values), the simulation codes in Fig. 5 are used in Python. Line 2 seeds the generated random values with 10 (see table 3, interval-1). Line 3 generates the random values of selling prices at 15 instances. Since the range of the selling price values for interval-1 is 129 Won/kWh -131 Won/kWh (see table 2(a), interval 1), line 4 generates the result within this range and limits the decimal places of the generated values to 2. Thus, this implies that, at time 1:00 hrs, 15 different quantities of energy were sold at 15 different prices ranging from 129Won/kWh to 131Won/kWh. Similarly, at the time of 14:00 hrs, 15 different quantities of energy were bought at 15 different prices ranging from 138Won/kWh to 140Won/kWh (see table 2(a), interval 14). The corresponding simulation codes are given in Fig. 6. Line 2 seeds the generated random values with 37 (see Table 3, interval-14). Similarly, at time 24:00 hrs, 15 different quantities of energy were sold ranging from 13.87 kWh to 15.87 kWh (see Table 2(b), interval 24). The simulation codes are shown in Fig. 7. Line 2 seeds the generated random values with 56 (see Table 3, interval-24).
The random seed values were arbitrarily selected and used to obtain the transaction data. These include the buying prices, selling prices, and the corresponding quantities bought and sold. This aids reproducibility of this paper. The modeling and simulation of the profiled transaction data are thereafter performed.

B. TRANSACTION MODEL SIMULATION
The transaction model is simulated using the available transaction data. Simulations are performed in 3 steps. First, the transaction data are simulated for pattern recognition. This is to obtain the equation of the relationship between the input and output data. Secondly, the obtained relationship equation is used to optimize the model. Finally, the optimized model is fitted using the decision tree algorithm for instant referencing during best-price-decisions.

1) PATTERN RECOGNITION SIMULATION
In our simulation, the buying and selling prices represent the output data while the corresponding energy quantities   represent the input data. Since the input and output data are two folds, these are segmented into two-phase simulations. The first phase contains the buying prices and the corresponding energy quantities bought. The second phase comprises the selling prices and the corresponding energy quantities sold. Considering the first phase, the plot of the graph of the buying prices and corresponding energy quantities is shown in Fig. 8. This comprises a 2-head (first two intervals -intervals 1 and 2) and 2-tail (last two intervals -intervals 23 and 24) data visualization. From Fig. 8, since the input and output data maintained a linear relationship, the linear regression algorithm is used VOLUME 10, 2022 to model the transaction data to obtain the fitting equation. The buying prices (P buy ) were thus modeled with the corresponding energy quantities (Q buy ) using the linear regression algorithm. Because the energy prices vary based on time of use (TOU) [35], [36], each of the 24 hourly intervals has different price values. Therefore, the modeling is performed individually for each of the 24 hourly intervals, thus 24 times. The general equation of the obtained fitting formula is of the form presented in (1).
where m 1 is the rate of change of P t buy in the first phase with respect to Q t buy , k 1 is the graphical intercept on the P t buy axis in the first phase, and t = hourly interval under consideration (ranging from 1 to 24). Hence, the equations range from P 1 buy = m 1 Q 1 buy + k 1 to P 24 buy = m 1 Q 24 buy + k 1 . Similarly, for the second phase of the simulation, the plot of the graph of the selling prices (P sell ) and the corresponding energy quantities (Q sell ) is shown in Fig. 9. This comprises a 2-head and 2-tail data visualization. Likewise, its general equation is of the form given in (2), and ranging from P 1 sell = m 2 Q 1 sell + k 2 to P 24 sell = m 2 Q 24 sell + k 2 .
where m 2 is the rate of change of P t sell in the second phase with respect to Q t sell , k 2 is the graphical intercept on the P t sell axis in the second phase. It is necessary to mention that the modeling algorithm, linear regression, selected was based on the kind of relationship (linear) discovered among the trading data. Other algorithms could be selected depending on the input-output relationship in the modeling data. For instance, if the input-output data had rather maintained exponential, polynomial, logarithm, etc relationships, their respective model equations would be selected instead.
By multiplying through (2) by Q t sell , (7) is obtained.
By putting (6) in (7), (8) is obtained.  Considering (5) and (8), P t buy Q t buy and P t sell Q t sell represent cost component and profit component, respectively. Therefore, both are combined and optimized by minimizing the cost component and maximizing the profit component. This is achieved by minimizing the positive component of the cost and minimizing the negative component of the profit. The emerging expression and function equations are given in (9.1) and (9.2), respectively with associated constraints given in (10).
Taking P t buy Q t buy − P t sell Q t sell = M t , where M = objective function = f (P buy , P sell ), The functions M 1 -M 24 are subsequently optimized in the following section to obtain the optimal trading prices in each interval at which minimum costs and maximum profits are achieved.

2) OPTIMIZATION OF ENERGY PRICES
The optimal trading prices are achieved via optimizations of the objective functions, M 1 -M 24 . Following the heuristic characteristic price variations in the energy trading platform, the PSO algorithm is used for the optimal trading price determination. It is used to achieve optimizations in each of the hourly intervals. Several particles are consequently deployed to locate the optimal points in the individual functions. Given each particle's initial position as X i , the new position, X i+1 , is given in (35). where V i+1 is the new velocity with the expression given in (36).
where w = particle's weight inertia, V i = particle's initial velocity, c 1 and c 2 = particle's acceleration coefficients, P b = particle's local best position, P g = particle's global VOLUME 10, 2022  position, P g . This represents the point of optimal result and was recorded for each interval.

3) DATA FITTING OF OPTIMIZED PRICES
For convenient reference, the optimal results of the trading prices obtained in each of the 24 hourly intervals are subsequently fitted. Because energy prices vary based on TOU, the various optimized results vary in each of the 24 intervals leading to a non-linear relationship. Hence, the data is modeled and fitted using the decision tree algorithm in section IV. Its goal is to predict the target variable, hourly optimized price, and represent the results in tree form. Fig. 10 shows a flowchart representation of the three simulation sequences as implemented.

IV. ANALYSIS OF RESULTS
Having performed the three sequential simulations, the results of the PSO-optimizations are presented in Fig. 11, Fig. 12, Fig. 13, and Fig. 14, and Table 5. The data fitting of the optimized result is thereafter presented in Fig. 15(a) and Fig. 15(b). Fig. 11 -Fig. 14 sequentially show particles' swarm in 2-head and 2-tail graphical visualization leading to the optimized results. The tuning parameters, the respective resulting global best particle positions (optimized prices), and their corresponding values of the objective function are shown in Table 5.
From Fig. 11, it is seen how 10 deployed particles that were originally at their initial positions in Fig 11(a) converged more to the new positions in Fig. 11(b) during the search process. They eventually converged fully in Fig. 11(c) leading to a global optimum position. This took place in the 1st-hour interval. Similarly, in Fig. 12, 10 deployed particles that were originally at their initial positions in Fig 12(a) converged gradually to the new positions in Fig. 12(b) in the search space. They eventually converged fully in Fig. 12(c) leading to a global optimum position. This took place in the 2nd-hour interval. A similar particles swarm optimization was recorded in Fig. 13 and Fig. 14 for the 23rd and 24th-hour intervals, respectively. The values of the tuning parameters in table 5 (c 1 , c 2 , w, and I) were gradually increased, ranging from (a) to (c), in each step of the simulation process. This is to be able to graphically visualize the particles' sequential swarm positions before reaching full convergence. The selected values of the tuning parameters are noticeably quite small. This is because of the little search space within the upper and lower limits of the variables to be optimized. Selection of larger values would result in particles jumping over (ahead and behind) the global optimum during the swarm (search) process. This, it would continue to do without reaching convergence.
The resulting optimal trading price for each hourly interval is summarized in 2-decimal values in Table 6. From Table 6, it can be observed that the values are nonlinear across the hourly intervals. Therefore, to accurately fit the trading data to the hourly intervals, a nonlinear model, DecisionTreeRegressor (DTR) algorithm, is used. This is as shown in Fig. 15(a) and 15(b) for the 24 hours selling and buying prices, respectively. Focusing on the price range control, the selling prices (Fig  15(a)) are only used for a reference purpose to be informed of the current market peak selling price in each time interval. The focus lies on the minimum buying price (Fig 15(b)) with which the maximum cost (per unit kWh of energy) is saved. This would also serve as a price control strategy which replaces the pricing control function of the nonexisting traditional grid. Regarding the tree, four parameters could be seen in each block. The first is the time interval. Next is the mean square error (mse) obtained from fitting each of its two branches. Following is the number of samples fitted by the block. This is equivalent to the summation of the samples in its two branches. Final is the value of the resulting fitted outcome (optimal buying price). As an alternative to the trees, their underlying models can be used to make a prediction of the optimal buying price and/or selling price in any of the time intervals ranging from 1 to 24. The time intervals represent the explanatory variable while the buying and selling prices denote the response variable.

V. CONCLUSION
Controlled trading of standalone remote energy generations enables the local consumers to adequately and conveniently meet the energy demands of their load system. Since there is no better-of cost-effective alternative to regulate the energy purchase prices, sole consumers are restrained to frequently venturing into buying energies at the existing cost. The enterprising activities of prosumers and middle traders however result in energy price fluctuations. Our contribution profers a method of achieving cost-effective market prices for both buyers and sellers. This updates a consumer on the best price choice given fluctuating market prices. This is to make the best price decision. Sellers would also be informed of the real-time upper and lower price ranges per kWh which helps in deciding a suitable selling price. The entire practice would aid greater penetration of the generated energy via the price convenience achieved among buyers. Furthermore, it would ensure price stability. Thus, the inherent price regulation feature of the nonexisting conventional grid is recovered. Consequently, the monopolistic tendency in the energy sellers would plummet resulting in greater competition, instead. The blockchain-offered transaction platform would also assist producers to suitably adapt to users' load profiles in the generation schedule following the purchase history of individuals recorded by the blockchain network.