Next Article in Journal
Two-Stage Optimal Scheduling of Highway Self-Consistent Energy System in Western China
Previous Article in Journal
A Position-Insensitive Nonlinear Inductive Power Transfer System Employing Saturable Inductor
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Peer-to-Peer Energy Trading through Swarm Intelligent Stackelberg Game

by
Chathurangi Edussuriya
1,*,
Umar Marikkar
2,
Subash Wickramasinghe
3,
Upul Jayasinghe
4 and
Janaka Alawatugoda
5,6
1
Department of Computer Science, Aalto University, 02150 Espoo, Finland
2
Department of Electrical and Electronic Engineering, Surrey University, Surrey GU2 7XH, UK
3
Department of Electrical and Electronic Engineering, Faculty of Engineering, University of Peradeniya, Peradeniya 20400, Sri Lanka
4
Department of Computer Engineering, Faculty of Engineering, University of Peradeniya, Peradeniya 20400, Sri Lanka
5
Research & Innovation Centers Division, Faculty of Resilience, Rabdan Academy, Abu Dhabi P.O. Box 114646, United Arab Emirates
6
Institute for Integrated and Intelligent Systems, Griffith University, Nathan, QLD 4111, Australia
*
Author to whom correspondence should be addressed.
Energies 2023, 16(5), 2434; https://doi.org/10.3390/en16052434
Submission received: 25 January 2023 / Revised: 17 February 2023 / Accepted: 21 February 2023 / Published: 3 March 2023

Abstract

:
The development of smart grids has paved the way for sustainable energy infrastructure to transition towards decentralized energy trading. As intelligent agents, energy sources engage in energy trading based on their energy surplus or deficit. Buyers and sellers (participants) should achieve maximum payoffs in which buyers cut costs and sellers improve their utilities, and the security of sensitive information of smart agents must be guaranteed. This paper provides a blockchain-based energy trading network where intelligent agents can exchange energy in a secure manner, without the intervention of third parties. We model energy trading as a Stackelberg game, ensuring that the platform maximizes social welfare while participants increase their payoffs. Using the inherited characteristics of blockchain technology, a novel decentralized swarm intelligence technique is applied to solve the game while ensuring the privacy of the smart agents’ sensitive information. The numerical analysis demonstrates that the suggested method outperforms the present methods (Constant Utility Optimization, average method...) for optimizing the objectives of each agent by maximizing the sellers’ utilities and reducing the buyers’ costs. In addition, the experimental results demonstrate that it significantly reduces carbon footprint (15%) by enhancing energy exchange between intelligent agents.

1. Introduction

With the introduction of the smart grid, distributed energy resource (DER) power transfers have become increasingly advanced. This evolution requires intelligent devices that can generate and inject energy into a system. Prosumers, also known as intelligent devices, are connected to distributed energy resources (DERs). The devices generate excess energy and experience energy deficiency in the future according to energy production. Peer-to-peer energy trading enables prosumers to exchange energy without the intervention of a third-party vendor in a decentralized manner. Utilizing a wide range of energy sources, peer-to-peer energy trading can assist in maintaining a balance between energy production and consumption [1].
Few smart grid pilot projects incorporating peer-to-peer energy trading have been implemented. The FIT and MicroFIT [2] programs in Ontario, Canada, have successfully encouraged residents to participate in renewable energy projects. Denmark and Germany are market leaders in decentralized energy trading, with the largest national and international smart grid deployments [3]. However, this sustainable mechanism still faces significant obstacles in its complete implementation of decentralized energy trading.
Multiple buyers and sellers engage in peer-to-peer trade, with the goal of the seller being to increase profits and the goal of the buyer being to reduce expenses. A thorough market model should optimize the goals of each prosumer while facilitating transactions. In addition, the power trading mechanism should preserve the privacy of participants, as the proposed market model would require prosumers to reveal private information such as satisfaction and price sensitivity. In order to develop a fair market, it is necessary to verify the transparency and honesty of transactions. The trading method must be scalable, meaning it must not fail as the number of participants increases. Thus, a secure decentralized energy trading platform resistant to a single point of failure should be implemented while protecting users’ sensitive data.
In a smart grid, the immutable, tamper-proof, and transparent blockchain architecture offers a comprehensive solution for peer-to-peer energy trading. Through Bitcoin [4], Satoshi Nakamoto introduced blockchain technology, which facilitates transactions between unreliable parties. Beyond cryptocurrencies, blockchain technology has been widely used by decentralized distributed systems such as peer-to-peer trading platforms.
Over the years, numerous blockchain-based platforms that integrate IoT devices have been established [5,6]. The decentralized peer-to-peer architecture of the smart grid can be realized utilizing the same concepts as blockchain-based IoT devices. Moreover, smart grid systems make use of the diverse services offered by blockchain technology.
Intelligent devices serving as consumers on the trading platform can connect to the blockchain, verify their identities, and trade energy on the blockchain-enabled platform. The use of blockchain technology will make it possible to verify the identity of each customer and ensure that all transactions are conducted in an honest and trustworthy manner.
Blockchain technology provides a crucial service for cryptocurrencies. They can be utilized as energy tokens to support smart grid transactions without the requirement for a third-party source. Hence, it enhances transaction efficiency and reduces transaction costs. DeepCoin is an energy framework that supports energy transactions through the use of blockchain and tokens. In addition, it presents a strategy based on deep learning to identify intrusions using Recurrent Neural Networks (RNN). A blockchain framework is provided in [7], with a market structure based on the marginal pricing of end-users while meeting the power system requirements. In [8], the details retrieved by smart-metering devices are kept in a tamper-proof manner in the blockchain. Smart contracts describe the rewards and penalties connected with each prosumer within this framework, which is built on the Ethereum blockchain. The operation of crowd-sourced Energy Systems (CES) with peer-to-peer energy trade transactions is conducted through a blockchain-based architecture in [9]. In this paper, a three-part operational method is designed for scheduling peer-to-peer energy generation and exchange in distribution networks, with day-ahead, hour-ahead, and real-time time horizons. Energy is traded in [10] via a mechanism for forming blockchain coalition. In the study, multiple coalition formation algorithms are conducted asynchronously. It reduces the time required to communicate with other microgrids. Using machine learning and blockchain technology, [11] proposes a blockchain-based platform and a smart-contract-enabled predictive analytics module. This platform accurately forecasts the short-term energy consumption necessary for making future resource management decisions based on historical energy consumption data. In [12], the privacy of prosumers is safeguarded by encrypting bids using a smart contract based on functional encryption. Nevertheless, the analysis of energy exchange pathways has received less attention in the aforementioned studies.
In a smart grid, the behavior of intelligent devices is varied and complex. The interactions between agents lead to outcomes that vary according to the agents’ individual preferences. Game theory can be utilized to arrange the dynamic characteristics of prosumers through strategic analysis. While the existing state of the art provides market models, the unique capabilities of blockchain technology have not been completely used to develop market models that protect user privacy and increase consumer profitability.
Peer-to-peer energy trading has been extensively studied by researchers [13,14,15,16,17]. Game theory is beneficial in many fields to technology including artificial intelligence and Wireless Sensor Networks (WSNs). The method of employing game theory in WSNs is adaptable to the application of game theory in smart grids [18,19,20,21]. Game theory has been widely used to model prosumer behavior and market structure of the smart grid. The strategic interaction between participants can be modeled as a game by examining the psychological behavior of traders. The [13] outlines game-theoretical concepts applicable to the smart grid. Before engaging in energy trading within the framework, the participants must demonstrate their willingness. In the smart grid, a market model for DERs, energy storage systems, and electric vehicles is created by placing consumers first. For power management, [14] employs a Stackelberg game and Lyapunov optimization, utilizing multi-objective optimization in clusters to reduce power consumption and scheduling delay. By imitating the structure of the stock market, [15] creates a strategy for maximizing profits. For simulation convergence and diversion, a multi-agent energy simulation framework with three types of agents and three related models is utilized. Using economic indices, the proposed system is evaluated. A general Nash game is utilized to solve the market-clearing process in [22]. Agent privacy is maintained without having to disclose sensitive information. The notion of “absorbable region” is introduced to illustrate the adaptability of the strategy in comparison to the centralized approach.
Many strategies have been implemented for energy trading on the smart grid. Bilateral energy trading is the direct exchange of energy between market customers without the use of intermediaries. As buyers and sellers engage in direct communication, transaction costs are reduced. Bilateral energy trading gives prosumers greater control over their transactions. However, because there is no central governance, energy trading could be highly risky. Energy trading is also possible in a fully peer-to-peer market. It is possible to trade more locally sourced energy and transaction costs could be reduced, but it could also increase transaction risk. Microgrid technology is another energy trading technique. It promotes energy supply independence and resilience, and facilitates the incorporation of renewable energy resources. Indeed, it bears substantial maintenance and capital expenditures.
Several interfaces are needed to link multiple peers inside a decentralized system. In a fully peer-to-peer approach, all peers connect directly with one another, with no central authority or intermediary. It requires a network interface (peers connect via a network), a payment interface (which allows peers to transfer funds), and a data interface (enables peers to exchange data related to energy consumption and production). In a peer-to-peer community approach, peers are organized into smaller groups or communities that are linked via a central platform. In addition to the interfaces specified in a fully peer-to-peer system, a community peer-to-peer system requires a platform interface (which allows peers to access a centralized platform). The hybrid peer-to-peer model combines the community and fully peer-to-peer approaches. Peers are fully peer-to-peer connected, but they are also connected to a central platform. This includes all interfaces of the community peer-to-peer paradigm.
Researchers in recent studies have made use of a method known as Continuous Double Auction (CDA), which is a method for modeling markets. Because both buyers and sellers submit bids for quantity and price, the auction method is called a double auction. In energy scheduling, the process occurs continually. The CDA facilitates the effective allocation of resources and the discovery of prices, whereas it inequitably distributes resources among participants. Double auction and game theory are utilized in [16]. The authors describe an algorithm based on the Stackelberg game that illustrates market participant behavior. The technique of double auctions determines the clearance price, which is the price for energy units at the auction. The [17] outlines the application of a double auction method in a Low-Voltage Network. This article describes a technique that enables energy exchanges without breaching network restrictions.
The primary purpose of the double auction process is to determine the market’s clearing price. Utility theory is crucial in determining the clearance price. The utility function expresses the player’s double auction choices. In a few studies, the utility function is regarded as linear; however, utility functions can also take on a nonlinear shape. In addition, it is assumed that all participants in the double auction mechanism have the same utility functions [7,16,23]. In reality, however, the utility functions of buyers and sellers are distinct.
An energy trading mechanism’s ultimate goal should be to raise the platform’s overall social welfare while increasing participant profits. Because prosumer data raises concerns about privacy and secrecy, most state-of-the-art technologies are unable to achieve this goal. In our work, we propose a solution to this issue. In addition, intelligent grids should encourage sustainable energy generation by enhancing localized energy exchange and decreasing energy obtained from the major power grid. The majority of the primary energy grid is fueled by nonrenewable energy sources with significant carbon emissions. Our research enhances the local energy unit exchange, hence decreasing the carbon footprint of energy derived from the primary grid. In addition, architectural considerations should be made for decentralized communication on an energy trading platform as opposed to a centralized architecture, with security implications being the most important. The implementation of these design requirements is explained in the subsequent Section 2.
In accordance with the aforementioned objectives, a secure energy trading platform based on game theory and blockchain technology is created. The following is an overview of the contributions of the study.
  • Development of a peer-to-peer energy trading platform to facilitate the secure exchange of energy amongst prosumers.
  • Formulation of energy trading market models as a Stackelberg game involving prosumers, and explanation of the existence of equilibrium in the suggested Stackelberg game.
  • Introduction of a novel method for winner determination of the game using a modified Cuckoo search algorithm and the architecture of blockchain technology.
  • Implementation of the proposed trading mechanism on the energy trading platform and a numerical study of the winner determination methods.

Organization of the Paper

Section 2 describes the developed energy trading platform. The structure of the market is explained in Section 3. Section 4 explains the energy trading process. The Stackelberg game and solutions to the Stackelberg game are elucidated in Section 5. The novel Swarm intelligent solution is described in Section 6. Section 7 gives the results of the paper. The conclusion of the paper is followed by the results section.

2. Peer-to-Peer Energy Trading Platform

2.1. Considerations for the Design of the Platform

This section highlights the design considerations that went into the development of the blockchain-powered platform.
  • Privacy—The specifics of an agent’s energy use, production, and exchange should not be disclosed to other agents. If other agents have access to this information, they can utilize it to build and design strategies.
  • No single point of failure—Agents are connected to the platform, and it is not governed by a central authority. If a system agent or node fails, other agents should not be affected.
  • Integrity—Malicious agents/nodes should not be able to profit from making faulty bids through deceptive conduct.
  • Authentication—The devices and agents connecting to the system must be correctly identified and authenticated.
All agents should have access to information regarding the transactions (energy exchange) that took place on the platform.

2.2. Overview of the Platform

This section provides an overview of the peer-to-peer trading marketplace for energy. In the majority of studies undertaken, energy trading systems are constructed with two layers: a blockchain layer and a market layer. The agents are solely connected to the market layer, while the blockchain layer stores transaction details. In the design, the blockchain serves just as a storage device, and its security capabilities are not fully employed. Moreover, malicious nodes are able to connect to the market layer, posing security risks to the smart grid, because the agents are not authorized by the blockchain. In our research, the platform consists of five layers. Figure 1 illustrates the integration between the different layers of the platform.
The infrastructure layer connects smart agents to devices such as Advanced Metering Infrastructure (AMIs) [24]. The AMIs are responsible for data collection, low-level grid control, and grid monitoring. With the AMIs, Hardware Security Module (HSM) is implemented to protect the hardware system from external threats such as unauthorized access and data manipulation. Through the integration layer, agents are connected to the blockchain. Separate security procedures are incorporated into the layer to prevent malicious devices from connecting to the platform. Each agent is provided with a security wallet holding digital certificates needed to validate the agent’s identity. The blockchain generates an unreplicable wallet once an agent establishes a connection to the platform. The wallet stores the certificate used to identify the HSM, whereas the HSM maintains the private key. The agents are responsible for making intelligent judgments regarding the devices, such as high-level monitoring, energy scheduling, and energy production forecasting. The blockchain layer is the platform’s primary actor. This layer is responsible for initiating and storing transactions, as well as authenticating agents and infrastructure. The market layer supports peer-to-peer energy trade between agents. As stated in Section 4, a smart contract with a swarm intelligent Stackelberg game is deployed to enable peer-to-peer energy trading.
With the aforementioned layered architecture, transactions can be decentralized and conducted securely. The agents initially notify the blockchain layer of their intention to connect to the platform. The blockchain issues a wallet that serves as the agent’s identity upon validation. Depending on energy demands, the agent may participate in energy trading cycles. If the agent determines that it will need energy or create excess energy in the period after t period, it may engage in the market for that specific time. After the market model determines the energy quantity and price, energy can be transferred from sellers to buyers, and buyers will provide sellers with energy tokens.

3. Architecture of the Market

3.1. Design Considerations of the Market

There are several factors to consider while designing the market for energy exchange between smart grid agents.
  • Decentralized communication—There are two mechanisms that can be used.
    Direct bargaining—Prosumers are capable of interacting directly with one another and reaching an agreement. In this mechanism, prosumers continually seek to maximize their welfare, regardless of the grid’s overall performance. Additionally, participants must divulge sensitive information to others, jeopardizing the agents’ confidentiality.
    Smart contract—A smart contract can be implemented in the blockchain layer with the primary goal of maximizing the overall profit of the smart grid while boosting participant payoffs. This approach alleviates the need for prosumers to disclose sensitive information. Additionally, the aggregate profit is increased rather than the profit of individual agents, guaranteeing that no agent is mistreated.
    Hence, a governing smart contract is used that will ensure that the overall profit of the market is optimized.
  • Delivery period—This element defines the market’s time scale. It can range from day-ahead to real-time scheduling, depending on the agents’ requirements.
  • Winner determination/price clearing method—The mechanism by which the quantity of energy traded between prosumers and the price at which they agree on the transaction are determined.

3.2. Market Design

This section discusses the market’s overall architecture. In this study, a community peer-to-peer model is used. Multiple interfaces are used to build the market structure. The platform interface gives access to the centralized communication. Network interface enables communication with market prosumers. The payment interface is used to transfer payments, while the data interface facilitates the interchange of information regarding energy output and consumption.
The Energy Trading Smart Contract (ETSC) is executed every T time slot. Bids submitted during the current T1 cycle will be considered for the subsequent T2 contract execution.

3.2.1. Initialization

Initially, agents must assess, based on their energy production, whether they will require energy or supply energy to the grid in the subsequent period T2. In addition, the agents can modify their utility functions and strategies based on their past performance in maximizing their utility while considering external factors such as price sensitivity [25].

3.2.2. Affiliation

After determining the act (buyer/seller), the agent can inform the ETSC of its intent to participate in the following market cycle as either a buyer or a seller. Prior to affiliation, the ETSC validates the agent’s identification. The ETSC registers the agent as a market participant and assigns a unique identifier for the duration of the market cycle upon verification. The ETSC returns the agent the freshly generated identification of the user.
The agents can place their bid after joining the market. The bid should consist of the following details.
  • AffiliationID—The ID of the agent given by the ETSC after affiliation.
  • ActorType—The indicator of whether the agent will act as a buyer or a seller
  • Timestamp—The timestamp at which the bid was sent by the user. This is used to prevent double spending of the tokens [15].
  • AcceptablePrice—If the actor type is a buyer, the highest price the buyer can afford is specified; if the actor type is a seller, the lowest price acceptable is specified.
  • Quantity—The maximum quantity that is provided/required by the prosumer.
To ensure secrecy, the agents encrypt and transmit the bid to the platform. The bid is added to the current cycle when the market verifies the user’s identification. Until the energy trading cycle is initiated, the data connected with an energy bid are encrypted and held on the blockchain.
The ETSC assumes all participants in the energy trading cycle are trustworthy. The buyers hold the tokens specified in the bid, whilst the sellers possess the claimed energy. If an agent is found to be a fraud node after an energy trading cycle has concluded and energy has been distributed, the actor is penalized.

4. Energy Trading

This section outlines the winner selection or market clearing process employed in the proposed platform. In peer-to-peer trading, the buyers have cost functions where they try to minimize the cost and sellers have utility functions where they try to maximize utility.
A consumer’s cost model is composed of three major components: the cost of energy used by the user, the cost of energy traded with other consumers, and the cost of transmission [26]. However, in this study the grid is considered to be localized where the cost of energy transmission is negligible. Furthermore, the smart grid is considered as a strictly Renewable Energy Source (RES) system where the carbon emission of the system in negligible. Hence, the cost function is,
ζ t = j = 1 n E i , j , t P j , i , t + ( γ j , t m i n E i , j , t ) P j , t g
where ζ t is the total cost of consumer i, E i , j , t and P j , i , t are the energy and price between i , j users, γ j , t m i n is the minimum energy required by the user, and P j , t g is the unit cost set by the main grid. ( γ j , t m i n E i , j , t ) P j , t g is used to show that the user will buy the energy from the main grid if the user cannot obtain energy from other producers.

4.1. Utility Function

In certain studies, the utility function is calculated only based on price, whereas external factors such as price sensitivity and participation desire are neglected. In addition, it is anticipated that all prosumers participating in the market will have an identical utility function with equivalent parameters for all users, as described in Section 1. When all prosumers are assumed to have the same utility function, it is impossible to accurately reflect users’ complex architecture and psychological behavior because essential factors affecting the agent’s utility are overlooked.
This study introduces a mechanism wherein prosumers can provide their utility function to the ETSC. The agents can optimize the utility function by incorporating past data and evolutionary game theory in order to acquire a more accurate utility function [25]. It is ensured that the utility function is inaccessible to market participants other than the ETSC and the designated agent. The utility functions are stored as the agent’s private data on the blockchain. As mentioned in Section 6.1, when the ETSC is executed, the utility function is received via a separate contract from the blockchain.
The study uses two utility function formats in the form of logarithmic and quadratic functions that are often employed in research. The quadratic utility function is,
ϵ t = j = 1 n P j , t m i n E i , j , t θ i , t 2 E i , j , t 2
where P j , t m i n is the price provided by the user, E i , j , t is the energy traded between i , j and θ i , t is the price sensitivity of the user. When the value of θ i , t is high, the user is willing to reduce the energy consumption whereas, for a lower value, the user is trying to increase the energy consumption. E i , j , t can be shown as,
j = 1 n E i , j , t = E i g E i , t
where E i g is the energy required by user i and E i , t is the energy produced by the user i Additionally, the logarithmic utility function is,
ϵ t = j = 1 n k i , j l n ( α i , j + E i , t ) + ( E i g E i , t ) P j , i , t
where k i , j l n ( α i , j + E i , t ) is the utility of a user by consuming E i g where k i , j , α i , j are constants and ( E i g E i , t ) P j , i , t is the profit obtained by selling energy.

5. Stackelberg Game

The energy trading between prosumers can be analyzed as a Stackelberg game between the ETSC and the prosumers. The existence of Stackelberg equilibrium has been widely studied in peer-to-peer energy trading schemes [16,27,28]. The ETSC acts as the game leader, while the prosumers act as the followers. The followers optimize their objective function in the game, while the leader maximizes overall social welfare by eliciting the best response from the followers. Stackelberg Equilibrium (SE) is considered as a solution for this game. The leader achieves optimal social welfare, followed by the optimal prices obtained by the followers. The optimal energy quantity is considered the quantity that provides the optimal price. In Stackelberg Equilibrium, no player benefits from altering strategy. As the buyers who participate in the game want to increase its utility and the sellers who participate want to decrease the cost, the social welfare problem can be formed as,
i , j P ,
S W = m a x j = 1 n ζ t ( E i , j , t , P j , i , t ) ϵ t ( E i , j , t , P j , i , t )
P i , t P j , i , t
P j , t P j , i , t
E i g E i , t E j , i , t
0 E j , i , t γ j , t m i n
The formation of the Stackelberg game can be shown as,
G = { A P , { S i } , { ζ t } , { ϵ t } , i P }
where A is the ETSC and P are the prosumers, the { S i } represents the set of strategies used by prosumers and { ζ t } represents the utility functions of prosumers and { ϵ t } represents the cost functions of prosumers. Depending on the energy consumption, a prosumer can be a buyer or a seller with the respective strategies, utility functions and cost functions.

5.1. Existence of Stackelberg Equilibrium

The Stackelberg game shown in Equation (10) will reach equilibrium if and only if the chosen strategies satisfy the following inequalities.
ζ t ( E i , j , t * , P j , i , t * ) ζ t ( E i , j , t , P j , i , t * )
ϵ t ( E i , j , t * , P j , i , t * ) ϵ t ( E i , j , t , P j , i , t * )
This implies that by changing the utility functions or cost functions of prosumers, a solution better than the derived optimal solution should not be obtained.
It can be shown that the utility function of sellers is strictly concave by obtaining the second derivative of the Equation (2).
ϵ t = j = 1 n P j , t m i n ( E i ( g ) E i , t ) θ i , t 2 ( E i ( g ) E i , t ) 2
ϵ t E i , t = j = 1 n P j , t m i n + θ i , t ( E i ( g ) E i , t )
2 ϵ t E i , t 2 = j = 1 n θ i , t < 0
In the same manner, it can be shown that the second derivative of Equation (4) is also negative.
ϵ t E i , t = j = 1 n k i , j α i , j + E i , t P j , i , t
2 ϵ t E i , t 2 = j = 1 n k i , j ( α i , j + E i , t ) 2 < 0
As the utility function is strictly concave, there exists a maximum value in the function where the sellers cannot obtain a better solution by changing the strategy.
Furthermore, the second derivative of the cost function Equation (1) of buyers is strictly convex as shown below, that implies the existence of a minimum value for the function, where the buyers cannot obtain a better cost reduction by changing the strategy.
ζ t = j = 1 n ( E i ( g ) E i , t ) P j , i , t + ( γ j , t m i n ( E i ( g ) E i , t ) ) P j , t ( g )
Lets consider that Equation (16) to get the optimal P j , i , t value.
ϵ t E i , t = j = 1 n k i , j α i , j + E i , t P j , i , t = 0
E i , t = k i , j P j , i , t α i , j
By substituting in Equation (18),
ζ t = j = 1 n E i ( g ) k i , j P j , i , t α i , j P j , i , t + γ j , t m i n E i ( g ) k i , j P j , i , t α i , j P j , t ( g )
It can be shown that the function is convex by obtaining the second derivative.
ζ t P j , i , t = j = 1 n E i ( g ) + α i , j P j , t ( g ) k i , j P j , i , t 2 = 0
2 ζ t P j , i , t 2 = j = 1 n P j , t ( g ) k i , j P j , i , t 3 > 0
In the same manner, it can be proved that if the consumer has a quadratic utility function the cost function Equation (2) is convex. Hence, it can be said that a unique equilibrium exists, through the social welfare problem Equation (5) defined for the pricing market game.

