Energy Crowdsourcing and Peer-to-Peer Energy Trading in Blockchain-Enabled Smart Grids

The power grid is rapidly transforming, and while recent grid innovations increased the utilization of advanced control methods, the next-generation grid demands technologies that enable the integration of distributed energy resources (DERs)---and co…

Authors: Shen Wang, Ahmad F. Taha, Jianhui Wang

Energy Crowdsourcing and Peer-to-Peer Energy Trading in   Blockchain-Enabled Smart Grids
IEEE TRANSA CTIONS ON SYSTEMS, MAN AND CYBERNETICS: SYSTEMS, IN PRESS 1 Ener gy Cro wdsourcing and Peer -to-Peer Ener gy T rading in Blockchain-Enabled Smart Grids Shen W ang, Student Member , IEEE, Ahmad F . T aha, Member , IEEE, Jianhui W ang, Senior Member , IEEE, Karla Kv aternik, Member , IEEE, Adam Hahn, Member , IEEE. Abstract —The po wer grid is rapidly transforming, and while recent grid innovations increased the utilization of advanced con- trol methods, the next-generation grid demands technologies that enable the integration of distributed energy resources (DERs)— and consumers that both seamlessly buy and sell electricity . This paper develops an optimization model and blockchain- based ar chitecture to manage the operation of crowdsourced energy systems (CES), with peer -to-peer (P2P) energy trading transactions. An operational model of CESs in distribution networks is presented considering various types of energy trading transactions and cr owdsourcees. Then, a two-phase operation algorithm is presented: Phase I focuses on the day-ahead schedul- ing of generation and controllable DERs, whereas Phase II is developed f or hour -ahead or real-time operation of distribution networks. The developed approach supports seamless P2P energy trading between individual prosumers and/or the utility . The presented operational model can also be used to operate islanded microgrids. The CES framework and the operation algorithm are then prototyped through an efficient blockchain implementation, namely the IBM Hyperledger Fabric. This implementation allows the system operator to manage the network users to seamlessly trade energy . Case studies and prototype illustration are pro- vided. Index T erms —Energy Cro wdsourcing, Blockchain, Ener gy T rading, Peer -to-Peer Energy Management. I . I N T R O D U C T I O N S MAR T grid technologies, such as microgrids and distributed energy resources (DERs), hav e drastically changed the way electricity is generated and consumed in two dimensions. First, the rapid increase in energy pr osumers intro- duces new grid participants and provides a more decentralized and open power grid. Second, this changes the role of a system operator or utility from a power retailer to a service provider— renting transmission/distribution lines to prosumers, rather than solely selling units of energy . This paradigm shift requires the creation of ne w trusted software platforms, distributed operation/control algorithms, and computational methods to enable reliable grid operations, prosumer engagement, and incentivize utility business model innov ations. S. W ang and A. F . T aha are with the Department of Electrical and Computer Engineering, The Univ ersity of T exas at San Antonio, TX. J. W ang is with the Department of Electrical Engineering, Southern Methodist University , Dallas, TX. Karla Kvaternik is with Siemens Corporate T echnology , Princeton, NJ. Adam Hahn is with the School of Electrical Engineering and Computer Science, W ashington State University , Pullman, W A. E-mails: mvy292@my.utsa.edu, ahmad.taha@utsa.edu, jianhui@smu.edu, karla.kvaternik@siemens.com, ahahn@eecs.wsu.edu . An earlier version of this paper was presented at the 2018 IEEE Power & Energy Society General Meeting in Portland, Oregon, August 5–9, 2018. A preprint of the conference paper can be found in [ 1 ], which shows the significant extensions and contributions of this paper in comparison with [ 1 ]. Fig. 1. Blockchain-assisted architecture of operation in CESs. Crowdsourcing [ 2 ] is a major dri ve for various industries, and has been utilized in various disciplines such as medicine, cyber physical systems, and engineering system design. The central theme in cro wdsourcing is the utilization of the cro wd’ s power to achie ve system-le vel objectiv es. T o see how cro wd- sourcing can be applied in energy systems, we provide an analogy from the most popular crowdsourcing markets, the Amazon Mechanical T urk (MT urk) [ 3 ], which enables people to post jobs with monetary rewards and expiry dates. Energy crowdsourcing of fers the possibility of the transformation in energy systems, and this paper puts forth operational models of crowdsourced ener gy system for collaborativ e production and consumption in ener gy markets, shown in Fig. 1 . The tasks in cro wdsourced energy system can be plugging in an electric vehicle, charging/discharging a battery , deferring loads, and supplying the power network with rene wable energy via solar panels—with the objectiv e of satisfying a near-real- time demand shortage/surplus. These tasks can be automated via smart in verters, plugs, and meters while interf acing with power utilities and a distributed blockchain implementation. This transformation in sustainable energy systems, where energy management is crowdsourced by prosumers, will be supported by two key , disrupti ve scientific technologies: (i) new modeling and cro wdsourcing-centered methods that per- form real-time grid management while maintaining the grid’ s stability . (ii) A secure c yber-infrastructure design to man- age and coordinate millions of energy-trading transactions ( pr osumer-pr osumer or pr osumer-operator trades ). The majority of the new modeling methods are based on IEEE TRANSA CTIONS ON SYSTEMS, MAN AND CYBERNETICS: SYSTEMS, IN PRESS 2 optimal power flo w (OPF) operation models and the secure cyber -infrastructure design is implemented by the promising blockchain technology . Ho wever , both the ne w modeling meth- ods and the implementation of blockchain hav e limitations. First, the computed OPF setpoints for DERs and controllable loads might not be ev entually adopted by crowdsourcees and prosumers. Second, it is unclear ho w energy trading between prosumers can take place within the operational models. Third, the utilized blockchain architectures are not scalable to include millions of energy trading transactions—especially that blockchain-based trades consume a significant amount of ener gy . The paper addresses these gaps, and the main contributions and organization are gi ven as follows. • An operational framework and model of crowdsourced energy systems in distribution networks is presented con- sidering v arious types of energy trading transactions and crowdsourcees. The presented framework enables P2P en- ergy trading at the distribution lev el, where ubiquitous distribution-le vel asset owners can trade with each other . This has not done before in association with distrib uted OPF routines and blockchain-enabled architecture. In such a frame work, an operator is needed to clear the market and ensure there is no violation of any technical constraints (e.g., distribution line limits). A distribution system operator can assume this role running the presented CES operational model (Section III ). Extensions to operator -free, islanded microgrids are also sho wcased. • A two-phase, near real-time operation algorithm for cro wd- sourced energy systems is explored. The first phase focusing on the day-ahead scheduling of generation and control- lable DERs manages the b ulk of grid-operation, while the second phase is developed to balance hour-ahead e ven real-time deficit/surplus in energy via monetary incentiv es. The developed two-phase algorithm supports arbitrary P2P energy trading between prosumers and utility , resulting in a systematic way to manage distribution networks amid P2P energy trading while incenti vizing crowdsourcees to con- tribute to this ecosystem. The algorithm supports operation of islanded, self-autonomous microgrid (Section IV ). • The CES framew ork is implemented and prototyped within IBM Hyperledger Fabric platform—an efficient blockchain implementation. This implementation allows the system operator to manage the network and supports users to log in, manage their own account and carry on the en- ergy trading with utilities or neighborhoods. This prototype communicates with the two-phase algorithm presented in this paper , is open source, and can be used by utilities (Section V ). Finally , numerical tests on a distribution net- work and blockchain prototype illustration are provided (Section VI ). I I . L I T E R AT UR E R E V I E W A. Grid Operation, OPF , and Demand Response Recent studies hav e in vestigated integrating the operation of DERs in distribution networks. The focus of majority of these studies [ 4 ], [ 5 ] is on unit commitment, economic dispatch problems, scheduling of DERs, and maintaining the grid’ s T ABLE I V A R IO U S I MP L E M EN TA T I O N S O F B L O C KC H A I N . P O W A N D R B F T S TAN D F O R P RO O F O F W OR K A N D R E D UN DA N T B Y ZA N T IN E F AU L T T O L ER A N C E . Bitcoin Ether eum Hyperledger F abric Cryptocurr ency Bitcoin Ether None Network public public permissioned T ransactions anonymous anonymous public/confidential Consensus PoW PoW RBFT Smart Contracts None Solidity Chaincode Language C++ C++/Golang Golang/Jav a frequency and voltage within acceptable ranges while giv en uncertainty from rene wables and load forecasts. Another branch of related work [ 6 ] studies the design of demand response signals and incenti ves to dri ve DER owners to contribute to energy production. In summary , there are three approaches to demand response: (a) Reducing demand by using local DERs. (b) Reducing demand through shifting controllable loads. (c) Designing ef ficient generator setpoints to reduce the total generation [ 7 ]. The majority of demand response schedules focus on operational timescale. Further , the need for real-time regulation and distrib uted dynamic pricing as a function of the grid’ s physical status motiv ates new physics-aw are pricing mechanisms [ 8 ], [ 9 ]. Background on blockchain and energy trading routines is given next. B. Blockc hain and Ener gy T rading Systems Blockchain is a distributed ledger based on a set of com- munication and consensus protocols that ensure the ledger in- tegrity through interlinked, cryptographically signed, and time- stamped blocks that define transactions [ 10 ]. The blockchain concept originated with the Bitcoin protocol, which utilized a proof of w ork (PoW) consensus mechanism where miners combine transactions into Merkle tree-based blocks and com- pete to find a random nonce that produces a hash digest within a predefined range. Howe ver , this approach has many limita- tions including its significant energy consumption, scalability in the number of transactions/seconds, priv acy concerns with a public ledger , and single purpose application (i.e., an exchange of the Bitcoin cryptocurrency [ 19 ]). A number of additional blockchain technologies have been introduced to address these challenges as suggested belo w: • Efficient consensus mechanisms: A consensus protocol is used to ensure the unambiguous ordering of transactions and guarantees the integrity and consistency of the blockchain across distributed nodes [ 20 ]; the annual estimated elec- tricity consumption of Bitcoin PoW consensus is 47.1 T erawatt-hour —a staggering 0.21% of worlds electricity consumption [ 21 ]. Furthermore, PoW techniques typically hav e limitations on the number of transactions per sec- ond, which limits use in high performance en vironments. Other consensus mechanisms, such as Proof of Stake (e.g., Ethereum Casper [ 22 ]) or Redundant Byzantine Fault T ol- erance (RBFT) (e.g., IBM Hyperledger Fabric [ 23 ]), can be used to reduce energy consumption. • Smart contracts: Smart contracts provide protocols and T ur- ing complete virtual machines that enable nodes to e xecute some program based on the results of ne w transactions and IEEE TRANSA CTIONS ON SYSTEMS, MAN AND CYBERNETICS: SYSTEMS, IN PRESS 3 T ABLE II V A R IO U S F OC U S E S O F T Y P I CA L P 2 P E N E RG Y T R AD I N G S Y S TE M S . Refer ence [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ 16 ] [ 17 ] [ 18 ] Market Mechanism Information System Blockchain Blockchain Blockchain Blockchain Blockchain Blockchain (Consensus) PoW(Public) Self-designed Self-designed N A NA N A NA PoW Optimization + Grid Constraints Scenario Microgrid EV EV EV Microgrid Microgrid EV Microgrid means not considered ; means partially considered ; means fully considered ; N A means not applicable or the authors do not cov er the aspect; Self-designed means that authors design a new , corresponding consensus mechanism for their own blockchain implementation; allow the blockchain to support sophisticated logic. Smart contracts and blockchain provide an excellent platform to perform energy trading transactions. In particular , the authors in [ 24 ] provide a high-le vel description to the main merits of using cryptocurrency and blockchain in energy systems. • P ermissioned and privacy mechanisms: Blockchain plat- forms can be categorized into public and pri v ate, where public implies that an y miner can contrib ute to the consensus and block creation, while permissioned chains restrict block creation to a predefined set of parties. Therefore, permis- sioned chains may be preferred in applications with defined authorities or entities with management responsibilities. T ab . I summarizes the attributes of dif ferent implementations of current blockchains, and Section V provides additional discussion on why the Hyperledger platform is selected to implement the proposed crowdsourced energy system scheme. In T ab . II , various focuses of recent P2P energy trading routines are compared according to focus aspects; the first three aspects are deriv ed from [ 25 ]. These aspects reflect corresponding modules in Fig. 1 , and are explained here. First, The market mechanism including the participant setup, and pricing mechanism is designed to incentivize participants while maximizing the social welfare. The participant setup defines market participants, and the form of energy trading, while pricing mechanism, i.e., incentiv e design, and bidding strategy , comprises the markets allocation and payment rules. Second, the information system is designed to connect all market participants, pro vide the market platform, of fer mar- ket access, and monitor the market operations. No wadays blockchain is suitable to implement part of information system . Third, the optimization and grid constr aints refer to scheduling of DERs while maintaining the grid in an optimal way as we discussed in Section II-A . Our corresponding implementation of the above aspects are presented in Section V -B . Finally , as for the scenario in these papers, we notice that most papers focuses on microgrids and electric vehicles. After comparing the typical papers in T ab. II , we notice the follo wing. First, references [ 11 ]–[ 14 ], [ 17 ] focus more on approach to managing the grid with the assistance of simple negotiation, auction, or bidding mechanism and implementing the information system via thriving blockchain technology , since the security and priv acy can be guaranteed. Specifically , The contrib ution of [ 12 ] is more about the multi-agent system based trading negotiation mechanism. The authors in [ 13 ] propose a contract based blockchain for secure EV charging, and a reputation based Byzantine fault tolerance consensus algorithm is proposed. In [ 17 ], the ne w and hybrid charging scenario, i.e., mobile charging vehicle-to-v ehicle, and grid- to-vehicle are considered. Second, the authors in [ 15 ], [ 16 ], [ 18 ] pay attention on designing different marketing/pricing mechanism, but the power flow model is ignored in their optimization. For example, game theoretical approaches are adopted to achie ve real-time pricing in [ 15 ], [ 26 ], [ 27 ]. Besides the typical paper listed above, the attack/threat model are explored further in energy blockchain in [ 28 ], [ 29 ] to enhance the security and priv acy . Especially in [ 29 ], the authors design a special trust authority node with a veto power to prevent malicious voting. Ho we ver , the marketing/pricing mechanism and platform design for P2P energy markets do not receiv e too much attention and still are an open research area. Beyond research-oriented studies, companies (i.e., [ 30 ]– [ 32 ]) mainly focus on the development of business models, and the possibility of introducing those models to local energy market and design of control systems are not fully considered. I I I . I N T E G R ATE D O P E R A T I O NA L M O D E L O F C E S S In this section, we present an integrated operational model of cro wdsourced energy systems that considers a wide range of DERs, dif ferent types of cro wdsourcees and energy trading transactions in distrib ution networks. For simplicity , we focus on radial distribution networks with a single feeder connected to traditional generation and utility-scale renew ables. W e con- sider a CES at the feeder le vel with n b uses modeled by a tree graph ( N , E ) , where N = { 1 , . . . , n } is the set of nodes and E ⊆ N × N is the set of lines. Define the partition N = G S C S L , where G = { 1 , . . . , n g } collects the n g utility- scale po wer generation connected to the feeder/substation; C = { 1 , . . . , n c } collects the buses containing n c users who signed up for cro wdsourcing schedules; L = { 1 , . . . , n l } collects load buses. The cr owdsour cer , one type of participants, here is the utility company or any other system operator , we distin- guish between two types of crowdsour cees in C . T ype 1 crowdsourcees commit in the day-ahead markets (and perhaps monthly or yearly) to the cro wdsourcing tasks requested by the operator . T ype 1 crowdsourcees also include users who give complete control of their DERs to the operator . In return, the IEEE TRANSA CTIONS ON SYSTEMS, MAN AND CYBERNETICS: SYSTEMS, IN PRESS 4 Substation Bus 0 CT 1 CT 1 CT 2 . . . Bus 1 Bus n Bus 2 Type of Crowdsourcees CT 1 Solar Panel Shapeable Load Battery CT 2 Solar Panel Shapeable Load Battery Fig. 2. A radial network with different types of crowdsourcees: C T 1 (blue) and C T 2 (red). ETT Type A CT 2 CT 1 Utility ETT Type A E T T T y p e B E nergy T ransactions T rading Automatically Controlled by Utility Semi - Autonomously (Sell energy to utility given designed incentive) Fig. 3. T ypes of crowdsourcees and energy trading transactions. operator pro vides socio-economic incentiv es or discounts on the electric bill. T ype 2 crowdsourcees provide near real-time adjustments or decisions based on real-time notifications and decisions from the operator . For example, the operator informs T ype 2 crowdsourcees about the cr owdsourced task (e.g., charging/dischar ging an electric vehicle) which depends on the users’ location in the network and the physical state of the grid. T ype 1 cro wdsourcees provide operators with day-ahead planning flexibility , in contrast with T ype 2 cro wdsourcees who operate on a faster timescale. The distinction between these two types of users is needed as it resembles projected market setups [ 33 ]. W e define these two types as C T 1 and C T 2 , with C = C T 1 S C T 2 ; this is depicted in Fig. 2 . W e consider two types of energy trading transactions (ETT). T ype A : This is akin to what takes place in today’ s grids, where T ype 1 or 2 crowdsourcees feed the grid with power . This type of transaction is solely between crowd- sourcees and the network operator . T ype B : Crowdsourcees can trade energy with each other where the seller injects power into the grid. Fig. 3 sho ws the types of crowdsourcees and transactions. Since energy production and demand response from T ype 1 cro wdsourcees are controlled by the operator, T ype B transactions only occur among T ype 2 cro wdsourcees. Howe ver , T ype A transactions can also take place between T ype 2 crowdsourcees and the utility . The participants and the transaction types are showed in detail in Fig. 3 . The Brooklyn Microgrid [ 34 ] project is an example of T ype B transactions for T ype 2 crowdsourcees. A. Operational Model of Gener ators, Loads and DERs Let i ∈ N denote the b us inde x of the distribution system and t denote the time-period. W e consider bulk, dispatchable generation from traditional synchronous generators, renewable energy generation from solar panels, fully controllable station- ary batteries, uncontrollable loads, and shapeable loads. 1) Dispatchable Generators: Dispatchable generators are considered in this paper with a quadratic cost function. Dis- patchable generation S g i,t = P g i,t + j Q g i,t for i ∈ G at t are considered to hav e quadratic cost functions as C i,t ( P g i,t ) = α i,t ( P g i,t ) 2 + β i,t P g i,t + γ i,t where α i,t , β i,t , and γ i,t are giv en parameters for the cost function of the i -th generator at t . 2) Solar Energy Generation: Solar panels generate real power P r i,t for bus i ∈ C at t . Note that C T 1 crowdsourcees do not control whether P r i,t is fed into the grid or not (it is con- trolled by the utility/operator), whereas C T 2 crowdsourcees dictate whether to use P r i,t locally or sell it to the CES operator or other users. 3) Stationary Batteries: Batteries are modeled as dispatch- able loads that can be controlled to withdraw or inject po wer . The quantity P b i,t defines the output po wer of the batteries where i ∈ C . Negati ve P b i,t implies that po wer is withdrawn. The battery operational model [ 11 ] is described as: E b i,t = E b i,t − 1 + H b i,t η i,in − D b i,t /η i,out (1a) P b i,t = D b i,t − H b i,t (1b) 0 ≤ D b i,t ≤ P b i,t, dis (1c) 0 ≤ H b i,t ≤ P b i,t, cha (1d) E b, min ≤ E b i,t ≤ E b, max . (1e) In the above battery model, we consider a unit time-period; η i,in and η i,out represent charging and discharging efficienc y constants. H b i,t and D b i,t is the charging and discharging power —both are optimization v ariables. The variable E b i,t , upper and lo wer bounded by E b, min and E b, max , denotes the energy stored in battery at time t . The net power P b i,t at t is the difference between the power of discharging and char ging. P b i,t, dis stands for the limitation of dischar ging power , P b i,t, cha has a similar meaning for charging power . All of v ariables related to batteries model are included in a single vector variable x b i,t := ( E b i,t , H b i,t , D b i,t , P b i,t ) . 4) Uncontr ollable Loads: Uncontrollable loads (lights, plug loads, street lights, et cetera) are considered to be giv en and are denoted by S u i,t for all i ∈ L (loads can include reacti ve power), where S u i,t = P u i,t + j Q u i,t . 5) Shapeable Loads: W e consider shapeable loads, defined by S s i,t = P s i,t + j Q s i,t for i ∈ L , such as plug-in electric vehi- cles and loads from appliances with flexible power profile but fixed energy demand E s i, demand in 24 hours. These shapeable loads must be satisfied between t i, start and t i, end . The model describing the shapeable loads [ 11 ] is gi ven next. E s i, demand = P T t =1 S s i,t ∆ t (2a) S s i,t = 0 , for t = 1 , . . . , t i, start , t i, end , . . . , T (2b) S s, min i ≤ S s i,t ≤ S s, max i , (2c) where T is the length of the time-horizon and ∆ t is the time interval. Similarly , a single vector v ariable x s i,t := ( S s i,t ) collects v ariables related to shapeable loads. B. Distribution Network Model For each b us i ∈ N , denote V i = | V i | e j θ i as its complex voltage and v i = | V i | 2 as its magnitude squared. Let s i = p i + j q i be node i ’ s net complex power injection. Also, p i denotes net real power injection. From Section III-A , the net real po wer injection for each bus i at t can be expressed as p i,t = P g i,t + P b i,t + P r i,t − P u i,t − P s i,t . (3) IEEE TRANSA CTIONS ON SYSTEMS, MAN AND CYBERNETICS: SYSTEMS, IN PRESS 5 Similarly for the net reactiv e power injection. F or each line i ∈ E , we denote bus i ’ s parent and children b uses as A i and C i . Let z i = r i + j x i be its complex impedance, I i be the complex branch current from b us i to A i , and l i = | I i | 2 be its magnitude squared. The variable S i = P i + j Q i denotes the branch power flow from bus i to A i . For all buses in the network, define x t := ( x b , x s ) t as a variable vector collecting the variables related to batteries and shapeable loads. Since two types of crowdsourcees are defined, x t is di vided into two v ariables x 1 t and x 2 t , which stands for the variables belong to T ype 1 and T ype 2 crowdsourcees and hence x t = ( x 1 , x 2 ) t . Let y t := ( P u i,t , P r i,t ) be a variable vector collecting the variables related to uncontrollable loads and solar ener gy . The preferences and setting parameters of cro wdsourcees including the willingness to sell energy , constants related to batteries, solar panel or loads are communicated with the utility or the operator are denoted by X t . T o model power flow in distribution networks, we use the branch flow model [ 35 ], [ 36 ]. This model eliminates the phase angles of V i and I i and uses only ( v i , l i , s i , S i ) . v A i = v i − 2( r i P i + x i Q i ) + ` i ( r 2 i + x 2 i ) i ∈ E (4a) P j ∈ C i ( P j − ` j r j ) + p i = P i i ∈ N (4b) P j ∈ C i ( Q j − l j x j ) + q i = Q i i ∈ E (4c) P 2 i + Q 2 i = v i ` i i ∈ E (4d) Due to ( 4d ), the branch flow model is not conv ex. Howe ver , the model can be con vexified using the second order cone program (SOCP) relaxation [ 37 ] and re written as           2 0 0 0 0 2 0 0 0 0 1 − 1       P i Q i v i l i             ≤  0 0 1 1      P i Q i v i l i     (5) The noncon ve x branch flow model can be cast through con vex SOCP constraints denoted by CvxFlowModel( z t ) that collects equations ( 4a )–( 4c ) and ( 5 ), and can be solv ed efficiently by interior-point method in polynomial time [ 38 ]. In this paper, all branch flow variables are collected in a single vector variable z t := ( v , l , s , S ) t at time t . T ab . III lists all variables introduced in this study . The next section introduces the CES optimal power flow formulation and incentive design. I V . C E S - O P F A N D I N C E N T I V E S D E S I G N In this section, we propose a two-phase algorithm mini- mizing the cost of generation and thermal losses by reschedul- ing users’ shapeable loads and DERs ahead of time. The algorithm also designs localized incentives that persuade users to participate in crowdsourced energy system. In addition, the presented algorithm supports P2P energy trading transactions between dif ferent crowdsourcees and the utility . The de veloped two-phase algorithm supports arbitrary P2P energy trading between prosumers and utility , resulting in a systematic way to manage distribution netw orks amid P2P energy trading while incentivizing cro wdsourcees to contribute to this ecosystem. The algorithm also supports the operation of islanded, self- autonomous microgrids. The algorithm is described next. T ABLE III N OTA T I O N F O R V A RI O U S D E R S I N C E S ∗ . Symbols Description S g i,t Dispatchable generation P r i,t Real power generated from solar panel P b i,t Output power of the battery S u i,t Apparent power of uncontrollable load S s i,t Apparent power of shapeable load p i,t Net real power injection at each b us x b i,t A variable collecting all of the v ariables in battery model x s i,t A variable collecting all of the v ariables in shapeable model x t A variable collecting v ariables in battery and shapeable model y t A variable collecting the v ariables of uncontrollable loads and solar energy z t A variable collecting all of the branch flo w variables X t Preferences and setting parameters of crowdsourcees ∗ Symbols with or without subscript i, t have the same meaning for simplicity . T ABLE IV E T T T Y P E S A N D T H E C O R RE S P O ND I N G I N R E LE V A N C E T O T H E T WO - P H AS E A L GO R I T HM . Seller Buyer Pricing Mechanism Optimization Phase ETT T ype A C T 1 Utility Contract pricing Phase I ETT T ype A C T 2 Utility Incentiv e pricing Phase II ETT T ype B C T 2 C T 2 Negotiated pricing Phase I The first phase of the algorithm is akin to day-ahead scheduling gi ven load, solar forecasts, which belongs to op- timization and grid constraints in Section II-B . This phase takes into account the types of crowdsourcees and their day- ahead preferences as well as the pre-scheduled ETTs among crowdsourcees. Giv en the day-ahead solutions from the first phase, the second phase reflecting market mechanism in Section II-B performs two significant operations. First, rec- tifying the mismatch in the day-ahead forecasts and hence the demand shortage/surplus by (a) obtaining more accurate, hour- ahead forecasts and (b) solving for real-time deviations in the generator and DER setpoints. Second, allowing for real-time energy transactions through the design of monetary incentiv es that re ward crowdsourcees. T ab . IV summarizes the ETT types in relev ance to the two-phase algorithm. For different phases and users, the pricing mechanism also changes. Con- tract pricing is decided by contract between C T 1 and utility , incentiv e pricing for C T 2 is further explained in Section IV -B . Negotiated pricing is determined between the cro wdsourcees and their neighbors. In short, the first phase manages the larger chunk of operations, whereas the second phase deals with the mismatch in load and renewable energy generation. The next two sections present the details of the two-phase algorithm. A. Phase I: Day-Ahead CES Operation As discussed in Section III , the network operator com- pletely controls C T 1 users’ DERs according to the signed contract, while C T 2 users decide to participate or not in the cro wdsourcing schedules based on their preferences and the offered incentiv es. E.g., C T 2 users can sell their surplus solar power to the utility if designed incentive is suf ficient or acceptable in the hour-ahead or real-time markets. This entails—and due to the nature of C T 2 users—that the output from solar panels P r i,t , batteries P b i,t , and shapeable loads P s i,t for users i ∈ C T 2 are uncontrollable by the utility . Hence, if IEEE TRANSA CTIONS ON SYSTEMS, MAN AND CYBERNETICS: SYSTEMS, IN PRESS 6 T ype 2 crowdsourcees declare that the y would not trade energy with other users (T ype B transactions), then in this phase these quantities are excluded in ( 3 ) by setting them to zero yielding P r i,t = P b i,t = P s i,t = 0 , i ∈ C T 2 . (6) Otherwise, the sellers and buyers should send the energy supply-demand requests for P2P energy trading day ahead to the utility . These requests for C T 2 users in time-period t are expressed as constraint EnergyT rading ( x 2 t , y t ) . This constraint ultimately transforms variables x 2 t , y t to mere predefined constants since the users decide to inject (or re- ceiv e) a certain amount of energy into (from) the grid. The Crowdsourced Energy System Optimal Power Flow (CES- OPF) is formulated as CES-OPF: min x t , z t P g t P T t =1 J t ( x t , z t , P g t ) s . t . ( 1 ) − ( 3 ) , ( 6 ) , y t = y f − 24hr t , x t ∈ X t (7) CvxFlo wMo del( z t ) , z min t ≤ z t ≤ z max t P g t ∈ P , EnergyT rading ( x 2 t , y t ) . The objecti ve function of CES-OPF at time t is defined as J t ( x t , z t , P g t ) = n g X i =1 C i,t ( P g i,t ) + |E | X i =1 l i,t r i + |C T 1 | X i =1 U i ( x t ) . The objecti ve is to minimize the generator’ s cost function, giv en by P n g i =1 C i,t ( P g i,t ) , in addition to the thermal losses that are characterized by P |E | i =1 l i,t r i , and crowdsourcees’ disutility function U i ( x t ) = u i ( S s i,t − S s, max i ) 2 , ∀ t ≤ T set designed to compensate for the incon venience caused by rescheduling shapeable load. The parameter u i ∈ [0 , 1] stands for the urgenc y to finish a certain task before a setting time T set ; the S s, max i is the same parameter appearing in ( 2 ); and u i is parameter determined by users through preferences X t . The CES-OPF captures the cost of power losses between two peers through the second term of J t ( · ) which sums the losses for all lines E in a distribution network. These lines include the distribution lines between any two users/peers, including traditional energy consumers. Preferences set by users are included in X t and are assumed to be linear and time-dependent; y f − 24hr t is the day-ahead uncontrollable load and solar energy forecasts. Constants z min t and z max t are lower and upper bounds on branch flow model variable z t ; i.e. , the voltage in p.u. at each node is in [0 . 95 1 . 05] . The linear ramp constraints and upper/lo wer bounds on P g t are denoted by P . The CES-OPF can be decomposed into small optimization sub-problems by decoupling v ariables and constraints—the ov erall problem can be then solved through a decentralized al- ternating direction method of multipliers (ADMM) algorithm; see [ 39 ]. Another approach is to simply solve CES-OPF in a centralized fashion after requesting the user’ s preferences X t ahead of time for medium- or small-scale distribution networks and microgrids. Another way of making CES-OPF more computationally tractable is to replace the con ve xified branch flo w model with the LinDistFlo w( z t ) model [ 40 ] which is linear in z t ; this transforms CES-OPF to a quadratic program that can be solved for large-scale networks. After solving CES-OPF , we obtain the equilibrium S g , eq i,t = P g , eq i,t + j Q g , eq i,t and x eq 1 t which includes P b , eq i,t and S s , eq i,t . This entails that the utility-scale generation, batteries and shapeable loads belonging to C T 1 users will be fixed with this equi- librium for the next 24 hours. T o compensate cro wdsourcees for their contributions, the distributed locational marginal price (DLMP)—the time-v arying electricity price for users at various b uses in the network—is computed by finding the dual variables associated with the real po wer balance constraint in the con vexified branch flo w model, and denoted by λ eq i,t . B. Phase II: Real-T ime CES Incentives Design As outlined in Section IV -A , we solve CES-OPF and obtain setpoints for utility-scale po wer plants and T ype 1 crowdsourcees, knowing that some enery trading transactions will take place between crowdsourcees. In this section, the presented crowdsourcing incentive design performs the two key functions: (a) Incentivizes T ype 2 cro wdsourcees to sell excess solar po wer to the utility; (b) Mitigates and balances the unexpected load and solar output fluctuations due to the forecast error in the grid. The formulation presented in this section is solved e very hour or less, depending on the av ail- ability of hour-ahead forecasts and the operator’ s preference. Here, we outline the design of crowdsourcing incenti ves that pro vide near real-time ancillary services to relie ve real- time demand shortage or surplus—and hence the additional incentiv es which based on the amount of energy provided to the grid are offered for C T 2 . For i ∈ C T 2 , the amount of energy pro vided to the grid is depicted by the net injection power P ni i,t and computed as P ni i,t = P r i,t − P s i,t + P b i,t , i ∈ C T 2 . (8) This indicates when solar panels produce more power , and the shapeable load reduces, more net injected power can be sold to the utility or other crowdsourcees through energy trading. Here, for i ∈ C T 2 , shapeable loads and batteries cannot be scheduled 24 hours ahead since no contract exists between T ype 2 crowdsourcees and the utility . Hence, P s i,t and P b i,t belonging to variable x 2 t are treated now as uncontrollable loads for C T 2 in Phase II. In addition, solar energy is also known ahead of time. Hence, P ni i,t is known and not an optimization v ariable for T ype 2 crowdsourcees from ( 8 ). The crowdsourcing incentive design routine for crowdsourcees i at time t is formulated as CES-ID: min x t , z t P g t , λ a t b t n g X i =1 C i,t ( P g i,t − P g , eq i,t ) + |E | X i =1 l i,t r i + |C T 2 | X i =1 b i,t s . t . ( 1 ) − ( 3 ) , ( 8 ) , x 1 t = x eq 1 t , x 2 t ∈ X 2 t y t = y f − 1hr t , z min t ≤ z t ≤ z max t (9) CvxFlo wMo del( z t ) , P g t ∈ P b i,t = P ni i,t ( λ eq i,t + λ a i,t ) , b i,t ≥ 0 , i ∈ C T 2 P |C T 2 | i =1 b i,t ≥ b total t , i ∈ C T 2 . In CES-ID, the objectiv e is to minimize (a) the deviation in the cost of generation from the day-ahead operating point, (b) the IEEE TRANSA CTIONS ON SYSTEMS, MAN AND CYBERNETICS: SYSTEMS, IN PRESS 7 network’ s thermal losses, and (c) the budget P |C T 2 | i =1 b i,t (in $) which the operator has allocated to spend on the real-time incentiv es at the feeder level. The constraints are explained as follows. W e set v ariables P b i,t , S s i,t ∈ x 1 t to the equilibrium P b , eq i,t , S s , eq i,t ∈ x eq 1 t which is obtained by CES-OPF to schedule DERs that are controlled by the utility . For i ∈ C T 2 , the willingness to sell energy to the utility is set in preference X 2 t which sent to system operator . The constraints on y t , z t , P g t are the same as CES-OPF ( 7 ) except that y t is set to the hour - ahead (or shorter) av ailable forecast y f − 1hr t . Besides the optimization variables mentioned above, we consider that T ype 2 cro wdsourcees recei ve the final incentiv e price λ eq i,t + λ a i,t where λ a i,t , additional variable, is an adjustment price which varies with the net energy injected to grid and location of C T 2 ; λ eq i,t is DLMP computed by CES-OPF . The variable budget b i,t for i ∈ C T 2 at t is equal to P ni i,t ( λ eq i,t + λ a i,t ) , which is always greater than 0. As mentioned P ni i,t , λ eq i,t are known. When the crowdsourcee i has no energy to sell to utility ( P ni i,t ≤ 0 ), variable λ a i,t is forced to approach − λ eq i,t to make b i,t as 0 + (a small positiv e value which is approximately close to zero). Hence no incentiv e is offered to those who inject no po wer into the grid. When P ni i,t > 0 which means crowdsourcee i at t has excess energy to sell, v ariable λ a i,t is forced to be small while also minimizing the final incenti ve price λ eq i,t + λ a i,t and budget b i,t for all T ype 2 crowdsourcees. At time t , the total budget for C T 2 is b total t , which can be set as a reasonable value. For example, this can be set to the cost for dispatchable generation to produce P |C T 2 | i =1 P ni i,t . Further explanations and examples are presented in Section VI-B . Notice that both CES-OPF and CES-ID are based on branch flow model which is con ve x, and can be solved with great efficienc y in polynomial time by interior-point optimizer . The CES-ID is solved hourly , and the computed incentiv es are sent to users at the end of the day . Thus, the energy trading (T ype A transactions) between C T 2 users and the utility is finished. The transactions are done by the assist of blockchain, which is explained in next section. V . B L O C K C H A I N A N D S M A RT C O N T R A C T S I M P L E M E N T A T I O N F O R C E S S In this section, we discuss an implementation for blockchain that is scalable to accommodate millions of crowd- sourcees and energy trading transactions. An algorithm to integrate the optimization models in Section IV with this blockchain implementation is also presented. A. Blockc hain and Smart Contracts Implementation for CESs While T ab . I summarizes the attributes of dif ferent blockchain platforms, this section identifies the properties most applicable for the proposed crowdsourced energy sys- tem model and algorithms introduced in Section III and IV . Specifically , the blockchain platform must adequately address the goals to incorporate a precise set of CES users, the com- putational requirements of the cro wdsourced energy system algorithms, the performance of the consensus algorithms, and the pri v acy demands of the users. The CES requirements and blockchain properties for each of these domains are T ABLE V C E S R E Q UI R E M EN T S M A P P IN G T O B L O CK C H A IN F E A T U R E S . CES Requirements Blockchain F eatures Participants The CES will be operated for a distribution grid, so users will be confined to a geographic area users Permissioned chain as users should be restricted to those currently within that distribution area Computation CES must require perform- ing non-linear optimiza- tions such as solving po wer flow and economic dis- patch Efficient smart contracts requiring the ability to ex- ecute Turing complete pro- grams on large quantities of data without heavy cost Consensus Minimal energy usage to ensure energy sustainabil- ity goals of CES A void computationally ex- pensiv e PoW consensus al- gorithms Privacy Crowdsourcee preferences and usages likely exposes priv acy data Permissioned model that protects crowdsourcee data from external observers identified in T ab . V . Based on this analysis, the Hyperledger is selected to meet the required CES requirements and necessary blockchain features. As previously mentioned, Hyperledger uses RBFT for consensus, which should minimize the energy required for each transaction. Furthermore, Hyperledger’ s per - missioned model ensures that the participants are restricted to those within the distribution grids service region, and also prev ents the exposure of priv acy data from crowdsourcees. Finally , the smart contracts can be implemented through the chaincode mechanisms, which does not require the per- operation execution costs that are enforced on other public blockchains. This, unlike other blockchain applications, still requires a central authority—the utility company or the system operator to manage the grid, provide technical supports for each small- scale energy trading, clear the market, and ensure there is no violation of any technical constraints (e.g., distrib ution line limits). Small-scale energy trading without a central authority can take place (see [ 41 ]), yet the scaling of these transactions to include thousands of people and millions of daily energy transactions without the utility coordinating the communica- tion among small-scale energy trading systems is remote in todays mark ets. T o this end, the presented architecture in this paper requires a central authority to manage the grid but can also autonomously be run in islanded microgrids as we showcase in the case studies section. B. Blockc hain Implementation using Hyperledger F abric W e integrate and implement blockchain and smart contracts with the optimization models gi ven in Section IV . This is shown in Fig. 4 . The presented CES implementation consists of three modules—surrounded by the dotted lines in Fig. 4 . Module I, corresponding to optimization and grid constraints in Section II-B , includes the optimization problems in Sec- tion IV which are coded by CVXPY [ 42 ]. Module II is a Node.js application, also take care of the communication between Python-written optimization problem and Module III. This process is finished by the child_process standard library which generates a python process and computes the solutions to CES-OPF ( 7 ), CES-ID ( 9 ) while returning results back to Node.js program. IEEE TRANSA CTIONS ON SYSTEMS, MAN AND CYBERNETICS: SYSTEMS, IN PRESS 8 Fig. 4. Architecture of combining blockchain and smart contract with the optimization formulations presented in this paper . Module III, the information system in Section II-B , is im- plemented by the IBM Hyperledger Fabric Network deployed in cloud to provide the blockchain service. The network consists of many peers that communicate with each other , runs smart contracts called chaincode which is written by Go language, holds state and ledger data. Peers in the Hyperledger Fabric Network are different from the ones in the other blockchain implementations. The roles of peers relate to the life-cycle of transactions which is one ke y difference between Hyperledger Fabric and many other blockchain platforms. The life-cycle of a transaction in other blockchain platforms is usually order-e xecute, which means that transactions are added to the ledger in a specific order and executed sequentially . But in Hyperledger Fabric, it is a three-step process: e xecute-order - validate. First, transactions are e xecuted in parallel considering any order . Second, they are ordered by an ordering service. Third, each peer validates and applies the transactions in sequence. The roles of peers also ha ve a strong relationship with rob ust pri v acy and permission support, the reader is referred to [ 43 ] for more information. The crowdsourcees shown in Fig. 4 are the end-users in the distribution network and can perform energy trading. Thousands of cro wdsourcees are allowed to connect and sign up to the F abric network via a browser after recei ving a code from the operator . The operator also can log in via browser to manage the overall system—screen shots are gi ven in the next section showing the graphical user interface. After enrolling in the netw ork via Fabric-CA [ 44 ], a certificate needed for enrollment through a software dev elopment kit (SDK), crowdsourcees can communicate with the network through fabric-sdk-node [ 45 ], update their preferences to blockchain and store it in W orld State [ 46 ] which is the database. Peers in Hyperledger are used to commit trans- actions, maintain the world state and a copy of the ledger (consists of blocks). The chaincode in Hyperledger F abric is deployed into peers and is ex ecuted as a user satisfies their commitments. Then, or dering service , akin to mining in Bitcoin, generates ne w blocks in Fabric. Ev ery peer updates their local blockchain after recei ving ordered state updates in the form of blocks from the ordering service. In this way , the order and number of blocks, a form of blockchain, are Algorithm 1 Blockchain-Assisted CES Operation Phase I: Obtain crowdsourcees preferences X t Request/obtain day-ahead P2P ETT requests via blockchain imple- mentation dev eloped (Fig. 4 ) Estimate day-ahead forecasts y f − 24 hr t Solve CES-OPF ( 7 ) and obtain generator and DER schedules Establish T ype A ETTs smart contracts for users i ∈ G S C T 1 Establish T ype B ETTs smart contracts for users i ∈ C T 2 Phase II: while t ∈ 1 , . . . , 24 hrs do Select T ype 2 crowdsourcees willing to sell solar power to the utility at time t according to the preferences X 2 t Obtain hour-ahead forecasts y f − 1 hr t Solve CES-ID ( 9 ) at time t Communicate to cro wdsourcees i ∈ C T 2 incentiv es λ eq i,t + λ a i,t Establish T ype A ETTs smart contracts for users i ∈ C T 2 end while Reconcile payments weekly or monthly maintained and synchronized for all peers. The ETTs records are included in blockchain stored at each peer’ s repository and protected by this mechanism. This specific implementation is endowed with the follo wing characteristics: (i) Scalable to million of crowdsourcees, (ii) Requires little understanding of the blockchain technology from the users’ side, (iii) Communicates seamlessly with any optimization-based formulation, and (iv) Requires very little energy to run blockchain. Algorithm 1 illustrates ho w the de veloped optimization routines are implemented with blockchain and smart contracts. V I . C A S E S T U D I E S A. Simulation Setup The numerical tests are simulated in Ub untu 16.04.4 L TS with an Intel(R) Xeon(R) CPU E5-1620 v3 @ 3.50 GHz. W e use the Southern California Edison (SCE) 56-bus test feeder [ 47 ] as a distribution network. Reasonable uncontrol- lable load profile P u is generated for T = 24 hrs from California Independent System Operator (CAISO) [ 48 ] and normalized to ensure that the optimization problems ha ve feasible sets for dif ferent time-periods. W e modify SCE 56-bus IEEE TRANSA CTIONS ON SYSTEMS, MAN AND CYBERNETICS: SYSTEMS, IN PRESS 9 Power Grid EET Type A EET Type B Solar Panel Load (Home Appliance) Switchboard Inverter Battery Node 2 (CT 2 ) Node 53 (CT 2 ) Node 43 (CT 2 ) Fig. 5. Scenarios of energy trading transactions. 0 5 10 15 20 T ime (h) − 3 − 2 − 1 0 1 2 3 4 Power (MW) P g o r i g P g C E S − O P F P u P r C E S − O P F of C T 1 Net Supply by C T 1 P s o r i g of all users P s C E S − O P F of C T 1 P b C E S − O P F of C T 1 Fig. 6. Aggregate load profile and generation after solving CES-OPF ( 7 ). test feeder as shown in Fig. 2 and place stationary batteries, solar panels, uncontrollable and shapeable loads at each b us in the network; see Fig. 5 . Similar to [ 11 ], batteries are set up with a po wer capacity of 80% of the peak uncontrollable load at the bus, an 4-hour energy storage capacity with 20% initial energy storage. W e assume that the solar generation power profile is gi ven and contributes to 50% of the uncontrollable load at peak for each bus. Shapeable loads ha ve net ener gy demand that is up to 20% the peak po wer consumption of the uncontrollable loads and can be char ged for 4–8 hours. The scheduling time of shapeable loads is from 8 am to 11 pm. W e also assume that each bus is connected to a crowd- sourcee of T ype 1 ( C T 1 ) or T ype 2 ( C T 2 ). W e make the following assignment: If the number of a bus is a prime number , then the user belongs to C T 2 , otherwise they belong to C T 1 (we hav e |C T 1 | = 40 and |C T 2 | = 16 ). From the above setup, Nodes 2, 43 and 53 belong to C T 2 in Fig. 5 . As we present in T ab . IV , two types of energy trading transactions take place in crowdsourced ener gy systems. T ype A transactions occur between C T 1 or C T 2 with utilities, while the trading transactions among C T 2 users are T ype B transactions. In Fig. 5 , we present two scenarios of ener gy trading transaction for further explanation: (i) ETT T ype A where Node 2 decides to sell e xcess solar energy to the utility , (ii) ETT T ype B where Node 43 chooses to buy ener gy from Node 53. The next section presents the outcome of the two- phase optimization discussed in Section IV . B. Results and Discussions In order to present the effecti veness of our algorithm, we compare the cases with and without considering the energy 0 5 10 15 20 T ime (h) 11 12 13 14 15 16 17 Price ($/MWh) Price comparison of Node 1 and 55 DLMP of Node 1 without scheduling DERs DLMP of Node 1 λ e q 1 with DERs DLMP of Node 55 without scheduling DERs DLMP of Node 55 λ e q 55 with DERs Fig. 7. Price comparison of Node 1 and 55 before and after CES-OPF . 0 5 10 15 20 − 10 0 10 20 30 40 50 Price ($/MWh) Node 2’s DLMP and final incentive price Final Incentive Price λ e q 2 + λ a 2 Additional Price λ a 2 DLMP λ e q 2 0 5 10 15 20 T ime (h) 0.00 0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 Incentive Money($) Incentive Money b 2 Net Injection P n i 2 − 0.015 − 0.010 − 0.005 0.000 0.005 0.010 0.015 0.020 0.025 Net Injection(MWh) Node 2’s net injection and incentive money Fig. 8. Final incentiv e price, net injection and incentiv e money for Node 2. trading among crowdsourcees based on the modified SCE 56 bus test feeder illustrated in Section VI-A . 1) Phase I: Day-Ahead CES Operation: solving CES- OPF ( 7 ). Fig. 6 shows P u , P s orig and P g orig (the aggreg ate uncontrollable load, shapeable load, and the output of gen- erator) when our algorithm is not applied—in the absence of energy cro wdsourcing or trading between crowdsourcing. Fig. 6 also shows the aggregate load profile and generation after solving the CES-OPF for T = 24 hrs . The figure shows that battery variable P b CES − OPF charges when the solar panel produces and injects power P r CES − OPF into network. The reason why the curve of P b CES − OPF does not change significantly is that the solar panels do not generate enough energy in this setup. Hence the algorithm is less inclined to store energy into batteries. As for the scenarios when the solar panel produces enough energy , please refer to Fig. 11 in the section of Islanded Microgrid T est ( VI-B3 ). Fig. 6 indicates that shapeable loads of C T 1 are rescheduled to P s CES − OPF . The updated power generation P g CES − OPF is smaller than P g orig due to the injections of solar po wer, scheduling of batteries and shapeable loads from crowdsourcees C T 1 .Fig. 7 presents the changes in the DMLPs with and without scheduling DERs in the distribution network through CES-OPF ( 7 ) for Nodes 1 and 55. The DLMPs for both nodes are smaller due to the net injection from T ype 1 crowdsourcees (shaded orange area in Fig. 6 ). This illustrates how the DLMP price becomes lo wer when rescheduling DERs and injecting renewable energy into the grid. IEEE TRANSA CTIONS ON SYSTEMS, MAN AND CYBERNETICS: SYSTEMS, IN PRESS 10 0 5 10 15 20 − 10 0 10 20 30 40 50 Price ($/MWh) Node 53’s DLMP and final incentive price Final Incentive Price λ e q 53 + λ a 53 Additional Price λ a 53 DLMP λ e q 53 0 5 10 15 20 T ime (h) 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 Incentive Money($) Incentive Money b 53 Net Injection P n i 53 − 0.015 − 0.010 − 0.005 0.000 0.005 0.010 0.015 0.020 0.025 Net Injection(MWh) Node 53’s net injection and incentive money Fig. 9. Final incentive price, net injection and incentive money for Node 53. T ABLE VI T R AN S AC T I ON D E T A I LS F O R N O D E 5 3 . T ime Seller Buyer Ener gy ETT T ype Phase 6 am–9 am Node 53 Utility 0.0385 MWh T ype A Phase II 9 am–2 pm Node 53 Node 43 0.119 MWh T ype B Phase I 14 pm–5 pm Node 53 Utility 0.062 MWh T ype A Phase II 2) Phase II: Real-T ime CES Incentives Design: CES-ID is solved once every hour but it can also be solved ev- ery 5–15 minutes depending on the av ailability of accurate weather/load forecasts. The monetary re wards offered to T ype 2 crowdsourcees are obtained from CES-ID. W e assume that the crowdsourcees of T ype 2 at Nodes 2, 43, and 53 accept the designed incenti ves. Fig. 8 shows the final incentive price, net injection, and ov erall incentiv e money for Node 2. The time-varying nature of the final incentive price of a node is due to v ariations of its DLMP and its net injection. W e assume that the solar panel produces energy between 6 am and 7 pm. The solar panel of Node 2 produces solar po wer and incentiv es are earned by the customer between 6 am and 2 pm as sho wn in Fig. 8 . Howe ver , the load at Node 2 starts to consume energy at 5 pm making the net injection of Node 2 is 0 MWh. Hence, no monetary incenti ves are offered from 7 pm to 11 pm. Fig. 9 presents the results for T ype B transactions for C T 2 user at Node 53. The user at Node 43 decides to charge the battery at a constant charging rate between 9 am and 2 pm, and the excess solar energy produced from Node 53’ s solar power can satisfy this demand shortage. Notice that Node 43 only consumes energy while Node 53 earns incentiv e rewards from the utility and negotiated money from Node 43 during different time periods. The transaction details between these crowdsourcees are summarized in T ab . VI . Fig. 10 depicts the aggregate load profile and generation af- ter Algorithm 1 terminates. More rene wable energy is injected into the grid and traded via the designed incentiv es for C T 2 crowdsourcees. The net contrib ution of C T 2 crowdsourcees is shaded in red. It is notew orthy to mention that the utility cannot schedule the shapeable loads of C T 2 crowdsourcees. The blue area in Fig. 10 displays the unexpected load demand of C T 2 crowdsourcees. The generator at the substation cov ers this demand shortage; see Fig. 10 where P g CES − ID is greater than P g CES − OPF from 3 pm to 11 pm. 0 5 10 15 20 T ime (h) − 0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 Power (MW) P g o r i g P g C E S − O P F P g C E S − I D P r C E S − I D of C T 2 Net Supply by C T 1 Net Supply by C T 2 P s C E S − I D of C T 2 Fig. 10. Aggregate load profiles and generation after Algorithm 1 terminates and the incentives are designed. 0 5 10 15 20 T ime (h) − 4 − 2 0 2 4 6 8 Power (MW) P g i s l a n d P r i s l a n d P s i s l a n d P u i s l a n d P b i s l a n d Fig. 11. Results for an islanded, autonomous microgrid operation. 3) Islanded Micr ogrid T est: After implementing P2P en- ergy trading, we simulate a scenario of a small islanded, autonomous microgrid. In this microgrid, we assume the fol- lowing. First, all users have (a) enough solar power to produce enough energy to supply the grid, and (b) the microgrid has a battery with sufficient capacity to store excess solar energy . Second, each user agrees to participate in the program and their DERs would be fully controlled by the microgrid management algorithm akin to Algorithm 1 . The simulation setup remains the same as in Section VI-A except the solar panels produce more energy and the capacities of batteries are enlarged. Fig. 11 shows the outcome of the autonomous microgrid operation. Between 6 am and 7 pm, the solar panel on each crowdsourcees’ roof not only produces enough energy to meet the real-time load demand b ut also stores excess energy into batteries for night use. At night, batteries start to discharge ener gy to cover the demand shortage facilitating energy trading transactions with cro wdsourcees in need for energy using blockchain and smart contracts. 4) Blockc hain and ETT GUI: Fig. 12 shows a web-based user prototype that we implemented using Hyperledger Fab- ric as described in Section V . The web application shows the system operation which includes creating crowdsourcees, selling energy to the utility or neighborhood, and listing all energy trading transactions with information about the prices and the users. This web-based prototype interacts with the optimization solvers and algorithms that generate forecasts, as well as the cro wdsourcees. V I I . P A P E R S U M M A RY , L I M I T AT I O N S A N D F U T U R E W O R K The paper introduces the notion of blockchain-assisted crowdsourced ener gy systems with a specific implementation IEEE TRANSA CTIONS ON SYSTEMS, MAN AND CYBERNETICS: SYSTEMS, IN PRESS 11 Fig. 12. W eb-based user interface for CESs with Hyperledger Fabric. and prototype of blockchain that scales to include millions of crowdsourcees and P2P energy trading transactions. A thorough revie w of the blockchain technology for energy systems is given. V arious types of crowdsourcees and energy trading transactions are introduced to mimic current and projected energy market setups. Then, an operational OPF- based model of CESs with batteries, shapeable loads, and other DERs is introduced for distribution networks—considering energy trading transactions and crowdsourcees preferences— yielding a day-ahead market equilibrium. Monetary incenti ves are designed to attract cro wdsourcees in hour -ahead and real- time markets to the computed equilibrium while satisfying a demand shortage or surplus. Furthermore, an implementation of blockchain through the IBM Hyperledger Fabric is dis- cussed with its coupling with the optimization models. This implementation allows the system operator to manage the network users to seamlessly trade energy . Finally , case studies are giv en to illustrate the practicality of the presented methods for classical distribution networks, as well as self-suf ficient and islanded microgrids. There is still a uncontrollable risk in blockchain based energy trading system, i.e., the attack from malicious market operator , stakeholders or outsider . (1) A malicious market operator will attempt to modify the operation of the market algorithms in order to produce results that provide an output (market price, load demand) providing them with a financial advantage over the authentic price or demand outputs. (2) A malicious stakeholder might try to produce a false clearing price offering them with reduced energy costs. Howe ver , because Hyperledger messages are digitally signed, the con- sensus results will not be manipulated as long as there are 2 f + 1 total operators, where f is the number of malicious operators. (3) A malicious outsider will try to remotely tamper with all messages communicated between the crowdsourcees and market operators. Their goal is to manipulate the resulting market operations in order to either manipulate (i) the load demand bids submitted by the cro wdsourcees or (ii) the market clearing prices. In future work, we plan to extend the presented research to address distributed consensus mechanisms for blockchain in crowdsourced energy system, and threats from malicious crowdsourcees, market operators, and outsiders. R E F E R E N C E S [1] S. W ang, A. T aha, and J. W ang, “Blockchain-assisted crowdsourced energy systems, ” in 2018 IEEE PES General Meeting, P ortland, Ore gon , August 2018. [Online]. A vailable: https://arxiv .org/abs/1802.03099 [2] J. Howe, “The rise of crowdsourcing, ” Wir ed magazine , vol. 14, no. 6, pp. 1–4, 2006. [3] P . G. Ipeirotis, “ Analyzing the amazon mechanical turk marketplace, ” XRDS: Cr ossroads, The ACM Magazine for Students , vol. 17, no. 2, pp. 16–21, 2010. [4] X. He, D. W . Ho, T . Huang, J. Y u, H. Abu-Rub, and C. Li, “Second- order continuous-time algorithms for economic power dispatch in smart grids, ” IEEE T ransactions on Systems, Man, and Cybernetics: Systems , vol. 48, no. 9, pp. 1482–1492, 2018. [5] X. He, T . Huang, J. Y u, C. Li, and Y . Zhang, “ A continuous-time algorithm for distrib uted optimization based on multiagent networks, ” IEEE T ransactions on Systems, Man, and Cybernetics: Systems , pp. 1– 10, 2018. [6] M. H. Hajiesmaili, M. Chen, E. Mallada, and C.-K. Chau, “Crowd- sourced storage-assisted demand response in microgrids, ” in Pr oceedings of the Eighth International Conference on Future Energy Systems . A CM, 2017, pp. 91–100. [7] R. Deng, Z. Y ang, M. Y . Chow , and J. Chen, “ A surve y on demand response in smart grids: Mathematical models and approaches, ” IEEE T ransactions on Industrial Informatics , vol. 11, no. 3, pp. 570–582, June 2015. [8] C. Langbort, “On real-time pricing for strategic agents, ” in W orkshop on Multi-Agent Coordination and Estimation , 2010. [9] T . Namerikaw a, N. Okubo, R. Sato, Y . Okawa, and M. Ono, “Real- time pricing mechanism for electricity market with built-in incentive for participation, ” IEEE Tr ansactions on Smart Grid , vol. 6, no. 6, pp. 2714–2724, Nov 2015. [10] Y . Y uan and F . W ang, “Blockchain and cryptocurrencies: Model, tech- niques, and applications, ” IEEE Tr ansactions on Systems, Man, and Cybernetics: Systems , vol. 48, no. 9, pp. 1421–1428, Sept 2018. [11] E. M ¨ unsing, J. Mather , and S. Moura, “Blockchains for decentralized optimization of ener gy resources in microgrid networks, ” in Contr ol T echnology and Applications (CCT A), 2017 IEEE Confer ence on . IEEE, 2017, pp. 2164–2171. [12] F . Luo, Z. Y . Dong, G. Liang, J. Murata, and Z. Xu, “ A distributed electricity trading system in activ e distribution networks based on multi- agent coalition and blockchain, ” IEEE T ransactions on P ower Systems , 2018. [13] Z. Su, Y . W ang, Q. Xu, M. Fei, Y .-C. Tian, and N. Zhang, “ A secure charging scheme for electric vehicles with smart communities in energy blockchain, ” IEEE Internet of Things Journal , 2018. [14] J. Kang, R. Y u, X. Huang, S. Maharjan, Y . Zhang, and E. Hossain, “Enabling localized peer-to-peer electricity trading among plug-in hybrid electric vehicles using consortium blockchains, ” IEEE T ransactions on Industrial Informatics , vol. 13, no. 6, pp. 3154–3164, 2017. [15] A. Paudel, K. Chaudhari, C. Long, and H. B. Gooi, “Peer-to-peer energy trading in a prosumer based community microgrid: A game-theoretic model, ” IEEE Tr ansactions on Industrial Electr onics , 2018. [16] C. Long, J. W u, Y . Zhou, and N. Jenkins, “Peer-to-peer energy sharing through a two-stage aggregated battery control in a community micro- grid, ” Applied Energy , vol. 226, pp. 261–276, 2018. [17] X. Huang, Y . Zhang, D. Li, and L. Han, “ An optimal scheduling algo- rithm for hybrid ev charging scenario using consortium blockchains, ” Futur e Generation Computer Systems , vol. 91, pp. 555–562, 2019. IEEE TRANSA CTIONS ON SYSTEMS, MAN AND CYBERNETICS: SYSTEMS, IN PRESS 12 [18] A. Hahn, R. Singh, C. Liu, and S. Chen, “Smart contract-based campus demonstration of decentralized transacti ve energy auctions, ” in 2017 IEEE PES Innovative Smart Grid T echnologies , 2017. [19] M. Swan, Blockchain: Blueprint for a new economy . ” O’Reilly Media, Inc. ”, 2015. [20] A. Baliga, “Understanding blockchain consensus models, ” T ech. rep., Persistent Systems Ltd, T ech. Rep, T ech. Rep., 2017. [21] “Digiconomist, ” accessed 7 Feb. 2019. [Online]. A vailable: https: //digiconomist.net/bitcoin- energy- consumption [22] V . Zamfir , “Introducing casper the friendly ghost, aug. 2015. blog. ethereum. org, ” 2015. [23] “Hyperledger open source blockchain technologies, ” accessed 7 Feb. 2019. [Online]. A vailable: https://www .hyperledger .org [24] J. Licata, “500 billion reasons blockchain can be a po wer play, ” Mar 2017, accessed 7 Feb . 2019. [Online]. A vailable: https://www .greenbiz. com/article/500- billion- reasons- blockchain- can- be- power - play [25] E. Mengelkamp, J. G ¨ arttner , K. Rock, S. Kessler , L. Orsini, and C. W einhardt, “Designing microgrid energy markets: A case study: The brooklyn microgrid, ” Applied Ener gy , vol. 210, pp. 870–880, 2018. [26] H. W ang, T . Huang, X. Liao, H. Ab u-Rub, and G. Chen, “Reinforce- ment learning in energy trading game among smart microgrids, ” IEEE T ransactions on Industrial Electr onics , v ol. 63, no. 8, pp. 5109–5119, 2016. [27] S. P ark, J. Lee, S. Bae, G. Hwang, and J. K. Choi, “Contribution- based energy-trading mechanism in microgrids for future smart grid: A game theoretic approach, ” IEEE T ransactions on Industrial Electronics , vol. 63, no. 7, pp. 4255–4265, 2016. [28] K. Gai, Y . W u, L. Zhu, M. Qiu, and M. Shen, “Pri v acy-preserving ener gy trading using consortium blockchain in smart grid, ” IEEE Tr ansactions on Industrial Informatics , 2019. [29] L. Zhu, Y . Wu, K. Gai, and K.-K. R. Choo, “Controllable and trust- worthy blockchain-based cloud data management, ” Futur e Generation Computer Systems , vol. 91, pp. 527–535, 2019. [30] “D AISEE, ” accessed 8 Feb . 2019. [Online]. A vailable: https://daisee.org [31] “Grid+, ” accessed 8 Feb . 2019. [Online]. A vailable: https://gridplus.io/ [32] “Brooklynmicrogrid.com, ” accessed 7 Feb . 2019. [Online]. A vailable: http://bankymoon.co.za/ [33] P . T erium, “The global energy system is changing, and customers must tak e center stage. ” [Online]. A v ailable: https://www .weforum.org/agenda/2017/03/ how- customers- are- taking- centre- stage- to- transform- the- ener gy- system/ [34] “Brooklynmicrogrid.com, ” accessed 8 Feb . 2019. [Online]. A vailable: http://brooklynmicrogrid.com/ [35] M. Fariv ar and S. H. Low , “Branch flo w model: Relaxations and con ve xificationpart i, ” IEEE T ransactions on P ower Systems , vol. 28, no. 3, pp. 2554–2564, 2013. [36] S. H. Low , “Con vex relaxation of optimal power flowpart ii: Exactness, ” IEEE T ransactions on Control of Network Systems , vol. 1, no. 2, pp. 177–189, 2014. [37] M. Baran and F . F . W u, “Optimal sizing of capacitors placed on a radial distribution system, ” IEEE T ransactions on power Delivery , v ol. 4, no. 1, pp. 735–743, 1989. [38] M. S. Lobo, L. V andenberghe, S. Boyd, and H. Lebret, “ Applications of second-order cone programming, ” Linear algebra and its applications , vol. 284, no. 1-3, pp. 193–228, 1998. [39] Q. Peng and S. H. Low , “Distributed algorithm for optimal power flow on a radial network, ” in Decision and Contr ol (CDC), 2014 IEEE 53rd Annual Conference on . IEEE, 2014, pp. 167–172. [40] K. Turitsyn, P . Sulc, S. Backhaus, and M. Chertkov , “Options for control of reactive po wer by distributed photovoltaic generators, ” Proceedings of the IEEE , vol. 99, no. 6, pp. 1063–1073, 2011. [41] J. Cottrell and M. Basden, “How utilities are using blockchain to modernize the grid, ” Harvar d Business Review , Mar 2017. [42] S. Diamond and S. Boyd, “CVXPY: A Python-embedded modeling lan- guage for con ve x optimization, ” Journal of Machine Learning Researc h , vol. 17, no. 83, pp. 1–5, 2016. [43] “Peers hyperledger-fabricdocs master documentation, ” accessed 8 Feb. 2019. [Online]. A vailable: https://hyperledger- fabric.readthedocs.io/en/ latest/peers/peers.html [44] “hyperledger/fabric-ca, ” accessed 7 Feb. 2019. [Online]. A vailable: https://github .com/hyperledger/fabric- ca [45] “hyperledger/fabric-sdk-node, ” accessed 7 Feb . 2019. [Online]. A vailable: https://github.com/hyperledger/f abric- sdk- node [46] “Ledger h yperledger-fabricdocs master documentation, ” accessed 7 Feb . 2019. [Online]. A vailable: https://hyperledger- fabric.readthedocs. io/en/latest/ledger/ledger .html [47] Q. Peng and S. H. Low , “Optimal branch exchange for distribution system reconfiguration, ” arXiv pr eprint arXiv:1309.0651 , 2013. [48] CAISO, “Real time demand curves, ” July 2017. [Online]. A vailable: http://www .caiso.com/outlook/SystemStatus.html Shen W ang received the master’ s degree in Control Science and Engineering from the University of Science and T echnology of China, Hefei, China, in 2016. He is currently pursuing a Ph.D. degree in Electrical Engineering at the University of T exas at San Antonio, T exas. His current research interests include optimal control in cyber-physical systems with special focus on energy and water systems. Ahmad F . T aha is an assistant professor with the Department of Electrical and Computer Engineering at the University of T exas, San Antonio. He recei ved the B.E. and Ph.D. degrees in Electrical and Com- puter Engineering from the American Uni versity of Beirut, Lebanon in 2011 and Purdue Uni versity , W est Lafayette, Indiana in 2015. Dr . T aha is inter - ested in understanding how complex cyber-physical systems (CPS) operate, behav e, and misbehave . His research focus includes optimization, control, and security of CPSs with applications to power , water, and transportation networks. Jianhui W ang (M’07-SM’12) receiv ed the Ph.D. degree in electrical engineering from Illinois Insti- tute of T echnology , Chicago, Illinois, USA, in 2007. Presently , he is an Associate Professor with the Department of Electrical Engineering at Southern Methodist University , Dallas, T exas, USA. Prior to joining SMU, Dr . W ang had an ele ven-year stint at Argonne National Laboratory with the last appoint- ment as Section Lead Advanced Grid Modeling. Dr . W ang is the secretary of the IEEE Power & Energy Society (PES) Power System Operations, Planning & Economics Committee. He has held visiting positions in Europe, Australia and Hong K ong including a VELUX V isiting Professorship at the T echnical Univ ersity of Denmark (DTU). Dr . W ang is the Editor-in-Chief of the IEEE T ransactions on Smart Grid and an IEEE PES Distinguished Lecturer . He is also a Clarivate Analytics highly cited researcher for 2018. .pdf Karla Kvater nik is Research Scientist in the Predic- tiv e Analytics research group at Siemens Corporate T echnology , in Princeton, NJ. Dr . Kvaternik holds a Ph.D. in systems and control theory from the Univ ersity of T oronto, focusing on the synthesis of decentralized optimization algorithms, networked multiagent coordination control methods and stabil- ity analysis techniques thereof. Prior to her doctoral studies, she won the Best Student Paper A ward at the IEEE Multiconference on Systems and Control, for her M.Sc. work on multivariable output feedback for nonlinear systems. As a Research Associate at Princeton Univ ersity , Karla studied multiagent reinforcement learning algorithms applied to multiarmed bandit settings. At Siemens, Dr. Kvaternik enjoys addressing a v ariety of data-driv en decision support problems and prototyping transactiv e energy applications. Adam Hahn is currently an assistant professor in the Department of Electrical Engineering and Computer Science at W ashington State University . His research interests include cybersecurity of the smart grid and cyber -physical systems (CPS), including intrusion detection, risk modeling, vulnerability assessment, and secure system architectures. He received M.S. and Ph.D. degrees from the Department of Electrical and Computer Engineering at Iowa State University in 2006 and 2013. Previously , he worked as a Senior Information Security Engineer at the MITRE Cor - poration, supporting numerous cybersecurity assessments within the federal government and leading research projects in CPS security

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment