ArticlePDF Available

Enhanced Time-of-Use Electricity Price Rate Using Game Theory_ With Source _Code

Authors:

Abstract and Figures

The emergence of the Demand Response (DR) program optimizes the energy consumption pattern of customers and improves the efficacy of energy supply. The pricing infrastructure of the DR program is dynamic (time-based). It has rather complex features including marginal costs, demand and seasonal parameters. There is variation in DR price rate. Sometime prices go high (peak load) if the demand of electricity is more than the generation capacity. The main objective of DR is to encourage the consumer to shift the peak load and gets incentives in terms of cost reduction. However, prices remain the same for all the users even if they shift the peak load or not. In this work, Game Theory (GT)-based Time-of-Use (ToU) pricing model is presented to define the rates for on-peak and shoulder-peak hours. The price is defined for each user according to the utilize load. At first, the proposed model is examined using the ToU pricing scheme. Afterward, it is evaluated using existing day-ahead real-time pricing scheme. Moreover, shifting load from on-peak hours to off-peak hours may cause rebound peak in off-peak hours. To avert this issue, we analysis the impact of Salp Swam Algorithm (SSA) and Rainfall Algorithm (RFA) on user electricity bill and PAR after scheduling. The experimental results show the effectiveness of the proposed GT-based ToU pricing scheme. Furthermore, the RFA outperformed SSA.
Content may be subject to copyright.
electronics
Article
Enhanced Time-of-Use Electricity Price Rate Using
Game Theory
Adia Khalid 1, Nadeem Javaid 1,* , Abdul Mateen 2, Manzoor Ilahi 1, Tanzila Saba 3
and Amjad Rehman 4
1Department of Computer Science, COMSATS University Islamabad, Islamabad 44000, Pakistan;
adia.khalid@gmail.com (A.K.); tamimy@comsats.edu.pk (M.I.)
2Department of Computer Science, Federal Urdu University of Arts, Science and Technology,
Islamabad 44000, Pakistan; abdulmateen@fuuastisb.edu.pk
3College of Computer and Information Sciences, Prince Sultan University, Riyadh 11586, Saudi Arabia;
tsaba@psu.edu.sa
4College of Computer and Information Systems, Al Yamamah University, Riyadh 11512, Saudi Arabia;
drrehman70@gmail.com
*Correspondence: nadeemjavaidqau@gmail.com; Tel.: +92-300-579-2728
Received: 25 November 2018; Accepted: 28 December 2018; Published: 2 January 2019


Abstract:
The emergence of the Demand Response (DR) program optimizes the energy consumption
pattern of customers and improves the efficacy of energy supply. The pricing infra-structure of
the DR program is dynamic (time-based). It has rather complex features including marginal costs,
demand and seasonal parameters. There is variation in DR price rate. Sometime prices go high (peak
load) if the demand of electricity is more than the generation capacity. The main objective of DR
is to encourage the consumer to shift the peak load and gets incentives in terms of cost reduction.
However, prices remain the same for all the users even if they shift the peak load or not. In this
work, Game Theory (GT)-based Time-of-Use (ToU) pricing model is presented to define the rates for
on-peak and shoulder-peak hours. The price is defined for each user according to the utilize load.
At first, the proposed model is examined using the ToU pricing scheme. Afterward, it is evaluated
using existing day-ahead real-time pricing scheme. Moreover, shifting load from on-peak hours to
off-peak hours may cause rebound peak in off-peak hours. To avert this issue, we analysis the impact
of Salp Swam Algorithm (SSA) and Rainfall Algorithm (RFA) on user electricity bill and PAR after
scheduling. The experimental results show the effectiveness of the proposed GT-based ToU pricing
scheme. Furthermore, the RFA outperformed SSA.
Keywords:
pricing scheme; game theory; meta-heuristic; optimization; scheduling; salp swarm
algorithm; rain fall optimization algorithm
1. Introduction
Today, the power industry is the highest producer of electricity to balance demand and supply.
The major considerations of the power industry are environmental protection, energy demand and the
integration of renewable energy resources. The distributed renewable energy resources are installed to
resolve the environmental related issues and energy demand. Moreover, energy generated by these
resources is cheap as compared to power plants. However, a backup is needed for constant energy
flow because of varying weather conditions which effects the generation of power. As the demand of
power changes with the varying weather conditions. The change in energy demand and supply is very
common. The Demand Response (DR) program is designed to cope with the load balancing problem.
Various pricing strategies under DR program have been introduced in order to overcome the extensive
Electronics 2019,8, 48; doi:10.3390/electronics8010048 www.mdpi.com/journal/electronics
_ With Source _Code
Electronics 2019,8, 48 2 of 26
use of electricity during on-peak hours (i.e., increased load demand). The electricity consumers who
implement the DR are given incentives for shifting energy consumption to off-peak hours from on-peak
hours. Initially [
1
,
2
] proposed price rates for peak hours. For this purpose, they used variable pricing
strategies. Boiteux et al. have presented the fixed price rate according to the consumption of electricity.
However, utility charge extra cost, if power consumption reaches the generation capacity. The high
rates of electricity during the on-peak hours can manage the load. However, there is a chance of high
energy demand during the off-peak hours.
Under DR, linear and non-linear pricing strategies have been designed. Manual pricing strategies
are mapped in the linear fashion. In nonlinear pricing scheme, quantity and total price are mapped in
the nonlinear fashion. Real-Time Price (RTP), Time-of-Use (ToU) and Curtailable/Interruptible (C/I)
pricing tariffs are presented as nonlinear [
3
]. Other time-varying approaches ar Variable Peak Pricing
(VPP), Critical Peak Pricing (CPP) and Critical Peak Rebate (CPR).
RTP and ToU are widely used pricing schemes throughout the world. RTP varies all the time
according to the wholesale price and demand. This fluctuation may discomfort the consumer. The ToU
tariff is divided into three blocks: off-peak, shoulder-peak and on-peak hours and prices during these
time span remain fixed throughout the season. Utilities (or aggregators; i.e., electricity providers)
define price rates for each block (off-peak, shoulder-peak and on-peak) of ToU after observing historical
behavior of the users’ energy consumption patterns. As, after collecting the energy consumption
patterns of three hundred prosumers in Cyprus, Venizelou et al., in [
4
] designed the ToU tariff.
However, in our proposed work we modified the already defined ToU price signals in order to provide
the incentives to the users who shift the peak load. For this research work, seasonally defined ToU
electricity rates are taken from [5].
Some of the consumers shift the peak load to reduce the electricity cost. However, price rate
remains the same even though if the user shifts the peak load. The utilities having CPR rate, pay
incentives to the users who shift the on-peak load. The CPR pricing approach is introduced to give
the money back to the customers after reducing the energy consumption [
6
]. This is applicable only
during the critical peak hours. Among all these tariffs, the most widely used tariff around the globe is
ToU. However, no economic gain is observed because of zero energy consumption during the on-peak
hours [7].
In this price model, electricity per unit rate for each user is defined according to the increase in
power consumption. This is applicable during shoulder-peak and on-peak hours. In the proposed
pricing model, coalition-based Game Theory (GT) model is used to distribute the extra generation
cost among the users in a specific residential sector. In the proposed price model, GT distributes
the generation cost among all the users as a pay-off. Energy management system controls, monitors
and manges the user demand according to the energy supply. It could be centralized, decentralized
or hybrid depending on the geographical location of the area. In an aggregated residential sector,
time-varying pricing scheme, coupled with large-scale energy management system can rebound
peak [
8
]. Rebound effect is shifting of the load from on-peak to the off-peak hours. Especially, when all
the users are subject to the same price (global price policy) [9].
To cope with this problem, we proposed a constraint-based cost minimization function for optimal
scheduling of electric appliances. Salp Swarm Algorithm (SSA) and Rainfall Algorithm (RFA) are used
to verify the compatibility of the proposed pricing scheme with energy management system.
Some machine learning techniques are also being studied to investigate the SG related issues.
The combined problem of multiple power companies and DR management in a smart gird network is
studied by [10] through reinforcement learning and GT technique.
Problem Statement
Every power generation plant can generate a fixed quantity of power. However, energy demand
cannot be fixed. It varies from time to time which destabilizes the utility. DR program is designed
to cope with the load balancing problem. Under DR program, price-based tariffs such as CPP, RTP
Electronics 2019,8, 48 3 of 26
and ToU tariffs are introduced. To minimize the extensive usage of electricity during on-peak hours
(i.e., energy demand increases). The DR program encourages the user to shift the load from on-peak
hours and get incentives. ToU tariff is the most common pricing scheme amongst others [
4
]. The ToU
tariff is divided into three blocks: off-peak, shoulder-peak and on-peak hours. Although, ToU
tariff can reduce the peak-load of electricity demand. However, almost zero energy consumption is
observed during some peak period [
7
]. Zero energy consumption means no revenue. To achieve the
better performance, an energy management controller is required to schedule the load in mean level.
The electricity price for load shifting consumer is the same as other consumers [
7
]. A peak-rebate
concept is introduced in this proposed work. Where a game theory model is presented to facilitate
the load shifting consumers with price incentives. Moreover, to avoid the peak formation during the
off-peak hours, meta-heuristic-based scheduling algorithm is presented in this work.
The rest of the paper is organized as follows: related work is discussed in Section 2. While system
model is discussed in Section 3. Section 4discusses the proposed methodology. Simulation results are
shown in Section 5and conclusion is provided in Section 6.
2. Related Work
Pricing schemes under DR program are defined to minimize the load on the generation unit.
Two predominant electricity price rates are commonly used, i.e., flat rate and dynamic price rate. Prices
under flat rates (traditional) remain stable regardless of the rise in load demands. Whereas dynamic
price rates (cost-reflective) reflect the true cost of generation and supply. It might be helpful to reduce
the load in a smaller region. The main components that influencing the electricity price model are;
seasonal price spikes, seasonal volatility and seasonal fluctuation in demand and supply [
11
]. Authors
in [
11
] consider these factors when designing electricity price model. This price model is based on
stochastic time change and deterministic feature. Nowadays forecasting methods are introduced in the
electricity price model. Authors in [
12
] study the long-term seasonal components’ effect in day-ahead
price forecasting. Further, NARX Neural Network (NN) model is employed by [
12
] for electricity price
forecasting. Similarly work on NN-based electricity price forecasting model is proposed in [
13
]. At first,
the model consists of a two-layer decomposition technique. Thereafter, a hybrid model based on fast
ensemble empirical mode decomposition, variational mode decomposition and back propagation
NN is proposed. Finally, NN model is optimized using the firefly algorithm. Although, these price
prediction techniques generalize the actual electricity price. However, prediction of weather condition
and user demand cannot be 100% accurate.
In the literature, several works focus on event-based and time driven pricing schemes while
neglecting that environmental conditioning may affect pricing schemes. As a consequence, authors
in [
14
] inspire from psychology and behavioural economics, design cost-reflective tariffs. These tariffs
are applied to the larger cross-section of the population. However, the existing pricing schemes like ToU
are defined for two or three blocks, whereas pricing scheme defined on the human stochastic behaviour
may not be applicable for the long-term periods. In this regard, ref. [
15
] propose the enhanced ToU
tariffs in which 24 hours time slots are divided into periods of six blocks. While using this scheme,
user can schedule the on-peak load towards the shoulder-peak or off-peak hours. Therefore, no proper
mechanism is defined to cope with the peak formation during the shoulder-peak hours, as already
these hours have much load.
Work in [
16
] designs the ToU tariff that is generated through flat-rates using clustering technique.
Besides, the Gaussian mixture model clustering technique is used to group the half-hour time-span
tariff and load demand into shoulder-peak, off-peak and on-peak hours. The main drawback of such
models is lack of load controlling mechanism that can shift the shoulder-peak into on-peak hours
of next day. Decision making another strategy is combined with electricity price model and in this
regards, authors in [
17
,
18
] design the GT-based pricing model. Firstly, work in [
17
] uses GT Nash
equilibrium strategy to define the ToU price rate for Ntime-frame of a day where electricity demand
is a key factor that affects the electricity cost. Lastly, electricity price model in [
18
] calculates flat and
Electronics 2019,8, 48 4 of 26
elastic prices. This elastic price varies according to the generation and demand. However, the extra
generation cost will be divided equally to each user. This can inconvenience the user who had already
shifted his load and has compromised comfort.
Simple time-varying electricity pricing schemes and automated energy management system can
rebound peaks in the residential home when each user wants to reduce electricity bill by shifting load
from on-peak to off-peak hours [
8
]. To deal with this problem, innovative electricity price structures
such as Multi-ToU and Multi-CPP are proposed in [
8
]. Simulation results depict that proposed pricing
schemes smoothen the aggregate demand. Similarly, the peak load of the aggregated load demand
problem is also discussed in [
19
]. Authors in [
19
] propose adaptive consumption level pricing scheme
to shift the peak load demand. A case study test results show that the proposed scheme achieves
peak load reduction up to 35% and a reduced electricity cost up to 53%. In addition, the user gets
a reduced cost up to 53% by curtailing their load. This curtail load scheduled on the next day, which
can discomfort the user.
Pricing mechanism is a solution for on-peak load management; however, the scheduling
mechanism is required to shift load in a suitable manner. To achieve this, works in [
20
39
] present
different load controlling techniques and strategies. For instance, the work in [
20
] proposes a Distributed
Energy Storage Planning (DESP) for PAR minimization. As first, residential users are allowed to select
an appropriate storage space so that balance between the installation and savings is maintained.
Thereafter, a Genetic Algorithm (GA) is used for DESP whereas, a GT approach is used for distributed
energy management. Moreover, this work also considered consumers’ privacy. Simulations results
show that the proposed scheme minimizes PAR as well as consumers electricity bill. The authors
in [
21
] present an algorithm for peak load reduction with coordinated response using Electricity Storage
System (ESS), Photovoltaics (PV) and electric vehicle. In their work, peak load is reduced by observing
the residential load of consumer using AMI in real-time. In addition, Artificial Neural Network
(ANN) technique for peak load prediction is examined. The authors evaluate the effectiveness of the
proposed scheme with Decision Tree (DT) algorithm. Furthermore, simulation results show that taking
appropriate coordinated actions, the proposed scheme minimizes the peak load reasonably.
Some machine learning techniques are also being studied to investigate the smart grid related
issues. The combined problem of multiple power companies and DR management in a smart gird
network is studied by [
10
] through reinforcement learning and GT technique. To balance the power
and supply [
22
] function binding is proposed. Where equilibrium is achieved between competitive
and oligopolistic markets using GT. Another article [
23
], studied the DR framework, here authors
simulated for stochastic environment. For real time scenario, values are taken after forecasting.
These studies show the importance of GT model in DR. Further, In [
24
], Asif et al. develop a
priority-based Demand side management DSM strategy for scheduling home appliances. Three known
meta-heuristic techniques namely GA, Binary Particle Swarm Optimization (BPSO) and Enhanced
Differential Evaluation (EDE) algorithm are employed. These techniques incorporate SS to solve the
load shifting problem in SH. Furthermore, to tackle the problem of rebound peaks and enhance the
stability of the grid, the knapsack capacity limit is used. From the simulation results, the cost is reduced
by 60%. However, this work considered a limited number of home appliances.
A nonlinear programming model is proposed by [
25
]. In this work, the real-time DR model is
presented to minimize the electricity cost associated with consumption through appliance scheduling
while ignoring consumer comfort. Another article [
26
] presents a model for residential users to minimize
their consumption cost. It is assumed that all consumers are selfish and they are only concerned about
minimizing their energy utilization cost. For this purpose, the work adopts a non-cooperative game
theoretic approach to optimize their battery capacity and schedule their electricity consumption.
Besides, the work examines bilateral trading between the utility and consumers. In addition, this
approach encourages the consumers to minimize their consumption cost and reduces the PAR.
The experimental results show that the scheme achieves energy utilization cost reduction up to
5% and PAR reduction up to 50%. The authors in [
27
] develop a SHEMS to minimize consumption cost,
Electronics 2019,8, 48 5 of 26
PAR and user discomfort. In their work, the authors use three known meta-heuristic techniques namely
Ant Colony Optimization (ACO), BPSO and GA. For the electricity tariff implementation, authors
merge the ToU and IBR pricing signals. In addition, authors combine the RES and ESS. The simulation
results show that GA-based SHEMS outperforms BPSO and ACO-based SHEMS in cost and PAR
reduction with a tolerable user discomfort.
In [
28
], a multi-objective model for DSM is proposed by Dan Li. In his work, the author considers
a day-ahead market with a hierarchical framework for the three grid participants namely: DR aggregator,
utility and consumers. In his framework, all the grid participants have different objectives. The utility
seeks to minimize its operational cost and increases its revenue. Whereas DR aggregator acts as a broker
between consumer and the utility. The utility ensures that DSM services will be provided whereas,
consumers are assured that the electricity bill will be curtailed if they eagerly participate in DSM
programs. To give maximum benefit to all the participants, Artificial Immune Algorithm (AIA) is
employed [28]. AIA uses a Pareto optimal set to ensure fairness among all grid participants.
Ren Shiou Liu [
29
] presents a multi-agent-based decentralized mechanism for SHs to share
electricity within the neighbouring homes. The mechanism uses two algorithms namely Column and
Constraint Generation (CCG) algorithm and Scalable and Robust DSM (SRDSM) algorithm. In addition,
RES and ESS are incorporated to meet the electricity demand of the SH. The simulation results show
that CCG is effective in cost reduction as compared to SRDSM. Whereas SRDSM outperforms CCG
in PAR reduction. However, the performance of CCG is affected by increasing number of SHs.
Furthermore, the proposed scheme only relies on solar irradiation for energy production. Therefore,
the performance of this scheme is affected by uncertain weather conditions.
To minimize PAR, Vivekananthan et al. [
30
] analyze data gathered from several homes. The work
uses an incentive-based scheme to reward consumers who actively participate in PAR reduction.
However, the authors assume that all the consumers have a similar load profile and usage pattern
of the home appliances. Simulation results show that the proposed scheme reasonably minimized
the PAR. In [31], the authors develop a SHEMS to curtail the peak demand by motivating consumers
to eagerly participate in the DSM strategies using the ToU scheme. In addition, GA and PSO-based
known meta-heuristic techniques are implemented in a typical SG scenario. Furthermore, the authors
highlight the advantages of ESS. Experimental results illustrate that the given optimization problem is
effectively solved using PSO.
To automatically control and implement distributed DR [
32
], the authors proposed Overgrid,
a distributed peer-to-peer architecture. Overgrid balances the power demand of its system buildings
which belongs to virtual microgird. Qian et al. [
33
] proposed DR strategy in SG to minimize PAR.
In addition, consumers minimize the electricity bill whereas, the utility plans to get more profits.
To derive advantages of DR strategies for all the participates, Simulated-Annealing-based Price
Control Algorithm (SAPCA) along with an iterative algorithm for scheduling the home appliances are
examined. SAPCA maximizes the profit of utility whereas, iterative algorithm curtails the consumers’
electricity bill. In addition, the income of the utility is increased.
In order to keep the balance in demand and supply, flow updating distributed algorithm is
implemented for monitoring the electricity consumption. Another article [
34
] presented the teletraffic
tool to control the energy load. They proposed control schemes which are tuned to achieve the trade-off
among control overhead, usage and privacy leakage. In power system, the utility stability is not only
a matter of fact but also consumer satisfaction. Consumer satisfaction usually means minimum cost
with maximum comfort. Developing an energy conservation plan at the consumer end can reduce up
to 40% annual energy bills [
35
] by ensuring the fair level of user comfort. To achieve this goal, [
35
]
compared the proportional-integral-derivative and Model Predictive Control (MPC) control methods
of an air conditioner of a home.
The authors in [
36
] develop a SHEMS for scheduling home appliances and power trading
simultaneously. It is assumed that each home has its own microgrid and ESS. Moreover, the SH
is connected with the utility to trade the deficit/surplus energy on the basis of its requirements.
Electronics 2019,8, 48 6 of 26
The electricity demand of the SH is directly fulfilled by the MG and ESS. To schedule the home
appliances, the work implements Cuckoo Search Algorithm (CSA) and SA. Simulation results show
that the proposed scheme reduces the PAR and energy utilization cost. Furthermore, it shows that the
performance of CSA is superior to SA in terms of cost minimization and earnings maximization.
Asif et al. [
37
] develop a scheme that derives an absolute comfort level for domestic users.
In their scheme, the consumer is assigned a unique priority for each appliance on the basis of time and
operational properties. It is assumed that the priorities assigned to each appliance vary according to
the preferences of consumers. The work uses an Evolutionary Accretive Comfort Algorithm (EACA)
with GA to generate an operational schedule of home appliance that yields a maximum User Comfort
(UC) with a pre-determined budget. Simulation results report that their scheme achieves a reasonable
UC within a small budget. The authors in [
38
] present a scheme that enhances UC via renowned
meta-heuristic techniques, GA and PSO. The work maintains a specific environment inside an SH.
To achieve the desired objective, the authors analyze a dataset recorded over a period of one month
inside a laboratory. Experimental results report that the proposed scheme achieves the desirable
objective. However, the work ignores PAR and electricity utilization cost.
Bharathi et al. [
39
] present a technique to minimize energy utilization cost. In their work,
the authors analyze the energy utilization pattern of domestic, commercial and industrial consumers
from different data repositories. To minimize the energy consumption cost of consumers, the authors
use GA. Experimental results review that GA-based DSM achieves cost minimization as compared to
the situation when GA is not used. Although, optimization techniques can be effective for a specific
scenario. However, to derive the universal optimal solution is a challenging task. As a consequence,
this work proposes a new optimization technique for appliances scheduling to reduce electricity cost
and PAR.
3. System Model
Under DR program different electricity tariffs (i.e., ToU, RTP, CPP, etc.) have been defined in
order to reduce electricity demand during the on-peak hours. The DR strategy provides the incentive
to shift the load from on-peak to off-peak hours. Where prices during the off-peak hours are low
as compared to the on-peak hours. The prices during the on-peak hours increase as the demand
of electricity increases and the excessive demand is fulfilled by costly energy generation units i.e.,
(fuel generators). The electricity per unit price is not only about the generation cost; however, there are
also some other factors. The main factors that effect the electricity price signals are: generation cost,
transmission cost and distribution cost [
6
] as described in Figure 1. The prices are highly influenced
by the user demand and utility. Utility is known as service provider, it regulates the electricity rate
seasonally (ToU and CPP), weekly, daily or hourly (variable peak price rebate or RTP).
In this paper, an enhanced ToU tariff based on GT (GTToU) is proposed for a residential sector.
In this model, each user’ s per unit price of shoulder-peak and on-peak hour is calculated according to
the electricity load profile and extra generation cost. Further, the proposed scheme is compared with
that of day-ahead RTP. An overview of the proposed system model and information flow between
the system components is provided in Figure 1. The electricity used by the end user passed through
different processes. First, the generated energy is transmitted towards the distribution units through
transmission lines. In the distributed unit, transformers stepping down the energy voltage to the level
used by the consumer and distributed towards the end users through distribution lines. In this work,
each home is considered as a smart home. A smart meter and an Energy Management Controller (EMC)
are installed at each home. The smart meter acts as a gateway to exchange the information between the
utility and a smart home. The EMC manages and controls the electricity load by scheduling the smart
electrical appliances. A scheduler installed in the EMC schedules appliances according to constraint(s)
defined by the optimization framework [
40
]. In this proposed work, utility asks for the user energy
demand before the start of the day and it could be one hour before or 5 minutes before. The constraint
(threshold level) will be set by the utility and scheduler according to the provided information. In our
Electronics 2019,8, 48 7 of 26
proposed work appliances are scheduled from on-peak to off-peak hours according to the provided
electricity rates and demand through smart meter.
Generation
A
Transmission
B
Distribution
C
Residential Sector
Utility
EMC
Demand
Generation and Price Tariff
Schedule
Control
Figure 1. Proposed system model for GT pricing model and energy management scheduler.
The utility has a price regulator that calculates each user’s shoulder-peak and on-peak price
according to the consumed power. The utility also monitors the other costs (i.e., generation, transmission
and distribution cost). However, in our scenario, we focus on the users’ power consumption. The price
regulator calculates the price using GT and updates the users through the smart meter. Moreover,
the user manages the load during the shoulder-peak and on-peak hours through scheduling. Whereas
a meta-heuristic-based scheduler is embedded in EMC. In addition, we consider two meta-heuristic
algorithms, SSA and RFA.
3.1. Formulation of GTToU
Due to the high demand of electricity during some specific hours, generation increases and
has impact on electricity price and user’ s electricity bill. In this section, a mathematical model is
formulated to enhance the ToU electricity price signals. In ToU rate, a day is broken up into three
blocks: on-peak, shoulder-peak and off-peak. Prices during the on-peak and shoulder-peak hours
are high due to high demand and generation units. It is worth mentioning here that each customer is
Electronics 2019,8, 48 8 of 26
charged the same price even if any of them shifts load towards off-peak hours. In this proposed price
rate, each user’s per unit price is calculated during the shoulder-peak and on-peak hours according to
the generation of extra energy and users’ consumed electricity. Further, in this section, we will discuss
the constrained-based scheduling problem. The focus of the proposed work is cost minimization.
Besides, the load shifting from on-peak and shoulder-peak hours to off-peak hours is also done.
3.1.1. Modified ToU Tariff
The modified ToU tariff is based on the extra generation cost and the load demand of user’s
during the specific hours. The changes per hour units are made for shoulder-peak and on-peak hours.
The formal representation of modified ToU price signal (ΞP(hour)) is given as (1):
ΞPh(hour) = (ToU(hour)if Ho f f
p
=h(hour), else (1)
where
Ho f f
p
represents the off-peak hours. Utilities define the price rate according to the demand,
where electricity prices are high during the periods of high power demand (on-peak hours) and lower
during the periods of low power demand (off-peak hours) [
41
]. off-peak hours are usually when
homes and offices use less electricity.
In this scenario, we consider on-peak and Shoulder peak as on-peak hours. The
h
denotes
the
N
number of homes (
h=
1, 2, 3, ...,
N
) in a specific area. The value of
=
depends on extra
cost (ß%) rather than the off-peak price, the value of ß% depends upon the extra generated energy.
The increasing amount of generation will increase the ß percentage of user per unit charge. The ß%
amount will be distributed among all the users within a specific time interval according to their
consumed electric energy.
3.1.2. Electricity Cost Minimization
DSM strategy, load shifting is adopted to reduce the electricity cost. EMC is used for home
load management and appliances scheduling. However, this load shifting may results in undesirable
rebound peaks because every consumer tries to reduce the electricity bill. To tackle with the rebound
peak issue, we have proposed a constraint-based electricity cost minimization function. Here, electricity
load is shifted from shoulder-peak and on-peak hours towards off-peak hours according to given
constraint in Equation
(3)
. In this equation, a threshold level according to aggregate load of all
connected homes is defined for the on-peak, shoulder-peak and off-peak hours. The scheduler installed
in energy management controller schedules the load according to the limits of power demand. It also
prevents the rebound peak. The objective function of electricity cost minimization is mathematically
written as:
min(E.Ch
total )(2)
Subject to the constraint:
E.Lhlimit1 if Ho f f
p(3)
E.Lh<limit1E.Llimit2 otherwise (4)
limt1=mean(E.LUS )(5)
limit2=std(E.LU S )(6)
where
std
denotes standard deviation;
E
.
LUS
is the total aggregated load of
N
homes. Appliances
will be scheduled according to the constraint defined in Equation
(3)
. In this equation, load limits
are defined for the on-peak and off-peak hours. This threshold avoids the load to increase from
Electronics 2019,8, 48 9 of 26
a specific limit which helps in avoiding the rebound peak. The electricity load of an individual home is
calculated as:
E.Lh
hour =
D
d=1
(Appd
Prate ×)(7)
where
= [
0, 1
]
represents the On and Off status of an appliance. The total electricity cost
E
.
Ctotal
is
calculated as:
E.Ch
total =
H
hour=1
(E.Ch
hour )(8)
The Equation (9) is formulated to calculate the E.Ch
hour .
E.Ch
hour =ΞPh(hour)×E.Lh
hour (9)
where ΞPh(hour)is the list of electricity price signal.
4. Proposed Methodology
4.1. GT Based Price Model
In this section, the proposed GTToU tariff is briefly discussed. In this work, the ToU price signals
are enhanced using cooperative GT. In cooperative game, players cooperate to form some coalitions to
distribute the profit according to the contribution (pay-off). The player with maximum contribution
can obtain more profit. Every participant in coalition wants maximum profit [
42
]. In cooperative GT,
Shapley value, a solution concept is proposed in [
43
]. In this work, the concept of Shapley value is
used for fair distribution of extra generation cost among the
N
homes in a coalitional game
(
,
ν)
. Fair
in the sense, the home with maximum load has been charged more as compared to the customer who
shifted the peak load. The extra generation cost that will be added in the home
h
electricity bill is
calculated as [44]:
=h
hour =
S⊆ℵ\{h}
|S|!(ℵ − |S| − 1)!
|ℵ!|(ν(S∪ {h})ν(S)). (10)
The Shapely value
=h
hour
is expected electricity cost (pay-off or marginal distribution) of home
h
. Where
is a set of
N
homes and
ν
is the function that maps subsets of
to the real numbers
<
(i.e.,
ν:
2
<
). The
|S|
represents the number of member in a coalition
S
and
|ℵ|
(=
N
) is the total
number of homes. For coalition
S
,
ν(S)
describes the total expected sum of marginal distribution that
a member of
S
can obtain. In Equation
(10)
, numerator is equal to the number of permutations of
S
whereas denominator is the total number of permutation [
42
]. Permutation is used to find out all
the possibilities in which coalition can formed, for
N
homes it is calculated as 2
N
. The complexity of
electricity bill calculation procedure is O(N×2n).
4.2. SSA Based Scheduling Model
To optimally schedule the home appliances, SSA home appliances scheduling mechanism is
proposed in this work as given in Algorithm 1. SSA behaviour is adopted from the Salps swarm
navigating and foraging behaviour in oceans. Salp belongs to the Salpidae’ s family. The main
motivation to adopt this technique for optimization is their swarming behaviour where all Salps move
and forage food together [45]. This behaviour helps the Salp to explore and exploit the search space.
In this EMC, each salp is considered as an appliance. Where the target is to find the best swarm,
i.e., a group of appliances. The salps’ swarm move together and find an optimal solution to survive.
In our case, a group of appliances will have to find the best optimal point during a time-interval. Where,
its target is to consume a moderate level of electricity so that neither it creates peak nor increases
the price.
Electronics 2019,8, 48 10 of 26
Algorithm 1 Pseudocode of Salp swarm optimization
Require: Input: [Initialize the population]
1: for time_slot 1 to 48 do
2: while itertaion <MaxIteration do
3: Calculate the fitness of each swarm using objective function.
4: F = Find the best search agent
5: for i1 to length(population)do
6: if i== 1then
7: Update position of leading Salp
8: else
9: Update position of follower Salp
10: end if
11: end for
12: Update Salp
13: end while
14: Select the best Salp for schedule
15: Sch(time_slot) = best
16: end for
SAA
There is a chain of Salp swarm. This swarm is then divided into leaders and followers. A Salp
leading a chain is said to be a leader Salp and others are follower Salps. The leader Salp guides the
follower Salp. An
n
-dimensional search space is considered. n indicates the number of variables of
a given optimization problem.
X
is a two-dimensional matrix used to denote the positions of Salps.
Fis a food source assumed in the search space. A Salp target inside the search space is F.
Following equation is used to update the leader position [45].
x1
j=(Fj+c1((ubjlbj)c2+lbj)c30
Fjc1((ubjlbj)c2+lbj)c3>0(11)
j
is a dimension of a search space.
x1
j
is a position of leader Salp in a
j
th dimensional search space.
Fj
is considered as a food source in
j
th dimensional search space. Where
ubj
and
lbj
are the upper and
lower bounds of search space with dimension j.c1,c2and c3are random numbers.
The leader Salp position depends on the food source.
c1
is a coefficient.
c1
balance the exploration
and exploitation. It is a very important parameter for Salp algorithm.
c1=2e(4l
L)2(12)
c2
and
c3
are random numbers. The value of
c2
and
c3
is 0.5.
c2
and
c3
decides whether the next step
should be towards positive or negative infinity.
Newton’s law of motion is used to update the position of follower Salps. Equation
(13)
is used for
this purpose:
xi
j=1
2at2+vot(13)
Electronics 2019,8, 48 11 of 26
where
xi
j
indicates the position of follower Salp in search space of dimension
j
.tshows the iteration,
vo
represents the initial speed. Where
a=vf inal
vo
and
v=xxo
t
. The above equation can be expressed as:
xi
j=1
2(xi
j+xi1
j)(14)
4.3. RFA Based Scheduling Model
To optimally schedule the home appliances, RFA is proposed in this work. RFA mimics the
behavior of rain drops. In EMC, each drop of rain is considered as an appliance. The drops of the
water are collected in the deepest valley (local search) and then reach the global optimal solution (i.e.,
sea level).
4.3.1. RFA
In the RFA, the particles move like gradient descent and hill climbing. The pseudocode of the
proposed work is given in Algorithm 2. RFA optimization starts with initialization of population and
parameters used. The terms used in the proposed algorithm are: raindrop, neighborhood, neighbor
point, active drop, inactive drop, explosion process, raindrops rank and merit order list. These terms
are described below.
Algorithm 2 Pseudocode of Rain-fall optimization
1: Initialize the population nPop
2: Initialize parameters np, MaxIt, Iteration = 1, Drop no = 1 and ec = 0
3: for iteration = 1:MaxIter do
4: Generate np neighbor points
5: Calculate cost for raindrop and its neighbor points
6: if any dominant neighbor then
7: Replace drop with the most non dominant neighbor point
8: else
9: Set the drop’s status to inactive
10: Create a merit-order list
11: Set lowest-rank raindrop as inactive
12: end if
13: Iteration = Iteration + 1;
14: if any active drop and iterations <=MaxIter then
15: Go to step 4
16: Calculate the cost function values of all the raindrops
17: Find the raindrop with minimum cost function
18: Print the raindrop position and cost as the optimum solution
19: else
20: End
21: end if
22: end for
4.3.2. Raindrop
A single particle of a population is said to be a raindrop. It is a vector used to store the
variables involved in optimization problem. It is used to satisfy the constraints of the optimization
Electronics 2019,8, 48 12 of 26
problem. mrepresents the size of the population, iis used to show the drop numbers. It is defined in
Equation (15) [46].
Di= [xi,1 xi,2 xi,3 ...xi,k...xi,n]ie1, 2, 3, ..., m(15)
where nis used to represent the variables used in optimization problem,
xi,k
shows the
k
th variable used
in optimization problem.
Di
is the
i
th drop number. The constraint used is given in Equation
(16)
[
46
].
xi,k=U(lowk,upk)(16)
where Uis used to show uniform distribution function. Upper and lower limits are represented as
lowkand upk.
4.3.3. Neighborhood
Neighborhood is the domain with radius raround raindrop in
N
-dimensional search space.
It changes with the change of raindrop value.
4.3.4. Neighbor Point
In optimization, a random generation of a point is said to be a neighbor point.
NPi
j
shows the
neighbor point jof raindrop i. The formula for NPi
jis given below in Equations (17) and (18) [46]:
||(DiNPi
j).¯
uk|| ≤ ||r.¯
uk|| (17)
r=rinitial ×f(iteration)(18)
whereas,
i=
1, 2, 3, ...,
m
,
j=
1, 2, 3, ...,
np
and
k=
1, 2, 3, ...,
n
, and rshows real vector,
rinitial
is the
initial neighborhood size and np represents the neighborhood points.
4.3.5. Dominant Drop
The point performs well in neighborhood is said to be dominant. It reaches a optimum value of
given objective problem. Dominant drop is represented as
NPd
i
. F shows the function required to solve
objective problem. Following formulas are used to find the value of raindrop
(F(Di))
and its neighbor
point (F(NPi
j)) (F(NPi
d)<F(Di)).
F(NPi
d)<F(NPi
j)je{1, 2, 3, ..., np} − {d}(19)
4.3.6. Active Drop
The variable having a dominant neighbor is said to be active drop.
4.3.7. Inactive Drop
The variable having no dominant neighbor is said to be inactive drop.
4.3.8. Explosion Process
The explosion process is done when the drop is inactive, i.e., it has no dominant neighbor during
optimization or there are not sufficient neighbors. This process is done to take rain drop out of this
situation. The explosion process runs for Ne times. (np(ex)) is used to verify the neighbors in explosion
process as Equation (20) in [46].
np(ex) = np ×eb ×ec (20)
where neighbor points are represented as np, explosion base is shown as eb and the explosion counter
is given as ec.
Electronics 2019,8, 48 13 of 26
4.3.9. Raindrops Rank
There is a merit list in which different ranks are given to all raindrops. The ranks of raindrops are
calculated as Equations (21)–(23) in [46].
C1i
t=F(Di)|attth iteratio n F(Di)|at1st iteration (21)
C2i
t=F(Di)|attth iteratio n (22)
Rankit =ω1×order(C1i
t) + ω2×order(C2i
t)(23)
where
ω
1 and
ω
2 are weighting co-efficients. The value of
ω
1 and
ω
2 is 0.5.
(C
1
i
t)
and
(C
2
i
t)
shows
the change in value of objective function for raindrops at iteration t.
Rankit
shows the rank of rain
drop at iteration t.
4.3.10. Merit Order List
A merit list is used to save the ranks of raindrops in ascending order. A raindrop from merit list
is removed and considered in optimization problem. At first iteration, the raindrops are generated
randomly. After generation of raindrop, a neighborhood is assigned to each raindrop and the neighbor
points are also generated randomly according to the constraints of objective function. Some constraints
are discussed below for assigning neighbor points using Equations (24) and (25) [46]:
i f (NPi
j)k<lowkthen(N Pi
j)k=lowkotherwise (24)
i f (NPi
j)k>upkthen(N Pi
j)k=upk(25)
The cost is calculated for each rain drop and its neighbors. All values of neighborhood are
compared with value of raindrop to find out the most dominating neighbor point.
5. Simulation Results and Discussion
5.1. Experiment Configuration
Simulations are performed to investigate the impact of GTToU and compared with Flat Rate (FR)
and ToU (seasonal fixed) price signal on the user
'
s electricity bill. The FR is considered as a baseline
electricity rate in [
47
]. As discussed earlier, dynamic and time-based electricity rates determine on the
basis of generation cost and consumed energy. However, generation cost is somehow confidential.
So, for this experimental study, we assume an increase in the generation where rates of ToU price are
high. The FR and ToU tariff for this experimental study is taken from [
5
]. The ToU tariff is given in
Figure 2. The FR price for each hour remains fix and it is 7.7 per kWh up to 1000 kWh and 8.9 for more
than 1000 kWh. In order to find the difference in the total cost and per unit price, three homes are
considered with the same number of appliances and the same load demand. However, appliances
operational time varies according to the customer life style as shown in Figure 3.
The electricity bill can be further reduced after scheduling the electric appliances. Further
experiments are carried out to study the impact of scheduling using two meta-heuristic optimization
algorithms: SSA and RFA. We also investigated the impact of proposed pricing technique after load
shifting through scheduling.
Three smart homes are considered for scheduling where each home has 12 appliances. For fair
comparison of three homes’ electricity bill, we have considered the same energy demand by each user.
The detailed description of each appliance is given in Table 1. The selected appliances have three
groups: schedulable interruptible, schedulable non-interruptible and non-schedulable appliances.
Different time slots can be allocated for interruptible appliances, whereas non-interruptible appliances
cannot be interrupted during the working cycle (e.g., washing machine and cloth dryer). Moreover,
Electronics 2019,8, 48 14 of 26
dishwasher will always start working after the oven. There could be a gap between oven and
dishwasher. However, this gap is not acceptable in case of cloth dryer and washing machine.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
6
7
8
9
10
11
12
13
14
Electricity Price($)
ToU
Home 1 Unscheduled
Home 1 Scheduled Salp
Home 2 Unscheduled
Home 2 Scheduled Salp
Home 3 Unscheduled
Home 3 Scheduled Salp
(a)SSA
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
8
10
12
14
16
18
20
22
24
26
28
Electricity Price($)
RTP
Home 1 Unscheduled
Home 1 Scheduled Salp
Home 2 Unscheduled
Home 2 Scheduled Salp
Home 3 Unscheduled
Home 3 Scheduled Salp
(b)RFA
Figure 2. ToU price regulated by PG&E and price according to the proposed scheme.
Electronics 2019,8, 48 15 of 26
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Power Consumption (kWh)
Home 1 Unscheduled Load
Home 1 Scheduled Load Salp
Home 2 Unscheduled Load
Home 2 Scheduled Load Salp
Home 3 Unscheduled Load
Home 3 Scheduled Load Salp
(a)SSA
0 1 2 3 4 5 6 7 8 9 10 1112 13 1415 16 17 1819 20 2122 23
Time
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Power Consumption (kWh)
Home 1 Unscheduled Load
Home 1 Scheduled Load RainFall
Home 2 Unscheduled Load
Home 2 Scheduled Load RainFall
Home 3 Unscheduled Load
Home 3 Scheduled Load RainFall
(b)RFA
Figure 3. Load profiles of three homes before and after scheduling with ToU and GTToU.
Table 1. Detail description of appliances used in simulations.
Group Appliances Power Rate (kWh) Daily Usage (h)
Water motor 1 2
Interruptible load Dish washer 1.8 2
Iron 1 1
Non-interruptible load Washing machine 0.7 1.5
Cloth dryer 5 1
Oven 2.15 1.5
Blender 0.3 1.5
Light1 0.03 9
Non-schedule able load Light2 0.03 9
Light3 0.011 20
Light4 0.18 28
Refrigerator 0.225 24
Electronics 2019,8, 48 16 of 26
5.2. Experimental Results for GTToU
The difference in electricity cost for FR, GT-based ToU price (GTToU) and ToU without scheduling
can be envisioned in Figure 4. In this figure, the electricity price of each user changes according to the
consumed energy during the shoulder-peak and on-peak hours.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
0
10
20
30
40
50
60
70
Electricity Cost ($)
Home 1 ToU
Home 1 GTToU
Home 2 ToU
Home 2 GTToU
Home 3 ToU
Home 3 GTToU
Figure 4. Electricity bill of three users before scheduling with ToU and GTToU.
A slightly different behaviour in scheduled load is observed with the RFA, as shown in Figure 2b.
At the 7 p.m. point, the unscheduled power consumption of Home 2 is less than Home 1 and 3 and the
price is also minimized for this particular slot (see Figures 2and 3) which shows reduction in electricity
cost as shown in Figure 5. Moreover, the Figure 5a,b show that the load at 6:30 p.m. is the same for
Home 3.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
0
5
10
15
20
25
30
35
40
45
Electricity Cost ($)
Home 1 ToU
Home 1 GTToU
Home 2 ToU
Home 2 GTToU
Home 3 ToU
Home 3 GTToU
(a)SSA
Figure 5. Cont.
Electronics 2019,8, 48 17 of 26
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
0
5
10
15
20
25
30
35
40
45
Electricity Cost ($)
Home 1 ToU
Home 1 GTToU
Home 2 ToU
Home 2 GTToU
Home 3 ToU
Home 3 GTToU
(b)RFA
Figure 5. Effect of scheduling on electricity cost for ToU and GTToU.
The price during the off-peak hours remain same. From simulation results, it is analyzed that
using FR, a user has to pay 483.767
¢
for 62.870 kW for one day load. Which is higher than the scheduled
load by RFA. While comparing GTToU with ToU approximately, 1% decrement is observed in electricity
bill using GTToU. However, this difference is increased after scheduling as described in Table 2. With
Salp scheduler, the difference between between scheduled and unscheduled cost for the three homes
is calculated as 6%, 4% and 13%. Whereas RFA scheduler outperformed by reducing 14%, 5% and
12% electricity cost. This shows that the price is reduced after shifting the peak load from on-peak
hours towards the off-peak hours. Moreover, the electricity cost per hour is decreased for each home
using the GT model. The percentage difference of cost between scheduled and unscheduled homes
using GTToU is 28% for Home 1, 25% for Home 2 and 29% for Home 3 for SSA. Whereas for RFA, the
difference is 32%, 29% and 31% of targeted homes.
Table 2. Electricity cost (¢) before and after scheduling with ToU and GTToU.
Unscheduled SSA RFA
Home 1 Home 2 Home 3 Home 1 Home 2 Home 3 Home 1 Home 2 Home 3
ToU
643.99¢ 617.84¢ 645.61¢ 603.21¢ 590.74¢ 563.38¢ 554.58¢ 586.760¢ 567.70¢
GTToU
639.73¢ 611.07¢ 640.66¢ 458.76¢ 456.48¢ 456.33¢ 436.42¢ 435.59¢ 438.95¢
If we compare ToU and GTToU electricity cost after scheduling, it is observed that electricity cost
decreases after calculating the price using GTToU up-to 21%, 26% and 23% for Home 1, Home 2 and
Home 3, respectively for RFA. Similar behavior is observed for SSA, where 24%, 23% and 19% decrease
in cost for GTToU is observed for Home 1, Home 2 and Home 3, respectively. Table 2shows that each
home electricity cost is different although each home has the same load. This shows that the home
with the maximum load during on-peak hour has a high electricity bill. In summary, the proposed
pricing scheme GTToU outperformed as compare to ToU rate after scheduling.
Electronics 2019,8, 48 18 of 26
The impact of scheduled load on price is given in Figure 2. This figure depicts that the electricity
price changes according to the user load profile given in Figure 3. As shown in Figure 3a for Salp
algorithm, at 6 p.m. (shoulder-peak hour) load of Home 1 and Home 3 is higher than the Home 2
which reflects the price rate (see Figure 2a) whereas the cost of Home 1 and 3 is higher than the Home 2.
After scheduling, a remarkable difference is observed in electricity cost and PAR as given in Table 2.
The overall percentage difference is 4% in cost after scheduling with GTToU. Where the PAR difference
for scheduled and unscheduled homes is 52% for Home 1, 29% for Home 2 and 43% for Home 3. This
reduction in PAR shows that proposed constraint-based cost minimization function avoid the peak
rebounding. Moreover, from Figure 3it can be observed that the maximum unscheduled power load
is 5 kWh; however, after scheduling maximum peak load is 3.5 kWh.
5.3. Experimental Results for Day-Ahead RTP
The RTP price can be defined as a week-ahead, day-ahead and an hour-ahead. The week-ahead
and day-ahead pricing schemes are determined on the basis of previous electricity demand. RTP
hourly pricing scheme is defined as the projection of incremental demand and generation cost per
day. It is easy to schedule the electrical appliances for week-ahead and a day-ahead pricing schemes.
However, scheduling of appliances for an hour-ahead pricing scheme is quite challenging. The price
during on-peak and off-peak hours varies, so it is difficult to schedule the appliances for an hour-ahead
pricing strategy. Load forecasting can be used to tackle the aforementioned problem.
The proposed SSA-based scheduling scheme is tested for day-ahead RTP signals. The results
are given in Figure 6, it depicts that the load is increased during the on-peak hours which affects the
electricity cost. A minor difference (i.e., 1%) is observed between RTP and GTRTP price as shown in
Table 3. However, the cost is increased with both schedulers. 13% cost is increased for Home 2 with
Salp scheduler and 7% is increased with RFA for the same home. However, it is observed that the cost
and price decreased after scheduling with GTRTP. The total difference in cost between the scheduled
and unscheduled cost using Salp is 14%, 14% and 15% for Home 1, 2 and 3, whereas the difference is
16%, 15% and 16% with RFA. The results further confirmed that the RFA outperformed. The PAR value
decreases up to 52% with Salp and 17% for RFA. In Figure 6, at 11:30 a.m., the energy consumption of
Home 2 is higher than the Home 1 and 3.
24 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Power Consumption (kWh)
Home 1 Unscheduled Load
Home 1 Scheduled Load
Home 2 Unscheduled Load
Home 2 Scheduled Load
Home 3 Unscheduled Load
Home 3 Scheduled Load
(a)SSA
Figure 6. Cont.
Electronics 2019,8, 48 19 of 26
24 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Power Consumption (kWh)
Home 1 Unscheduled Load
Home 1 Scheduled Load
Home 2 Unscheduled Load
Home 2 Scheduled Load
Home 3 Unscheduled Load
Home 3 Scheduled Load
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Power Consumption (kWh)
Home 1 Unscheduled Load
Home 1 Scheduled Load RainFall
Home 2 Unscheduled Load
Home 2 Scheduled Load RainFall
Home 3 Unscheduled Load
Home 3 Scheduled Load RainFall
(b)RFA
Figure 6. Load profiles of three homes before and after scheduling with RTP and GTRTP.
Table 3. Electricity cost before and after scheduling for ToU and GTToU.
Unscheduled SSA RFA
Home 1 Home 2 Home 3 Home 1 Home 2 Home 3 Home 1 Home 2 Home 3
ToU
791.11 790.84 804.80 889.48 892.40 875.95 818.66 843.91 839.73
GTToU
791.05 783.01 791.96 681.27 676.54 676.51 663.18 667.30 661.77
It can be envisioned from Figures 7and 8that the electricity cost is not high during some specific
hours. After scheduling the cost varies accordingly. Figure 9shows that the price during on-peak hours
is reduced due to the shifting of load. To avoid the peak formation, scheduling is done. The PAR value
decreases up to 52% with Salp and 17% for RFA. In Figure 6, at 11:30 a.m., the energy consumption of
Home 2 is higher than the Home 1 and 3. Further, Figures 3and 6show the peak load and cost during
on-peak and off-peak hours. The RFA efficiently dealt with the distribution of load during on-peak
hours. Despite this, there is a minor difference between SSA and RFA. As shown in Figure 6a,b, RFA
avoids peak formation and keeps the load on the average level. A Salp algorithm somewhere exceeds
the average level (Figure 6a).
The results of ToU and day-ahead RTP tariff policies show that ToU is more convenient. In ToU
tariff policy, the consumers have to pay less than the RTP users. Moreover, the proposed scheme
efficiently reduced the electricity bill. Before scheduling, the difference between the electricity bill
of ToU and GTToU is less. However, GTToU is effective after scheduling. Moreover, the simulation
results depict that RFA effectively explores and exploits the search space.
The day-ahead RTP and ToU pricing schemes are efficient for scheduling the load profiles of
electricity. The RTP has been defined for week-ahead, day-ahead and hour-ahead pricing schemes.
The week-ahead and day-ahead pricing schemes are defined on the bases of previous electricity
demand. The pricing scheme for an hour is defined for RTP hour-ahead price. It depends on the
prediction of incremental demand and generation cost per day. It is easy to schedule electrical
appliances using week-ahead and day-ahead pricing schemes. However, for an hour-ahead pricing
Electronics 2019,8, 48 20 of 26
scheme, it is difficult to schedule the appliances as the price per hour is different. Load forecasting is
one of the solutions to solve the aforementioned issues. For this purpose, simulations are done for the
load forecasting to deal with hourly ahead RTP signal using ensemble classifiers.
24 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
Power Consumption (kWh)
Home 1 Unscheduled Load
Home 1 Scheduled Load
Home 2 Unscheduled Load
Home 2 Scheduled Load
Home 3 Unscheduled Load
Home 3 Scheduled Load
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
0
10
20
30
40
50
60
Electricity Cost ($)
Home 1 RTP
Home 1 GTRTP
Home 2 RTP
Home 2 GTRTP
Home 3 RTP
Home 3 GTRTP
Figure 7. Electricity bill of three user before scheduling with RTP and GTRTP.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
0
10
20
30
40
50
60
70
80
Electricity Cost ($)
Home 1 RTP
Home 1 GTRTP
Home 2 RTP
Home 2 GTRTP
Home 3 RTP
Home 3 GTRTP
(a)SSA
Figure 8. Cont.
Electronics 2019,8, 48 21 of 26
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hour)
0
10
20
30
40
50
60
70
80
90
100
Electricity Cost (¢)
Home 1 RTP
Home 1 GTRTP
Home 2 RTP
Home 2 GTRTP
Home 3 RTP
Home 3 GTRTP
(b)RFA
Figure 8. Effect of scheduling on electricity cost with RTP and GTRTP.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
8
10
12
14
16
18
20
22
24
26
28
Electricity Price($)
RTP
Home 1 Unscheduled
Home 1 Scheduled Salp
Home 2 Unscheduled
Home 2 Scheduled Salp
Home 3 Unscheduled
Home 3 Scheduled Salp
(a)SSA
Figure 9. Cont.
Electronics 2019,8, 48 22 of 26
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Time (hours)
8
10
12
14
16
18
20
22
24
26
28
Electricity Price($)
RTP
Home 1 Unscheduled
Home 1 Scheduled RainFall
Home 2 Unscheduled
Home 2 Scheduled RainFall
Home 3 Unscheduled
Home 3 Scheduled RainFall
(b)RFA
Figure 9. RTP tariff and electricity price of all three homes according to the proposed scheme.
5.4. Experimental Results for Ensemble Regression
In order to study the impact of ensemble classifiers on load prediction, the weather and load data
is taken from [
48
]. The datasets available in [
49
] contain the weather and energy consumption record
of different homes. From this available records, we analyze and predict the Home A power load. This
data contains the each mints load and weather detail.
In the proposed work, the data of summer season is considered. So the data for June, July, August
and September is taken. Regression model is used to train the data of June–August. Whereas the
testing is performed on the data of September. The prediction of load depends on the conditions of the
weather. To analyze the behaviour of regression model, different load patterns are studied as given in
Figures 1012. These figures show the users behaviour for an hour, day and month.
1 2 3 4 5 6 7 8 9 10 1112 13 141516 17 1819 20 212223 24
Time (hours)
5
10
15
20
25
30
35
40
45
50
Electricity Load (kW)
Actual Load
naive Bayes
K-Nearest Neighbour
Support Vector Regression
Ensemble
Figure 10. Predicted load of a day.
Electronics 2019,8, 48 23 of 26
Figure 10 shows that the load profile of users is stochastic. The load demand is high in morning
and evening. The electricity consumption also depends on the working hours. For one day prediction,
only the first day of each month is taken for the purpose of training and testing. The Figure 10 shows
that the K-nearest neighbour prediction is different from the actual data.
The user electricity consumption is given in Figure 11. Where electricity load profile shows
a different behaviour for each day. From this, we analyze that the demand for a day and hour changes
as given in Figure 12. Moreover, the minimum error is shown by Naive Bayes. However, its trend
is different from the actual behaviour. From this trend, scheduler can estimate the on-peak and
off-peak hours.
1 2 3 4 5 6 7 8 9 101112131415161718192021222324252627282930
Time (day)
200
250
300
350
400
450
500
550
600
Electricity Load (kW)
Actual Load
naive Bayes
K-Nearest Neighbour
Support Vector Regression
Ensemble
Figure 11. Predicted load of a month.
1 25 49 73 97 121 145 169 193 217 241 265 289 313 337 361 385 409 433 457 481 505 529 553 577 601 625 649 673 697
Time (hours)
0
10
20
30
40
50
60
Electricity Load (kW)
Actual Load
Naive Bayes
K-Nearest Neighbour
Support Vector Regression
Ensemble
Figure 12. Per-hour predicted load of a month.
6. Conclusions
In this study, the coalition-based GT model is proposed to formulate the pricing scheme model.
Dynamic DR price models are used to charge the electricity cost per unit. The main purpose of the
proposed work is to shift the load from on-peak hours to off-peak hours. Furthermore, some incentives
are also defined for users. However, a per unit cost is same for all users. There is a pay-off incentive for
Electronics 2019,8, 48 24 of 26
the users who have shifted the load from on-peak to off-peak hours. The purpose of the proposed model
is to charge the per unit price according to the consumed energy and the extra generation cost. The
shappley value distributes the extra generation cost among each user according to the electricity load
profile. The cost is directly proportional to the load peak during on-peak hours. Moreover, SSA and
RFA are used to automate home appliances. Experimental results show 50% reduction in PAR and 32%
in cost with RFA using GTToU. This shows the effectiveness of RFA. A remarkable difference between
schedule load price for ToU and the proposed technique is observed. However, this difference is minor
for unscheduled ToU and GTToU electricity bill. The proposed scheme is further compared with
day-ahead RTP. Simulation results show that the proposed GTToU price model is more cost effective
as compared to day-ahead RTP. Moreover, electricity load is predicted using ensemble classifier for
hourly-ahead RTP rates. Simulation results show that ensemble regression model outperformed
the single regression model. In this work, we have studied ensemble classifiers impact on the load
forecasting technique. In the future, we will enhance the techniques for load prediction.
Author Contributions:
A.K., N.J. and M.I. proposed, implemented and wrote heuristic schemes. A.M., T.S. and
A.R. wrote rest of the paper. All authors together organized and refined the paper.
Funding: This research received no external funding
Conflicts of Interest: The authors declare no conflict of interest
Nomenclature
Symbols Description Symbols Description
C/I Curtailable/Interruptible E.LUS Total aggregated load of Nhomes
CPP Critical Peak Pricing γConstant value
CPR Critical Peak Rebate E.Ctotal Total electricity cost
DR Demand Response [0, 1]ON and OFF status of appliance d
EMC Energy Management Controller UUniform distribution function
GT Game Theory =h
hour Pay-off of each home
GTToU GT-based Price Signal , ¯hTuple of the game
NN Neural Network mSize of the population
PAR Peak to Average Ratio iDrop numbers
RFA Rain Fall Algorithm lowkupkLower and upper limits
RTP Real Time Pricing NPi
jNeighbor point jof raindrop i
SH Smart Home rReal vector
SHEMS SH Energy Management System riniti al Initial neighborhood size
SSA Salp Swarm Algorithm np Neighborhood points
ToU Time-of-Use NPd
iDominant drop
VPP Variable Peak Pricing FObjective function
ΞPh(hour)Modified TOU Price Signal FDiValue of raindrop
Ho f f
pOff Peak Hours F(NPi
j)Neighbor point
hSet of Nnumber of homes np(ex)Neighbors in explosion process
=h
hour Depends on extra cost C1i
tRank of rain drops
ß% Extra generated energy ω1,ω2Weighting co-efficients
std Standard deviation C1i
t,C2i
tChange in value of objective function for
raindrops at iteration
References
1. Steiner, P.O. Peak loads and efficient pricing. Q. J. Econ. 1957,71, 585–610. [CrossRef]
2. Boiteux, M. Peak-load pricing. J. Bus. 1960,33, 157–179. [CrossRef]
3. Wilson, R.B. Nonlinear Pricing; Oxford University Press: Oxford, UK, 1993.
4.
Venizelou, V.; Philippou, N.; Hadjipanayi, M.; Makrides, G.; Efthymiou, V.; Georghiou, G.E. Development of
a novel time-of-use tariff algorithm for residential prosumer price-based demand side management. Energy
2018,142, 633–646. [CrossRef]
Electronics 2019,8, 48 25 of 26
5.
PG & E. Available online: https://www.pge.com/en_US/business/rate-plans/rate-plans/time-of-use/
time-of-use.page (accessed on 6 August 2018).
6.
EIA. Available online: https://www.eia.gov/energyexplained/index.php?page=electricityfactors_affecting_
prices (accessed on 6 August 2018).
7.
Yang, Y.; Wang, M.; Liu, Y.; Zhang, L. Peak-off-peak load shifting: Are public willing to accept the peak and
off-peak time of use electricity price? J. Clean. Prod. 2018,199, 1066–1071. [CrossRef]
8.
Muratori, M.; Rizzoni, G. Residential demand response: Dynamic energy management and time-varying
electricity pricing. IEEE Trans. Power Syst. 2016,31, 1108–1117. [CrossRef]
9.
Hayes, B.; Melatti, I.; Mancini, T.; Prodanovic, M.; Tronci, E. Residential demand management using
individualized demand aware price policies. IEEE Trans. Smart Grid 2017,8, 1284–1294. [CrossRef]
10.
Apostolopoulos, P.A.; Tsiropoulou, E.E.; Papavassiliou, S. Demand response management in smart grid
networks: A two-stage game-theoretic learning-based approach. Mob. Netw. Appl. 2018, 1–14. [CrossRef]
11.
Borovkova, S.; Schmeck, M.D. Electricity price modeling with stochastic time change. Energy Econ.
2017
,63,
51–65. [CrossRef]
12.
Marcjasz, G.; Uniejewski, B.; Weron, R. On the importance of the long-term seasonal component in day-ahead
electricity price forecasting with NARX neural networks. Int. J. Forecast. 2018. [CrossRef]
13.
Wang, D.; Luo, H.; Grunder, O.; Lin, Y.; Guo, H. Multi-step ahead electricity price forecasting using a hybrid
model based on two-layer decomposition technique and BP neural network optimized by firefly algorithm.
Appl. Energy 2017,190, 390–407. [CrossRef]
14.
Hobman, E.V.; Frederiks, E.R.; Stenner, K.; Meikle, S. Uptake and usage of cost-reflective electricity pricing:
Insights from psychology and behavioural economics. Renew. Sustain. Energy Rev.
2018
,57, 455–467.
[CrossRef]
15.
Azman, N.A.M.; Abdullah, M.P.; Hassan, M.Y.; Said, D.M.; Hussin, F. Enhanced Time-of-Use Electricity
Pricing for Commercial Customers in Malaysia. Pertanika J. Sci. Technol. 2017,25, 285–294.
16.
Li, R.; Wang, Z.; Gu, C.; Li, F.; Wu, H. A novel time-of-use tariff design based on Gaussian Mixture Model.
Appl. Energy 2016,162, 1530–1536. [CrossRef]
17.
Yang, P.; Tang, G.; Nehorai, A. A game-theoretic approach for optimal time-of-use electricity pricing.
IEEE Trans. Power Syst. 2013,28, 884–892. [CrossRef]
18.
Srinivasan, D.; Rajgarhia, S.; Radhakrishnan, B.M.; Sharma, A.; Khincha, H.P. Game-Theory based dynamic
pricing strategies for demand side management in smart grids. Energy 2017,126, 132–143. [CrossRef]
19.
Haider, H.T.; See, O.H.; Elmenreich, W. Dynamic residential load scheduling based on adaptive consumption
level pricing scheme. Electr. Power Syst. Res. 2016,133, 27–35. [CrossRef]
20.
Wang, K.; Li, H.; Maharjan, S.; Zhang, Y.; Guo, S. Green Energy Scheduling for Demand Side Management in
the Smart Grid. IEEE Trans. Green Commun. Netw. 2018,2, 596–611. [CrossRef]
21.
Mahmud, K.; Hossain, M.J.; Town, G.E. Peak-Load Reduction by Coordinated Response of Photovoltaics,
Battery Storage, and Electric Vehicles. IEEE Access 2018,6, 29353–29365. [CrossRef]
22.
Li, N.; Chen, L.; Dahleh, M.A. Demand response using linear supply function bidding. IEEE Trans. Smart Grid
2015,6, 1827–1838. [CrossRef]
23.
Jacquot, P.; Beaude, O.; Gaubert, S.; Oudjane, N. Analysis and implementation of an hourly billing mechanism
for demand response management. IEEE Trans. Smart Grid 2018. [CrossRef]
24.
Khan, A.; Javaid, N.; Ahmad, A.; Akbar, M.; Khan, Z.A.; Ilahi, M. A priority-induced demand side
management system to mitigate rebound peaks using multiple knapsack. J. Ambient Intell. Hum. Comput.
2018, 1–24. [CrossRef]
25.
Veras, J.M.; Silva, I.R.S.; Pinheiro, P.R.; Rabelo, R.A. Towards the Handling Demand Response Optimization
Model for Home Appliances. Sustainability 2018,10, 616. [CrossRef]
26.
Gao, B.; Liu, X.; Wu, C.; Tang, Y. Game-theoretic energy management with storage capacity optimization in
the smart grids. J. Mod. Power Syst. Clean Energy 2018,6, 656–667. [CrossRef]
27.
Rahim, S.; Javaid, N.; Ahmad, A.; Khan, S.A.; Khan, Z.A.; Alrajeh, N.; Qasim, U. Exploiting heuristic
algorithms to efficiently utilize energy management controllers with renewable energy sources. Energy Build.
2016,129, 452–470. [CrossRef]
28.
Li, D.; Chiu, W.Y.; Sun, H.; Poor, H.V. Multiobjective Optimization for Demand Side Management Program
in Smart Grid. IEEE Trans. Ind. Inform. 2018,14, 1482–1490. [CrossRef]
Electronics 2019,8, 48 26 of 26
29.
Liu, R.S.; Hsu, Y.F. A scalable and robust approach to demand side management for smart grids with
uncertain renewable power generation and bi-directional energy trading. Int. J. Electr. Power Energy Syst.
2018,97, 396–407. [CrossRef]
30.
Vivekananthan, C.; Mishram, Y.; Ledwich, G.; Li, F. Demand response for residential appliances via customer
reward scheme. IEEE Trans. Smart Grid 2014,5, 809–820. [CrossRef]
31.
Das, N.R.; Rai, S.C.; Nayak, A. Intelligent Scheduling of Demand Side Energy Usage in Smart Grid Using
a Metaheuristic Approach; Modern Education and Computer Science Press: Hong Kong, China, 2018.
32.
Croce, D.; Giuliano, F.; Tinnirello, I.; Galatioto, A.; Bonomolo, M.; Beccali, M.; Zizzo, G. Overgrid: A Fully
Distributed Demand Response Architecture Based on Overlay Networks. IEEE Trans. Autom. Sci. Eng.
2017
,
14, 471–481. [CrossRef]
33.
Qian, L.P.; Zhang, Y.J.A.; Huang, J.; Wu, Y. Demand response management via real-time electricity price
control in smart grids. IEEE J. Sel. Areas Commun. 2013,31, 1268–1280. [CrossRef]
34.
Neglia, G.; Giarré, L.; Tinnirello, I.; Di Bella, G. Teletraffic engineering for direct load control in smart grids.
Sustain. Energy Grids Netw. 2018,16, 167–176. [CrossRef]
35.
Godina, R.; Rodrigues, E.M.; Pouresmaeil, E.; Matias, J.C.; Catalão, J.P. Model predictive control home energy
management and optimization strategy with demand response. Appl. Sci. 2018,8, 408. [CrossRef]
36.
Aslam, S.; Javaid, N.; Khan, F.A.; Alamri, A.; Almogren, A.; Abdul, W. Towards Efficient Energy Management
and Power Trading in a Residential Area via Integrating a Grid-Connected Microgrid. Sustainability
2018
,
10, 1245. [CrossRef]
37.
Khan, A.; Javaid, N.; Khan, M.I. Time and device based priority induced comfort management in smart
home within the consumer budget limitation. Sustain. Cities Soc. 2018,41, 538–555. [CrossRef]
38.
Ullah, I.; Kim, D. An improved optimization function for maximizing user comfort with minimum energy
consumption in smart homes. Energies 2017,10, 1818. [CrossRef]
39.
Bharathi, C.; Rekha, D.; Vijayakumar, V. Genetic algorithm based demand side management for smart grid.
Wirel. Pers. Commun. 2017,93, 481–502. [CrossRef]
40.
Ahmed, N.; Levorato, M.; Li, G.P. Residential consumer-centric demand side management. IEEE Trans.
Smart Grid 2018,9, 4513–4524. [CrossRef]
41.
Dusonchet, L.; Favuzza, S.; Massaro, F.; Telaretti, E.; Zizzo, G. Technological and legislative status point of
stationary energy storages in the EU. Renew. Sustain. Energy Rev. 2019,101, 158–167. [CrossRef]
42.
Kaushal, R.K.; Nema, A.K. Game Theory-Based Multistakeholder Planning for Electronic Waste Management.
J. Hazard. Toxic Radioact. Waste 2012,17, 21–30. [CrossRef]
43. Shapley, L.S.A. A value for n-person games. Contrib. Theory Games 1953,2, 307–317.
44. Ichiishi, T. Game Theory for Economic Analysis; Academic Press: Cambridge, MA, USA, 2014.
45.
Mirjalili, S.; Gandomi, A.H.; Mirjalili, S.Z.; Saremi, S.; Faris, H.; Mirjalili, S.M. Salp Swarm Algorithm:
A bio-inspired optimizer for engineering design problems. Adv. Eng. Softw. 2017,114, 163–191. [CrossRef]
46.
Kaboli, S.H.A.; Selvaraj, J.; Rahim, N.A. Rain-fall optimization algorithm: A population based algorithm for
solving constrained optimization problems. J. Comput. Sci. 2017,19, 31–42. [CrossRef]
47.
Thumim, J.; Parade, B. Investigating the Potential Impacts of Time-of-Use (TOU) Tariffs on Domestic Electricity
Customers; Centre for Sustainable Energy: Bristol, UK, 2014.
48.
Gelazanskas, L.; Gamage, K.A. Demand side management in smart grid: A review and proposals for future
direction. Sustain. Cities Soc. 2014,11, 22–30. [CrossRef]
49.
UMassTraceRepository. Available online: http://traces.cs.umass.edu/index.php/Smart/Smart (accessed on
5 November 2018).
©
2019 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access
article distributed under the terms and conditions of the Creative Commons Attribution
(CC BY) license (http://creativecommons.org/licenses/by/4.0/).
MATLAB Source Code for paper
Enhanced Time-of-Use Electricity Price Rate Using Game Theory
Authors: Adia Khalid, Nadeem Javaid, Abdul Mateen, Manzoor Ilahi, Tanzila Saba
and Amjad Rehman
For further queries you can contact on following email IDs: adia.khalid@gmail.com,
nadeemjavaidqau@gmail.com
Note: The provided code contains one m file. Code has two portions: one for scheduling and
other for prediction.
DataSet: In this paper, we have used two data files: 1). Weather data (saved as:
“homeA2016_Refined.csv”,) and 2). Electricity load data (saved as: “HomeA-
meter4_2016.csv”): Datasets used in this code are taken from
http://traces.cs.umass.edu/index.php/Smart/Smart. These dataset in excel files are also
provided in Researchgate along with complete code.
https://www.researchgate.net/publication/342242039_GT_ToU_MatlabCode
Link of the paper: https://www.mdpi.com/2079-9292/8/1/48
Citation: Adia Khalid, Nadeem Javaid, Abdul Mateen, Manzoor Ilahi, Tanzila Saba and
Amjad Rehman, "Enhanced Time-of-Use Electricity Price Rate Using Game Theory",
Electronics, Volume: 8, Issue: 1, Pages: 1-26, Article Number: 48, Published: January 2019,
EISSN 2079-9292. DOI: https://doi.org/10.3390/electronics8010048.
% Keep both .csv file and .m file in same folder
% The original Source of .csv files is: "http://traces.cs.umass.edu/index.php/Smart/Smart"
%% New price tariff based on Game theory coalition based strategy
% Don't forget yours results EP_ToU depended on the pay-off value.
% In this code define pay-off values are according to our given condition
% You must have to change according to your requirements
%% Also scheduling is performed using "Salp optimization" and "Rainfall" Algorithm detail of code is given in SLAP algo
code file
%% Results contains two part
%% Part1: Comparison of uscheduled values using ToU or RTP and proposed pricing scheme
%% Part2: Comparison of uscheduled values using proposed pricing scheme
%% Created and modified by ADIA KHALID
close all
clear all
clc
%% Code 1 Prediction
%% For each classification we have Adjust the data accordingly.
% Auto-generated by MATLAB on 15-Jun-2020 18:32:29 (Just for the uploading
% the data file automatically.)
% You may need to Change these bcode up to the line
% HomeAmeter42016 = readtable("HomeA-meter4_2016.csv", opts);
% Because this code vary from version to version (We are using matlab 2019a)
%% Setup the Import Options
% If you get error go to home-->import Data--> and select
% HomeA-meter4_2016.csv ... After that go to the Import selection --->
% generate script. Copy and past the automatic generated code here. If you
% get data in cell formate convert it into matrix using ---> cell2mat
opts = delimitedTextImportOptions("NumVariables", 15);
%Specify range and delimiter
opts.DataLines = [2, Inf];
opts.Delimiter = ",";
%Specify column names and types
opts.VariableNames = ["DateTime", "usekW", "genkW", "KitchenDenLightskW", "MasterBedBathLightskW",
"MasterOutletskW", "DenOutdoorLightskW", "DenOutletskW", "RearBasementLightskW", "KitchenOutletsEastkW",
"KitchenOutletsSouthkW", "DishwasherDisposalSinkLightkW", "RefrigeratorkW", "MicrowavekW", "OfficeLightskW"];
opts.VariableTypes = ["datetime", "double", "double", "double", "double", "double", "double", "double", "double", "double",
"double", "double", "double", "double", "double"];
opts = setvaropts(opts, 1, "InputFormat", "yyyy-MM-dd HH:mm:ss");
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
%Import the data
HomeAmeter42016 = readtable("HomeA-meter4_2016.csv", opts);
%% End of Import Option
%% Summer Duration is June to September and started for 194524 and end at 414843
% Record for the electricity load
% These lines are written to convert data in matrics as above it is
% automatically converted into tabular form.
Data_Summer = HomeAmeter42016(194524:414843, 4:end);
Data_June = Data_Summer(1:43200, 4:end);
Data_June = table2array(Data_June);
Total_Load_June = sum(Data_June');
%% Data contains the each mints load we will consider the 30 mints load
% By adding the values
j = 1;
k = 60;
for i=1:720 % 1440 because we are going to divide each hour into two slot each of 30 mints. so we have total values 30*48
Slot_30_June(i) = sum(Total_Load_June(j:k));
j= k+1;
k = k+60;
end
Data_Jully = Data_Summer(43201:87840, 4:end);
Data_Jully = table2array(Data_Jully);
Total_Load_Jully = sum(Data_Jully');
j = 1;
k = 60;
for i=1:744%1488 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Slot_30_Jully(i) = sum(Total_Load_Jully(j:k));
j= k+1;
k = k+60;
end
Data_August = Data_Summer(87841:132480, 4:end);
Data_August = table2array(Data_August);
Total_Load_August = sum(Data_August');
j = 1;
k = 60;%30;
for i=1: 744 %1488 % 1448 because we are going to divide each hour into two slot each of 30 mints. So we have total values
31*48
Slot_30_August(i) = sum(Total_Load_August(j:k));
j= k+1;
k = k+60;
end
Data_September = Data_Summer(132481:175680, 4:end);
Data_September = table2array(Data_September);
Total_Load_September = sum(Data_September');
j = 1;
k = 60;
for i=1:720%1440 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Slot_30_September(i) = sum(Total_Load_September(j:k));
j= k+1;
k = k+60;
end
%% Sum the load for forecast here we do forecasting based on weather data
%% Import the weather data these are the features whereas above define load is taken as predicted values
%% Import data from text file
% Script for importing data from the following text file:
% Auto-generated by MATLAB on 16-Jun-2020 11:15:39
%% Setup the Import Options
% If you get error go to home-->import Data--> and select
% HomeA-meter4_2016.csv ... After that go to the Import selection --->
% generate script. Copy and past the automatic generated code here. If you
% get data in cell formate convert it into matrix using ---> cell2mat
opts = delimitedTextImportOptions("NumVariables", 11);
% Specify range and delimiter
opts.DataLines = [2, Inf];
opts.Delimiter = ",";
% Specify column names and types
opts.VariableNames = ["temperature", "humidity", "visibility", "apparentTemperature", "pressure", "windSpeed",
"cloudCover", "windBearing", "precipIntensity", "dewPoint", "precipProbability"];
opts.VariableTypes = ["double", "double", "double", "double", "double", "double", "double", "double", "double", "double",
"double"];
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
% Import the data
dataArray = readtable("homeA2016_Refined.csv", opts);
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file and version of matlab, try regenerating the code
% from the Import Tool.
homeA2016 = table2array(dataArray); % Convert Table into Array
%% separate from a single file month wise
Weather_Data_June = homeA2016(3649:4368, 1:end);
Weather_Data_Jully = homeA2016(4369:5112, 1:end);
Weather_Data_August = homeA2016(5113:5856, 1:end);
Weather_Data_September = homeA2016(5857:6576, 1:end);
Weather_Data_June_Update = Weather_Data_June;
Weather_Data_Jully_Update = Weather_Data_Jully;
Weather_Data_August_Update = Weather_Data_August;
Weather_Data_September_Update = Weather_Data_September;
Train_Data = [Weather_Data_June_Update; Weather_Data_Jully_Update; Weather_Data_August_Update];
Train_Label = [Slot_30_June'; Slot_30_Jully'; Slot_30_August'];
Test_Data = [Weather_Data_September_Update];
Test_Label = [Slot_30_September'];
Train_Data(isnan(Train_Data))=0;
Test_Data(isnan(Test_Data)) =0; % Test Lables
%% Start of Baysen regression model
p=11;
Mdl_BN = bayeslm(p,'ModelType','conjugate'); % Build the model using baye
PosteriorMdl = estimate(Mdl_BN,Train_Data,Train_Label,'Display',false); % Estimate the values
Out_put_BN = forecast(PosteriorMdl,Test_Data); % Forecast the values for the test data
%% Start of KNN
% mdl = fitcknn(citynames,citycodes, 'NumNeighbors',50, 'NSMethod','exhaustive', 'Distance',@levenshtein);
Mdl_KNN = fitcknn(Train_Data,Train_Label, 'NumNeighbors',1,'Standardize',1);
Out_put_KNN = predict(Mdl_KNN,Test_Data);
%% Start of SVM
Mdl_SVM = fitrsvm(Train_Data,Train_Label,'KernelFunction','gaussian','KernelScale','auto',...
'Standardize',true);
Out_put_SVM = predict(Mdl_SVM,Test_Data);
%% Main Classifier
Mdl_BN = bayeslm(p,'ModelType','conjugate'); % Build the model using baye
PosteriorMdl = estimate(Mdl_BN,Train_Data,Train_Label,'Display',false); % Estimate the values
Out_put_BN_Main = forecast(PosteriorMdl,Test_Data); % Forecast the values for the test data
Mdl_BN = bayeslm(p,'ModelType','conjugate'); % Build the model using baye
PosteriorMdl = estimate(Mdl_BN,Train_Data,Train_Label,'Display',false); % Estimate the values
Out_put_BN_Main2 = forecast(PosteriorMdl,Test_Data); % Forecast the values for the test data
Mdl_BN = bayeslm(p,'ModelType','conjugate'); % Build the model using baye
PosteriorMdl = estimate(Mdl_BN,Train_Data,Train_Label,'Display',false); % Estimate the values
Out_put_BN_Main2 = forecast(PosteriorMdl,Test_Data); % Forecast the values for the test data
%% Ensembling the output of all three classifiers
Out_put_EN_C = [Out_put_BN'; Out_put_KNN'; Out_put_SVM'; Out_put_BN_Main'];
Out_put_EN_C = mean(Out_put_EN_C);
err_NB = immse(Test_Label,Out_put_BN)
err_SVM = immse(Test_Label,Out_put_SVM)
err_KNN = immse(Test_Label,Out_put_KNN)
err_EN_C = immse(Test_Label,Out_put_EN_C')
%% Plot the values for Figure 12. Per-hour predicted load of a month.
figure (1)
plot(1:720, Test_Label', 'Color',[0.6 0.7 0],'Marker','>','LineWidth',1.4);
hold on
plot(1:720, Out_put_BN', 'Color',[0 0.6 1],'Marker','s','LineWidth',1.4);
hold on
plot(1:720, Out_put_KNN', 'Color',[0.75 0 0],'Marker','*','LineWidth',1.4);
hold on
plot(1:720, Out_put_SVM', 'Color',[0.75 0 0.6],'Marker','+','LineWidth',1.4);
hold on
plot(1:720, Out_put_EN_C', 'Color',[0.3 0.2 0.2],'Marker','p','LineWidth',1.4);
xlabel('Time (hours)');
ylabel('Electricity Load (kW)');
set(gca, 'XTick',1:24:720)
legend('Actual Load','Naive Bayes', 'K-Nearest Neighbour', 'Support Vector Regression','Ensemble');
legend('Location','NorthEast');
grid on
hold off
%% Per Month prediction
Data_Summer = []; Data_June = []; Data_June = []; Total_Load_June = []; % To avoid duplication
%% Summer Duration is June to September and started for 194524 and end at 414843
% Record for the electricity load
Data_Summer = HomeAmeter42016(194524:414843, 4:end);
Data_June = Data_Summer(1:43200, 4:end);
Data_June = table2array(Data_June);
Total_Load_June = sum(Data_June');
%% Data contains the each mints load we will consider the 30 mints load
j = 1;
k = 60;
Slot_30_June1=[];
for i=1:720 % 1440 because we are going to divide each hour into two slot each of 30 mints. so we have total values 30*48
Slot_30_June1(i) = sum(Total_Load_June(j:k));
j= k+1;
k = k+60;
end
j = 1;
k = 24;
Slot_30_June=[];
for i=1:30 % 1440 because we are going to divide each hour into two slot each of 30 mints. so we have total values 30*48
Slot_30_June(i) = sum(Slot_30_June1(j:k));
j= k+1;
k = k+24;
end
Data_Jully = Data_Summer(43201:87840, 4:end);
Data_Jully = table2array(Data_Jully);
Total_Load_Jully = sum(Data_Jully');
j = 1;
k = 60;
Slot_30_Jully1=[];
for i=1:744%1488 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Slot_30_Jully1(i) = sum(Total_Load_Jully(j:k));
j= k+1;
k = k+60;
end
j = 1;
k = 24;
Slot_30_Jully=[];
for i=1:30%1488 % 1448 because we are going to divide each hour into two slot each of 30 mints. So we have total values
31*48
Slot_30_Jully(i) = sum(Slot_30_Jully1(j:k));
j= k+1;
k = k+24;
end
Data_August = []; Data_August = []; Total_Load_August = []; % To avoid duplication
Data_August = Data_Summer(87841:132480, 4:end);
Data_August = table2array(Data_August);
Total_Load_August = sum(Data_August');
j = 1;
k = 60;%30;
Slot_30_August1=[];
for i=1: 744 %1488 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Slot_30_August1(i) = sum(Total_Load_August(j:k));
j= k+1;
k = k+60;
end
j = 1;
k = 24;%30;
Slot_30_August=[];
for i=1: 30 %1488 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Slot_30_August(i) = sum(Slot_30_August1(j:k));
j= k+1;
k = k+24;
end
Data_September = Data_Summer(132481:175680, 4:end);
Data_September = table2array(Data_September);
Total_Load_September = sum(Data_September');
j = 1;
k = 60;
Slot_30_September1=[];
for i=1:720%1440 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Slot_30_September1(i) = sum(Total_Load_September(j:k));
j= k+1;
k = k+60;
end
Slot_30_September=[];
j = 1;
k = 24;
for i=1:30%1440 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Slot_30_September(i) = sum(Slot_30_September1(j:k));
j= k+1;
k = k+24;
end
%% Sum the load for forecaste here we do forecasting based on weather data
j = 1;
k = 24;
Weather_Data_June_Update=[];
for i=1:30%1440 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Weather_Data_June_Update(i,:) = mean(Weather_Data_June(j:k,1:end));
j= k+1;
k = k+24;
end
j = 1;
k = 24;
Weather_Data_Jully_Update=[];
for i=1:30%1440 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Weather_Data_Jully_Update(i,:) = mean(Weather_Data_Jully(j:k,1:end));
j= k+1;
k = k+24;
end
j = 1;
k = 24;
Weather_Data_August_Update=[];
for i=1:30%1440 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Weather_Data_August_Update(i,:) = mean(Weather_Data_August(j:k,1:end));
j= k+1;
k = k+24;
end
j = 1;
k = 24;
Weather_Data_September_Update=[];
for i=1:30%1440 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Weather_Data_September_Update(i,:) = mean(Weather_Data_September(j:k,1:end));
j= k+1;
k = k+24;
end
Train_Data = [Weather_Data_June_Update; Weather_Data_Jully_Update; Weather_Data_August_Update];
Train_Label = [Slot_30_June'; Slot_30_Jully'; Slot_30_August'];
Test_Data = [Weather_Data_September_Update];
Test_Label = [Slot_30_September'];
Train_Data(isnan(Train_Data))=0;
Test_Data(isnan(Test_Data)) =0; % Test Lables
%% Start of Baysen regression model
p=11;
Mdl_BN = bayeslm(p,'ModelType','conjugate'); % Build the model using baye
PosteriorMdl = estimate(Mdl_BN,Train_Data,Train_Label,'Display',false); % Estimate the values
Out_put_BN = forecast(PosteriorMdl,Test_Data); % Forecast the values for the test data
%% Start of KNN
% mdl = fitcknn(citynames,citycodes, 'NumNeighbors',50, 'NSMethod','exhaustive', 'Distance',@levenshtein);
Mdl_KNN = fitcknn(Train_Data,Train_Label, 'NumNeighbors',1,'Standardize',1);
Out_put_KNN = predict(Mdl_KNN,Test_Data);
%% Start of SVM
Mdl_SVM = fitrsvm(Train_Data,Train_Label,'KernelFunction','gaussian','KernelScale','auto',...
'Standardize',true);
Out_put_SVM = predict(Mdl_SVM,Test_Data);
%% Main Classifier
Mdl_BN = bayeslm(p,'ModelType','conjugate'); % Build the model using baye
PosteriorMdl = estimate(Mdl_BN,Train_Data,Train_Label,'Display',false); % Estimate the values
Out_put_BN_Main = forecast(PosteriorMdl,Test_Data); % Forecast the values for the test data
Mdl_BN = bayeslm(p,'ModelType','conjugate'); % Build the model using baye
PosteriorMdl = estimate(Mdl_BN,Train_Data,Train_Label,'Display',false); % Estimate the values
Out_put_BN_Main1 = forecast(PosteriorMdl,Test_Data); % Forecast the values for the test data
Mdl_BN = bayeslm(p,'ModelType','conjugate'); % Build the model using baye
PosteriorMdl = estimate(Mdl_BN,Train_Data,Train_Label,'Display',false); % Estimate the values
Out_put_BN_Main2 = forecast(PosteriorMdl,Test_Data); % Forecast the values for the test data
%% Ensemble Classifier
Out_put_EN_C = [Out_put_BN'; Out_put_KNN'; Out_put_SVM'; Out_put_BN_Main';
Out_put_BN_Main1';Out_put_BN_Main2'];
Out_put_EN_C = mean(Out_put_EN_C);
err_NB = immse(round(Test_Label),round(Out_put_BN))
err_SVM = immse(Test_Label,Out_put_SVM)
err_KNN = immse(Test_Label,Out_put_KNN)
err_EN_C = immse(Test_Label,Out_put_EN_C')
%% Plot the values Figure 11. Predicted load of a month.\
figure (2)
plot(1:30, Test_Label', 'Color',[0.6 0.7 0],'Marker','>','LineWidth',1.4);
hold on
plot(1:30, Out_put_BN', 'Color',[0 0.6 1],'Marker','s','LineWidth',1.4);
hold on
plot(1:30, Out_put_KNN', 'Color',[0.75 0 0],'Marker','*','LineWidth',1.4);
hold on
plot(1:30, Out_put_SVM', 'Color',[0.75 0 0.6],'Marker','+','LineWidth',1.4);
hold on
plot(1:30, Out_put_EN_C', 'Color',[0.3 0.2 0.2],'Marker','p','LineWidth',1.4);
xlabel('Time (day)');
ylabel('Electricity Load (kW)');
set(gca, 'XTick',1:1:30)
legend('Actual Load','naive Bayes', 'K-Nearest Neighbour', 'Support Vector Regression','Ensemble');
legend('Location','NorthEast');
grid on
hold off
%% Predicted load of a day
Data_Summer=[]; Data_June=[];Data_June=[]; Total_Load_June=[];
Data_Summer = HomeAmeter42016(194524:414843, 4:end);
Data_June = Data_Summer(1:43200, 4:end);
Data_June = table2array(Data_June);
Total_Load_June = sum(Data_June');
%% Data contains the each mints load we will consider the 30 mints load
j = 1;
k = 60;
Slot_30_June=[]; Slot_30_June1=[];
for i=1:720 % 1440 because we are going to divide each hour into two slot each of 30 mints. so we have total values 30*48
Slot_30_June1(i) = sum(Total_Load_June(j:k));
j= k+1;
k = k+60;
end
Slot_30_June = Slot_30_June1(1:24);
Total_Load_Jully=[]; Data_Jully=[];
Data_Jully = Data_Summer(43201:87840, 4:end);
Data_Jully = table2array(Data_Jully);
Total_Load_Jully = sum(Data_Jully');
j = 1;
k = 60;
Slot_30_Jully=[];Slot_30_Jully1=[];
for i=1:744%1488 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Slot_30_Jully1(i) = sum(Total_Load_Jully(j:k));
j= k+1;
k = k+60;
end
Slot_30_Jully = Slot_30_Jully1(1:24);
Data_August=[]; Total_Load_August=[];
Data_August = Data_Summer(87841:132480, 4:end);
Data_August = table2array(Data_August);
Total_Load_August = sum(Data_August');
j = 1;
k = 60;%30;
Slot_30_August1=[]; Slot_30_August=[];
for i=1: 744 %1488 % 1448 because we are going to divide each hour into two slot each of 30 mints. so we have total values
31*48
Slot_30_August1(i) = sum(Total_Load_August(j:k));
j= k+1;
k = k+60;
end
Slot_30_August = (Slot_30_August1(1:24));
Data_September=[]; Total_Load_September=[];
Data_September = Data_Summer(132481:175680, 4:end);
Data_September = table2array(Data_September);
Total_Load_September = sum(Data_September');
j = 1;
k = 60;
for i=1:720%1440 % 1448 because we are going to divide each hour into two slot each of 30 mints. So we have total values
31*48
Slot_30_September1(i) = sum(Total_Load_September(j:k));
j= k+1;
k = k+60;
end
Slot_30_September = (Slot_30_September1(1:24));
Weather_Data_June_Update = [];
Weather_Data_Jully_Update = [];
Weather_Data_August_Update = [];
Weather_Data_September_Update = [];
Weather_Data_June_Update = Weather_Data_June(1:24,1:end);
Weather_Data_Jully_Update = Weather_Data_Jully(1:24,1:end);
Weather_Data_August_Update = Weather_Data_August(1:24,1:end);
Weather_Data_September_Update = Weather_Data_September(1:24,1:end);
Train_Data = [Weather_Data_June_Update; Weather_Data_Jully_Update; Weather_Data_August_Update];
Train_Label = [Slot_30_June'; Slot_30_Jully'; Slot_30_August'];
Test_Data = [Weather_Data_September_Update];
Test_Label = [Slot_30_September'];
Train_Data(isnan(Train_Data))=0;
Test_Data(isnan(Test_Data)) =0; % Test Labels
%% Start of Baysen regression model
p=11;
Mdl_BN = bayeslm(p,'ModelType','conjugate'); % Build the model using baye
PosteriorMdl = estimate(Mdl_BN,Train_Data,Train_Label,'Display',false); % Estimate the values
Out_put_BN = forecast(PosteriorMdl,Test_Data); % Forecast the values for the test data
%% Start of KNN
% mdl = fitcknn(citynames,citycodes, 'NumNeighbors',50, 'NSMethod','exhaustive', 'Distance',@levenshtein);
Mdl_KNN = fitcknn(Train_Data,Train_Label, 'NumNeighbors',1,'Standardize',1);
Out_put_KNN = predict(Mdl_KNN,Test_Data);
%% Start of SVM
Mdl_SVM = fitrsvm(Train_Data,Train_Label,'KernelFunction','gaussian','KernelScale','auto',...
'Standardize',true);
Out_put_SVM = predict(Mdl_SVM,Test_Data);
%% Main Classifier
Mdl_BN = bayeslm(p,'ModelType','conjugate'); % Build the model using baye
PosteriorMdl = estimate(Mdl_BN,Train_Data,Train_Label,'Display',false); % Estimate the values
Out_put_BN_Main = forecast(PosteriorMdl,Test_Data); % Forecast the values for the test data
Mdl_BN = bayeslm(p,'ModelType','conjugate'); % Build the model using baye
PosteriorMdl = estimate(Mdl_BN,Train_Data,Train_Label,'Display',false); % Estimate the values
Out_put_BN_Main1 = forecast(PosteriorMdl,Test_Data); % Forecast the values for the test data
Mdl_BN = bayeslm(p,'ModelType','conjugate'); % Build the model using baye
PosteriorMdl = estimate(Mdl_BN,Train_Data,Train_Label,'Display',false); % Estimate the values
Out_put_BN_Main2 = forecast(PosteriorMdl,Test_Data); % Forecast the values for the test data
%% Ensemble Classifier
Out_put_EN_C = [Out_put_BN'; Out_put_KNN'; Out_put_SVM'; Out_put_BN_Main';
Out_put_BN_Main1';Out_put_BN_Main2'];
Out_put_EN_C = mean(Out_put_EN_C);
err_NB = immse(round(Test_Label),round(Out_put_BN))
err_SVM = immse(Test_Label,Out_put_SVM)
err_KNN = immse(Test_Label,Out_put_KNN)
err_EN_C = immse(Test_Label,Out_put_EN_C')
%% Plot the values Figure 10. Predicted load of a day
figure
plot(1:24, Test_Label', 'Color',[0.6 0.7 0],'Marker','>','LineWidth',1.4);
hold on
plot(1:24, Out_put_BN', 'Color',[0 0.6 1],'Marker','s','LineWidth',1.4);
hold on
plot(1:24, Out_put_KNN', 'Color',[0.75 0 0],'Marker','*','LineWidth',1.4);
hold on
plot(1:24, Out_put_SVM', 'Color',[0.75 0 0.6],'Marker','+','LineWidth',1.4);
hold on
plot(1:24, Out_put_EN_C', 'Color',[0.3 0.2 0.2],'Marker','p','LineWidth',1.4);
xlabel('Time (hour)');
ylabel('Electricity Load (kW)');
set(gca, 'XTick',1:1:24)
legend('Actual Load','naive Bayes', 'K-Nearest Neighbour', 'Support Vector Regression','Ensemble');
legend('Location','NorthEast');
grid on
hold off
%% Code Scheduling
%% RTP tariff
% Data is taken form:
% https://hourlypricing.comed.com/live-prices/week/
%% Price tarffic ToU
%% Data is taken form:
% https://www.pge.com/en_US/business/rate-plans/rate-plans/time-of-use/time-of-use.page
% (Visit at 06/August/2018)
%% 12:00 AM - 8:30 AM : OFF-PEAK $0.217 per kWh
%% 8:30 AM - NOON (12:00 PM) : PARTIAL-PEAK $0.244 per kWh
%% NOON (12:00 PM) - 6:00 PM : ON-PEAK $0.268 per kWh
%% 6:00 PM - 9:30 PM : PARTIAL-PEAK $0.244 per kWh
%% 9:30 PM - 11:59 PM : OFF-PEAK $0.217 per kWh
%%
[_____________________________________________________________________AM___________________________
__________________________________________]
[_____________________________________________________________________PM___________________________
____________________________________________]
%Time_Devi = [_____________________________________OFF-PEAK: (1-
17)__________________________________] [_________Partial-PEAK: (18:24)_______]
[____________________ ON-PEAK: (25_36) ______________________] [_______ Partial-PEAK: (37:43)_____]
[_____ OFF-PEAK: (44:48)_____]
%Time_Slots= [12:00,12:30,1:00,1:30,2:00,2:30,3:00,3:30,4:00,4:30,5:00,5:30,6:00,6:30,7:00,7:30,8:00,
8:30,9;00,9:30,10:00,10:30,11:00,11:30, 12:00,12:30,1:00,1:30,2:00,2:30,3:00,3:30,4:00,4:30,5:00,5:30,
6:00,6:30,7:00,7:30,8:00,8:30,9;00, 9:30,10:00,10:30,11:00,11:30 ] %% Just for defining EP_ToU_List (Electric Price
list)
% [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0]
% % % % % Time_Slots=
[12:00,12:30,1:00,1:30,2:00,2:30,3:00,3:30,4:00,4:30,5:00,5:30,6:00,6:30,7:00,7:30,8:00,
8:30,9;00,9:30,10:00,10:30,11:00,11:30, 12:00,12:30,1:00,1:30,2:00,2:30,3:00,3:30,4:00,4:30,5:00,5:30,
6:00,6:30,7:00,7:30,8:00,8:30,9;00, 9:30,10:00,10:30,11:00,11:30 ] %% Just for defining EP_ToU_List (Electric Price
list)
% % % % %
% % % % % Home(1).Iron_Operational_time = [0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0];
% % % % % Home(1).Dish_Washer_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0
0 0];
% % % % % Home(1).Water_motor_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
0 0];
% % % % % Home(1).Washing_Machine_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0];
% % % % % Home(1).Cloth_Dryer_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0];
% % % % % Home(1).Oven = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0];
% % % % % Home(1).Blender = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0];
% % % % % Home(1).Light1 = [1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
0];
% % % % % Home(1).Light2 = [1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1
0];
% % % % % Home(1).Light3 = [1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0
0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 1 1 1 1 1
1];
% % % % % Home(1).Light4
%%
% EP_ToU =
[0.217,0.217,0.217,0.217,0.217,0.217,0.217,0.217,0.217,0.217,0.217,0.217,0.217,0.217,0.217,0.217,0.217,0.244,0.244,0.244
,0.244,0.244,0.244,0.244,0.268,0.268,0.268,0.268,0.268,0.268,0.268,0.268,0.268,0.268,0.268,0.268,0.244,0.244,0.244,0.244
,0.244,0.244,0.244,0.217,0.217,0.217,0.217,0.217];
% OFF_PEAK = [(1:17), (44:48)];
% Partial_PEAK(1,:) = [(18:24),(37:43)];
% ON_PEAK(1,:) = [(25:36)];
%% Another price tariff is taken form
%% https://www.wnhydro.com/en/your-home/time-of-use-rates.asp last visited on 9-10-2018
%% 12:00 AM - 6:30 AM : OFF-PEAK 6.5 (cent) per kWh
%% 7:00 AM - 10:30 AM) : PARTIAL-PEAK 9.4 (cent) per kWh
%% 11:00 AM - 4:30 PM : ON-PEAK 13.2 (cent) per kWh
%% 5:00 PM - 6:30 PM : PARTIAL-PEAK 9.4 (cent) per kWh
%% 7:00 PM - 11:59 PM : OFF-PEAK 6.5 (cent) per kWh
EP_ToU = [6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 9.4, 9.4, 9.4, 9.4, 9.4, 9.4, 9.4, 9.4, 13.2,
13.2, 13.2, 13.2, 13.2, 13.2, 13.2, 13.2, 13.2, 13.2, 13.2, 13.2, 9.4, 9.4, 9.4, 9.4, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5, 6.5];
%% This code is adjuste for the ToU price rate. In the paper we have also comapre these results with RTp
% For RTP comment line that is explaining EP_ToU and uncomment first two lines given
% below: Also in the graph replace ToU with RTP.
% EP_RTP = [9.83 9.83 8.63 8.63 8.87 8.87 12 12 9.19 9.19 12.27 12.27 20.69 20.69 26.82 26.82 27.35 27.35 17.31
17.31 16.42 16.42 16.44 16.44 16.19 16.19 13.81 13.81 8.87 8.87 8.35 8.35 8.65 8.65 9.35 9.35 8.11 8.11 8.25 8.25 8.10
8.10 8.14 8.14 8.13 8.13 8.34 8.34];
% EP_ToU = EP_RTP;
OFF_PEAK = [(1:14), (39:48)];
Partial_PEAK(1,:) = [(15:22),(35:38)];
ON_PEAK(1,:) = [(23:34)];
nHomes = 3;
Appliances = ['Iron', 'Dish washer', 'Water Motor', 'Washing Machine', 'Cloth Dryer'];
%% User Demanded hours
% for i=1:nHomes
%% Scheduleable appliance
%%
[_____________________________________________________________________AM___________________________
__________________________________________]
[_____________________________________________________________________PM___________________________
____________________________________________]
%Time_Devi = [________OFF-PEAK: ________] [_Partial-PEAK_][_______ON-
PEAK:______][Partial][______OFF-PEAK____]
%Time_Devi = [___________(1-14)_________]
[____(15:22)___][______(23_34)________][_35:38_][______(44:48)_____]
%Time_Devi = [________12:00-6:30)_______] [__7:00-10:30__][_____11:00-4:30______][5:-
6:30][____7:00-11:30____
% 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12
Home(1).Iron_Operational_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0];
Home(1).Dish_Washer_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0];
Home(1).Water_motor_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0
1 0 0 0];
%% Scheduleable non intrubtable
Home(1).Washing_Machine_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0];
Home(1).Cloth_Dryer_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0];
%% NoN-scheduleable appliances
% 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12
Home(1).Oven = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0];
Home(1).Blender = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0];
Home(1).Light1 = [0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0];
Home(1).Light2 = [1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 0];
Home(1).Light3 = [1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1];
Home(1).Light4 = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1];
Home(1).HVAC = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0];
Home(1).Refrigerator = [1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1];
%Time_Devi = [________OFF-PEAK: ________] [_Partial-PEAK_][_______ON-
PEAK:______][Partial][______OFF-PEAK____]
%Time_Devi = [___________(1-14)_________]
[____(15:22)___][______(23_34)________][_35:38_][______(44:48)_____]
%Time_Devi = [________12:00-6:30)_______] [__7:00-10:30__][_____11:00-4:30______][5:-
6:30][____7:00-11:30____]
% 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12
Home(2).Iron_Operational_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0];
Home(2).Dish_Washer_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0
0 0 0 0];
Home(2).Water_motor_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
0 0 0 0];
Home(2).Washing_Machine_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0];
Home(2).Cloth_Dryer_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0
0 0 0];
Home(2).Oven = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0];
Home(2).Blender = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0];
Home(2).Light1 = [0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1];
Home(2).Light2 = [1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 1 1 1 1 1 0 0 1 1 1 0];
Home(2).Light3 = [1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 0];
Home(2).Light4 = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1];
Home(2).HVAC = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0];
Home(2).Refrigerator = [1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1];
%Time_Devi = [________OFF-PEAK: ________] [_Partial-PEAK_][_______ON-
PEAK:______][Partial][______OFF-PEAK____]
%Time_Devi = [___________(1-14)_________]
[____(15:22)___][______(23_34)________][_35:38_][______(44:48)_____]
%Time_Devi = [________12:00-6:30)_______] [__7:00-10:30__][_____11:00-4:30______][5:-
6:30][____7:00-11:30____]
% 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12
Home(3).Iron_Operational_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0];
Home(3).Dish_Washer_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0
0 0 0 0];
Home(3).Water_motor_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0];
Home(3).Washing_Machine_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0];
Home(3).Cloth_Dryer_Opera_time = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0];
Home(3).Oven = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0];
Home(3).Blender = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0];
Home(3).Light1 = [0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 1 1 1];
Home(3).Light2 = [1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 0];
Home(3).Light3 = [1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 1 1 1 1 1 1];
Home(3).Light4 = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1];
Home(3).HVAC = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0];
Home(3).Refrigerator = [1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1];
Appliances_Sch_H1 = [Home(1).Iron_Operational_time;
Home(1).Dish_Washer_Opera_time;Home(1).Water_motor_Opera_time;Home(1).Washing_Machine_Opera_time;Home(1)
.Cloth_Dryer_Opera_time; Home(1).HVAC];
Appliances_NoNSch_H1 = [Home(1).Oven; Home(1).Blender; Home(1).Light1; Home(1).Light2; Home(1).Light3;
Home(1).Light4; Home(1).Refrigerator ];
Home(1).All_Appliances_Unshc = [Appliances_Sch_H1' Appliances_NoNSch_H1'];
Appliances_Sch_H2 = [Home(2).Iron_Operational_time;
Home(2).Dish_Washer_Opera_time;Home(2).Water_motor_Opera_time;Home(2).Washing_Machine_Opera_time;Home(2)
.Cloth_Dryer_Opera_time; Home(2).HVAC];
Appliances_NoNSch_H2 = [Home(2).Oven; Home(2).Blender; Home(2).Light1; Home(2).Light2; Home(2).Light3;
Home(2).Light4; Home(2).Refrigerator];
Home(2).All_Appliances_Unshc = [Appliances_Sch_H2' Appliances_NoNSch_H2'];
Appliances_Sch_H3 = [Home(3).Iron_Operational_time;
Home(3).Dish_Washer_Opera_time;Home(3).Water_motor_Opera_time;Home(3).Washing_Machine_Opera_time;Home(3)
.Cloth_Dryer_Opera_time; Home(3).HVAC];
Appliances_NoNSch_H3 = [Home(3).Oven; Home(3).Blender; Home(3).Light1; Home(3).Light2; Home(3).Light3;
Home(3).Light4; Home(3).Refrigerator ];
Home(3).All_Appliances_Unshc = [Appliances_Sch_H3' Appliances_NoNSch_H3'];
LOT = [2 4 4 3 2 16 3 3 18 18 20 28 40];
LOT_Rain_Fall = LOT;
Power_rates = [1 1.8 1 0.7 5 1.2 2.15 0.3 0.03 0.03 0.011 0.018 1.8];
Power_rates = Power_rates /2;
for i = 1:nHomes
Appliances_Unshc= Home(i).All_Appliances_Unshc;
for T_Slot=1:48
Electricity_cost=EP_ToU(T_Slot)*Power_rates;
Home(i).unscheduledload(T_Slot)=Appliances_Unshc(T_Slot,:)*Power_rates';
Home(i).unschedulecost_ToU(T_Slot)=Home(i).unscheduledload(T_Slot)*EP_ToU(T_Slot)';
end
Appliances_Unshc=[];
Home(i).sum_unscheduledload_ToU=sum(Home(i).unscheduledload);
Home(i).sum_unscheduled_cost_ToU=sum(Home(i).unschedulecost_ToU);
Home(i).PAR_unscheduled_ToU=max(Home(i).unscheduledload)^2/(mean(Home(i).unscheduledload))^2;
end
%% Electricity Cost Calculation using flat-rate
for i = 1:nHomes
Appliances_Unshc= Home(i).All_Appliances_Unshc;
for T_Slot=1:48
Electricity_cost=EP_ToU(T_Slot)*Power_rates;
Home(i).unscheduledload(T_Slot)=Appliances_Unshc(T_Slot,:)*Power_rates';
Home(i).unschedulecost_FR(T_Slot)=Home(i).unscheduledload(T_Slot)*7.7;
end
end
%% Proposed Price Tariff
%% Here we will calculate the cost according to new price tariff
%% Where each home have to pay bill according to the load utilize
%%
i=1;
for T_Slot=1:48
Electricity_cost=EP_ToU(1)*Power_rates;
if EP_ToU(T_Slot) < mean(EP_ToU) %OFF_PEAK(i)
Home(1).unschedulecost_PS(T_Slot)=Home(1).unscheduledload(T_Slot)*EP_ToU(T_Slot);
Home(1).price(T_Slot) = EP_ToU(T_Slot);
Home(2).unschedulecost_PS(T_Slot)=Home(2).unscheduledload(T_Slot)*EP_ToU(T_Slot);
Home(2).price(T_Slot) = EP_ToU(T_Slot);
Home(3).unschedulecost_PS(T_Slot)=Home(3).unscheduledload(T_Slot)*EP_ToU(T_Slot);
Home(3).price(T_Slot) = EP_ToU(T_Slot);
i=i+1;
else
% Calculate the cost according to the Off-Peak price rate
Home_1= Home(1).unscheduledload(T_Slot)*EP_ToU(1);
Home_2= Home(2).unscheduledload(T_Slot)*EP_ToU(1);
Home_3= Home(3).unscheduledload(T_Slot)*EP_ToU(1);
% Subtract form the orignal calculated cost
Xtra_Cost_1 = Home(1).unschedulecost_ToU(T_Slot) - Home_1;
Xtra_Cost_2 = Home(2).unschedulecost_ToU(T_Slot) - Home_2;
Xtra_Cost_3 = Home(3).unschedulecost_ToU(T_Slot) - Home_3;
% Total_Load = [Home(1).unscheduledload(T_Slot) Home(2).unscheduledload(T_Slot)
Home(3).unscheduledload(T_Slot)];
Total_Xtra = Xtra_Cost_1 + Xtra_Cost_2 + Xtra_Cost_3; % here we assume that it is extra generation cost
Extra = [Xtra_Cost_1 Xtra_Cost_2 Xtra_Cost_3];
% Total_Load = [Home_1 Home_2 Home_3];
% Devided the extra charges according to the utilized load
if Total_Xtra >0 && sum(Extra(1:end)>0)>1
Var1 = [Home(1).unscheduledload(T_Slot) Home(2).unscheduledload(T_Slot) Home(3).unscheduledload(T_Slot)];
Var2 = (Var1/100)*20;
Total_Load = [Home_1 Home_2 Home_3];
%% &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& %%
%% More the load they will utilize more they have to pay the cost
[Total_Allocation, Marginal_Distribution] = Game_Theory_Shapley(Total_Load, Total_Xtra);
clc
Extra = [Xtra_Cost_1 Xtra_Cost_2 Xtra_Cost_3];
Marginal_Distribution;
sum(Marginal_Distribution);
sum(Extra);
Total_Load;
Home(1).unschedulecost_PS(T_Slot) = Home_1 + Marginal_Distribution(1);
Home(1).price(T_Slot) = Home(1).unschedulecost_PS(T_Slot) / Home(1).unscheduledload(T_Slot);
Home(2).unschedulecost_PS(T_Slot) = Home_2 + Marginal_Distribution(2);
Home(2).price(T_Slot) = Home(2).unschedulecost_PS(T_Slot) / Home(2).unscheduledload(T_Slot);
Home(3).unschedulecost_PS(T_Slot) = Home_3 + Marginal_Distribution(3);
Home(3).price(T_Slot) = Home(3).unschedulecost_PS(T_Slot) / Home(3).unscheduledload(T_Slot);
else
Home(1).unschedulecost_PS(T_Slot)=Home(1).unscheduledload(T_Slot)*Electricity_cost';
Home(1).price(T_Slot) = Home(1).unschedulecost_PS(T_Slot) / Home(1).unscheduledload(T_Slot);
Home(2).unschedulecost_PS(T_Slot)=Home(2).unscheduledload(T_Slot)*Electricity_cost';
Home(2).price(T_Slot) = Home(2).unschedulecost_PS(T_Slot) / Home(2).unscheduledload(T_Slot);
Home(3).unschedulecost_PS(T_Slot)=Home(3).unscheduledload(T_Slot)*Electricity_cost';
Home(3).price(T_Slot) = Home(3).unschedulecost_PS(T_Slot) / Home(3).unscheduledload(T_Slot);
end
end
end
Home(1).sum_unscheduled_cost_PS=sum(Home(1).unschedulecost_PS);
Home(2).sum_unscheduled_cost_PS=sum(Home(2).unschedulecost_PS);
Home(3).sum_unscheduled_cost_PS=sum(Home(3).unschedulecost_PS);
%% Scheduling of a single home and comparision of cost for two price tariffs
%% Scheduling and cost estimation for the ToU price tariffs %%
Max_iter=200; % Maximum numbef of iterations
lb=0.1; % Lower Bound of Variables
ub=0.9; % Upper Bound of Variables%% which we will pass as a parameter
N = 100;
dim = 13;
LOT1 = LOT;
for i =1: 3
Load_All(i,:) = Home(i).unscheduledload;
end
Var_Load = sum(Load_All);
PAR_unscheduled_ToU=max(Var_Load)^2/(mean(Var_Load)^2);
limit1 = mean(Var_Load); %this will define the limit for off peak hour
limit2 = std(Var_Load); %-(mean(unscheduledload)-std(unscheduledload)); % for on peak hour
%%
%% Scheduling of home appliances %%
%% Salp Algorithm %%
for i = 1: 3
app_Sch_C=zeros(48,13);
Appliances_Status = Home(i).All_Appliances_Unshc;
LOT = LOT1;
for hour=1:48 % one day scheduling
% electricity_cost=EP_ToU(hour)*Power_rates; % Price for each appliance
%% %%%%%%%%%%%% Working %%%%%%%%%%%% %%
%% START %%
%% %%
[FoodFitness,FoodPosition,FoodPosition_B, Convergence_curve] = SalpSwarmAlgo(N,Max_iter,lb,ub, Power_rates, dim,
EP_ToU,hour, LOT, app_Sch_C, Appliances_Status, limit1, limit2);
%% Set Appliances and calculate cost and PAR you can set more performance parameter here
gbest=FoodPosition_B;
[gbest] = B_Values(gbest,dim,hour,LOT, app_Sch_C, Appliances_Status);
%% Set Appliances and calculate cost and PAR you can set more performance parameter here
gbest1=gbest;
Home(i).schedule_load_P(hour)=FoodFitness(1,1);
Home(i).E_Cost_SS_P(hour)=FoodFitness(1,2);
app_Sch_C(hour,:)=gbest(1,:);
LOT = LOT - gbest;
Home(i).P_app_Sch_P(hour,:)=gbest; % for scheduling waiting time
end % end of schedule
Home(i).PAR_scheduled = max(Home(i).schedule_load_P)^2/(mean(Home(i).schedule_load_P))^2;
Home(i).Total_Cost = sum(Home(i).E_Cost_SS_P);
end
%%
%% %%%%%Estimation of cost based on price tariffs defined on the basis of GT %%%%%% %%
for T_Slot=1:48
Electricity_cost=EP_ToU(1)*Power_rates;
if EP_ToU(T_Slot) < mean(EP_ToU) %OFF_PEAK(i)
%% Salp algorthm
Home(1).Schedulecost_PS(T_Slot)=Home(1).schedule_load_P(T_Slot)*EP_ToU(1);
Home(1).Schprice(T_Slot) = EP_ToU(T_Slot);
Home(2).Schedulecost_PS(T_Slot)=Home(2).schedule_load_P(T_Slot)*EP_ToU(1);
Home(2).Schprice(T_Slot) = EP_ToU(T_Slot);
Home(3).Schedulecost_PS(T_Slot)=Home(3).schedule_load_P(T_Slot)*EP_ToU(1);
Home(3).Schprice(T_Slot) = EP_ToU(T_Slot);
%%
i=i+1;
else
%% Calculate the cost according to the Off-Peak price rate Salp Algo
%% %% Salp
Home_1= Home(1).P_app_Sch_P(T_Slot,:)*Electricity_cost';
Home_2= Home(2).P_app_Sch_P(T_Slot,:)*Electricity_cost';
Home_3= Home(3).P_app_Sch_P(T_Slot,:)*Electricity_cost';
%% %% Salp
% Subtract form the orignal calculated cost
Xtra_Cost_1 = Home(1).E_Cost_SS_P(T_Slot) - Home_1;
Xtra_Cost_2 = Home(2).E_Cost_SS_P(T_Slot) - Home_2;
Xtra_Cost_3 = Home(3).E_Cost_SS_P(T_Slot) - Home_3;
%% Salp
% Total_Load = [Home(1).Scheduledload(T_Slot) Home(2).Scheduledload(T_Slot) Home(3).Scheduledload(T_Slot)];
Total_Xtra = Xtra_Cost_1 + Xtra_Cost_2 + Xtra_Cost_3; % here we assume that it is extra generation cost
Extra = [Xtra_Cost_1 Xtra_Cost_2 Xtra_Cost_3];
% Devided the extra charges according to the utilized load
if Total_Xtra >0 && sum(Extra(1:end)>0)>1
Var1 = [Home(1).schedule_load_P(T_Slot) Home(2).schedule_load_P(T_Slot) Home(3).schedule_load_P(T_Slot)];
Var2 = (Var1/100)*20;
Total_Load = Var2*EP_ToU(1);
[Total_Allocation, Marginal_Distribution] = Game_Theory_Shapley(Total_Load, Total_Xtra);
clc
Extra = [Xtra_Cost_1 Xtra_Cost_2 Xtra_Cost_3];
Marginal_Distribution;
sum(Marginal_Distribution);
sum(Extra);
Total_Load;
Home(1).Schedulecost_PS(T_Slot) = Home_1 + Marginal_Distribution(1);
Home(1).Schprice(T_Slot) = Home(1).Schedulecost_PS(T_Slot) / Home(1).schedule_load_P(T_Slot);
Home(2).Schedulecost_PS(T_Slot) = Home_2 + Marginal_Distribution(2);
Home(2).Schprice(T_Slot) = Home(2).Schedulecost_PS(T_Slot) / Home(2).schedule_load_P(T_Slot);
Home(3).Schedulecost_PS(T_Slot) = Home_3 + Marginal_Distribution(3);
Home(3).Schprice(T_Slot) = Home(3).Schedulecost_PS(T_Slot) / Home(3).schedule_load_P(T_Slot);
else
%% Salp
Home(1).Schedulecost_PS(T_Slot) = Home(1).schedule_load_P(T_Slot)*EP_ToU(1);
Home(1).Schprice(T_Slot) = Home(1).Schedulecost_PS(T_Slot) / Home(1).schedule_load_P(T_Slot);
Home(2).Schedulecost_PS(T_Slot) = Home(2).schedule_load_P(T_Slot)*EP_ToU(1);
Home(2).Schprice(T_Slot) = Home(2).Schedulecost_PS(T_Slot) / Home(2).schedule_load_P(T_Slot);
Home(3).Schedulecost_PS(T_Slot) = Home(3).schedule_load_P(T_Slot)*EP_ToU(1);
Home(3).Schprice(T_Slot) = Home(3).Schedulecost_PS(T_Slot) / Home(3).schedule_load_P(T_Slot);
end
end
end
%% Salp
Home(1).sum_Scheduled_cost_PS=sum(Home(1).Schedulecost_PS);
Home(2).sum_Scheduled_cost_PS=sum(Home(2).Schedulecost_PS);
Home(3).sum_Scheduled_cost_PS=sum(Home(3).Schedulecost_PS);
%%
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
%%
%%
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
%%
%% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%
%% vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %%
%% RainFall %%
for i = 1: 3
app_Sch_C_RainFall=zeros(48,13);
Appliances_Status = Home(i).All_Appliances_Unshc;
LOT_Rain_Fall = LOT1;
for hour=1:48 % one day scheduling
% electricity_cost=EP_ToU(hour)*Power_rates; % Price for each appliance
%% %%%%%%%%%%%% Working %%%%%%%%%%%% %%
%% START %%
%% %%
[Fitness,Position_B, Position] = Rain_Fall_Func(N,Max_iter,lb,ub, Power_rates, dim, EP_ToU,hour, LOT_Rain_Fall,
app_Sch_C_RainFall, Appliances_Status, limit1, limit2);
%% Set Appliances and calculate cost and PAR you can set more performance parameter heregbest=Position_B;
[gbest] = B_Values(Position,dim,hour,LOT_Rain_Fall, app_Sch_C_RainFall, Appliances_Status);
%% Set Appliances and calculate cost and PAR you can set more performance parameter here
gbest1=Position_B;
Fitness(1,1) =Power_rates*gbest'; % load
Fitness(1,2)= Fitness(1,1)*EP_ToU(hour);
Home(i).schedule_load_RainFall(hour)=Fitness(1,1);
Home(i).E_Cost_SS_P_RainFall(hour)=Fitness(1,2);
app_Sch_C_RainFall(hour,:)=gbest(1,:);
LOT_Rain_Fall = LOT_Rain_Fall - gbest;
Home(i).P_app_Sch_P_RainFall(hour,:)=gbest; % for scheduling waiting time
end % end of schedule
Home(i).PAR_scheduled_RainFall =
max(Home(i).schedule_load_RainFall)^2/(mean(Home(i).schedule_load_RainFall))^2;
Home(i).Total_Cost_RainFall = sum(Home(i).E_Cost_SS_P_RainFall);
end
%% RainFall Price for GT according to RainFall
%% %%%%%Estimation of cost based on price tariffs defined on the basis of GT %%%%%% %%
for T_Slot=1:48
Electricity_cost=EP_ToU(1)*Power_rates;
if EP_ToU(T_Slot) < mean(EP_ToU) %OFF_PEAK(i)
%% RainFall algorthm
Home(1).Schedulecost_PS_R(T_Slot)=Home(1).schedule_load_RainFall(T_Slot)*EP_ToU(1);
Home(1).Schprice_R(T_Slot) = EP_ToU(T_Slot);
Home(2).Schedulecost_PS_R(T_Slot) =Home(2).schedule_load_RainFall(T_Slot)*EP_ToU(1);
Home(2).Schprice_R(T_Slot) = EP_ToU(T_Slot);
Home(3).Schedulecost_PS_R(T_Slot) =Home(3).schedule_load_RainFall(T_Slot)*EP_ToU(1);
Home(3).Schprice_R(T_Slot) = EP_ToU(T_Slot);
%%
i=i+1;
else
%% Calculate the cost according to the Off-Peak price rate Salp Algo
%% %% RainFall
Home_1= Home(1).P_app_Sch_P_RainFall(T_Slot,:)*Electricity_cost';
Home_2= Home(2).P_app_Sch_P_RainFall(T_Slot,:)*Electricity_cost';
Home_3= Home(3).P_app_Sch_P_RainFall(T_Slot,:)*Electricity_cost';
%% %% RainFall
% Subtract form the orignal calculated cost
Xtra_Cost_1 = Home(1).E_Cost_SS_P(T_Slot) - Home_1;
Xtra_Cost_2 = Home(2).E_Cost_SS_P(T_Slot) - Home_2;
Xtra_Cost_3 = Home(3).E_Cost_SS_P(T_Slot) - Home_3;
%% RainFall
%Total_Load = [Home(1).Scheduledload(T_Slot) Home(2).Scheduledload(T_Slot) Home(3).Scheduledload(T_Slot)];
Total_Xtra = Xtra_Cost_1 + Xtra_Cost_2 + Xtra_Cost_3; % here we assume that it is extra generation cost
Extra = [Xtra_Cost_1 Xtra_Cost_2 Xtra_Cost_3];
% Devided the extra charges according to the utilized load
if Total_Xtra >0 && sum(Extra(1:end)>0)>1
Var1 = [Home(1).schedule_load_RainFall(T_Slot) Home(2).schedule_load_RainFall(T_Slot)
Home(3).schedule_load_RainFall(T_Slot)];
Var2 = (Var1/100)*20;
Total_Load = Var2*EP_ToU(1);
[Total_Allocation, Marginal_Distribution] = Game_Theory_Shapley(Total_Load, Total_Xtra);
clc
Extra = [Xtra_Cost_1 Xtra_Cost_2 Xtra_Cost_3];
Marginal_Distribution;
sum(Marginal_Distribution);
sum(Extra);
Total_Load;
Home(1).Schedulecost_PS_R(T_Slot) = Home_1 + Marginal_Distribution(1);
Home(1).Schprice_R(T_Slot) = Home(1).Schedulecost_PS_R(T_Slot) / Home(1).schedule_load_RainFall(T_Slot);
Home(2).Schedulecost_PS_R(T_Slot) = Home_2 + Marginal_Distribution(2);
Home(2).Schprice_R(T_Slot) = Home(2).Schedulecost_PS_R(T_Slot) / Home(2).schedule_load_RainFall(T_Slot);
Home(3).Schedulecost_PS_R(T_Slot) = Home_3 + Marginal_Distribution(3);
Home(3).Schprice_R(T_Slot) = Home(3).Schedulecost_PS_R(T_Slot) / Home(3).schedule_load_RainFall(T_Slot);
else
%% RainFall
Home(1).Schedulecost_PS_R(T_Slot) = Home(1).schedule_load_RainFall(T_Slot)*EP_ToU(1);
Home(1).Schprice_R(T_Slot) = Home(1).Schedulecost_PS_R(T_Slot) / Home(1).schedule_load_RainFall(T_Slot);
Home(2).Schedulecost_PS_R(T_Slot) = Home(2).schedule_load_RainFall(T_Slot)*EP_ToU(1);
Home(2).Schprice_R(T_Slot) = Home(2).Schedulecost_PS_R(T_Slot) / Home(2).schedule_load_RainFall(T_Slot);
Home(3).Schedulecost_PS_R(T_Slot) = Home(3).schedule_load_RainFall(T_Slot)*EP_ToU(1);
Home(3).Schprice_R(T_Slot) = Home(3).Schedulecost_PS_R(T_Slot) / Home(3).schedule_load_RainFall(T_Slot);
end
end
end
%% Salp
Home(1).sum_Scheduled_cost_PS_R=sum(Home(1).Schedulecost_PS_R);
Home(2).sum_Scheduled_cost_PS_R=sum(Home(2).Schedulecost_PS_R);
Home(3).sum_Scheduled_cost_PS_R=sum(Home(3).Schedulecost_PS_R);
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
%**************************************************************************
%**************************************************************************
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
%% Display Results For Salp
for i=1:3
Sche_Load_Total(i,:) = Home(i).schedule_load_P;
end
%% Display of results for Comparison of two price tariffs ToU and proposed
display('--------------SALP--------------');
display('--------------Unscheduled Reuslts--------------');
display('Proposed scheme Electicity Bill');
for i = 1: 3
display(Home(i).sum_unscheduled_cost_PS);
end
display('ToU Electicity Bill');
for i = 1: 3
display(Home(i).sum_unscheduled_cost_ToU);
end
display('PAR');
for i = 1: 3
display(Home(i).PAR_unscheduled_ToU);
end
display('------ scheduled results -----')
display('Proposed scheme Electicity Bill');
for i = 1: 3
display(Home(i).sum_Scheduled_cost_PS);
end
display('ToU Electicity Bill');
for i = 1: 3
display(Home(i).Total_Cost);
end
display('PAR');
for i = 1: 3
display(Home(i).PAR_scheduled);
end
for i = 1:3
display('Flat Rate')
display(sum(Home(i).unschedulecost_FR));
end
%% Unschedule Calculation
%% Figure 4. Electricity bill of three users before scheduling with ToU and GTToU.
figure
stairs(Home(1).unschedulecost_ToU, 'Color',[0.9 0.1 0.1],'Marker','p','LineWidth',1.4);
hold on
stairs(Home(1).unschedulecost_PS, 'Color',[0.9 0.9 0.1],'Marker','^','LineWidth',1.4);
hold on
stairs(Home(1).unschedulecost_FR, 'Color', [0.7 0 0],'LineWidth',1.4);
hold on
stairs(Home(2).unschedulecost_ToU, 'Color',[0.8 0.6 0.6],'Marker','s','LineWidth',1.4);
hold on
stairs(Home(2).unschedulecost_PS, 'Color',[0 0.9 0.9],'Marker','*','LineWidth',1.4);
hold on
stairs(Home(2).unschedulecost_FR, 'Color',[0 0 0.7],'LineWidth',1.4);
hold on
stairs(Home(3).unschedulecost_ToU, 'Color',[0.3 0.8 0.3],'Marker','h','LineWidth',1.4);
hold on
stairs(Home(3).unschedulecost_PS, 'Color',[0.5 0 0.7],'Marker','d','LineWidth',1.4);
hold on
stairs(Home(3).unschedulecost_FR, 'Color',[0 0.7 0], 'LineWidth',1.4);
xlabel('Time');
ylabel('Electricity Cost ($)');
% set(gca, 'XTick',1:48, 'XTickLabel',{'12:00' '12:30' '1:00' '1:30' '2:00' '2:30' '3:00' '3:30' '4:00' '4:30' '5:00' '5:30' '6:00' '6:30'
'7:00' '7:30' '8:00' '8:30' '9;00' '9:30' '10:00' '10:30' '11:00' '11:30' ' 12:00' '12:30' '1:00' '1:30' '2:00' '2:30' '3:00' '3:30' '4:00'
'4:30' '5:00' '5:30' '6:00' '6:30' '7:00' '7:30' '8:00' '8:30' '9;00' '9:30' '10:00' '10:30' '11:00' '11:30' })
% set(gca, 'XTick', 1:48, 'XTickLabel',{'12' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '10' '15' '16' '17' '18' '19' '20' '21' '22'
'23'})
set(gca, 'XTick',1:2:48, 'XTickLabel',{'0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '20' '21' '22' '23'})
legend('Home 1 ToU','Home 1 GTToU','Home 2 ToU','Home 2 GTToU','Home 3 ToU','Home 3 GTToU');
legend('Location','NorthEast');
grid on
hold off
%% Schedule results
%% Per hour Cost
figure
%% Salp Figure 5 a. Effect of scheduling on electricity cost for ToU and GTToU.
stairs(Home(1).E_Cost_SS_P, 'Color',[0.9 0.1 0.1],'Marker','p','LineWidth',1.4);
hold on
stairs(Home(1).Schedulecost_PS,'Color',[0.9 0.9 0.1],'Marker','^','LineWidth',1.4);
hold on
stairs(Home(2).E_Cost_SS_P,'Color',[0.8 0.6 0.6],'Marker','s','LineWidth',1.4);
hold on
stairs(Home(2).Schedulecost_PS,'Color',[0 0.9 0.9],'Marker','*','LineWidth',1.4);
hold on
stairs(Home(3).E_Cost_SS_P, 'Color',[0.3 0.8 0.3],'Marker','h','LineWidth',1.4);
hold on
stairs(Home(3).Schedulecost_PS,'Color',[0.5 0 0.7],'Marker','d','LineWidth',1.4);
xlabel('Time');
ylabel('Electricity Cost ($)');
% set(gca, 'XTick',1:2:48, 'XTickLabel',{'12 am' '1 am' '2 am' '3 am' '4 am' '5 am' '6 am' '7 am' '8 am' '9 am' '10 am' '11 am'
'12 pm' '1 pm' '2 pm' '3 pm' '4 pm' '5 pm' '6 pm' '7 pm' '8 pm' '9 pm' '10 pm' '11 pm'})
set(gca, 'XTick',1:2:48, 'XTickLabel',{'0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '20' '21' '22' '23'})
legend('Home 1 ToU','Home 1 GTToU','Home 2 ToU','Home 2 GTToU','Home 3 ToU','Home 3 GTToU');
legend('Location','NorthEast');
grid on
hold off
%% per hour Load
% Figure 3 a. Load profiles of three homes before and after scheduling with ToU and GTToU.
figure
stairs(Home(1).unscheduledload, 'Color',[0.9 0.1 0.1],'Marker','p','LineWidth',1.4);
hold on
stairs(Home(1).schedule_load_P, 'Color', [0.9 0.9 0.1],'Marker','^','LineWidth',1.4);
hold on
stairs(Home(2).unscheduledload, 'Color', [0.8 0.6 0.6],'Marker','s','LineWidth',1.4);
hold on
stairs(Home(2).schedule_load_P, 'Color', [0 0.9 0.9],'Marker','*','LineWidth',1.4);
hold on
stairs(Home(3).unscheduledload, 'Color',[0.3 0.8 0.3],'Marker','h','LineWidth',1.4);
hold on
stairs(Home(3).schedule_load_P, 'Color', [0.5 0 0.7],'Marker','d','LineWidth',1.4);
xlabel('Time');
ylabel('Power Consumption (kWh)');
% set(gca, 'XTick',1:2:48, 'XTickLabel',{'12 am' '1 am' '2 am' '3 am' '4 am' '5 am' '6 am' '7 am' '8 am' '9 am' '10 am' '11 am'
'12 pm' '1 pm' '2 pm' '3 pm' '4 pm' '5 pm' '6 pm' '7 pm' '8 pm' '9 pm' '10 pm' '11 pm'})
set(gca, 'XTick',1:2:48, 'XTickLabel',{'0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '20' '21' '22' '23'});
legend('Home 1 Unscheduled Load','Home 1 Scheduled Load Salp','Home 2 Unscheduled Load','Home 2 Scheduled Load
Salp','Home 3 Unscheduled Load','Home 3 Scheduled Load Salp');
legend('Location','NorthEast');
grid on
hold off
%% Price graph
% Figure 2a. ToU price regulated by PG&E and price according to the proposed scheme.
figure
stairs(EP_ToU, 'Marker','x','LineWidth',1.4);
hold on
stairs(Home(1).price, 'Color',[0.9 0.25 1],'Marker','p','LineWidth',1.4);
hold on
stairs(Home(1).Schprice, 'Color', [0.6 0.2 0.6],'Marker','^','LineWidth',1.4);
hold on
stairs(Home(2).price, 'Color', [0 0.6 1],'Marker','s','LineWidth',1.4);
hold on
stairs(Home(2).Schprice, 'Color', [0 0 0.6],'Marker','*','LineWidth',1.4);
hold on
stairs(Home(3).price, 'Color',[0.6 1 0.5],'Marker','h','LineWidth',1.4);
hold on
stairs(Home(3).Schprice, 'Color', [0.2 0.7 0.1],'Marker','d','LineWidth',1.4);
xlabel('Time');
ylabel('Electricity Price($)');
set(gca, 'XTick',1:2:48, 'XTickLabel',{'0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '20' '21' '22' '23'});
% set(gca, 'XTick',1:2:48, 'XTickLabel',{'12 am' '1 am' '2 am' '3 am' '4 am' '5 am' '6 am' '7 am' '8 am' '9 am' '10 am' '11 am'
'12 pm' '1 pm' '2 pm' '3 pm' '4 pm' '5 pm' '6 pm' '7 pm' '8 pm' '9 pm' '10 pm' '11 pm'})
legend('ToU','Home 1 Unscheduled','Home 1 Scheduled Salp','Home 2 Unscheduled','Home 2 Scheduled Salp','Home 3
Unscheduled','Home 3 Scheduled Salp');
legend('Location','NorthEast');
grid on
hold off
%% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %%
%% vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv %%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% %%
%%
%%
%% Display of results for Comparison of two price tariffs ToU and proposed
display('--------------RainFall--------------');
display('--------------Unscheduled Reuslts--------------');
display('Proposed scheme Electicity Bill');
for i = 1: 3
display(Home(i).sum_unscheduled_cost_PS);
end
display('ToU Electicity Bill');
for i = 1: 3
display(Home(i).sum_unscheduled_cost_ToU);
end
display('PAR');
for i = 1: 3
display(Home(i).PAR_unscheduled_ToU);
end
display('------ scheduled results -----')
display('Proposed scheme Electicity Bill');
for i = 1: 3
display(Home(i).sum_Scheduled_cost_PS_R);
end
display('ToU Electicity Bill');
for i = 1: 3
display(Home(i).Total_Cost_RainFall);
end
display('PAR');
for i = 1: 3
display(Home(i).PAR_scheduled_RainFall);
end
%% Schedule results
%% Per hour Cost
figure
%% Figure 5 b. Effect of scheduling on electricity cost for ToU and GTToU.
stairs(Home(1).E_Cost_SS_P_RainFall, 'Color',[0.7 0.2 0.2],'Marker','>','LineWidth',1.4);
hold on
stairs(Home(1).Schedulecost_PS_R,'Color',[0.7 0.7 0.3],'Marker','<','LineWidth',1.4);
hold on
stairs(Home(2).E_Cost_SS_P_RainFall,'Color',[0.6 0.4 0.4],'Marker','+','LineWidth',1.4);
hold on
stairs(Home(2).Schedulecost_PS_R,'Color',[0.1 0.7 0.7],'Marker','x','LineWidth',1.4);
hold on
stairs(Home(3).E_Cost_SS_P_RainFall, 'Color',[0.1 0.6 0.2],'Marker','v','LineWidth',1.4);
hold on
stairs(Home(3).Schedulecost_PS_R,'Color',[0.4 0 0.6],'Marker','o','LineWidth',1.4);
xlabel('Time');
ylabel('Electricity Cost ($)');
% set(gca, 'XTick',1:2:48, 'XTickLabel',{'12 am' '1 am' '2 am' '3 am' '4 am' '5 am' '6 am' '7 am' '8 am' '9 am' '10 am' '11 am'
'12 pm' '1 pm' '2 pm' '3 pm' '4 pm' '5 pm' '6 pm' '7 pm' '8 pm' '9 pm' '10 pm' '11 pm'})
set(gca, 'XTick',1:2:48, 'XTickLabel',{'0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '20' '21' '22' '23'})
legend('Home 1 ToU','Home 1 GTToU','Home 2 ToU','Home 2 GTToU','Home 3 ToU','Home 3 GTToU');
legend('Location','NorthEast');
grid on
hold off
%% per hour Load
% Figure 3b. Load profiles of three homes before and after scheduling with ToU and GTToU.
figure
stairs(Home(1).unscheduledload, 'Color',[0.7 0.2 0.2],'Marker','>','LineWidth',1.4);
hold on
stairs(Home(1).schedule_load_RainFall, 'Color', [0.7 0.7 0.3],'Marker','<','LineWidth',1.4);
hold on
stairs(Home(2).unscheduledload, 'Color', [0.6 0.4 0.4],'Marker','+','LineWidth',1.4);
hold on
stairs(Home(2).schedule_load_RainFall, 'Color', [0.1 0.7 0.7],'Marker','x','LineWidth',1.4);
hold on
stairs(Home(3).unscheduledload, 'Color',[0.1 0.6 0.2],'Marker','v','LineWidth',1.4);
hold on
stairs(Home(3).schedule_load_RainFall, 'Color', [0.4 0 0.6],'Marker','o','LineWidth',1.4);
xlabel('Time');
ylabel('Power Consumption (kWh)');
% set(gca, 'XTick',1:2:48, 'XTickLabel',{'12 am' '1 am' '2 am' '3 am' '4 am' '5 am' '6 am' '7 am' '8 am' '9 am' '10 am' '11 am'
'12 pm' '1 pm' '2 pm' '3 pm' '4 pm' '5 pm' '6 pm' '7 pm' '8 pm' '9 pm' '10 pm' '11 pm'})
set(gca, 'XTick',1:2:48, 'XTickLabel',{'0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '20' '21' '22' '23'});
legend('Home 1 Unscheduled Load','Home 1 Scheduled Load RainFall','Home 2 Unscheduled Load','Home 2 Scheduled
Load RainFall','Home 3 Unscheduled Load','Home 3 Scheduled Load RainFall');
legend('Location','NorthEast');
grid on
hold off
%% Figure 2b. ToU price regulated by PG&E and price according to the proposed scheme.
figure
stairs(EP_ToU, 'Marker','x','LineWidth',1.4);
hold on
stairs(Home(1).price, 'Color',[0.9 0.25 1],'Marker','p','LineWidth',1.4);
hold on
stairs(Home(1).Schprice_R, 'Color', [0.4 0 0.4],'Marker','<','LineWidth',1.4);
hold on
stairs(Home(2).price, 'Color', [0 0.6 1],'Marker','s','LineWidth',1.4);
hold on
stairs(Home(2).Schprice_R, 'Color', [0 0 0.4],'Marker','x','LineWidth',1.4);
hold on
stairs(Home(3).price, 'Color',[0.6 1 0.5],'Marker','h','LineWidth',1.4);
hold on
stairs(Home(3).Schprice_R, 'Color', [0.05 0.5 0],'Marker','o','LineWidth',1.4);
xlabel('Time');
ylabel('Electricity Price($)');
set(gca, 'XTick',1:2:48, 'XTickLabel',{'0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '20' '21' '22' '23'});
% set(gca, 'XTick',1:2:48, 'XTickLabel',{'12 am' '1 am' '2 am' '3 am' '4 am' '5 am' '6 am' '7 am' '8 am' '9 am' '10 am' '11 am'
'12 pm' '1 pm' '2 pm' '3 pm' '4 pm' '5 pm' '6 pm' '7 pm' '8 pm' '9 pm' '10 pm' '11 pm'})
legend('ToU','Home 1 Unscheduled','Home 1 Scheduled RainFall','Home 2 Unscheduled','Home 2 Scheduled
RainFall','Home 3 Unscheduled','Home 3 Scheduled RainFall');
legend('Location','NorthEast');
grid on
%% Start________________________________________________________________________________
% Salp Swarm Algorithm (SSA) source codes version 1.0
%
% Developed in MATLAB R2016a
%
% Author and programmer: Seyedali Mirjalili
%
% e-Mail: ali.mirjalili@gmail.com
% seyedali.mirjalili@griffithuni.edu.au
%
% Homepage: http://www.alimirjalili.com
%
% Main paper:
% S. Mirjalili, A.H. Gandomi, S.Z. Mirjalili, S. Saremi, H. Faris, S.M. Mirjalili,
% Salp Swarm Algorithm: A bio-inspired optimizer for engineering design problems
% Advances in Engineering Software
% DOI: http://dx.doi.org/10.1016/j.advengsoft.2017.07.002
% I have modifed this code according to my own requirments. You can see
% Original code on the Authors provided link above.
%____________________________________________________________________________________
% This function initialize the first population of search agents
function Positions=initialization(SearchAgents_no,dim,ub,lb)
Boundary_no= size(ub,1); % numnber of boundaries
% If the boundaries of all variables are equal and user enter a signle
% number for both ub and lb
if Boundary_no==1
Positions=rand(SearchAgents_no,dim).*(ub-lb)+lb;
end
% If each variable has a different lb and ub
if Boundary_no>1
for i=1:dim
ub_i=ub(i);
lb_i=lb(i);
Positions(:,i)=rand(SearchAgents_no,1).*(ub_i-lb_i)+lb_i;
end
end
end
%%
function [FoodFitness, FoodPosition,FoodPosition_B, Convergence_curve]=SalpSwarmAlgo(N,Max_iter,lb,ub,
Power_rates, dim, EP_ToU,hour, LOT, app_Sch_C, Appliances_Status, limit1, limit2)
CostFunction=@(y,Power_rates,dim,EP_ToU,hour,LOT,app_Sch_C, Appliances_Status)
Obj_Func(y,Power_rates,dim,EP_ToU,hour,LOT, app_Sch_C, Appliances_Status); % Cost Function
if size(ub,1)==1
ub=ones(dim,1)*ub;
lb=ones(dim,1)*lb;
end
Convergence_curve = zeros(2,Max_iter)';
%Initialize the positions of salps
SalpPositions=initialization(N,dim,ub,lb);
FoodPosition=zeros(1,dim);
FoodFitness=inf;
%% You may change the CostFunction according to you own objective function
[SalpPositions_B, SalpFitness] = CostFunction(SalpPositions,Power_rates,dim,EP_ToU,hour,LOT,app_Sch_C,
Appliances_Status);
FoodFitness =[];
%% Fitness criteria Here we set according to our defined objective
if EP_ToU(hour) < mean(EP_ToU) % (Off-peak price)
Var1 = (SalpFitness(:,1) > limit1); % constraint to find the values >= load limit
Var2 = SalpFitness(:,2).*Var1; % considered the cost of only those sets who have load according to targeted threshold
Var3 = find(Var2>0);
[FoodFitness1, Position] = min(SalpFitness((Var3),2));
FoodPosition = SalpPositions(Var3(Position), :);
FoodPosition_B = SalpPositions_B(Var3(Position), :);
FoodFitness = [SalpFitness(Var3(Position),1), FoodFitness1];
else
Var1 = (SalpFitness(:,1)>=limit2) ; % constraint to find the values >= load limit
Var2 = SalpFitness(:,2).*Var1;
Var3 = find(Var2>0);
[FoodFitness1, Position] = min(SalpFitness((Var3),2));
FoodPosition = SalpPositions(Var3(Position), :);
FoodPosition_B = SalpPositions_B(Var3(Position), :);
FoodFitness = [SalpFitness(Var3(Position),1), FoodFitness1];
end
if size(FoodFitness,1) == 0
Var1 = (SalpFitness(:,1)>=limit2); % constraint to find the values >= load limit
Var2 = SalpFitness(:,2).*Var1;
Var3 = find(Var2>0);
[FoodFitness1, Position] = min(SalpFitness((Var3),2));
FoodPosition = SalpPositions(Var3(Position), :);
FoodPosition_B = SalpPositions_B(Var3(Position), :);
FoodFitness = [SalpFitness(Var3(Position),1), FoodFitness1];
end
if size(FoodFitness,1) == 0
Var1 = (SalpFitness(:,1)> 0); % constraint to find the values >= load limit
Var2 = SalpFitness(:,2).*Var1;
Var3 = find(Var2>0);
[FoodFitness1, Position] = min(SalpFitness((Var3),2));
FoodPosition = SalpPositions(Var3(Position), :);
FoodPosition_B = SalpPositions_B(Var3(Position), :);
FoodFitness = [SalpFitness(Var3(Position),1), FoodFitness1];
end
%%
%Main loop
l=2; % start from the second iteration since the first iteration was dedicated to calculating the fitness of salps
while l<Max_iter+1
c1 = 2*exp(-(4*l/Max_iter)^2); % Eq. (3.2) in the paper
for i=1:size(SalpPositions,1)
SalpPositions= SalpPositions';
if i<=N/2
for j=1:1:dim
c2=rand();
c3=rand();
%%%%%%%%%%%%% % Eq. (3.1) in the paper %%%%%%%%%%%%%%
if c3<0.5
SalpPositions(j,i)=FoodPosition(j)+c1*((ub(j)-lb(j))*c2+lb(j));
else
SalpPositions(j,i)=FoodPosition(j)-c1*((ub(j)-lb(j))*c2+lb(j));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
elseif i>N/2 && i<N+1
point1=SalpPositions(:,i-1);
point2=SalpPositions(:,i);
SalpPositions(:,i)=(point2+point1)/2; % % Eq. (3.4) in the paper
end
SalpPositions= SalpPositions';
end
for i=1:size(SalpPositions,1)
Tp=SalpPositions(i,:)>ub';
Tm=SalpPositions(i,:)<lb';
SalpPositions(i,:)=(SalpPositions(i,:).*(~(Tp+Tm)))+ub'.*Tp+lb'.*Tm;
[SalpPositions_BB, Z]=CostFunction(SalpPositions(i,:), Power_rates,dim,EP_ToU,hour,LOT,app_Sch_C,
Appliances_Status);
SalpFitness(i,:) = Z;
if EP_ToU(hour) < mean(EP_ToU)
if (SalpFitness(i,1)< FoodFitness(1,1)) && SalpFitness(i,2)> limit1
FoodFitness = SalpFitness(i,:);
FoodPosition = SalpPositions(i,:);
FoodPosition_B = SalpPositions_BB;
end
else
if (SalpFitness(i,1)< FoodFitness(1,1)) && SalpFitness(i,2)>=limit2 && SalpFitness(i,2)< limit1
FoodFitness = SalpFitness(i,:);
FoodPosition = SalpPositions(i,:);
FoodPosition_B = SalpPositions_BB;
end
end
end
Convergence_curve(l,:)=FoodFitness;
l = l + 1;
end
end
%% You can change this code ocording to your own requirments
%% Here each appliance ON and OFF status is set according to the conditions define in the paper.
%% Also it is checked her if appliances working hours have already completed if yes it will be turn value 0.
% If still Some appliances need to be completed task and its working hourse
% are equal to the remaing time it will turn 1.
%%
function [x] = B_Values(y,D,hour,C_time_slots, app_Sch_C, Appliances)
%% Convert Into Binary Form
%%% Modified binary particle swarm optimization
% Instructions: z can be a matrix, vector or scalar
% For Matlab
% Instructions: z can be a matrix, vector or scalar
% g = 1.0 ./ ( 1.0 + exp(-x)); % For Matlab sigmoid function
for i_g=1:D
if rand> 0.5 %g(i_g) %You can change this accordingly
x(i_g)=1;
else
x(i_g)=0;
end
end
x = y>=0.5;
%% %%%% Non intruptible appliance: working in series %%%%
lhour=49-hour;
if lhour<=(C_time_slots(1,4)+C_time_slots(1,5))
if C_time_slots(1,4)<=0
x(:,5)=1;
elseif C_time_slots(1,4)>0
x(:,4)=1;
x(:,5)=0;
end
elseif hour>1
if app_Sch_C(hour-1,4)==1
x(:,4)=1;
x(:,5)=0;
end
if C_time_slots(1,4)<=0 && C_time_slots(1,5)> 0
x(:,5)=1;
x(:,4)=0;
end
end
if C_time_slots(1,4)> 0
x(:,5)=0;
end
%% Condition for diswasher
%% Dishwasher will be ON after the Oven
if sum(app_Sch_C(:,7))== 0
x(:,2)=0;
end
if sum(app_Sch_C(:,7)) == 1 && sum(app_Sch_C(:,2)) == 1
x(:,2)=0;
end
if sum(app_Sch_C(:,7)) == 2 && sum(app_Sch_C(:,2)) == 2
x(:,2)=1;
end
if sum(app_Sch_C(:,7)) == 2 && sum(app_Sch_C(:,2)) == 3
x(:,2)=0;
end
%%
%% ON THE NON SCHEDULED APPLIANCES
for i=(7:D) % 8-14 we have NON Scheduliable appliances
if (Appliances(hour, i)>0)
x(:,i)=1;
elseif (Appliances(hour, i)==0)
x(:,i)=0;
end
end
%% set the appliances status 0ne that can't be wait any more
for b=1:D
if C_time_slots(1,b)<=0
x(:,b)=0;
elseif (lhour<=C_time_slots(1,b)&& C_time_slots(1,b)>0)
x(:,b)=1;
end
end
end
%% Objjetcive Function it is refer as CostFunction above
function [x,z]=Obj_Func(y,p,D,EP,hour,C_time_slots, app_Sch_C, Appliances)
n=numel(y);
x=B_Values(y,D,hour,C_time_slots, app_Sch_C, Appliances);
%% Fitness function defination %%
F1 =p*x'; % load
F2=F1*EP(hour);
z=[F1' F2'];
end
%% Start of Coalition game
% This coalition code is taken from "" and must be cited for "Twan Burg (2020). Shapley Value for n-player Cooperative
Games (https://www.mathworks.com/matlabcentral/fileexchange/35334-shapley-value-for-n-player-cooperative-games),
MATLAB Central File Exchange. Retrieved June 17, 2020."
function [Total_Allocation, Marginal_Distribution] = Game_Theory_Shapley(xTra_Cost, Total_Xtra)
A =xTra_Cost; % each operational time of appliances are condidered as player
B =1:length(A); % Assign location to find the possible combination
Player.Location =[]; % players all possible combinations location
Player.Value =[]; % Players all possible combinations
Availabe_Price =Total_Xtra; % Availabe power Price
i=1;
while i<=length(A)
Player(i).Location = [combntns(B,i)]; % combntns will return the possible combination of set
if i>1 % seperate first combination as they are individual players they have seperate payOff
Player(i).Value = sum((A(Player(i).Location))'); % Add up the power Price to calculate the payOff
else
Player(i).Value = (A(Player(i).Location));
end
i=i+1;
end
v=[Player.Value];
%% I have set the pay-off table according to my requirments. So you can also change this
%% Payoff value assigned to the demand. Person who have high demand will be assign with high payoff
%% This Setup is as follows:
% a coalition of players cooperates, and obtains a certain overall gain from that cooperation.
% Since some players may contribute more to the coalition than others or may possess different
% bargaining power (for example threatening to destroy the whole surplus), what final distribution
% of generated surplus among the players should arise in any particular game? Or phrased differently:
% how important is each player to the overall cooperation, and what payoff can he or she reasonably expect?
% The Shapley value provides one possible answer to this question.
% pay_off(i)=
for i=1:length(v)
if v(i)== Availabe_Price
pay_off(i) = Availabe_Price;
elseif v(i) < Availabe_Price && v(i) > 0
pay_off(i) = v(i);
elseif v(i)> Availabe_Price % && abs(v(i)-Availabe_Price)<=0.09
pay_off(i) = Availabe_Price;
else
pay_off(i)=0;
end
end
%%
% Condition if one player demand is very high than the surplus and other
% demand is less than surplus what system should do
% pay_off(i)=
n=length(A);
% v=[1 3 0 0 9 8 3 8 4 7 6 2 0 1 2 0 9 8 3 8 4 7 6 2 0 1 2 2 0 1 2];
% n=5;
if n>1
B =[matr(n) pay_off'];
else
B =[1 pay_off];
end
Shapleyvalue =zeros(1,n);
for i=1:n
G = sortrows(B,[n+1 -i]);
Shapleyvalue(i) = Shappie(G(:,n+2)');
end
%% Basically shapley will assign the Price to each home according to pay-off
% Distribution = Total_Xtra/length(Shapleyvalue);
% Value=Shapleyvalue>0
% Distribution= Value*Distribution
Marginal_Distribution = Shapleyvalue; % Distribution+Shapleyvalue;
Total_Allocation = sum(Marginal_Distribution);
Price_D = sum(xTra_Cost);
if Total_Allocation > Availabe_Price
display('Total_Allocation is greater than Availabe_Price');
elseif Total_Allocation > sum(xTra_Cost)
display('Total_Allocation is greater than xTra_Cost');
end
end
function Shapley=Shappie(v)
%Calculates the Shapley value for individual a
n=log2(length(v)+1);
M=zeros(1,2^n-2);
M(1,1)=v(1)*factorial(n-1);
c=2; i=1;
while i<n
for j=c:c+nchoosek(n-1,i)-1
M(1,j)=(v(j+nchoosek(n-1,i))-v(j))*((factorial(n-1))/(nchoosek(n-1,i)));
end
c=c+2*(nchoosek(n-1,i));
i=i+1;
end
Shapley=sum(M)/factorial(n);
end
function matri=matr(n)
i=1; c=1;
if n==2 matri=[1 0; 0 1];
else
matri=zeros(2^n-1,n+1);
while i<n
for j=c:c+nchoosek(n-1,i-1)-1
matri(j,1)=1; %maakt de eerste kolom aan
end
c=c+nchoosek(n,i); i=i+1;
end
R=matr(n-1); t=2; k=1; r=1;
while k<n-1
matri(t:t+nchoosek(n-1,k)-1,2:n)=R(r:r+nchoosek(n-1,k)-1,1:n-1);
matri(t+nchoosek(n-1,k):t+2*nchoosek(n-1,k)-1,2:n)=R(r:r+nchoosek(n-1,k)-1,1:n-1);
t=t+2*nchoosek(n-1,k); r=r+nchoosek(n-1,k); k=k+1;
end
matri(2^n-2,2:n)=ones(1,n-1); matri(2^n-1,1:n)=ones(1,n); %de laatste 2 kolommen
end
g=1; c=1;
while g<=n
for j=c:c+nchoosek(n,g)-1 %bepaalt de groepsgrootte
matri(j,n+1)=g; end
c=c+nchoosek(n,g); g=g+1;
end
end
%% End of Coalition game
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% version 1.0.0.0 (4.46 KB) by Totok Biyanto
% Inspired by the pattern of physically rain water movements from air to the lowest place on the earth
function [Fbest, Lbest_B, Lbest]=Rain_Fall_Func(N,Max_iter,lb,ub, Power_rates, dim, EP_ToU,hour, LOT, app_Sch_C,
Appliances_Status, limit1, limit2)
CostFunction=@(y,Power_rates,dim,EP_ToU,hour,LOT,app_Sch_C, Appliances_Status)
Obj_Func(y,Power_rates,dim,EP_ToU,hour,LOT, app_Sch_C, Appliances_Status); % Cost Function
alfa=360;
G=10;
t = 1;
upbound = 5;
lowbound = -5;
Rpower=1;
min_flag=1;
minmax = 1;
Rnorm=2;
convergence_curve=zeros(1,Max_iter);
% Initialize population, position:
if size(upbound,2)==1
X=rand(N,dim).*(upbound-lowbound)+lowbound;
end
if size(upbound,2)>1
X(:,i_j)=rand(N,dim).*(upbound-lowbound)+lowbound;
end
Bestpos=zeros(1,dim);
Meanpos=zeros(1,dim);
FBest=zeros(1,dim);
LBest=zeros(1,dim);
Eo=zeros(N,dim);
V=zeros(N,dim);
M = zeros(N);
P = 0;
%% Main Program
for Max_iteration = 1:Max_iter
%% inisialisasi Search Agent dan Objective Function
[N,dim]=size(X);
for i_i=1:N
%%Agent that go out of the search space, are reinitialized randomly .
Tp=X(i_i,:)>upbound;
Tm=X(i_i,:)<lowbound;
% for kk=1:dim
% if (X(i_i,:) >
X(i_i,:)=(X(i_i,:).*(~((Tp+Tm) >= 1)))+((rand(1,dim).*(upbound-upbound)+lowbound).*((Tp+Tm) >= 1));
% end
end
% obj func
for i_i=1:N
%L is the location of agent number 'i'
L=X(i_i,:);
[X_BB, Z]=CostFunction(X(i_i,:), Power_rates,dim,EP_ToU,hour,LOT,app_Sch_C, Appliances_Status);
fitness(i_i,:) = Z; % it will return cost and load
X_B(i_i,:) = X_BB;
end
%%
%% Fitness criteria Here we set according to our defined objective
if EP_ToU(hour) < mean(EP_ToU) % (Off-peak price)
Var1 = (fitness(:,1) > limit1); % constraint to find the values >= load limit
Var2 = fitness(:,2).*Var1; % considered the cost of only those sets who have load according to targeted threshold
Var3 = find(Var2>0);
[Fbest1, Position] = min(fitness((Var3),2));
Lbest = X(Var3(Position), :);
Lbest_B = X_B(Var3(Position), :);
Fbest = [fitness(Var3(Position),1), Fbest1];
else
Var1 = (fitness(:,1)>=limit2) ; % constraint to find the values >= load limit
Var2 = fitness(:,2).*Var1;
Var3 = find(Var2>0);
[Fbest1, Position] = min(fitness((Var3),2));
Lbest = X(Var3(Position), :);
Lbest_B = X_B(Var3(Position), :);
Fbest = [fitness(Var3(Position),1), Fbest1];
end
if size(Fbest,1) == 0
Var1 = (fitness(:,1)>=limit2); % constraint to find the values >= load limit
Var2 = fitness(:,2).*Var1;
Var3 = find(Var2>0);
[Fbest1, Position] = min(fitness((Var3),2));
Lbest = X(Var3(Position), :);
Lbest_B = X_B(Var3(Position), :);
Fbest = [fitness(Var3(Position),1), Fbest1];
end
if size(Fbest,1) == 0
Var1 = (fitness(:,1)> 0); % constraint to find the values >= load limit
Var2 = fitness(:,2).*Var1;
Var3 = find(Var2>0);
[Fbest1, Position] = min(fitness((Var3),2));
Lbest = X(Var3(Position), :);
Lbest_B = X_B(Var3(Position), :);
Fbest = [fitness(Var3(Position),1), Fbest1];
end
%%
Bestpos=[Bestpos Fbest];
Meanpos=[Meanpos mean(fitness(:,1))];
%% Hujan jatuh = energi potensial = Ep = 1/2 mv^2
% velocity calculation
Fmax=max(fitness(:,1)); Fmin=min(fitness(:,1)); Fmean=mean(fitness(:,1));
[NN, ~]=size(fitness);
if Fmax==Fmin
vo=ones(NN,1);
else
best=Fmin;worst=Fmax;
vo=(fitness(:,1)-worst)./(best-worst);
end
M = rand(NN);
vo=(vo./sum(vo)).*t;
% velocity calculation berfungsi untuk menentukan butiran hujan yang jatuh
% terlebih dahulu berdasarkan fitness dari setiap agents.
%
% [N,dim]=size(X);
final_per=1.5; %In the last Max_iteration, only 1.5 percent of agents
kbest=final_per+(1-Max_iteration/Max_iter)*(100-final_per);
kbest=round(NN*kbest/100);
[Ms, ds]=sort(vo,'descend');
for ii=1:kbest % update Eo(i,k) (udpate 1 drop as much as kbest)
i_i = ceil(rand*N);
j=ds(ii);
if j~=i_i
R=norm(X(i_i,:)-X(j,:),Rnorm); %Euclidian distance. distance between two point
for k=1:dim
Eo(ii,k)=Eo(ii,k)+(vo(j))*((X(j,k)-X(i_i,k))/(R^Rpower+eps));
end
end
end
for i_i=1:N
ii = ceil(rand*kbest);
j=ds(ii);
if j~=i_i
R=norm(X(i_i,:)-X(j,:),Rnorm); %Euclidian distance. distance between two point
for k=1:dim
Eo(i_i,k)=Eo(i_i,k)+(vo(j))*((X(j,k)-X(i_i,k))/(R^Rpower+eps));
end
end
end
%%acceleration
E = Eo*exp(rand*-alfa*Max_iteration/Max_iter);
a = E.*G;
%movement.
% [N,dim]=size(X);
V=V+a;
X=X+V;
end
end

Supplementary resource (1)

Data
June 2020
Adia Khalid · Nadeem Javaid · Abdul Mateen · Manzoor Illahi · Amjad Rehman
ResearchGate has not been able to resolve any citations for this publication.
Article
Full-text available
An efficient power management control for microgrids with energy storage is presented in this paper. The proposed control scheme increases the reliability and resiliency of the microgrid based on three distributed energy resources (DERs), namely Photovoltaic (PV), battery, and diesel generator with local active loads. Coordination among the DERs with energy storage is essential for microgrid management. The system model and the control strategy were developed in Real Time Digital Simulator (RTDS). Decoupled d-q current control strategy is proposed and implemented for voltage source converters (VSCs) used to interface the PV and battery sources to the AC grid. A dc-dc buck converter with a maximum power point tracking function is implemented to maximize the intermittent energy generation from the PV array. A controller is proposed and employed for both grid connected and island modes of operation. In grid connected mode, the system frequency and voltage are regulated by the grid. During a fault in island mode, the diesel generator controls the system frequency and voltage in isochronous mode. Results based on the real time digital simulator are provided to verify the superiority and effectiveness of the proposed control scheme.
Article
Full-text available
In this paper, the combined problem of power company selection and demand response management (DRM) in a smart grid network consisting of multiple power companies and multiple customers is studied via adopting a reinforcement learning and game-theoretic technique. Each power company is characterized by its reputation and competitiveness. The customers, acting as learning automata select the most appropriate power company to be served, in terms of price and electricity needs’ fulfillment, via a reinforcement learning based mechanism. Given customers’ power company selection, the DRM problem is formulated as a two-stage game-theoretic optimization framework. At the first stage the optimal customers’ electricity consumption is determined and at the second stage the optimal power companies’ pricing is obtained. The output of the DRM problem feeds the learning system to build knowledge and to conclude to the optimal power company selection. To realize the aforementioned framework a two-stage Power Company learning selection and Demand Response Management (PC-DRM) iterative algorithm is introduced. The performance evaluation of the proposed approach is achieved via modeling and simulation and its superiority against other approaches is illustrated.
Article
Full-text available
Peak-load management is an important process that allows energy providers to reshape load profiles, increase energy efficiency, and reduce overall operational costs and carbon emissions. This paper presents an improved decision-tree-based algorithm to reduce the peak load in residential distribution networks by coordinated control of electric vehicles (EVs), photovoltaic (PV) units, and battery energy-storage systems (BESSs). The peak-load reduction is achieved by reading the domestic load in real time through a smart meter and taking appropriate coordinated action by a controller using the proposed algorithm. The proposed control algorithm was tested on a real distribution network using real load patterns and load dynamics, and validated in a laboratory experiment. Two types of EVs with fast and flexible charging capability, a PV unit, and BESSs were used to test the performance of the proposed control algorithm, which is compared with that of an artificial-neural-network technique. The results show that using the proposed method, the peak demand on the distribution grid can be reduced significantly, thereby greatly improving the load factor.
Article
Full-text available
Demand side management (DSM) in smart grid authorizes consumers to make informed decisions regarding their energy consumption pattern and helps the utility in reducing the peak load demand during an energy stress time. This results in reduced carbon emission, consumer electricity cost, and increased grid sustainability. Most of the existing DSM techniques ignore priority defined by consumers. In this paper, we present priority-induced DSM strategy based on the load shifting tech-nique considering various energy cycles of an appliance. The day-ahead load shifting technique proposed is mathematically formulated and mapped to multiple knapsack problem to mitigate the rebound peaks. The autonomous energy management controller proposed embeds three meta-heuristic optimization techniques; genetic algorithm, enhanced differential evolu-tion, and binary particle swarm optimization along with optimal stopping rule, which is used for solving the load shifting problem. Simulations are carried out using three different appliances and the results validate that the proposed DSM strategy successfully shifts the appliance operations to off-peak time slots, which consequently leads to substantial electricity cost savings in reasonable waiting time, and also helps in reducing the peak load demand from the smart grid. In addition, we calculate the feasible regions to show the relationship between cost, energy consumption, and delay. A priority-induced demand side management system to mitigate rebound peaks using multiple knapsack. Available from: https://www.researchgate.net/publication/323945280_A_priority-induced_demand_side_management_system_to_mitigate_rebound_peaks_using_multiple_knapsack [accessed Mar 26 2018].
Article
Full-text available
The Demand Response (DR) is used by public electric utilities to encourage consumers to change their consumption profiles to improve the reliability and efficiency of the electric power system (EPS) and at the same time to minimize the electricity costs for the final consumers. Normally, DR optimization models only aim to reduce the energy consumption and reduce the final cost. However, this disregards the needs of the consumer. Therefore, proposals which appear excellent in theory are usually impracticable and non-commercial. This paper proposes a real-time Demand Response (DR) optimization model to minimize the electricity costs associated with consumption without compromising the satisfaction or comfort of residential consumers. The proposed DR here considered the different home appliance categories and level of consumer satisfaction for the new load scheduling of the appliances and is much more comprehensive than the other models analyzed. Moreover, it can be applied in any country, under any energy scenario. This model was developed as a nonlinear programming problem subject to a set of constraints. An energy consumption analysis of 10 families for 2015 from five geographic and climatic regions of Brazil was carried out. A computational validation of the model was performed using a genetic algorithm (GA) to determine the programming of residential devices for the time horizon. The computational simulations showed a decrease in the cost of the electricity. Moreover, the results showed that there was no impairment to consumer satisfaction and comfort due to the scheduling of appliances.
Article
In this paper, the large-scale integration of plug-in electric vehicles (PEVs) with Vehicle-to-Grid (V2G) technology is taken as a promising way to promote the integration of renewable energy sources (RESs). But, it is a challenging task for the independent system operator (ISO) to manage the power flows in its system, especially in the large-scale integration of PEVs and RESs into the transmission system. The coordination between PEV, as distributed storage devices, and variable RESs create variable power flows and loop flows and quests for utilization of controllable devices to manage these flows. The On-load tap changing (OLTC) transformers and phase shifting transformers (PSTs) are two flexible transmission technologies that can be solved this challenge through controlling the power flows. In this paper, a novel model is developed for optimal operation of flexible transmission technologies for coordinated integration of PEVs and RESs in power transmission networks. The proposed model has been implemented on the six-bus and the IEEE 118-bus test systems. The simulation results imply that: (i) The V2G technology of PE