5.2. Solutions to the Stackelberg Game

The approaches that can be used to obtain the solution to the Stackelberg game are explained in this section.
The solution to the Stackelberg game can be obtained through backward induction [29]. A bi-level approach is taken where the optimization problem of maximizing the seller’s utility is solved, and the result is plugged into the next level of minimization of buyers’ cost, and optimum value is obtained. However, due to the constraints Equations (6)–(9), it is hard to formulate and solve the problem in this manner.
Dual decomposition [30], can also be used to solve the problem. The method relaxes the constraints and modifies constrained optimization problem into a dual problem by transforming the primal optimization problem where the individual sub-problems can be solved separately. The Lagrangian function of the Equation (5) and constraints Equations (6)–(9) can be shown as,
L j = S W ψ j ( P i , t P j , i , t S j 2 ) δ j ( P j , t P j , i , t + t j 2 ) + ξ j ( E i ( g ) E i , t E j , i , t + k j 2 ) η j ( E j , i , t g j 2 ) ϕ j ( γ j , t m i n E j , i , t + w j 2 )
where S j , t j , k j , g j , w j are constants. The function can be solved through the KKT conditions after decomposing the algorithm.
Furthermore, deterministic approaches with linear programming have been followed and gradient descent algorithms have been used to solve the optimization problem. However, the complexity of these approaches increase drastically when the number of prosumers increase. The computational time taken by these approaches is also high. Hence, a swarm intelligent approach is introduced to find the solution for the game.

6. Swarm Intelligent Solution

In this section, the swarm intelligent approach is presented that can be used to solve the Stackelberg game while obtaining SE. A Cuckoo Search algorithm (CSA) [31] inspired approach is used to solve the optimization problem. The CSA is considered as the base algorithmic structure to solve the Stackelberg game due to the high convergence rate and the accuracy as statistically shown in [32].
The CSA is based on the brood parasitism of a specific Cuckoo species and the characteristics related to Levy flights. There are two types of birds called Cuckoo birds who lay eggs in the nests and the host birds who build the nests. In the algorithm, initially, each Cuckoo bird lays the egg in a randomly selected nest, and the nest with the highest quality of eggs is considered over the next generations. The number of host nests is a constant, and the host bird can discover the egg with probability p a [ 0 , 1 ] . If the host bird discovers the egg, it can discard it or abandon it and build a new nest. The host bird will replace the M nests with a probability of p a . The host nest x i ( t ) is updated as,
x i ( t + 1 ) = x i ( t ) + α L e v y ( λ )
where α is the stepping size and ⊗ indicate the entry wise multiplications and L e v y ( λ is the Levy flight taken from the Levy distribution.
The Levy flight is approximated using the following equations.
s = u | ν | 1 β
where u , ν follow Gaussian distribution, u N ( 0 , σ 2 ) , ν N ( 0 , 1 ) and β = 1.5
σ = ( Γ ( 1 + β ) sin π β 2 β Γ ( 1 + β 2 ) 2 β 1 2 )
If the Cuckoo egg is abandoned, the Cuckoo finds a new location through,
x i ( t + 1 ) = x i ( t ) + α s H ( p a ) ( x j ( t ) x k ( t ) )
where x j ( t ) and x k ( t ) are randomly selected and H() is a Heaviside function, ∈ is a random through a distribution, s is the step size ( 0 , 1 ) and α is a scaling value. These functions are directly inferred from the literature [31].
By following this algorithm, a modified algorithm is developed to obtain the solution of the Stackelberg game. The CSA only replaces solutions when the new one outperforms the old one, and only a subset of the worst-performing solutions are changed. Social Welfare Smart Contract (SWSC) as described in Section 6.1 is used to calculate the output social welfare for a particular nest. The decision variables of the problem are the price and quantity of energy exchanged between a buyer and a seller. Hence, (number of buyers) × (number of sellers) × 2 number of decision variables are considered in the CSA that act as the dimensions of the CSA. Figure 2 shows the basic flow of the modified CSA.

6.1. Social Welfare Smart Contract (SWSC)

Social Welfare Smart Contract (SWSC) is used to calculate the social welfare of a specific nest. Certain parameters of the functions are sensitive information to the specific prosumer as emphasized in Section 4.1. Hence, a separate agent is created for each prosumer who has access to the private information of that prosumer, rather than providing sensitive information to the function. These agents have restricted read-only access to the private data, and the wallets of each agent are saved internally, ensuring that no outside party has access to the agents except for SWSC. Intelligent agents and SWSC agents do not communicate directly. The intelligent agents continuously optimize their utility functions, and the particular SWSC agent queries the private data and calculates the aggregate social welfare of the current iteration at each iteration as shown in Figure 3.

6.2. Penalty Functions

The social welfare function should be modified to include inequality constraints and be optimized using the CSA. A penalty approach process [33] is used for this purpose. The modified social welfare problem can be shown as follows.
S W m o d i f i e d = S W + η ( x )
η ( x ) = i = 1 m θ ( q i ( x ) ) q i ( x ) γ ( q i ( x ) )
where q i ( x ) = m a x { 0 , g i ( x ) } , i = 1 , , m . g i ( x ) are the inequality constraints as shown in Equations (6)–(9) ( g i ( x ) 0 ). The penalty parameters are chosen as follows.
γ ( q i ( x ) ) = 1 , if q i ( x ) < 1 . 2 , otherwise .
θ ( q i ( x ) ) = 10 , if q i ( x ) < 0.001 . 20 , if q i ( x ) < 0.1 . 100 , if q i ( x ) < 1 . 300 , otherwise .

7. Illustrative Results

The numerical analysis of the proposed solution is presented in this section.

7.1. Implementation of the Platform

The platform is designed with Hyperledger Fabric [34], which provides a modular architecture that is suitable for the study. In total, six initial prosumers are assumed to be connected to the platform via the agent layer in the study. Raft algorithm [35] is used as the consensus mechanism of the blockchain. A total of two peers are implemented for each agent in the blockchain to avoid a single point of failure. Each agent connected to the blockchain owns a wallet that consists of separate digital certificates. Respective certificate authorities are defined for each agent at the blockchain layer. The authentication of the agents is verified by the specific certificate authority of the agent. The agents created by the SWSC are also authenticated and verified through the certificate authorities. Each peer maintains a ledger containing the details about the transactions. Details about transactions are exchanged between peers, whereas agents’ private data are restricted at each peer’s ledger. The SWSC agents have limited access to the specific ledger of each prosumer. The Orderer maintains the order of the channel [36]. ETSC is implemented in the blockchain layer, and the market layer is integrated with the blockchain layer, where energy trading cycles can be executed every t time.

7.2. Experimental Setup

During the experiments, the prosumers were considered with distinct utility functions where the parameters were modified in separate iteration considered for Cuckoo Search Algorithm with Social Welfare Smart Contract (CSA-SWSC), i.e., if the utility function of one agent was considered as Equation (4), the k i , j and α i , j parameters were changed to resemble the behavior of intelligent agents modifying these parameters to maximize their utility. Conversely, Logarithmic utility function Equation (4) was considered as the utility function for all the agents and parameters with values, k i , j = 3 and α i , j = 1 for the current approach of Constant Utility Optimization (CUO) used in studies. Furthermore, the average method (AVG) was also considered in the numerical analysis. In the AVG, the buyers are sorted in descending order of the price b i > b i + 1 , i n , (n = number of buyers), where the sellers are sorted in ascending order s j < s j + 1 , j m , (m = number of sellers. The optimal price is considered as b i + s j 2 . The Stackelberg game was performed under 12 time slots where the prosumers’ requirements for energy quantity and prices were considered the same for the CSA-SWSC, the CUO, and the AVG approaches. The main grid price is, P t ( g ) = 30 $ and the price [ 10 , 30 ] $ whereas the quantity [ 1 , 20 ] kWh.
Figure 4 shows the variation in total utility of sellers during the time intervals. The proposed CSA-SWSC outperforms the CUO approach at each time interval where the individual agents increase their utilities as well.
Figure 5 shows the total cost of the sellers for the given time intervals. The total cost of the CSA-SWSC approach is lower than the CUO approach. However, a distinct margin between the two approaches is not visible as the same cost function Equation (1) is considered. The utility of sellers acquired through the AVG is comparatively higher compared with the CUO. However, the buyers’ cost in the AVG is significantly high as the average price of buyers and sellers is considered the optimal price without considering the prosumers’ behavior through utility and cost functions.
Buyers in the proposed design use energy from the primary power grid in cases where the smart grid is unable to meet their energy requirements, as demonstrated by Equation (1). Carbon emissions from the smart grid are disregarded because the system is entirely renewable energy-based, as mentioned in Section 4. A carbon footprint analysis was conducted to determine the reduction of carbon dioxide emitted by our suggested approach. Coal, natural gas, and petroleum are the primary fuels utilized in the world’s energy generation.
According to the United States Energy Information Administration [37], the generation of electricity in the United States produces 0.417305 kg of carbon dioxide per kilowatt-hour (kilograms CO 2 /kWh). Table 1 compares the total carbon emission. TE shows the carbon emission if the total energy requirement of buyers was fulfilled through the main power grid. TE calculates the carbon emissions produced if all of the buyers’ energy requirements were met by the main power grid. Total carbon emissions were significantly reduced due to peer-to-peer energy trading, as illustrated by the CUO, the CSA-SWSC, and the AVG. As the buyers purchase more energy units through the smart grid in the CUO, there is a further 15.67% reduction in carbon emissions compared with the CSA-SWSC.
In the initial setup, it was considered that the smart grid consists of six agents as prosumers. Figure 6 shows the fluctuation of the total utility with respect to the number of agents in the smart grid. The agents have maximized their profits further through the CSA-SWSC approach compared with the CUO and the AVG approaches. The overall utility gradually increases when the number of agents connected to the energy trading platform grows. Figure 7 plots the variance in overall cost as a function of the agent count. The CSA-SWSC strategy has a lower overall cost than other alternatives, whereas the AVG approach has a significantly higher total cost.

8. Conclusions

In this paper, a blockchain-based peer-to-peer energy trading platform is introduced. The energy exchange between prosumers is modeled as a Stackelberg game. The existence of the Stackelberg equilibrium is shown in the proposed game and is solved through a heuristic swarm intelligent approach instead of a deterministic approach. Hence, the computational complexity is reduced during periods where an increased number of prosumers are participating in the trading platform. The intelligent agents continuously optimize their utility functions to maximize their profits and update the utility functions stored in the blockchain. The proposed CSA with SWSC acquires the optimized utility function from the blockchain through SWSC agents during each trading cycle. This ensures that the prosumers obtain maximum utility while securing privacy without exposing sensitive information. The numerical analysis shows that the proposed mechanism enables sellers to obtain better utilities while buyers reduce their costs. Furthermore, the considered scenario demonstrates a 15% reduction in carbon emissions from electricity generated via the main power grid when compared with current approaches.
Currently, agent utility functions are not optimized in iterations of the energy distribution. In future work, we will focus on optimizing agent utility functions in each iteration of SWSC employing mechanisms such as evolutionary game theory and neural networks.

Author Contributions

Conceptualization, C.E.; methodology, C.E.; software, C.E., U.M. and S.W.; validation, C.E., U.M. and S.W.; formal analysis, C.E., U.M., S.W., U.J. and J.A.; investigation, C.E., U.M., S.W., U.J. and J.A.; resources, C.E., U.J. and J.A.; writing—original draft preparation, C.E. and U.M.; writing—review and editing, C.E., U.M., S.W., U.J. and J.A.; supervision, U.J. and J.A.; project administration, U.J. and J.A.; funding acquisition, U.J. and J.A. All authors have read and agreed to the published version of the manuscript.

Funding

APC is supported by the Rabdan Academy, UAE.

Data Availability Statement

The data are available upon request from the corresponding author.

Conflicts of Interest

The author declares no conflict of interest.

References

  1. Zhang, C.; Wu, J.; Long, C.; Cheng, M. Review of existing peer-to-peer energy trading projects. Energy Procedia 2017, 105, 2563–2568. [Google Scholar] [CrossRef]
  2. Yatchew, A.; Baziliauskas, A. Ontario feed-in-tariff programs. Energy Policy 2011, 39, 3885–3893. [Google Scholar] [CrossRef]
  3. Colak, I.; Fulli, G.; Sagiroglu, S.; Yesilbudak, M.; Covrig, C.F. Smart grid projects in Europe: Current status, maturity and future scenarios. Appl. Energy 2015, 152, 58–70. [Google Scholar] [CrossRef]
  4. Nakamoto, S. Bitcoin: A peer-to-peer electronic cash system. Decentralized Bus. Rev. 2008, 21260. [Google Scholar]
  5. Soto, E.A.; Bosman, L.B.; Wollega, E.; Leon-Salas, W.D. Peer-to-peer energy trading: A review of the literature. Appl. Energy 2021, 283, 116268. [Google Scholar] [CrossRef]
  6. Edussuriya, C.; Vithanage, K.; Bandara, N.; Alawatugoda, J.; Sandirigama, M.; Jayasinghe, U.; Shone, N.; Lee, G.M. BAT—Block Analytics Tool Integrated with Blockchain Based IoT Platform. Electronics 2020, 9, 1525. [Google Scholar] [CrossRef]
  7. Hamouda, M.R.; Nassar, M.E.; Salama, M. A Novel Energy Trading Framework Using Adapted Blockchain Technology. IEEE Trans. Smart Grid 2020, 12, 2165–2175. [Google Scholar] [CrossRef]
  8. Pop, C.; Cioara, T.; Antal, M.; Anghel, I.; Salomie, I.; Bertoncini, M. Blockchain based decentralized management of demand response programs in smart energy grids. Sensors 2018, 18, 162. [Google Scholar] [CrossRef] [Green Version]
  9. Wang, S.; Taha, A.F.; Wang, J.; Kvaternik, K.; Hahn, A. Energy crowdsourcing and peer-to-peer energy trading in blockchain-enabled smart grids. IEEE Trans. Syst. Man Cybern. Syst. 2019, 49, 1612–1623. [Google Scholar] [CrossRef] [Green Version]
  10. Thakur, S.; Breslin, J.G. Peer to peer energy trade among microgrids using blockchain based distributed coalition formation method. Technol. Econ. Smart Grids Sustain. Energy 2018, 3, 1–17. [Google Scholar] [CrossRef] [Green Version]
  11. Jamil, F.; Iqbal, N.; Ahmad, S.; Kim, D. Peer-to-peer energy trading mechanism based on blockchain and machine learning for sustainable electrical power supply in smart grid. IEEE Access 2021, 9, 39193–39217. [Google Scholar] [CrossRef]
  12. Son, Y.B.; Im, J.H.; Kwon, H.Y.; Jeon, S.Y.; Lee, M.K. Privacy-preserving peer-to-peer energy trading in blockchain-enabled smart grids using functional encryption. Energies 2020, 13, 1321. [Google Scholar] [CrossRef] [Green Version]
  13. Tushar, W.; Zhang, J.A.; Smith, D.B.; Poor, H.V.; Thiébaux, S. Prioritizing consumers in smart grid: A game theoretic approach. IEEE Trans. Smart Grid 2014, 5, 1429–1438. [Google Scholar] [CrossRef] [Green Version]
  14. Liu, N.; Yu, X.; Fan, W.; Hu, C.; Rui, T.; Chen, Q.; Zhang, J. Online energy sharing for nanogrid clusters: A Lyapunov optimization approach. IEEE Trans. Smart Grid 2017, 9, 4624–4636. [Google Scholar] [CrossRef]
  15. Chen, S.; Shroff, N.B.; Sinha, P. Energy trading in the smart grid: From end-user’s perspective. In Proceedings of the 2013 Asilomar Conference on Signals, Systems and Computers, Pacific Grove, CA, USA, 3–6 November 2013; pp. 327–331. [Google Scholar]
  16. Doan, H.T.; Cho, J.; Kim, D. Peer-to-Peer Energy Trading in Smart Grid Through Blockchain: A Double Auction-Based Game Theoretic Approach. IEEE Access 2021, 9, 49206–49218. [Google Scholar] [CrossRef]
  17. Guerrero, J.; Chapman, A.C.; Verbič, G. Decentralized P2P energy trading under network constraints in a low-voltage network. IEEE Trans. Smart Grid 2018, 10, 5163–5173. [Google Scholar] [CrossRef] [Green Version]
  18. Abdalzaher, M.S.; Seddik, K.; Muta, O. An effective Stackelberg game for high-assurance of data trustworthiness in WSNs. In Proceedings of the 2017 IEEE Symposium on Computers and Communications (ISCC), Heraklion, Greece, 3–6 July 2017; pp. 1257–1262. [Google Scholar]
  19. Abdalzaher, M.S.; Seddik, K.; Muta, O. Using Stackelberg game to enhance cognitive radio sensor networks security. IET Commun. 2017, 11, 1503–1511. [Google Scholar] [CrossRef]
  20. Abdalzaher, M.S.; Muta, O. Employing game theory and TDMA protocol to enhance security and manage power consumption in WSNs-based cognitive radio. IEEE Access 2019, 7, 132923–132936. [Google Scholar] [CrossRef]
  21. Abdalzaher, M.S.; Muta, O. A game-theoretic approach for enhancing security and data trustworthiness in IoT applications. IEEE Internet Things J. 2020, 7, 11250–11261. [Google Scholar] [CrossRef]
  22. Chen, Y.; Wei, W.; Wang, H.; Zhou, Q.; Catalão, J.P. An energy sharing mechanism achieving the same flexibility as centralized dispatch. IEEE Trans. Smart Grid 2021, 12, 3379–3389. [Google Scholar] [CrossRef]
  23. Esmat, A.; de Vos, M.; Ghiassi-Farrokhfal, Y.; Palensky, P.; Epema, D. A novel decentralized platform for peer-to-peer energy trading market with blockchain technology. Appl. Energy 2021, 282, 116123. [Google Scholar] [CrossRef]
  24. Hart, D.G. Using AMI to realize the Smart Grid. In Proceedings of the 2008 IEEE Power and Energy Society General Meeting-Conversion and Delivery of Electrical Energy in the 21st Century, Pittsburgh, PA, USA, 20–24 July 2008; Volume 10. [Google Scholar]
  25. Reddy, P.P.; Veloso, M.M. Strategy learning for autonomous agents in smart grid markets. In Proceedings of the Twenty-Second International Joint Conference on Artificial Intelligence, Barcelona, Spain, 16–22 July 2011. [Google Scholar]
  26. Anoh, K.; Bajovic, D.; Vukobratovic, D.; Adebisi, B.; Jakovetic, D.; Cosovic, M. Distributed energy trading with communication constraints. In Proceedings of the 2018 IEEE PES Innovative Smart Grid Technologies Conference Europe (ISGT-Europe), Sarajevo, Bosnia and Herzegovina, 21–25 October 2018; pp. 1–6. [Google Scholar]
  27. Tushar, W.; Saha, T.K.; Yuen, C.; Morstyn, T.; Poor, H.V.; Bean, R. Grid influenced peer-to-peer energy trading. IEEE Trans. Smart Grid 2019, 11, 1407–1418. [Google Scholar] [CrossRef] [Green Version]
  28. Yan, M.; Shahidehpour, M.; Paaso, A.; Zhang, L.; Alabdulwahab, A.; Abusorrah, A. Distribution network-constrained optimization of peer-to-peer transactive energy trading among multi-microgrids. IEEE Trans. Smart Grid 2020, 12, 1033–1047. [Google Scholar] [CrossRef]
  29. Anoh, K.; Maharjan, S.; Ikpehai, A.; Zhang, Y.; Adebisi, B. Energy peer-to-peer trading in virtual microgrids in smart grids: A game-theoretic approach. IEEE Trans. Smart Grid 2019, 11, 1264–1275. [Google Scholar] [CrossRef]
  30. Carøe, C.C.; Schultz, R. Dual decomposition in stochastic integer programming. Oper. Res. Lett. 1999, 24, 37–45. [Google Scholar] [CrossRef]
  31. Gandomi, A.H.; Yang, X.S.; Alavi, A.H. Cuckoo search algorithm: A metaheuristic approach to solve structural optimization problems. Eng. Comput. 2013, 29, 17–35. [Google Scholar] [CrossRef]
  32. Wang, Z.; Qin, C.; Wan, B.; Song, W.W. A Comparative Study of Common Nature-Inspired Algorithms for Continuous Function Optimization. Entropy 2021, 23, 874. [Google Scholar] [CrossRef]
  33. Parsopoulos, K.E.; Vrahatis, M.N. Particle swarm optimization method for constrained optimization problems. Intell. Technol. Theory Appl. New Trends Intell. Technol. 2002, 76, 214–220. [Google Scholar]
  34. Hyperledger. Open Source Blockchain Technologies. Available online: https://www.hyperledger.org/ (accessed on 20 October 2022).
  35. Ongaro, D.; Ousterhout, J. In search of an understandable consensus algorithm. In Proceedings of the 2014 USENIX Annual Technical Conference (Usenix ATC 14), Philadelphia, PA, USA, 19–20 June 2014; pp. 305–319. [Google Scholar]
  36. Androulaki, E.; Barger, A.; Bortnikov, V.; Cachin, C.; Christidis, K.; De Caro, A.; Enyeart, D.; Ferris, C.; Laventman, G.; Manevich, Y.; et al. Hyperledger fabric: A distributed operating system for permissioned blockchains. In Proceedings of the Thirteenth EuroSys Conference, Porto, Portugal, 23–26 April 2018; pp. 1–15. [Google Scholar]
  37. U.S. Energy Information Administration (EIA). The United States Energy Consumption by Sources. Available online: https://www.eia.gov/ (accessed on 10 October 2022).
Figure 1. Overview of the platform.
Figure 1. Overview of the platform.
Energies 16 02434 g001
Figure 2. Modified Cuckoo search algorithm.
Figure 2. Modified Cuckoo search algorithm.
Energies 16 02434 g002
Figure 3. Interaction between intelligent agents and SWSC agents.
Figure 3. Interaction between intelligent agents and SWSC agents.
Energies 16 02434 g003
Figure 4. Total utility of sellers.
Figure 4. Total utility of sellers.
Energies 16 02434 g004
Figure 5. Total cost of buyers.
Figure 5. Total cost of buyers.
Energies 16 02434 g005
Figure 6. Variation in total utility of sellers with number of agents.
Figure 6. Variation in total utility of sellers with number of agents.
Energies 16 02434 g006
Figure 7. Variation in total cost of buyers with number of agents.
Figure 7. Variation in total cost of buyers with number of agents.
Energies 16 02434 g007
Table 1. Total Carbon emission ( kg CO 2 ).
Table 1. Total Carbon emission ( kg CO 2 ).
Time SlotTotal EnergyCUOCSA-SWSCAVG
15.00770.93990.5650.8346
29.5982.43171.29471.2519
312.51925.00273.52313.7557
414.18847.63625.09095.425
513.35384.60053.15363.3384
617.52683.86672.83226.2596
715.44039.04957.7448.3461
815.85763.47552.70332.5038
916.69226.66243.47558.3461
1016.69225.59743.57844.1731
1114.60573.2982.26612.5038
124.17311.060900.4173
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Edussuriya, C.; Marikkar, U.; Wickramasinghe, S.; Jayasinghe, U.; Alawatugoda, J. Peer-to-Peer Energy Trading through Swarm Intelligent Stackelberg Game. Energies 2023, 16, 2434. https://doi.org/10.3390/en16052434

AMA Style

Edussuriya C, Marikkar U, Wickramasinghe S, Jayasinghe U, Alawatugoda J. Peer-to-Peer Energy Trading through Swarm Intelligent Stackelberg Game. Energies. 2023; 16(5):2434. https://doi.org/10.3390/en16052434

Chicago/Turabian Style

Edussuriya, Chathurangi, Umar Marikkar, Subash Wickramasinghe, Upul Jayasinghe, and Janaka Alawatugoda. 2023. "Peer-to-Peer Energy Trading through Swarm Intelligent Stackelberg Game" Energies 16, no. 5: 2434. https://doi.org/10.3390/en16052434

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop