Download as pdf or txt
Download as pdf or txt
You are on page 1of 50

Challenges and opportunities of blockchain-

based system for energy communities

Elyas Khorasani

Computer Science and Engineering, master's level (120 credits)


2022

Luleå University of Technology


Department of Computer Science, Electrical and Space Engineering
EMJMD GENIAL

Université de Lorraine
Faculté des Sciences & Technologies

Leeds Beckett University

School of Built Environment, Engineering and Computing

Luleå University of Technology

Faculty of Science and Technology

Erasmus Mundus Joint Masters Degree in GENIAL

Elyas Khorasani

<Challenges and opportunities of blockchain-based system


for energy communities>

Master of Science thesis

<August, 2022>
Examiners:

Pr. Jean-Philippe Georges (UL)

Dr. Ah-Lian Kor (LBU)

Dr. Solomon Sunday Oyelere (LTU)

Supervisors:

Pr. Jean-Philippe Georges (UL)

Dr. Marta Chinnici (Enea)

2/49
This thesis is prepared as part of an Erasmus Mundus Joint Masters Degree
GENIAL – GrEen NetworkIng And cLoud computing

Project number – 610619-EPP-1-2019-1-FR-EPPKA1-JMD-MOB

https://genial.univ-lorraine.fr

EMJMD GENIAL

This thesis has been accepted by partner institutions of the consortium (cf. 2020 GENIAL
Consortium Agreement).

Successful defence of this thesis is obligatory for graduation with the following national
diplomas:

• Masters in Complex Systems Engineering with specialisation Networks, Signals and


Green ICT (University of Lorraine, France)
• Masters in Information and Technology - Sustainable Computing (Leeds Beckett
University, United-Kingdom)
• Masters in Computer Science and Engineering with specialisation Green Networking
and Cloud Computing (Lulea University of Technology, Sweden)

3/49
Abstract

Blockchain technology has attracted a lot of interest recently. Many different sectors from all
over the world are now researching the technology to find any prospective uses that can
enhance their company. This is because, by introducing new processes, blockchain technology
has the ability to fundamentally alter the way that current systems now handle all types of
transactions. The loyalty reward program sector, which deals with the exchange of loyalty
points, may be able to take advantage of blockchain technology’s potential. Different Loyalty
Reward Program models, however, define the Loyalty Reward Programs sector.

Therefore, the current study investigates how blockchain technology may affect the
development of a new loyalty reward program. To conduct the research, an exploratory
multiple-case study was employed.

In this thesis, we first investigate the use of blockchain in energy communities and their
consumer incentives. Then we proposed a model for a novel blockchain-based rewarding
system and examined multiple case studies of their usage in energy communities. Our results
show that using a blockchain-based rewarding system in energy communities can benefit the
community, environment and energy consumers.

Keywords

Energy communities, Blockchain, Rewarding systems, Loyalty programs, Green energy


incentives

4/49
Candidate’s Declaration

I, Elyas Khorasani, confirm that this dissertation and the work presented in it are my own
achievement.

Where I have consulted the published work of others this is always clearly attributed;

Where I have quoted from the work of others the source is always given. With the exception
of such quotations this dissertation is entirely my own work;

I have acknowledged all main sources of help;

I have read and understand the penalties associated with Academic Misconduct.

Signed:

Date: 15/08/2022

5/49
Contents

1. Chapter 1 Introduction ___________________________________________________ 9


1.1. Background ______________________________________________________________ 9
1.2. Aim and Objectives_______________________________________________________ 10
1.3. Rationale _______________________________________________________________ 11
1.4. Contribution ____________________________________________________________ 11
1.5. Thesis outline ___________________________________________________________ 11
2. Chapter 2 Literature Review______________________________________________ 12
2.1. Blockchain Technology ____________________________________________________ 12
2.2. Benefits of using blockchain in energy communities ____________________________ 12
2.3. Case studies of using blockchain in energy communities (The Brooklyn Microgrid (BMG))
13
2.4. Energy Tokens ___________________________________________________________ 14
2.4.1. Green Energy Tokens (NRGcoin) __________________________________________________ 14
2.5. Energy Services __________________________________________________________ 14
2.6. Existing blockchain-based rewarding Systems _________________________________ 15
2.6.1. Steemit ______________________________________________________________________ 15
2.6.2. Indorse ______________________________________________________________________ 16

3. Chapter 3 Methodology _________________________________________________ 17


3.1. Inductive case study approach _____________________________________________ 17
3.2. Energy Saving Tokenization (Metered Energy Savings) __________________________ 18
3.3. Why Blockchain in Rewarding system ________________________________________ 18
3.4. SI model _______________________________________________________________ 19
3.5. Proposed Incentive programs ______________________________________________ 19
3.6. Invitation Rewarding system diagram _______________________________________ 21
3.7. The rewarding system formulation __________________________________________ 22
3.8. Streaks _________________________________________________________________ 22
4. Chapter 4 System model and evaluation ____________________________________ 23
4.1 The general structure of the model __________________________________________ 23
4.2 Weights distribution mechanism ____________________________________________ 24
4.3 The benefits of blockchain rewarding system _________________________________ 34
4.4 Three-way benefit _______________________________________________________ 35
5. Chapter 5 Conclusion ___________________________________________________ 37
5.1. Limitations and suggestions for further research _______________________________ 37

6/49
5.2. Future work ____________________________________________________________ 37
Bibliography ______________________________________________________________ 38
Appendix 1 _______________________________________________________________ 43
Appendix 2 _______________________________________________________________ 45
Appendix 3 _______________________________________________________________ 47

7/49
Acknowledgements

My sincere thanks go to Pr. Jean-Philippe Georges and Dr. Marta Chinnici for guiding this
work. I also thank all my GENIAL colleagues for several valuable suggestions.

8/49
1. Chapter 1 Introduction
The thesis is introduced in this chapter, which is organized as follows: Section 1.1 describes
the energy communities and the need for a new incentive scheme and the rise of usage of
blockchain technology as the platform for creating that system. Section 1.2 explains the
research objectives and research question of the thesis. Section 1.3 presents the rationale for
conducting this research, and in section 1.4, the contribution of this thesis to the research
area has been discussed. Finally, in section 1.5, the organisation of the thesis is presented.

1.1. Background
The rising necessity for a quick transition of current energy systems to more sustainable
models is demonstrated by the convergence of environmental, social, and political factors.
Energy communities (ECs) have been gaining traction as a niche innovation positioned within
the more significant historical evolution of energy systems as potential leverage of this shift
(Sciullo et al., 2022).

Energy communities are a form of ‘organizing’ collective energy that acts around open,
democratic participation and governance, as well as the provision of benefits to members of
the local community. Energy communities can play an essential role in supporting the
decentralization of the energy system and local renewable energy operations. Energy
communities can also help with localized power flow optimization and energy loss reduction.
Their long-term success, however, will be determined by their capacity to operate energy
networks in a cost-effective manner that benefits all customers as well as the entire energy
system (Joint Research Centre (European Commission), Uihlein and Caramizaru, 2020).
Energy communities provide flexibility for the electricity system and provide energy efficiency
for the citizens by organising energy actions. It mainly sets out new regulations that help
consumers produce, use, exchange, or trade electricity (HJ, 2020).

Energy cooperatives are not a new concept. They existed long before the Energy Transition
when the tendency for decentralised Renewable energy production became widespread in
distant places and on islands where fuels are scarce and expensive. However, as decentralised
renewable energy production and other kinds of consumer (co-)ownership in renewables
grow more prevalent, energy communities have the potential to become a regular paradigm
in the energy markets.

The authors of (Coenen and Hoppe, 2022) discuss that because energy communities are often
locally sited, in close social proximity to residents, and are already part of local structures and
share local institutions, they may be an interesting new stakeholder in stimulating home
energy-saving efforts by tenants and homeowners due to their potential for raising local
awareness and gaining public support for low-carbon energy and energy-savings projects. This
has numerous advantages because they already have a local reputation and social history with
the community and can be trusted by the latter. This makes them possibly better positioned

9/49
to use their agency to facilitate sustainable change than other—often less trusted—parties,
for example, government and commercial companies.

However, the energy community’s benefits are contingent on consumers’ active and voluntary
engagement in real time. Consumers must be motivated and aware in order to take advantage
of the available benefits (Bhattacharya et al., 2022).

The concept of blockchain technology is currently being developed to assure security and
guarantee trust in an energy network without the support of a third party. Blockchain
technology allows consumers to receive rewards without having to go through the energy
utility’s laborious traditional protocols (Samuel et al., 2022).

Blockchain is widely used for p2p transactions in various industries, particularly in the energy
market (Mannaro, Pinna and Marchesi, 2017). Applying blockchain in energy communities
through smart contracts makes energy production and consumption transparent and
traceable by letting the consumers know the actual cost and origin of the electricity and how
the tariff was made (Andoni et al., 2019).

The goal of this thesis is to propose a rewarding system that incentivizes and motivates
present and potential energy community consumers based on their energy savings.

Users will earn tokens and rewards for contributing to user invitations or using the community
services regularly, which will be directly related to their significance as a contributor to the
energy community. All incentives will be transacted via smart contracts on the Ethereum
Network at first. (Guidi et al., 2020)

At the end of each week, a fixed number of tokens based on the proposed model will be
distributed as a reward, depending on the service usage of the user in the community and
invitation activities.

1.2. Aim and Objectives


The aim is to propose a blockchain-based rewarding mechanism using tokens to be applied to
energy communities in order to incentivise consumers to participate and save energy.

Research Questions and Objectives:

• RQ1: How can blockchain technology be implemented in an energy community, and


what services can it offer?
o RO1: To identify the role of blockchain in the energy communities
o RO2: To identify the actors and services of the system
• RQ2: How to incentivize consumers to join and participate in an energy community,
and what is the benefit of using blockchain?
o RO3: To propose a blockchain-based rewarding system and identify the
benefits for consumers, the community and the environment
o RO4: To simulate and asses the proposed rewarding system

10/49
• RQ3: How a blockchain-based rewarding system can be implemented, and what is the
superiority of the proposed system compared to others?
o RO5: To assess the proposed rewarding system

1.3. Rationale
The construction of energy communities is motivated by a variety of goals, including
environmental preservation, energy conservation, local economic support, the value of
community service, and sustainability. Economic considerations are also a factor in such
communal decisions. Price reductions for energy consumers are proven to be one of the most
appealing motives. Despite the fact that the majority of community members think that
environmental and innovation benefits are significant, financial benefits remain important
factors in decision-making and project creation and administration. The proposed rewarding
mechanism of this thesis will take all the aspects of motivations that are needed for energy
communities into account, which based on (Joint Research Centre (European Commission) et
al., 2017) are: “Financial, Environmental, Uncertainty and trust, Security of supply and impact
of residence”.

1.4. Contribution
The overall contribution of this thesis is to use blockchain tokens with a novel rewarding
mechanism to incentivise participation in energy communities with the goal of energy saving.
A methodology with three phases is suggested to assess the proposed rewarding mechanism
with different weights and scenarios.

1.5. Thesis outline


The following is a breakdown of the paper’s structure. State of the art is presented in Section
2. Section 3 defines the Rewarding system model and the new token’s properties, and the
rewarding methodology. Section 4 defines different use cases and shows the results of the
simulations. Section 5 concludes with recommendations for future work.

11/49
2. Chapter 2 Literature Review
The available scientific literature that is relevant to the study described in this thesis is
summarized in this chapter. A thorough literature assessment on the use of blockchain
systems in energy communities will be presented first. Then, we will discuss recent research
that is connected to the study described in this publication.

2.1. Blockchain Technology


They are the foundation of cryptocurrency technology, enabling transactions to be completed
without the need for a reliable third party. A blockchain, in particular, is a list of blocks of
transactions that are shared and tamper-proof. All of the transactions that have occurred
since the inception of the cryptocurrency are contained in the blocks, which are disseminated
to all nodes of the network. As each block references the hash of the preceding block, new
transactions are added at the end of the chain and are connected to the previous block of
transactions (Joint Research Centre (European Commission) et al., 2017).

However, in addition to financial transactions, blockchain may be used to construct other


decentralized services that are built with confidence thanks to the inherent characteristics of
the technology. Additionally, blockchain is complemented by other features that improve
trust. Smart contracts are among the most encouraging.

A smart contract is computer software that may use a blockchain to execute or enforce a
predetermined agreement when and if certain criteria are satisfied. Its major objective is to
make it possible for two or more parties to conduct a trusted transaction without the need
for intermediaries. Additionally, smart contracts have no downtime, censorship, or outside
intervention since they inherit the features of blockchains (Joint Research Centre (European
Commission) et al., 2017).

Smart contracts, as mentioned by (Wang et al., 2018), are Scenario-Response procedural rules
and logic that make up smart contracts. In other words, they are trustworthy shared programs
that are decentralized and put on the blockchain. To automate the execution of the contract
on behalf of the signatories, the parties signing a contract should reach an agreement on the
contract’s terms, conditions for breach, liability for breach, and external verification data
sources (oracles). This agreement should then be deployed on the blockchain as a smart
contract. Any central organizations have no influence over the entire process.

2.2. Benefits of using blockchain in energy communities


Blockchain systems can guarantee that the generated energy is traced and trackable. It can
inform the consumers about the source and the actual costs of their electricity, and also it
makes the energy tariffs more transparent for the users (Botticelli et al.)

According to (Mannaro, Pinna and Marchesi, 2017), with the help of crypto-trading and
blockchain-based energy retail, the user can manage energy usage and sell the energy surplus.

12/49
According to (Mengelkamp et al., 2017), due to the increased demand for a new system to
assess the decentralised and dynamic electricity generation in smart grids, a blockchain
system can be helpful in a local energy market to reduce the electricity cost.

(Petri et al.) shows that using blockchain systems for energy trading helps protect the natural
world with the localization of energy production. Distribution and transmission of the energy
from the power grids or power generating factories have a risk of loss. Therefore consuming
locally generated electricity inside the energy community is more reliable, cheaper and more
sustainable.

In (Andoni et al., 2019), A “P2P” energy exchange architecture and a test case scenario using
Ethereum were analysed, making the creation of prosumers more efficient, reliably, and cost-
effectively.

2.3. Case studies of using blockchain in energy communities (The Brooklyn


Microgrid (BMG))
introduced a blockchain-based microgrid energy marketplace called the Brooklyn Microgrid
that consumers and prosumers can exchange self-made energy in a peer-to-peer manner
which helps keep the profit inside the local community (Fig. 1). Then, it performs an
assessment based on seven market components as a framework for building efficient
microgrid energy markets (Mengelkamp et al., “Designing Microgrid Energy Markets”).

Fig. 1. The BMG’s high-level topology (Mengelkamp et al., “Designing Microgrid Energy
Markets”).

13/49
They demonstrate that (private) blockchains are appropriate information platforms for
localized energy markets. A three-month test trial of the BMG (with a simplified market
configuration) had already been completed by the time the article was written. However,
further study is needed to adapt the market design to promote an optimal allocation of local
energy generation based on the socio-economic motivations of community members to
participate in localized energy markets.

2.4. Energy Tokens


The energy tokens are used to Remunerate the energy exchanges between prosumers,
producers and consumers and reward the users based on their provided services.

The 4New is the first-ever blockchain ecosystem built especially for electricity, and it has
aimed to mitigate the waste excess, energy shortage and greedy energy consumption of
cryptocurrencies. The 4New is powered by waste to electricity, based on Ethereum smart
contracts and applies the energy to a coin called KWATT (ABOSEDE GladMood).

PowerLedger (Power Ledger Pty Ltd) is an energy exchange platform that uses a dual token
system. POWR token is used to give access to the PowerLedger platform, and SPARKZ acts as
a trading token. The aim is to make a transparent energy exchange platform and remove the
need for trust in third parties.

2.4.1. Green Energy Tokens (NRGcoin)


There are different approaches to making an energy token green. For example, the reward
system can consider more rewards for a node that is creating electricity using greener energy
generators like wind power (Botticelli et al.). In addition, A prize can be given to those who
use less energy or use carbon-free devices and generators.

NRGcoin is a joint industry-academia project that began at the Vrije Universiteit Brussel’s
Artificial Intelligence Lab. Traditional high-risk renewable assistance programs are replaced by
the NRGcoin system, which uses a unique blockchain-based Smart Contract to reward green
energy better.

Consumers pay 1 NRGcoin to the Smart Contract for every 1kWh of green energy consumed.
Regardless of the retail value of electricity, this ratio (1kWh=1NRGcoin) always holds. From
the coins provided by the consumer, the Smart Contract pays all grid fees and taxes to the
DSO. The Smart Contract then uses a variety of approaches to verify the claimed injection of
green energy by prosumers.

However, NRGcoin does not include the bootstrapping phase of creating an energy
community. This thesis will show how to bootstrap an energy community.

2.5. Energy Services


Energy services are functions that are performed with energy as a method of obtaining or
facilitating desired end services or conditions (Fell, 2017).

14/49
Fig. 2: Examples of energy services (Fell, 2017)

The energy services such as Bike-sharing, Electric car-sharing, and Charging services will be
considered in this thesis.

2.6. Existing blockchain-based rewarding Systems


Steemit, Indorse, Sapien, and SocialX are examples of such platforms. Decentralization of data
created by these blockchain-powered social media platforms, as well as deep integration of
social platforms with the underlying cryptocurrency transfer networks on the blockchain, are
unique elements of these blockchain-powered social media platforms. Steemit is the first
blockchain-based social media platform that rewards both creators and curators of user-
generated content. (Li and Palanisamy, 2019)

2.6.1. Steemit

15/49
Fig. 3: Steem blockchain overview (Li and Palanisamy, 2019)

Users on Steemit can generate and distribute information in the form of blog entries. A blog
can be commented on, reposted, or voted on by other users after it has been published. Posts
are sorted based on the number of votes they receive, with the highest ranking posts making
it to the front page. The Steem-blockchain stores all of the data created by Steemit users. Data
contained in the Steem-blockchain, like that of other blockchains such as Bitcoin and
Ethereum, is publicly available and difficult to modify. Steemit’s decentralization and
cryptocurrency-based incentive structure for content authors and curators are at the heart of
the platform. (Li and Palanisamy, 2019)

2.6.2. Indorse
Indorse is a decentralized platform built on the Ethereum blockchain that works similarly to
LinkedIn. The goal is to establish a social network in the professional working world. Indorse
employs a scoring system and internal motivation that requires users to register their abilities
and professional accomplishments and obtain a score by checking the professional profiles of
other users. The platform employs a variety of approaches to validate skills in a
straightforward and impartial manner, including decentralized consensus, in which skill
demonstrations are judged anonymously by other users. For automated real-time validation,
it also employs AI-based technologies such as chatbots. (Guidi et al., 2020)

16/49
3. Chapter 3 Methodology
The Thesis’ goal is to propose a blockchain-based rewarding mechanism for smart
communities that incentivises the energy-saving behaviour of consumers.

The project envisions a number of energy services aimed at energy efficiency, persuasion
systems and mechanisms, and incentives, all of which aim to encourage better use of electrical
resources through the use of blockchain and smart contracts.

This goal will be achieved by creating a mechanism to reward energy saving for being used for
energy services as a participation incentive.

The thesis study will be carried out in three phases. Phase 1 will focus on the role of
blockchain, and rewarding tokens in the energy community and ENEA/Trakti platform will be
introduced. In Phase 2, a novel blockchain-based rewarding mechanism will be introduced,
and it will be coded and simulated to asses the effect based on different scenarios (Fig. 4).

Thesis study Phases

Phase 1 Phase 2 Phase 3

Role of blockchain Proposing a novel Emulate the


in energy blockchain-based rewarding system
communi�es rewarding with real �me data
mechanism
The use of
blockchain token to Simulate and asses
incen�vize the rewarding
behaviour mechanism

Fig. 4: Thesis Phases

3.1. Inductive case study approach


We apply an inductive case study approach to acquire insights into a new area due to a lack
of theory-guiding research on the blockchain (Eisenhardt, 1989).

The inductive approach also termed inductive reasoning, begins with observations, and
theories are presented as a result of those findings towards the conclusion of the research
process. Through a succession of hypotheses, the inductive inquiry “involves the search for
pattern from observation and the development of explanations - theories - for those
patterns.” Inductive investigations don’t start with theories or hypotheses in place, and once
the research process has started, the researcher is free to change the study’s path as they see
fit.

17/49
The hypothesis of this thesis is that first, the use of a blockchain platform can increase the
rewarding system efficiency and attractiveness for consumers and second, it also helps reduce
energy consumption and is a greener solution.

3.2. Energy Saving Tokenization (Metered Energy Savings)


This program uses normalized metered energy consumption (NMEC) to measure energy
savings at the meter (2022 Los Angeles County, n.d.). Each 1KWh energy saved is rewarded by
one token. (Energy Savings Calculation Methods under Article 7 of the Energy Efficiency
Directive)

The energy-saving can be calculated based on how much energy the node has saved compared
to the mean energy consumption of that area. In this way, each token will accumulate the
KWh of energy-saving achieved.

However, calculating approaches based on metered savings typically attain the maximum
complexity and implementation costs (per individual action executed).

In this situation, project-specific approaches are required to quantify energy savings, and
project implementers may incur additional expenses if the equipment is required to be
installed to assess the energy consumption of the chosen solutions after they have been
implemented.

The requirement to assess and approve each calculating technique as supplied by project
implementers leads to the creation of additional expenses for public authorities implementing
public authorities. However, the energy savings produced by projects assessed using metered
savings approaches are typically sufficient to offset these extra labour and complications.
Nevertheless, it is important to note that the complications brought about by the use of these
approaches can also be theoretical (and not merely stem from, for instance, a lack of
information or documentation that project implementers are required to offer). These kinds
of complications mostly have to do with the potential for creating a reference consumption
baseline and the evaluation of the additionality and lifespan of energy savings.

3.3. Why Blockchain in Rewarding system


A blockchain-based loyalty rewards program should reduce system management costs with
smart contracts that report secure, tracked, transparent transactions to legacy systems,
reducing costs associated with errors and fraud. Some of the reasons to use blockchain as a
platform for a rewarding system are as follows:

1. Open systems: A blockchain token’s ownership cannot be reversed, and it is publicly


recorded on the blockchain.

2. Less clutter: Blockchain tokens can be used for any of the services or saved for later use.

3. More flexibility: Customers have more freedom in how they use their rewards using
blockchain loyalty tokens.

18/49
4. Reduced costs: The program’s implementation and maintenance will not take years and
hundreds of thousands of dollars. There is already a loyalty record, thanks to blockchain’s
inherent ledger.

5. Overall transparency: Users understand that regulations or blockchain token amounts have
been changed. Customers will be satisfied knowing that they may redeem the rewards
whenever they want.

6. Less fraud, more security: The unchangeable blockchain ledger stores all relevant
information. The database entries are time-stamped and irreversible, prohibiting fraud and
transaction manipulation.

3.4. SI model

The SI model (Bill & Melinda Gates Foundation, n.d.) splits any population of users into two
groups, the susceptible individuals who may contract the disease and the infected individuals
who may spread the disease to the susceptibles. We can consider susceptible individuals as
the susceptible consumers and the infected individuals as the invited consumers.

S = S(n) is the number of susceptible consumers,

I = I(n) is the number of Invited consumers.

Fig. 5: SI model (Bill & Melinda Gates Foundation, n.d.)

3.5. Proposed Incentive programs


1. Multi-level invitation:

Employing loyalty programs has spread throughout the business world (Henderson, Beck
and Palmatier, 2011). and a few empirical investigations have shown their beneficial
effects on client loyalty (Leenheer et al., 2007). The previous literature on the effects of
loyalty programs has, however, ignored the “co-presence” of the costumers in social
contexts and the fairness aspect of loyalty programs according to (Colliander, Söderlund
and Szugalski, 2016) and because “co-presence” is thought to be able to elicit consumer

19/49
comparisons and influence subsequent judgments of fairness, the multi-level reward
program seems to consider these two aspects as it is created such that the degree of
membership depends on the input from the consumer. To put it another way, multi-level
loyalty programs seem to base rewards on inputs in a manner that reflects the classic
equity theory’s conception of fairness. This program type has been referred to in the
literature as a Type II program and as a program with a tiered incentive system (Berman,
2006) and (Tanford, 2013).

Multi-level marketing is centred on techniques that incentivize both direct and indirect
recommendations. The incentive for inviting a new member among the ancestors is shared
among the ancestors in geometrically decreasing shares in such processes. (Rahwan et al.,
2014)

In our proposed system, each user can invite other users to the system based on their
activity as well as invited users’ activity in the system, and they will both get rewarded. A
tree of Inviters and Invitees will be formed, and a percentage of the sum of tokens will be
rewarded to Inviters based on both their activities and their Invitees’ activities.

Fig. 6: Multi-level user invitation

2. Service usage Streaks:

Streaks count how many consecutive days consumers have been using any of the
community-offered services.

(Mehr et al., 2022) findings imply that rewarding consumers to start streaks can boost
persistence in time-consuming tasks, even when compared to higher-paying incentives.

Daily usage of any type of service will be a daily streak, and every seven daily streaks will
form a week streak. The streak counting and limit can be set by the energy community
creator.

20/49
For our simulation, the evaluation will be performed weekly for a month. Let’s define the
number of weeks as the number of streaks. A percentage of the sum of the tokens in the
community will be rewarded based on the number of consumer streaks.

3.6. Invitation Rewarding system diagram

Fig. 7: Invitation Rewarding system diagram

21/49
3.7. The rewarding system formulation
Total token used by the invitee nodes
Invitee Reward = × Weekly streak Multiplier × 𝞪𝞪
Number of Invitee nodes

Inviter Reward = Total Invitee Reward × Number of Invitee nodes of the branch × 𝞫𝞫

3.8. Streaks

Fig. 8: Streaks on the Duolingo app

Daily usage of any type of service will be a daily streak, and every seven daily streaks will form
a week streak. The evaluation will be performed weekly for a month. Let’s define the number
of weeks as the number of streaks. Therefore, week 1 = 1, week 2 = 2, week 3 = 3 and week
4 = 4 Maximum, to evaluate the reward generated by the community.

22/49
4. Chapter 4 System model and evaluation

4.1 The general structure of the model

Fig. 9: general structure of the rewarding system model

The above model describes the general structure of the invitation and reward model. In the
proposed model, the inviter will invite n people to join the community. The inviters in the
model are denoted by i, and the invitees are denoted by j. The system has different roles:
inviter, invitee, or inviter/invitee, and nodes will get rewarded based on their role. Each node
has a streak value (S) and also the number of tokens used in the last week (T).

In our model, we will target three different metrics.

Use case 1: one set of experiments will be done to evaluate the effect of the invitation of two
new nodes to the system. The number of the used tokens evaluated will be uniformly
distributed. The number of tokens is defined as t. Therefore the number of tokens is 10, 20,
30, 40, 50, and 60. In this evaluation, one token is 1kwh of energy saved. In this use case, we
experiment with different weights, number of streaks and number of used tokens in the
formula.

Fig. 10: use case one diagram

23/49
4.2 Weights distribution mechanism
The weights are set in a trial and error manner in which the system model will be simulated
based different on many possible weights based on changing different variables in the
formula, and the results will be studied.

Based on Used tokens:

Number of Invitee Inviter


Inviter(i) Invitee(j) weights(w) Streak(s) used Reward Reward
tokens(i) (R1) (R2)

Bob 1 0.5
α=0.1,
Alice 10 0.01
ß=0.01
Eve 1 0.5

Bob 1 1
α=0.1,
Alice 20 0.02
ß=0.01
Eve 1 1

Bob 1 1.5
α=0.1,
Alice 30 0.03
ß=0.01
Eve 1 1.5

Bob 1 2
α=0.1,
Alice 40 0.04
ß=0.01
Eve 1 2

Bob 1 2.5
α=0.1,
Alice 50 0.05
ß=0.01
Eve 1 2.5

Bob 1 3
α=0.1,
Alice 60 0.06
ß=0.01
Eve 1 3

Based on Streaks:

24/49
Number of Invitee Inviter
Inviter(i) Invitee(j) weights(w) Streak used Reward Reward
tokens(i) (R1) (R2)

Bob 1 0.5
α= 0.1,
Alice 10 0.01
ß=0.01
Eve 1 0.5

Bob 2 1
α= 0.1,
Alice 10 0.02
ß=0.01
Eve 2 1

Bob 3 1.5
α= 0.1,
Alice 10 0.03
ß=0.01
Eve 3 1.5

Bob 4 2
α= 0.1,
Alice 10 0.04
ß=0.01
Eve 4 2

Bob 1 0.5
α= 0.1,
Alice 10 0.025
ß=0.01
Eve 4 2

Bob 2 1
α= 0.1,
Alice 10 0.03
ß=0.01
Eve 4 2

Bob 3 1.5
α= 0.1,
Alice 10 0.035
ß=0.01
Eve 4 2

Based on weights:

Number of Invitee Inviter


Inviter(i) Invitee(j) weights(w) Streak used Reward Reward
tokens(i) (R1) (R2)

25/49
Bob 1 5
Alice α=1, ß=1 10 10
Eve 1 5

Bob 1 0.5
α=0.1,
Alice 10 1
ß=0.1
Eve 1 0.5

Bob 1 0.5
α=0.1, ß=
Alice 10 0.01
0.01
Eve 1 0.5

Bob 1 0.05
α=0.01,
Alice 10 0.001
ß=0.01
Eve 1 0.05

Bob 1 10
Alice α= 2, ß=2 10 40
Eve 1 10

Bob 1 1
α= 0.2,
Alice 10 0.4
ß=0.02
Eve 1 1

Bob 1 0.1
α= 0.02,
Alice 10 0.04
ß=0.02
Eve 1 0.1

Use case 2: one set of experiments will be done to evaluate the effect of a node having the
Inviter/Invitee node at the same time. Let us assume that Alice has invited two new nodes.
The two nodes Alice invited will, in turn, become both the inviter and invitee and are able to
invite n people. In our example, Bob and Eve have invited two people each (John and Sara)
and (Davide and Elena), respectively.

26/49
Fig. 11: use case two diagram

Based on Used tokens:

Number of Invitee Inviter


Inviter(i) Invitee(j) weights(w) Streak(s) used Reward Reward
tokens(i) (R1) (R2)

Bob 1 1
0.06
Eve 1 1

John 1 0.5
α= 0.1,
Alice 10 0.03
ß=0.01
Sara 1 0.5

David 1 0.5
0.03
Elena 1 0.5

Bob 1 2
0.12
Eve 1 2
α= 0.1,
Alice 20
ß=0.01
John 1 1
0.06
Sara 1 1

27/49
David 1 1
0.06
Elena 1 1

Bob 1 3
0.18
Eve 1 3

John 1 1.5
α= 0.1,
Alice 30 0.09
ß=0.01
Sara 1 1.5

David 1 1.5
0.09
Elena 1 1.5

Bob 1 4
0.24
Eve 1 4

John 1 2
α= 0.1,
Alice 40 0.12
ß=0.01
Sara 1 2

David 1 2
0.12
Elena 1 2

Bob 1 5
0.30
Eve 1 5

α= 0.1,
Alice John 1 50 2.5
ß=0.01
0.15
Sara 1 2.5

David 1 2.5 0.15

28/49
Elena 1 2.5

Bob 1 6
0.36
Eve 1 6

John 1 3
α= 0.1,
Alice 60 0.18
ß=0.01
Sara 1 3

David 1 3
0.18
Elena 1 3

Based on Streaks:

Number of Invitee Inviter


Inviter(i) Invitee(j) weights(w) Streak(s) used Reward Reward
tokens(i) (R1) (R2)

Bob 1 1
0.06
Eve 1 1

John 1 0.5
α= 0.1,
Alice 10 0.03
ß=0.01
Sara 1 0.5

David 1 0.5
0.03
Elena 1 0.5

29/49
Bob 2 1
0.09
Eve 2 1

John 1 0.5
α= 0.1,
Alice 10 0.03
ß=0.01
Sara 1 0.5

David 1 0.5
0.03
Elena 1 0.5

Bob 3 3
0.18
Eve 3 3

John 2 1.5
α= 0.1,
Alice 10 0.09
ß=0.01
Sara 2 1.5

David 1 1.5
0.09
Elena 1 1.5

Bob 6 4
0.24
Eve 5 4

John 4 2
α= 0.1,
Alice 10 0.12
ß=0.01
Sara 3 2

David 2 2
0.12
Elena 1 2

Based on weights:

30/49
Number of Invitee Inviter
Inviter(i) Invitee(j) weights(w) Streak(s) used Reward Reward
tokens(i) (R1) (R2)

Bob 1 1
0.06
Eve 1 1

John 1 0.5
α= 0.1,
Alice 10 0.03
ß=0.01
Sara 1 0.5

David 1 0.5
0.03
Elena 1 0.5

Bob 1 2
0.12
Eve 1 2

John 1 1
α= 0.1,
Alice 20 0.06
ß=0.01
Sara 1 1

David 1 1
0.06
Elena 1 1

Bob 1 3
0.18
Eve 1 3

α= 0.1,
Alice John 1 30 1.5
ß=0.01
0.09
Sara 1 1.5

David 1 1.5 0.09

31/49
Elena 1 1.5

Bob 1 4
0.24
Eve 1 4

John 1 2
α= 0.1,
Alice 40 0.12
ß=0.01
Sara 1 2

David 1 2
0.12
Elena 1 2

Bob 1 5
0.30
Eve 1 5

John 1 2.5
α= 0.1,
Alice 50 0.15
ß=0.01
Sara 1 2.5

David 1 2.5
0.15
Elena 1 2.5

Bob 1 6
0.36
Eve 1 6

John 1 3
α= 0.1,
Alice 60 0.18
ß=0.01
Sara 1 3

David 1 3
0.18
Elena 1 3

32/49
Use case 3: the last set of experiments will be done to evaluate the effect of a random
invitation tree design. Let us assume 100 nodes are participating in the community. The roles,
number of tokens used and streaks will be generated randomly.

Fig. 12: use case three diagram

This use case shows a dynamic random test on the proposed model to see the behaviour of
the system in a close-to-real situation.
One trial run of the code:

33/49
As can be seen in all the different use cases, the Inviters get the most reward taking into
consideration that they have their own rewards in addition to their invited node’s rewards.
Also, the number of rewards to all the consumers can be controlled based on the token
quantities of the blockchain system, the regulator or manager company’s policies or the
competition in the market, which makes the system flexible for different practices by changing
the weights in the formula or using a weight distribution policy.

Also, the system is not bound to certain blockchain technology and can be implemented in
any blockchain-based system since it can be translated into a smart contract rule.

4.3 The benefits of blockchain rewarding system


One of the main arguments raised against centralized loyalty programs is that their primary
goal is to increase corporate profits, which frequently makes it impossible for members to
receive just compensation for their efforts and spending. In this sense, the blockchain-based
rewarding systems promise to bring the advantages of the blockchain to closed and
centralized systems of rewards and loyalty programs, where a unified on-chain ledger will be
holding rewards and points (representing the blockchain’s assets) across various vendors,
providers, and end-users (Parizi and Dehghantanha, 2018).

Based on the results of the proposed model, it can be seen that both Invitee and Inviters in
the system, which are the consumers who are contributing to the rewarding system, take
advantage of the rewards. This shows that this system can be a benefit to the energy
communities.

Using blockchain as a platform for a rewarding system can have the following benefits for an
energy community (Shalchi, 2019):

1. Open systems: A blockchain token’s ownership cannot be reversed, and it is publicly


recorded on the blockchain.

2. Less clutter: Blockchain tokens can be used for any of the services or saved for later use.

3. More flexibility: Customers have more freedom in how they use their rewards using
blockchain loyalty tokens.

4. Reduced costs: The program’s implementation and maintenance will not take years and
hundreds of thousands of dollars. There is already a loyalty record, thanks to blockchain’s
inherent ledger.

5. Overall transparency: Users understand that regulations or blockchain token amounts have
been changed. Customers will be satisfied knowing that they may redeem the rewards
whenever they want.

6. Less fraud, more security: The unchangeable blockchain ledger stores all relevant
information. The database entries are time-stamped and irreversible, prohibiting fraud and
transaction manipulation.

34/49
4.4 Three-way benefit
The proposed blockchain-based rewarding system has the following advantages:

For the Community: Any positive activity of any user in the system not only has a reward for
itself but also rewards other users in that community, giving them a sense of community.
According to (Chavis et al., 1986), based on the Sense of Community Questionnaire and Index
(SCI), the proposed rewarding system can satisfy two of the four elements, which are
Membership and Influence. The sense of community is a novelty of the proposed system,
which makes it suitable for usage in energy communities.

For the Environment: Encouraging users to get more tokens and use the services, due to the
energy-saving nature of the tokens, will result in saving more energy (Energy Savings
Calculation Methods under Article 7 of the Energy Efficiency Directive). The existing
blockchain-based rewarding systems like Steemit and Indorse that are discussed in 2.6 use
simple tokenization, which does not take into account the effects on the environment. By
using energy-saving tokens, we consider the environmental aspect of the system’s
sustainability.

For the Users: Getting rewards based on their energy-saving, based on their participation in
making the community larger and based on the usage of the services, which makes the usage
of the services cheaper for members of the community due to the rewards that are given to
the consumers by the proposed model and result in 4.2 section that was not discussed in the
other green energy tokens that are shown in 2.4.1.

Fig. 13 shows the sustainability aspects of the proposed system, which are not considered in
the current state-of-the-art:

35/49
Sense of Data is safe on
community the blockchain

Motivation to join
energy
Cheaper
services
Potential high energy
consumption
Promoting less
energy saving managerial
More energy problems
services used
Remove the need
Less CO2
for third party
emission

Distribution
Lower of rewards
monopoly Higher profit

Electricity price
decreases

Fig. 13: the sustainability diagram of the proposed system

36/49
5. Chapter 5 Conclusion

To conclude, using blockchain as a rewarding mechanism in a loyalty program for energy


communities can benefit the community, environment and consumers, which can show that
the hypothesis was true. The proposed system’s model showed that the rewarding
mechanism could be used in energy communities to increase the chance of acceptance by
consumers by increasing their profit and raising the sustainability of the system at the same
time. Research questions one and two were studied and a novel rewarding system was
simulated and assessed based on different use cases and scenarios.

5.1. Limitations and suggestions for further research


Due to the lack of an emulator to implement the proposed system, the third research question
could not be answered. Also, because of the absence of a dataset based on the saved metered
energy, the input data for simulation are set by a trial and error mechanism.

5.2. Future work


The following points can be considered in future work on blockchain-based rewarding
systems:
• Considering the consumers that leave the community in the simulation (For example,
using the SIS model instead of the SI model) to have more realistic results.
• Evaluate the motivational aspect of the model with real consumers and communities
(That has similarly been done in (de Lange, Słupczyński and Klamma, 2020).

37/49
Bibliography

2022 Los Angeles County (n.d.). Metered Savings Program | SoCalREN. [online]
socalren.com. Available at: https://socalren.com/agencies/services/metered-savings [Accessed
31 May 2022].

ABOSEDE GladMood (2018). KWATT TOKEN: THE WORLD’S FIRST ECO-FRIENDLY


ENERGY REVOLUTION THROUGH THE BLOCKCHAIN TECHNOLOGY. [online]
www.linkedin.com. Available at: https://www.linkedin.com/pulse/kwatt-token-worlds-first-
eco-friendly-energy-revolution-blessing-yang/ [Accessed 25 Sep. 2021].

Andoni, M., Robu, V., Flynn, D., Abram, S., Geach, D., Jenkins, D., McCallum, P. and
Peacock, A. (2019). Blockchain technology in the energy sector: A systematic review of
challenges and opportunities. Renewable and Sustainable Energy Reviews, [online] 100,
pp.143–174. doi:10.1016/j.rser.2018.10.014.

Berman, B. (2006). Developing an Effective Customer Loyalty Program. California


Management Review, 49(1), pp.123–148. doi:10.2307/41166374.

Bhattacharya, S., Chengoden, R., Srivastava, G., Alazab, M., Javed, A.R., Victor, N.,
Maddikunta, P.K.R. and Gadekallu, T.R. (2022). Incentive Mechanisms for Smart Grid: State
of the Art, Challenges, Open Issues, Future Directions. Big Data and Cognitive Computing,
6(2), p.47. doi:10.3390/bdcc6020047.

Bill & Melinda Gates Foundation (n.d.). SI and SIS models — Generic Model documentation.
[online] docs.idmod.org. Available at: https://docs.idmod.org/projects/emod-
generic/en/latest/model-si.html#:~:text=with%20vital%20dynamics- [Accessed 31 May 2022].

Botticelli, M., Moretti, F., Pizzuti, S. and Romano, S. (2020). Challenges and opportunities of
Blockchain technology in the energy sector. In: 2020 AEIT International Annual Conference
(AEIT). doi:10.23919/aeit50178.2020.9241119.

Chavis, D.M., Hogge, J.H., McMillan, D.W. and Wandersman, A. (1986). Sense of community
through Brunswik’s lens: A first look. Journal of Community Psychology, 14(1), pp.24–40.
doi:10.1002/1520-6629(198601)14:1<24::aid-jcop2290140104>3.0.co;2-p.

Coenen, F.H.J.M. and Hoppe, T. (2022). Renewable Energy Communities as a New Actor in
Home Energy Savings. Urban Planning, 7(2), pp.108–122. doi:10.17645/up.v7i2.5088.

Colliander, J., Söderlund, M. and Szugalski, S. (2016). Multi-level loyalty program rewards
and their effects on top-tier customers and second-tier customers. Journal of Consumer
Marketing, 33(3), pp.162–171. doi:10.1108/jcm-03-2015-1349.

Energy Web Foundation (2021). System Contracts - Energy Web Digital Infrastructure.
[online] Gitbook.io. Available at: https://energy-web-foundation.gitbook.io/energy-
web/technology/the-stack/trust-layer-energy-web-chain/system-architecture/system-contracts
[Accessed 10 Dec. 2021].

Fell, M.J. (2017). Energy services: A conceptual review. Energy Research & Social Science,
27, pp.129–140. doi:10.1016/j.erss.2017.02.010.

Giulia (n.d.). Trakti | About us - Deals made easy! [online] Trakti. Available at:
https://www.trakti.com/about-en/ [Accessed 31 May 2022].

Guidi, B., Clemente, V., García, T. and Ricci, L. (2020). A Rewarding Model for the next
generation Social Media. Proceedings of the 6th EAI International Conference on Smart
Objects and Technologies for Social Good. doi:10.1145/3411170.3411247.

Henderson, C.M., Beck, J.T. and Palmatier, R.W. (2011). Review of the theoretical
underpinnings of loyalty programs. Journal of Consumer Psychology, 21(3), pp.256–276.
doi:10.1016/j.jcps.2011.02.007.

Hewitt, R.J., Bradley, N., Baggio Compagnucci, Andrea, Barlagne, C., Ceglarz, A., Cremades,
R., McKeen, M., Otto, I.M. and Slee, B. (2019). Social innovation in community energy in
europe: A review of the evidence. Frontiers in Energy Research, 7, p.31.
doi:10.3389/fenrg.2019.00031.

HJ (2020). Energy communities. [online] Energy - European Commission. Available at:


https://ec.europa.eu/energy/topics/markets-and-consumers/energy-communities_en [Accessed
Jun. 2021].

Joint Research Centre (European Commission), Karopoulos, G., Giuliani, R., Kounelis, I.,
Geneiatakis, D., Di Gioia, R., Steri, G., Neisse, R. and Nai-Fovino, I. (2017). Blockchain in
energy communities: a proof of concept. [online] Publications Office of the European Union.

39/49
LU: Publications Office of the European Union. Available at:
https://op.europa.eu/en/publication-detail/-/publication/5357a4de-fccc-11e7-b8f5-
01aa75ed71a1/language-en [Accessed 15 Dec. 2021].

Joint Research Centre (European Commission), Uihlein, A. and Caramizaru, A. (2020). Energy
communities: an overview of energy and social innovation. [online] Publications Office of the
European Union. LU: Publications Office of the European Union. Available at:
https://op.europa.eu/en/publication-detail/-/publication/a2df89ea-545a-11ea-aece-
01aa75ed71a1/language-en [Accessed 30 May 2022].

Jurowiec, P. (2019). Blockchain in the energy sector. [online] Good Audience. Available at:
https://miro.medium.com/max/3000/1*5kzdqlMAL4E2cY6vs69JQQ.png.

Leenheer, J., van Heerde, H.J., Bijmolt, T.H.A. and Smidts, A. (2007). Do loyalty programs
really enhance behavioral loyalty? An empirical analysis accounting for self-selecting
members. International Journal of Research in Marketing, 24(1), pp.31–47.
doi:10.1016/j.ijresmar.2006.10.005.

Li, C. and Palanisamy, B. (2019). Incentivized Blockchain-based Social Media Platforms.


Proceedings of the 10th ACM Conference on Web Science. doi:10.1145/3292522.3326041.

Malizou, A. (2018). ELECTRICITY AGGREGATORS: STARTING OFF ON THE RIGHT


FOOT WITH CONSUMERS The Consumer Voice in Europe. [online] The European Consumer
Organisation. Available at: https://www.beuc.eu/publications/beuc-x-2018-
010_electricity_aggregators_starting_off_on_the_right_foot_with_consumers.pdf.

Mannaro, K., Pinna, A. and Marchesi, M. (2017). Crypto-trading: Blockchain-oriented energy


market. 2017 AEIT International Annual Conference, pp.1–5. doi:10.23919/aeit.2017.8240547.

Mengelkamp, E., Gärttner, J., Rock, K., Kessler, S., Orsini, L. and Weinhardt, C. (2018).
Designing microgrid energy markets. Applied Energy, [online] 210, pp.870–880.
doi:10.1016/j.apenergy.2017.06.054.

Mengelkamp, E., Notheisen, B., Beer, C., Dauer, D. and Weinhardt, C. (2017). A blockchain-
based smart grid: towards sustainable local energy markets. Computer Science - Research and
Development, [online] 33, pp.207–214. doi:10.1007/s00450-017-0360-9.

40/49
OpenEthereum (n.d.). OpenEthereum Documentation - Permissioning. [online]
openethereum.github.io. Available at: https://openethereum.github.io/Permissioning [Accessed
10 Dec. 2021].

Parizi, R.M. and Dehghantanha, A. (2018). On the Understanding of Gamification in


Blockchain Systems. [online] IEEE Xplore. doi:10.1109/W-FiCloud.2018.00041.

Petri, I., Barati, M., Rezgui, Y. and Rana, O.F. (2020). Blockchain for energy sharing and
trading in distributed prosumer communities. Computers in Industry, 123(0166-3615),
p.103282. doi:10.1016/j.compind.2020.103282.

Power Ledger Pty Ltd (2017). Power Ledger Whitepaper. [online] www.powerledger.io.
Available at: https://www.powerledger.io/company/power-ledger-whitepaper.

Rathnayaka, A.J.D., Potdar, V.M., Dillon, T. and Kuruppu, S. (2015). Framework to manage
multiple goals in community-based energy sharing network in smart grid. International Journal
of Electrical Power & Energy Systems, 73, pp.615–624. doi:10.1016/j.ijepes.2015.05.008.

Samuel, O., Javaid, N., Almogren, A., Javed, M.U., Qasim, U. and Radwan, A. (2022). A secure
energy trading system for electric vehicles in smart communities using blockchain. Sustainable
Cities and Society, 79, p.103678. doi:10.1016/j.scs.2022.103678.

Sciullo, A., Gilcrease, G.W., Perugini, M., Padovan, D., Curli, B., Gregg, J.S., Arrobbio, O.,
Meynaerts, E., Delvaux, S., Polo-Alvarez, L., Candelise, C., van der Waal, E., van der Windt,
H., Hubert, W., Ivask, N. and Muiste, M. (2022). Exploring Institutional and Socio-Economic
Settings for the Development of Energy Communities in Europe. Energies, 15(4), p.1597.
doi:10.3390/en15041597.

Shalchi, C. (2019). Customer Loyalty Blockchain: A New Ecommerce Rewards Program.


[online] The BigCommerce Blog. Available at: https://www.bigcommerce.com/blog/customer-
loyalty-blockchain/#6-cases-for-blockchain-loyalty-tokens.

Tanford, S. (2013). The impact of tier level on attitudinal and behavioral loyalty of hotel reward
program members. International Journal of Hospitality Management, 34, pp.285–294.
doi:10.1016/j.ijhm.2013.04.006.

Toptal, L. (n.d.). Blockchain and crypto. [online] Toptal. Available at: https://bs-

41/49
uploads.toptal.io/blackfish-
uploads/components/service_centric_page/hero_section/content/background_image_file/back
ground_image/475505/08-Blockchain_and_Crypto-
dcbbb5f84d8c2371634d63ec02cc4249.svg.

Wang, S., Yuan, Y., Wang, X., Li, J., Qin, R. and Wang, F.-Y. (2018). An Overview of Smart
Contract: Architecture, Applications, and Future Trends. 2018 IEEE Intelligent Vehicles
Symposium (IV). [online] doi:10.1109/ivs.2018.8500488.

42/49
Appendix 1
The python code for the first use case

import networkx as nx
import dynetx as dn
import ndlib.models.ModelConfig as mc
import ndlib.models.dynamic as dm
from past.builtins import xrange
from ndlib.viz.mpl.DiffusionTrend import DiffusionTrend
import matplotlib.pyplot as plt

%matplotlib inline

# Dynamic Network topology


dg = dn.DynGraph()
paths = ["1","2"]
num_token_used = [50, 10, 60]
streak = [0, 1, 2]
alpha = 0.1
beta = 0.01

for t in xrange(0, 6):


g = nx.prefix_tree(paths)
dg.add_interactions_from(g.edges(), t)

# Model selection
model = dm.DynSIModel(dg)

# Model Configuration
config = mc.Configuration()
config.add_model_parameter('beta', 0.6)
infected_nodes = []
config.add_model_parameter("infected", infected_nodes) #initial_invited
model.set_initial_status(config)

#iterations = model.iteration()
iterations = model.execute_iterations()

trends = model.build_trends(iterations)

viz = DiffusionTrend(model, trends)


viz.plot()

def calc_token_used(node_number):

list_edges = list(g.edges(node_number))
total_token_used = 0

for k in list_edges:
each_token_used = num_token_used[k[0]]

43/49
total_token_used += each_token_used
return(total_token_used)

def calc_invitee(node_number):

list_edges = list(g.edges(node_number))
return(len(list_edges))
print(calc_invitee(0),calc_invitee(1),calc_invitee(2))

def inviters_list(edges):
listed_inviters=[]
for edge in edges:
if (edge[1] != -1) and (edge[0] not in listed_inviters):
listed_inviters.append(edge[0])
return(sorted(listed_inviters))

childs_dict = {}
def child_finder(edges):
parents = inviters_list(edges)
for parent in parents:
childs = edges(parent)
childs_nums = [(y[1]) for y in childs]
childs_dict[parent] = childs_nums
return(childs_dict)

invitee_reward ={}
inviter_childs = child_finder(g.edges)
for key in inviter_childs:
invitee_nums = inviter_childs[key]
for x in invitee_nums:
invitee_reward[x] = (calc_token_used(x)/len(invitee_nums))*streak[0+x]*alpha
print(x,"/",calc_token_used(x),"/",len(invitee_nums),"/",streak[0+x],"/",alpha)
print("invitee reward: ", invitee_reward)

inviter_reward ={}
for inviter_node in inviters_list(g.edges):
inviter_childs = child_finder(g.edges)
invitee_nums = inviter_childs[inviter_node]
#print(inviter_childs)
sum_reward = 0
for nums in invitee_nums:
sum_reward+=invitee_reward[nums]
inviter_reward[inviter_node] = sum_reward*len(inviter_childs)*beta
print("inviter reward: ", inviter_reward)

44/49
Appendix 2
The python code for the second use case

import networkx as nx
import dynetx as dn
import ndlib.models.ModelConfig as mc
import ndlib.models.dynamic as dm
from past.builtins import xrange
from ndlib.viz.mpl.DiffusionTrend import DiffusionTrend
import matplotlib.pyplot as plt

%matplotlib inline

# Dynamic Network topology


dg = dn.DynGraph()
paths = ["1a","1b","2c","2d"]
num_token_used = [50, 10, 60, 5, 100, 20, 40]
streak = [0, 4, 2, 0, 1, 1, 2]
alpha = 0.1
beta = 0.01

for t in xrange(0, 6):


g = nx.prefix_tree(paths)
dg.add_interactions_from(g.edges(), t)

# Model selection
model = dm.DynSIModel(dg)

# Model Configuration
config = mc.Configuration()
config.add_model_parameter('beta', 0.6)
infected_nodes = []
config.add_model_parameter("infected", infected_nodes) #initial_invited
model.set_initial_status(config)

#iterations = model.iteration()
iterations = model.execute_iterations()

trends = model.build_trends(iterations)

viz = DiffusionTrend(model, trends)


viz.plot()

def calc_token_used(node_number):

list_edges = list(g.edges(node_number))
total_token_used = 0

for k in list_edges:
each_token_used = num_token_used[k[0]]

45/49
total_token_used += each_token_used
return(total_token_used)

def calc_invitee(node_number):

list_edges = list(g.edges(node_number))
return(len(list_edges))
print(calc_invitee(0),calc_invitee(1),calc_invitee(2))

def inviters_list(edges):
listed_inviters=[]
for edge in edges:
if (edge[1] != -1) and (edge[0] not in listed_inviters):
listed_inviters.append(edge[0])
return(sorted(listed_inviters))

childs_dict = {}
def child_finder(edges):
parents = inviters_list(edges)
for parent in parents:
childs = edges(parent)
childs_nums = [(y[1]) for y in childs]
childs_dict[parent] = childs_nums
return(childs_dict)

invitee_reward ={}
inviter_childs = child_finder(g.edges)
for key in inviter_childs:
invitee_nums = inviter_childs[key]
for x in invitee_nums:
invitee_reward[x] = (calc_token_used(x)/len(invitee_nums))*streak[0+x]*alpha
print(x,"/",calc_token_used(x),"/",len(invitee_nums),"/",streak[0+x],"/",alpha)
print("invitee reward: ", invitee_reward)

inviter_reward ={}
for inviter_node in inviters_list(g.edges):
inviter_childs = child_finder(g.edges)
invitee_nums = inviter_childs[inviter_node]
#print(inviter_childs)
sum_reward = 0
for nums in invitee_nums:
sum_reward+=invitee_reward[nums]
inviter_reward[inviter_node] = sum_reward*len(inviter_childs)*beta
print("inviter reward: ", inviter_reward)
print(g.edges)

46/49
Appendix 3
The python code for the third use case

import networkx as nx
import dynetx as dn
import ndlib.models.ModelConfig as mc
#import ndlib.models.dynamic as dm
import ndlib.models.epidemics as ep
from past.builtins import xrange
from bokeh.io import output_notebook, show
from ndlib.viz.mpl.DiffusionTrend import DiffusionTrend
#from ndlib.viz.bokeh.DiffusionPrevalence import DiffusionPrevalence
from ndlib.viz.bokeh.MultiPlot import MultiPlot
import matplotlib.pyplot as plt
import random

%matplotlib inline

alpha = 0.001 #random.random()


beta = 0.01 #random.random()

g = nx.random_tree(n=100, seed=1, create_using=nx.DiGraph)

num_token_used = []
for node in g.nodes:
num_token_used.append(random.randrange(0,100))
print("Number of the tokens used: ",num_token_used)
print("Total number of the tokens used", sum(num_token_used))

streak = []
for node in g.nodes:
streak.append(random.randrange(0,5))
print("number of the streaks: ",streak)

# 1st Model selection


model = ep.SIModel(g)

# Model Configuration
config = mc.Configuration()
config.add_model_parameter('beta', 0.01)
infected_nodes = [1,2,3,4,5]
config.add_model_parameter("infected", infected_nodes) #initial_invited
model.set_initial_status(config)

# Simulation interaction graph based execution


iterations = model.iteration_bunch(200)
trends = model.build_trends(iterations)

viz = DiffusionTrend(model, trends)


p = viz.plot()

47/49
# 2nd Model selection
mmodel = ep.SIModel(g)

# Model Configuration
config = mc.Configuration()
config.add_model_parameter('beta', 0.02)
infected_nodes = [1,2,3,4,5]
config.add_model_parameter("infected", infected_nodes) #initial_invited
mmodel.set_initial_status(config)

# Simulation interaction graph based execution


iterations = mmodel.iteration_bunch(200)

trends = mmodel.build_trends(iterations)

viz2 = DiffusionTrend(mmodel, trends)


p2 = viz2.plot()

vm = MultiPlot()
vm.add_plot(p)
vm.add_plot(p2)
vm.plot()

def calc_token_used(node_number):

list_nodes = list(g.nodes(node_number))
total_token_used = 0

for k in list_nodes:
each_token_used = num_token_used[k[0]]
total_token_used += each_token_used
return(total_token_used)

def inviters_list(edges):
listed_inviters=[]
for edge in edges:
if (edge[1] != -1) and (edge[0] not in listed_inviters):
listed_inviters.append(edge[0])
return(sorted(listed_inviters))

childs_dict = {}
def child_finder(edges):
parents = inviters_list(edges)
for parent in parents:
childs = edges(parent)
childs_nums = [(y[1]) for y in childs]
childs_dict[parent] = childs_nums
return(childs_dict)

#print(model.get_info())
#print(model.get_status_map())

48/49
invitee_reward ={}
inviter_childs = child_finder(g.edges)
print("tree: ",inviter_childs,"\n")
for key in inviter_childs:
invitee_nums = inviter_childs[key]
for x in invitee_nums:
invitee_reward[x] = (calc_token_used(x)/len(invitee_nums))*streak[0+2]*alpha

print("invitee reward: ", invitee_reward,"\n")

inviter_reward ={}
inviter_childs = child_finder(g.edges)
sum_reward = []
for inviter_node in inviters_list(g.edges):
sum_reward = 0
invitee_nums = inviter_childs[inviter_node]
for numss in invitee_nums:
sum_reward += invitee_reward.get(numss)
inviter_reward[inviter_node] = sum_reward*len(inviter_childs)*beta

print("inviter reward: ", inviter_reward)

invitee_reward_values = invitee_reward.values()
print("total invitee reward: ", sum(invitee_reward_values))

inviter_reward_values = inviter_reward.values()
print("total inviter reward: ", sum(inviter_reward_values))

49/49

You might also like