Content uploaded by Nadeem Javaid

Author content

All content in this area was uploaded by Nadeem Javaid on Jul 01, 2020

Content may be subject to copyright.

SPECIAL SECTION ON ENERGY MANAGEMENT IN BUILDINGS

Received November 15, 2017, accepted December 23, 2017, date of publication January 9, 2018, date of current version April 25, 2018.

Digital Object Identifier 10.1109/ACCESS.2018.2791546

Towards Dynamic Coordination Among Home

Appliances Using Multi-Objective Energy

Optimization for Demand Side Management

in Smart Buildings

ADIA KHALID1, NADEEM JAVAID 1, (Senior Member, IEEE),

MOHSEN GUIZANI 2, (Fellow, IEEE), MUSAED ALHUSSEIN 3,

KHURSHEED AURANGZEB 3, AND MANZOOR ILAHI1

1COMSATS Institute of Information Technology, Islamabad 44000, Pakistan

2Electrical and Computer Engineering Department, University of Idaho, Moscow, ID 83844, USA

3College of Computer and Information Sciences, King Saud University, Riyadh 11543, Saudi Arabia

Corresponding author: Nadeem Javaid (nadeemjavaidqau@gmail.com)

This work was supported by the Deanship of Scientiﬁc Research at King Saud University through the Research Group under Grant

RG-1438-034.

ABSTRACT In this paper, we propose a home energy management system that employs load shifting strategy

of demand side management to optimize the energy consumption patterns of a smart home. It aims to manage

the load demand in an efﬁcient way to minimize electricity cost and peak to average ratio while maintaining

user comfort through coordination among home appliances. In order to meet the load demand of electricity

consumers, we schedule the load in day-ahead and real-time basis. We propose a ﬁtness criterion for proposed

hybrid technique, which helps in balancing the load during ON-peak and OFF-peak hours. Moreover, for real-

time rescheduling, we present the concept of coordination among home appliances. This helps the scheduler

to optimally decide the ON/OFF status of appliances in order to reduce the waiting time of appliance. For

this purpose, we formulate our real-time rescheduling problem as knapsack problem and solve it through

dynamic programming. This paper also evaluates the behavior of the proposed technique for three pricing

schemes including: time of use, real-time pricing, and critical peak pricing. Simulation results illustrate the

signiﬁcance of the proposed optimization technique with 95% conﬁdence interval.

INDEX TERMS Smart homes, home automation, energy, multi-objective optimization, embedded systems,

day-ahead and real-time scheduling, bacterial foraging optimization, genetic algorithm, coordination, hybrid

technique.

I. INTRODUCTION

For a couple of decades, an exponential growth in power

demand of consumers is observed. Due to the massive

increase in electricity demand, the traditional grid is experi-

encing numerous challenges like maintenance, sustainability

and reliability. It has been observed that around 30-40% of

energy is consumed in buildings throughout the world [1].

According to the International Energy Outlook 2013, the

energy consumption will increase by 56% in 2040 [2].

To overcome the challenges of traditional grid, the concept

of Smart Grid (SG) has evolved which integrates a two way

communication technology in the existing power system to

achieve a system which is more reliable, efﬁcient, cost effec-

tive and dynamically controllable. In the SG, the Demand

Side Management (DSM) plays a vital role by developing

strategies in a ﬂexible and diverse way to maintain the grid’s

stability [3]. The strategic planning of DSM helps to con-

trol and manage the increasing load demand of electricity

consumers. Basically, the DSM aims at educating electricity

consumers to modify their electricity usage patterns in order

to reduce stress on the main grid for continuous power supply

to the consumer [4]. In order to deal with changes in the

consumer load proﬁle, the proposed DSM strategies include

load shifting, strategic conservation, peak clipping and

VOLUME 6, 2018 This work is licensed under a Creative Commons Attribution 3.0 License. For more information, see http://creativecommons.org/licenses/by/3.0/ 19509

A. Khalid et al.: Toward Dynamic Coordination Among Home Appliances Using Multi-Objective Energy Optimization

FIGURE 1. DSM strategic planning.

valley ﬁlling as shown in Fig. 1. Where peak clipping, valley

ﬁlling and load shifting are known as classic form of load

management. Strategic conservation, strategic load growth

and ﬂexible load shaping are energy efﬁciency strategies of

the DSM [5]. However, load shifting is the most frequently

employed strategy in the literature in which load is managed

through a Demand Response (DR) [6]. Basically, the DR aims

at motivating electricity consumers to change their energy

consumption patterns with respect to the current electricity

price signal. This way, most of the consumers get incentives

(reduction in the electricity bill) [7] by shifting the load

demand from On-peak to Off-peak hours which enables the

upstream main utility grid to reduce the stress and minimize

the Peak to Average Ratio (PAR).

The main focus of the above mentioned strategies is to

encourage consumers to use less electricity during On-peak

hours and shift the load towards Off-peak hours which can

efﬁciently reduce the electricity cost and PAR more efﬁ-

ciently [7]. Most of the DSM strategies adapted schedul-

ing algorithms optimize the demand pattern by shifting the

load using DR programs [7]. This encourages the electric-

ity consumer to make changes in the load according to the

price tariff [8]. This is possibly implementable by using two-

way communication, smart metering infrastructure, smart

appliances, renewable energy sources, etc., Fig. 2depicts

the systematic model of the SG. However, the implemen-

tation of the SG and the DSM is a challenge, because

the system has to deﬁne and achieve the objectives inde-

pendently. To deal with electricity crises, the DSM has

to handle a large number of controllable loads of differ-

ent regions including residential, commercial and industrial

areas. There are many architectures that have been proposed

for the energy management of commercial and residential

areas, most of researchers in this area target residential areas

because of the number of appliances that are used. In this

respect, [9]–[13] and [15]–[25] proposed Home Energy Man-

agement Systems (HEMSs) which follow different pricing

approaches along with renewable and sustainable energy

resources. HEMS is deﬁned as the system which provides

services to monitor and manage the electricity ﬂow and

usage in a smart home [26]. The proposed HEMSs tech-

niques in [9]–[13] and [15]–[25] reduce the electricity cost

and PAR during the day when there is a high demand of

electricity, and the utilities need extra resources to fulﬁll the

demand. Though, these articles ignore the under developing

areas where these resources are not provided. Despite all

of these, most of them consider user comfort as minimum

waiting time of appliances. However, none of them discussed

the situation when a user wants to terminate the working

of an appliance during its allocated time-slot and real-time

rescheduling of the appliance in the mean time. In addi-

tion, it is very difﬁcult to schedule the appliances in real-

time at an optimal time slot because of static and sequential

inputs. In order to enable the dynamic scheduling in real-

time, [27] performed real-time rescheduling using dynamic

programing. In this work, the appliance rescheduling is based

on priority scheduling to reduce the cost and the power

demand. In this article, the prority appliance will be turned

ON while another low prority appliance will be turned OFF

and scheduled on next the day, this affects the user comfort.

Hence, the need for an efﬁcient HEMS emerges which can

deal with sudden changes in the load demand without sac-

riﬁcing the user comfort, dire need of coordination among

appliances.

This paper is an extension of [28], in which the focus of

the study is to employ DSM in HEMS for load management

to reduce electricity cost, PAR and user discomfort. To min-

imize user discomfort, we have introduced the concept of

coordination among home appliances to handle the interrupts

in an emergency situation. It allows the user to interrupt an

19510 VOLUME 6, 2018

A. Khalid et al.: Toward Dynamic Coordination Among Home Appliances Using Multi-Objective Energy Optimization

FIGURE 2. Smart Grid.

appliance and to allocate the remaining time-slot to any other

user preferred appliance(s) by rescheduling using dynamic

programming. This way, the extra time can be utilized to

reduce the waiting time of high priority appliances. To check

the effectiveness of the system, we propose a Hybrid Bacterial

Foraging and Genetic algorithm (HBG) optimization tech-

nique. The proposed technique is evaluated using different

price signals.

The contributions of this paper are as follows:

•HBG: In this paper, we focus on designing a hybrid opti-

mization technique. We demonstrate the performance of

already existing optimization approaches. After analyz-

ing the GA and the BFA, it is observed that there is

a need to develop such an optimization method which

can further improve search efﬁciency and which is ade-

quate to handle multiple constraints. Based on these

heuristic techniques, a hybrid technique is proposed con-

sidering the system objectives. Extensive simulations

are conducted to validate the results. The efﬁciency of

the proposed technique is validated by analyzing the

performance metrics, which show high cost savings with

minimum user PAR.

•In order to incorporate coordination among home appli-

ance, dynamic programming is used which helps to

reschedule the appliances in the real-time.

•We formulate the binary optimization problem through

Multiple Knapsack Problem (MKP). MKP helps in the

effort of ﬁnding an optimal solution while employing

dynamic programming and respecting the total capacity

of available amount of time.

The rest of the paper is organized as follows. Section II

reﬂects the state of the art in SG and DSM. Section III

highlights the related problem regarding the peak hours

and its consequences on grid and electricity consumers.

Section IV incorporates the proposed solution of high-

lighted problems with detailed description of previously

used approaches GA and BFA, and our proposed algo-

rithm. Results are illustrated and veriﬁed using simulation

VOLUME 6, 2018 19511

A. Khalid et al.: Toward Dynamic Coordination Among Home Appliances Using Multi-Objective Energy Optimization

in Section V. Finally, the conclusion of the research with

future work is discussed in Section VI.

NOMENCLATURE

ˆ

IUser interrupt

φiRandom direction vector of bacteria

θiNew position of bacteria

APP Appliance

APPα

cList of the appliances, user

want to reschedule

APPof User terminated appliance

APPSchh

dList contains each appliance

h=1-24 hour schedule for d∈

{1,2,...,M}where M is

total number of appliance

APPαAppliance rescheduled from APPα

c

APPdA particular appliance

Appd

WtWaiting time of an appliance

CStep size

Appd

DhUser demanded hour for a particular

appliance

Appd

ShScheduled hour of a particular

appliance

KSDeKnapsack dynamic equation

Ehour

cost Per hour cost of a day

Etotal

cost Total cost for a day

Eunsch

load List of unscheduled electricity load

for a day

Eschhour

load Scheduled load for particular hour

EiPoP

load Load of population

Ehour

price Electricity price per Hour

FPoP Fitness of population

FfFitness function

InterptInterrupt time

JiFitness of bacteria

KnapCap Knapsack capacity

knapsack capacity 60-Interpt

Listhour List of hours to be rescheduled

Listint

time List of working time interval

NpNumber of population

NeNumber of elimination steps

NrNumber of reproduction steps

NcNumber of chemotactic steps

NsNumber of swimming Steps

objhour

lcurve Per hour objective load

Appd

Prate Power rate of an appliance d

PoP Population set of bacteria or

chromosome i.e, possible solution set

Sch Complete schedule of 24 hours

SolSet Knapsack ﬁnal solution

std Stander deviation

Timeaval Available interval time

II. RELATED WORK

The optimization of SG components using DSM and DR

is a challenging task. Several solutions have been proposed

and implemented while aiming at Single Objective Opti-

mization (SOO) or Multi Objective Optimization (MOO)

with trade-off between different targeted objectives. Some

are quoted in [9]–[13] and [15]–[32], also their systematic

review is given in Table 1. Due to the importance of DSM

and its emergent need, it has been an active topic from

a couple of decades. Articles [9]–[13] and [15]–[32] tar-

get the user comfort, cost minimization on the consumer

side and PAR reduction which directly or indirectly bene-

ﬁts the utility using mathematical, statistical and some bio-

inspired artiﬁcial intelligence optimization techniques. These

approaches reduce the utility’s load by shifting the elec-

tricity power load on self-generated energy resources and

achieve the user comfort under various constraints. Authors

in [9]–[11], [13] and [15]–[25] formulate the problem as

SOO, where [12], [27], and [29] formulate the problem as

a MOO.

In this regard, in articles [9]–[13] and [15]–[18], authors

have discussed local optimization methods for energy

demand optimization. Article [9] formulated the ﬁnite time

horizon by considering the 30 minutes time-slot and mod-

eled mixed integer non-linear programming using Real Time

Price (RTP) tariff for scheduling. The proposed scheme

schedules the electrical and thermal appliances of a smart

home. This scheme reduces 22.2% cost for peak price and

11.7% for normal price scheme while shifting the peak

load on the thermal resources. Authors in [10] proposed a

linear programming based optimal scheduling technique to

minimize the electricity cost while focusing on the energy

storage. The discussed technique saved 20.39% average cost

and reduced 21.6% average peak load. Similarly, researchers

in [11], target the cost minimization and peak reduction in

order to balance the load for a single home using mixed

integer linear programming. Simulation results formulated

the real-time tariffs in the Czech Republic. The objectives

of [12] and [13] are: minimization of the overall electric-

ity production cost and the individual electricity bill. The

formulated model in [12] depends on the socio-economic

factors (employment status, family decomposition and num-

ber of occupants) and user preference. Simulation results

are conducted on real data provided by the Department of

Energy & Climate Change UK [14], with real-world electric-

ity prices by implementing the multi-objective mixed integer

programming. Authors in [13] and [15] used double coop-

erative game for energy management system. Simulations

are conducted by considering multiple utilities and multiple

consumers with plug-in electric vehicles by [13] and [16] and

plug-in electric bicycles used in the study in [15] which are

allowed to discharge electricity and sell out surplus power

back to respective utilities. Results illustrate that the pro-

posed approach satisﬁes both the electricity provider and the

consumer.

19512 VOLUME 6, 2018

TABLE 1. Literature survey.

The peak demand determination’s model in a resi-

dential area is presented by [17] under RTP for four

different scenarios. In order to express the ﬁnite number of

appliances, quasi random process is implemented and recur-

sive formula is developed to determine the peak demand.

The results achieved from this approach are compared with

undeﬁned number of appliances which may cause seri-

ous peak. Smart HEMS algorithm is proposed in [18] to

reduce the cost and overall electricity usage under Time

of Use (TOU) pricing scheme without compromising user

comfort.

In [19]–[25] bio-inspired artiﬁcial intelligence based tech-

niques are used. In this regard, a distributed framework to

overcome the cost is deﬁned in article [19] for multiple users

under a grid, where greedy iterative algorithm is proposed to

schedule the appliances according to different modes (low,

medium and high) and the RTP signals. Each user has prior

knowledge of electricity price which is to be contingent on the

aggregated load on the grid. In this work, a penalty function

is deﬁned to establish the coordination among users. Exper-

imental results show that this algorithm reduces the con-

sumer’s electricity cost and minimizes generation cost with

respect to the peak load. Article [20] reported an autonomous

system that adapts the GA as an AI based technique, and

advances a communication technology. The proposed system

in [20] grounded on Distributed Generation (DG) patterns

allowed two way energy ﬂow to maximize user comfort in

case of minimum wait and electric energy purchasing cost.

Experimental results of four different scenarios demonstrated

the 32.73% highest electric cost saving among all scenarios.

However, authors have completely ignored DG’s mainte-

nance and installation cost.

VOLUME 6, 2018 19513

The DR problem like user discomfort is studied in [21].

In this research article, the authors formulate the energy man-

agement problem as a reinforcement learning problem based

on Markov’s decision process model. Simulation results are

expressed by using a Q-learning algorithm to design the

scheduler. Another phenomena of DR peak shaving in micro-

grid is studied by [22]. Rabiee et al., in [22] handled the

peak shaving, load curve amendment and compensate the

uncertainties of photovoltaic and wind power. Binary Particle

Swarm Optimization (BPSO) algorithm is used for simul-

taneous scheduling of responsive load and electric vehicles

in the presence of photovoltaic and wind power. Simula-

tion results show that this approach reduced the cost and

emission. Rahim et al., in [23] present DSM controller to

avoid peak by using GA, BPSO and Ant Colony Optimiza-

tion (ACO) algorithm. Simulation results show that the GA

performs well as compared to the rest of the approaches. User

comfort is formulated as cost minimization and reduction

in appliance’s waiting time by [24]. In this article, Wind

Driven Optimization (WDO) algorithm is adapted and the

home appliances scheduling problem is formulated as a min-

max regret-based knapsack to minimize the cost and peak

load. The observational results show 8.7% PAR reduction and

39.04% electricity cost saving for TOU price tariff. Besides

all of these problems like high cost, user comfort and peak

load reduction, researchers also focused on the day-ahead

load forecasting to handle the situation for day-ahead price

tariffs. In this respect, authors in [25] adapt artiﬁcial neural

network for day-ahead load forecasting and achieve 97.11%

accuracy.

Authors in [27] targeted both SOO and MOO, where

the dynamic programming is adapted for a single objective

optimization with the targeting objectives: minimization of

electricity cost and CO2emissions, and maximization of total

allowed power demands. On the contrary, MOO is solved

by adopting the Evolutionary Algorithm (EA). The targeted

conﬂicting objectives in this article are: minimizing the elec-

tricity cost, maximization of the total number of allowed

power demand requests, minimization of CO2emission and

the maximization of the total number of allowed power

demand requests. To solve the MOO problem, [29] presents

different comfort levels to compute the user’s comfort level.

Simulation is performed using a modiﬁed PSO to solve the

conﬂicting objectives like: cost minimization and user com-

fort maximization.

In the literature, proposed SG and DSM systems mounted

with RES and storage devices must have charging and

the maintenance cost. Some techniques, as discussed above

like [9], [10], [13], [15] and [21]–[32], implemented RES

and storage devices. However, [13] ignored the charging cost

and [21], [24], and [25] did not analyze their installation and

maintenance cost. Whereas, in this article proposed HEMS

reduces the electricity cost and PAR without using any stor-

age or renewable device, while establishing the coordina-

tion among user and scheduler, and the scheduler and home

appliances.

III. PROBLEM STATEMENT

Since its existence, the DSM came up with numerous chal-

lenges like: load shifting, communication, fairness, security

and privacy [30]. DSM strategies are developed to overcome

the irregular usage of electric load on the consumer end. This

irregular usage is a challenging task to handle, because it

increases the load on the utility and generation units. The

extra generation of electricity is required because of high

demand in some speciﬁc hours (On-peak hours) resulting

in high electricity cost. In this regard, efﬁcient algorithm

for HEMS is required which helps users to shift the load

from On-peak to Off-peak hours in a balanced way. Though,

many systems like [9]–[13] and [15]–[35] have been devel-

oped to minimize the cost, PAR and discomfort, however,

the trade-off always occurs between cost and PAR, and cost

and comfort. The discussed targets have trade-off and are

not fully considered by all researchers, as authors in [10],

[11], [15], [17], and [19] did not consider user comfort. The

PAR is ignored by [12], [17], [19], and [20] which has bur-

dened the utility and generation units by creating the peak on

Off-peak hours, this is problematic, especially for day-ahead

or seasonally deﬁned price signals.

As it is clear that the cost and PAR can be reduced

by employing load shifting or using some other strategies,

e.g., proposed solutions in [10], [13], [15], [21], [24], and [25]

have incorporated Renewable Energy Resources (RES) to

reduce cost and PAR. Also ﬂuctuation in the generation of

RES is possible because of varying weather conditions sea-

sonally as cited by [22]. In particular, when conditions for

RES do not meet the needed energy (e.g., solar system may

produce low energy during the winter and cloudy days).

Efﬁciency does not only mean to reduce the On-peak hours

load or cost minimization, besides, other factors are also

involved. As discussed earlier, user comfort with respect to

the waiting time of appliance is an important factor. On the

other hand, scheduler’s suppleness can deal with sudden

changes without effecting demanded load and overall cost.

Researchers in [12] dealt with changes made by the user in

scheduling. However, demanded changes are executed during

a next day period. Authors in [27] performed rescheduling

on the basis of power demand. In this regard, high priority

appliance(s) are switched ON according to user requirements

in real-time and rescheduled to any other scheduled appliance

during another hour, which can create peak on end hours

because of static inputs for day-ahead scheduling. In order

to enable dynamic scheduling as per the consumer require-

ments, rescheduling the appliance’s operation needs ﬂexibil-

ity such that neither it creates peak nor it has much effect on

the total cost and PAR.

IV. PROPOSED SYSTEM MODEL

Due to energy constraints, HEMS is widely accepted to

efﬁciently utilize the energy. The overall framework of

HEMS consists of a control, monitoring and a management

unit. The monitoring unit monitors the user power demand,

price signals and electricity generation for the current time.

19514 VOLUME 6, 2018

FIGURE 3. Overview of the proposed system model and information flow between service provider and smart home user.

The management unit schedules the home appliances and

the control unit decides which appliance to turn ON or OFF

according to the assigned working hours. The success of

HEMS depends on the fair coordination between the user and

the system. In this way, the proposed system model focuses

on a scheduler working under the management unit. Dealing

with user run-time demand and electric appliances’ schedul-

ing are the responsibilities of a management unit.

An overview of the proposed system model and the infor-

mation ﬂow between the system components are illustrated

in Fig. 3. This demonstrates the information exchange and

power ﬂow between the service provider and the smart home.

The service provider ensures power reliability by enabling

the power transfer from the power generation plants to trans-

mission lines. The upstream utility grid sends the price of

the generated power to the smart meter deployed in each

smart home, where each smart home is equipped with a

HEMS. The smart meter acts as a gateway to exchange the

information between the consumer and the utility. In addition,

a smart meter consists of many components like embedded

computing platform, etc. The embedded computing plat-

form schedules the activities of the smart meter. Further,

the proposed optimization technique for HEMS schedules

the load demand of a consumer on day-ahead and real-

time basis using meta-heuristic and dynamic programming.

The real-time scheduling is implemented using a dynamic

programming by enabling coordination between the user

and the scheduler when an interrupt is generated by the

user.

The main objective of our proposed framework is: load

shifting to reduce the electricity cost and the PAR. During

load shifting, the load curve should be as close as possible to

the objective load curve. As explained in [8], if the objective

is to reduce the electricity cost, then the chosen objective

load curve should be inversely proportional to the electricity

market price. It also helps to make the system ﬂexible in

order to respond to changes in real-time. In our scenario,

the targeted objective load curve is based on the deﬁned

constraints of ﬁtness function given in Equation 4a. The sec-

ond main objective is that our proposed system can provide

VOLUME 6, 2018 19515

TABLE 2. Appliances used in simulations.

real-time scheduling. This will make the system ﬂexible

which in turn will provide users’ comfort.

A. PROBLEM FORM ULATION

The proposed HEMS shifts the load on a day-ahead and

real-time scheduling basis. Considering both of the schedul-

ing techniques, we focus on achieving multiple objectives.

The day-ahead objective includes the minimization of the

electricity cost, PAR and minimizing the distance between

the objective load curve and the actual energy consumption

pattern. The MOO model for home load management is given

by the following:

1) MOO MODEL FOR DAY-AHEAD AND REAL-TIME

HOME LOAD MANAGEMENT

a: LOAD SHIFTING

The proposed algorithm schedules the appliances to bring

consumption schedule load curve closer to the objective load

curve. The power load shifting technique is mathematically

formulated as given in [8]:

O1=min(Eschhour

load −objhour

lcurve ).(1)

The objective load curve objhour

lcurve has an inverse relation with

Ehour

price, this relation is mathematically modeled as follows:

objhour

lcurve ∝1

Eschhour

price

(2)

where Eschhour

load is the per hour scheduled electric power load

calculated using Equation 3. Where Eload represents the

aggregated load of ON appliances during a particular time.

Eload =

M

X

d=1

Appd

Prate ×℘. (3)

℘=1,0 is the ON or OFF status of an appliance during a

particular hour.

The above targeted objhour

lcurve is obtained using the constraints

in Fitness Function (Ff) presented in Equation 4. This deﬁned

function helps to ﬁnd out the optimal solution from the

search space, Ffselects the ﬁttest individual from the given

population PoP, to avoid the peak during the Off-peak hours.

Ff=min(FPoP) (4)

where FPoP is calculated using Equation 4a,

FPoP =(EiPoP

load ≥Pl1,if Hoff

p,

EiPoP

load >Pl2∧EiPoP

load <Pl3,if Hon

p.(4a)

Pl1=sum(Loadh

N)−std(Eunsch

load ),(4b)

Pl2=std(Eunsch

load )+η×min(Eunsch

load ) (4c)

Pl3=mean(Eunsch

load ) (4d)

Loadh

N=Eunsch

load (h)−min(Eunsch

load )

max(Eunsch

load )−min(Eunsch

load ),(4e)

where the value of ηis chosen such that the minimum load

limit for On-peak hours should be less than the minimum

limit of Off-peak hours. In our case η=2 and Loadh

N

is in the normalized form for uniform distribution ∀h∈

{1,2, ....., 24}.

The Off-Peak power limit (Pl1) and On-Peak power limit

Pl2are calculated using Equations 4b and 4c, respectively, so

that fair load distribution at the user’s end can be achieved by

the home load management scheduler. Where, EiPoP

load is the

calculated load for a single chromosome or bacteria ifrom

the generated solution space using Equation 3. On-peak hour

is mathematically represented as Hon

p>mean(Eprice) greater

than the mean of electric price list Eprice and Off-peak hour is

mathematically represented as Hoff

p≤mean(Eprice) less than

or equal to the mean of the price list.

b: ELECTRICITY COST MINIMIZATION

The second objective is the cost minimization which can be

mathematically written as follows:

O2=min(Etotal

cost ) (5)

The electric cost is minimized by the following objective load

curve, so O1deﬁned in Equation 1is used as a constraint here.

Etotal

cost =

24

X

hour=1

(Ehour

cost ) (6)

where Ehour

cost per hour cost is calculated using Equation 7,

Ehour

cost =

M

X

d=1

(Ehour

price ×Appd

Prate ×℘) (7)

Appd

Prate of each appliance is given in Table 2.

19516 VOLUME 6, 2018

c: PAR REDUCTION

Ensuring the grid’s stability is one of our core objectives

which is achieved by minimizing the PAR. Mathematically,

it can be written as follows:

O3=min(PAR) (8)

which is automatically accomplished by Equation 1. For-

mally, the PAR can be written as:

PAR =max(EschN

load )2

(avg(EschN

load ))2(9)

where EschN

load ={Esch1

load ,Esch2

load ,Esch3

load , ...., Esch24

load } is a list of per

hour scheduled electricity load calculated using Equation 3.

d: USER COMFORT MAXIMIZATION

In a practical situation, consumers require some ﬂexibil-

ity to schedule home appliances, where a user can switch

OFF an appliance and can demand to reschedule any other

appliance(s) according to the requirement. This rescheduling

somehow reduces the waiting time of user to turn ON the

required appliance. When an appliance is rescheduled on

demand, then its waiting time is considered zero regard-

less of the user previous demand time. We focus on max-

imizing the user’s comfort, which can be mathematically

expressed as:

O4=max(Comfort ).(10)

Where comfort is achieved by incorporating the coordination

between the scheduler and the user, when the scheduler gets

interrupt Î by the user to switch OFF an appliance and a

request for real-time rescheduling from Appα

c. This can be

formally expressed as:

Appα=(1,if ˆ

I,

0,otherwise .(11)

The user comfort and waiting time Appd

Wthave an inverse

relation, this relationship can be mathematically presented as

follows:

Comfort ∝1

Appd

Wt

(12)

where Appd

Wtis the waiting time of a particular appliance d,

it can be calculated as:

Appd

Wt=min|Appd

Dh−Appd

Sh|.(13)

2) MODEL TRANSFORMATION

The proposed MOO model discussed in Section IV-A.1 is

transformed into SOO. The proposed HEMS model is divided

into two parts, one is day-ahead scheduling and second is,

real-time rescheduling. The targeted objectives are: electric-

ity cost, PAR minimization and user comfort maximization.

However, due to the dependency of performance parameters

on each other, a trade-off always exists. In order to minimize

FIGURE 4. Graphical representation of feasible search space.

the trade-off between electricity cost and PAR for day-ahead

scheduling, we have used a constraint based MOO method.

In this scenario, O1is considered as the main objective which

is accomplished using the linear Equations 4a and 5. These

equations are used as constraints of O1. The graphical rep-

resentation of the linear Equation 4a is shown in Fig. 4for

On-peak and Off-peak hours. This graphical representation

illustrates that the selected feasible solution from the deﬁned

feasible region not only reduces the cost, but also maintains

the load curve which further helps to avoid the peak formation

(i.e., O3). On the other hand, for real-time rescheduling,

objective O4is considered. In order to minimize the trade-

off, we use the weighted sum MOO method as given in [29]

which is mathematically expressed as:

λ×(O1)+(1 −λ)×O4,

such that 4a,5and 13.(14)

Where λ=1 shows that during day-ahead scheduling the

user comfort is ignored.

B. PROPOSED ALGORITHM

The purpose of our work is to incorporate scheduling and

encourage coordination between a user and the scheduler.

Moreover, its ﬂexible nature allows the user to request ter-

minating an appliance and reschedule another appliance(s)

at any time during working hours. Our proposed home load

management scheduler has two distinct algorithms as dis-

cussed below:

1) DAY-AHEAD SCHEDULING

Algorithm 1 is designed for day-ahead scheduling where

optimal solution is selected on the basis of Equation 4from

the search space provided by HBG.

The HBG, is proposed to ﬁnd out an efﬁcient solution

that has qualities of both bio-inspired optimization techniques

BFA and GA. There are many reasons to adopt bio-inspired

meta-heuristic optimization techniques, such as: simplicity,

ﬂexibility and ergodicity [33]. First, most of these algorithms

VOLUME 6, 2018 19517

Algorithm 1 HBG for Scheduling in SG

Initialization (PoP,Np,Ne,Nr,Nc,Ns,C)

Evaluate the initial PoP using Equation 15

Jlast ←Ji

1: for l=1→Nedo

2: for k=1→Nrdo

3: for j=1→Ncdo

4: for i=1→Npdo

5: Tumble the bacteria and ﬁnd new position

θi[j,k,l] for PoP

Compute the Fitness Ji[j,k,l]

6: for s=1→Nsdo

7: if Ji<Jlast then

8: Jlast ←Ji

9: Move bacteria according to the current

position

10: else

11: Tumble bacteria and move in that direc-

tion

12: end if

13: end for

14: end for

15: end for

16: Calculate Ffand select the best bacteria form search

space using Equation 4

17: end for

18: Elimination-dispersal step using GA

Start GA for maximum iteration

End GA

19: Sch(l)←best

20: end for

are simple to implement as compared to other deterministic

techniques. Second, it is ﬂexible in a sense that these can

deal with a broad range of problems. Last, some of the tech-

niques have the ability to deal with ergodicity because they

can easily escape from the local minima. Ergodicity occurs

due to some nature process like crossover and mutation,

and statistical models such as random walks. Using meta-

heuristic techniques, one can get an optimal solution with

multiple objectives within one run. In addition, non-meta-

heuristic techniques require many assumptions whereas,

meta-heuristic techniques make few or no assumptions at

all [34].

Authors in [35] highlighted that searching ability of

any optimization technique can be divided into local and

global search ability. The BFA emphasizes on a local search

whereas, the GA focuses on a global search. Both techniques

are known as best searching approaches; however, both tech-

niques have some shortcomings. The GA has a convergence

problem, i.e., it requires maximum iterations and huge search

space. On the other hand, the elimination and dispersal step

of BFA diverges from the optimal solution. To avoid these

limitations, the HBG is proposed which has qualities of both

the GA and the BFA algorithms.

a: GA

An evolutionary meta-heuristic algorithm generates an opti-

mal solution search space for optimization problems. The

basic structure of the GA is based on the chromosomes. In this

section, we elucidate the steps of GA deﬁned in [36]. The GA

starts its working with the population size Npof chromosomes

which we generate randomly in a binary form, because of

ON or OFF status of appliances. Each chromosome has a

ﬁtness value Ff. Roulette wheel, a probabilistic based selec-

tion method is used to select two parents to produce new

offspringsusing crossover with probability pc, and mutation

probability pm =1−pc. After maximum generations, the

best solution is selected on the basis of constraints deﬁned in

Equation 4(a).

b: BFA

A meta-heuristic optimization technique was introduced by

Passino in [37]. Its working architecture is based on poor

foraging strategies. The detailed working strategy of BFA

is illustrated in Fig. 5. The algorithm’s statistic behavior

that allowed the cell to swarm stochastically and collectively

towards the optimal solution, encouraged us to implement

the BFA for optimal scheduling. In this section, we discuss

the steps of BFA to solve the scheduling problem. The BFA

starts by randomly generating a population of ﬁxed size Np,

where each swarm is considered as bacteria and each bacte-

ria contains Dbacterium. Initially, we calculate the ﬁtness

Jiof each bacteria. There are three main steps of BFA:

1) ‘chemotaxis’ length of life time of bacteria is measured by

the number of chemotactic steps. The ﬁtness Jiof bacteria is

calculated by the proximity to each bacterium’s new position

θd

iafter a tumble along the manipulated cost surface one at a

time by adding step size C. The value of Jiis calculated using

the function of Rosenbrock given in Equation 15. A random

direction vector 4ifor ith bacteria is generated to represent

the tumble movement. 2) ‘Reproduction’ where only those

cells will contribute to the next generation that performed

well over their lifetime. 3) ‘Elimination-dispersal’ where

cells are discarded and new random samples are inserted with

a low probability. At the end of all these steps, the best one is

selected as a schedule, based on Fffrom the updated PoP.

Ji[j,k,l]=

M

X

d=1

(100 ×(θ(i,d+1) −(θ(i,d))2)2

+(θ(i,d)−1)2).(15)

Where θiis calculated using Equation 16.

θi[j,k,l]=θi[j−1,k,l]+C4i

p4τ

i4i

(16)

c: HBG

The optimal search space in HBG is created using

BFA and GA. In order to explain each step of the pro-

posed algorithm precisely, HBG is explained in Algorithm 1.

In HBG, the steps of BFA are followed as explained in

previous section with the difference in elimination and

19518 VOLUME 6, 2018

FIGURE 5. Flow chart of BFA.

dispersal step. In BFA, after the reproduction step, the bac-

teria that survives for the next generation are randomly elim-

inated and dispersed. In HBG, the random elimination and

dispersal step is performed using crossover and mutation.

2) REAL-TIME SCHEDULING

To reschedule the appliances during the working hour is a

challenging task, where we have to shift the working hour

of an appliance while considering the user comfort. How-

ever, we cannot neglect the On-peak and Off-peak hours

and the electricity cost. Here, it is worth mentioning that

Algorithm 2 Real Time Coordination Among Appliances to

Handover the Working Time-Slot Using Knapsack: Dynamic

Programing

Input: (Sch,APPSch

d)

for Hour =1→24 do

2: if ˆ

I==yes then

Ask for APPof and Calculate the remaining time

Timeaval

4: end if

if APPα

c>0then

6: for c=1→Length(APPα

c)do

if APPSchh

c(Hour :end)>0then

8: Maintain Listhour ,Listint

time and Value

end if

10: end for

end if

12: if Listhour >0then

KnapCap ←Timeaval and VAR ←KnapCap

14: n=Length(Listhour )

Create a Table Tof size n+1×KnapCap +1

16: Set T[1 →n+1,1→KnapCap +1] =0 To

keep the record for possible solution set for cost

maximization and inf for minimization

Set S[1 →n+1,1→KnapCap +1] =0 Update

value as 1 if decide to select the solution

18: for ´

i=2→n+1do

for ´

j=2→KnapCap +1do

20: if Listint

time(´

i−1) <´

jthen

Update T[´

i,´

j] using Equation 18

22: Update S[´

i,´

j] using Equation 19

else

24: T[´

i,´

j]←T[´

i−1,´

j]

end if

26: end for

end for

28: Start process to select the optimal solution

for ´

i=n→1do

30: if S(i,VAR)== 1then

SolSet (´

i)←1

32: VAR ←VAR −List int

time(´

i)

else

34: SolSet (´

i)←0

end if

36: end for

end if

38: Update the Sch according to the SolSet

Switch OFF APPof and switch ON APPαaccording to

SolSet

40: end for

in our approach an appliance can be turned ON or OFF

during a given time interval through coordination as shown

in Fig. 6. In order to elaborate coordination between a user

and the scheduler, Algorithm 2 is given. Algorithm 2 starts

its processing when an interrupt is generated by the user.

VOLUME 6, 2018 19519

FIGURE 6. Coordination among appliances: an example scenario.

As an example: the scheduler maintains a list αof appliances

that a user wants to reschedule. The rescheduling problem is

formulated as a knapsack problem, where knapsack capacity

is considered as an available time interval. The weight of an

item is taken as available operational time of an appliance

and its value as cost during a particular hour according to

the price signal and operational time. The optimal solution

is computed by selecting the small items having a minimum

weight with a maximum value. Moreover, the total weight of

selected individuals should be less or equal to the knapsack

capacity.

Dynamic programming is used to solve the knapsack prob-

lem, which was introduced by Bellman [38]. It divides a

complex problem into overlapped subproblems which are

solved with the help of recursive bottom-up method. In a

real-time scenario, dynamic programming provides the

appropriate basis for compiling results. Based on the dynamic

programming strategy, the knapsack problem is divided into

nsubproblems and solution of each problem is maintained

in a table. In our work, small items having largest val-

ues, i.e, electricity cost are selected for Off-peak hours,

where a large item with small values are used to represent

On-peak hours. Results are computed using Equation 18 and

maintained in T[´

i,´

j]. The possible solution which covers the

maximum capacity and maximum beneﬁt is stored in S[´

i,´

j]

and optimal solution is selected using Equation 19.

KS1,2

De=[T[´

i−1,´

j],Value(´

i−1) +T[´

i−1,´

ij

−Listtime(´

i−1)]].(17)

19520 VOLUME 6, 2018

T[´

i,´

j]=(max(KSDe),if Hoff

p

minKSDe,if Hon

p

(18)

S[´

i,´

j]=(1,if T[´

i,´

j]== KS2

De

0,Otherwise (19)

V. SIMULATION RESULTS AND DISCUSSION

In this section, the performance of the proposed system is

validated through performing simulations in MATLAB and

the results are discussed hereafter. The results are conducted

for three pricing tariffs RTP, TOU and Critical Peak Pric-

ing (CPP) using HBG before and after coordination. Further,

results of our proposed technique are compared with GA

and BFA. We consider a single home with nine appliances,

i.e., M=9 that needs to be scheduled. For simulation pur-

poses, these appliances are grouped into three categories:

group A, group B and group C. These appliances are selected

because of their extensive usage throughout the year (e.g., AC

used for both cooling and heating purposes). Group A con-

tains the interruptible burst load appliances which includes

vacuum cleaner, water heater, water pump and dish washer.

These appliances can be turned ON at any time during the

day. Group B contains base load interruptible like refrigera-

tor, air conditioner and oven. Group C has non-interruptible

appliances that cannot be interrupted during their operational

cycle, e.g., washing machine and cloth dryer. In our work, we

consider that the cloth dryer will always be scheduled after

the washing machine. However, a user will be allowed to turn

OFF any appliance at any time.

In this scenario, to incorporate coordination, the vac-

uum cleaner and dish washer are selected for rescheduling,

because their working time is less than or equal to an hour

and can be called out 6 to 8 times in a day. A user will deﬁne

the operational time for a speciﬁc slot before scheduling, here

for simulations, the operational time is allocated randomly.

In this case, the knapsack weight capacity is the maximum

available time interval that is calculated as: Timeaval =

60-Interpt, where Interptis the time when a user requests

to switch ON an appliance and demands another appliance’s

rescheduling. The knapsack weight of an item in our case is

the available working time-slot of appliance in list α. Where

the item’s value is the cost during a particular interrupted hour

calculated using Equation 7. The power rating of appliance’s

and daily usage is listed in Table 2.

Fig. 10(a-c) right axis shows the price signals, Fig. 10(a)

represents the RTP price signals which are taken from [7].

TOU price tariff is taken from [39] and highlighted in

Fig. 10(b), here the price tariff is divided into three time

zones: On-peak hours 11:00am-4:00pm, MID-peak hours

7:00am-10:00am and 5:00pm-6:00pm and Off-peak 1:00am-

6:00am and 7:00pm-12:00pm. Where Fig. 10(c) shows the

CPP rate taken from [39], this price tariff has 11:00 am-

4:00 pm On-peak and 1:00am-10:00am and 5:00pm-12:00pm

Off-peak hours. To perform simulations for the TOU tariff,

only On-peak and Off-peak hours are considered. Where

shoulder or MID-peak hours are taken as On-peak hours.

A. PRICE TARIFF

As discussed earlier, the performance of the proposed sys-

tem is evaluated using three price tariffs. These tariffs are

discussed in the following subsection.

1) RTP

The RTP known as a dynamic price rate is grounded on the

hourly usage of electricity [40]. Utilities regulate the RTP in

two parts and the overall bill is the sum of these parts:

(a) Base bill is calculated on the basis of standard deﬁned

tariff for a particular customer depending on Customer

Baseline Load (CBL).

(b) Hourly prices are applied according to the consumer

usage that is the difference between the actual and the

CBL usage. Each user has to pay a wQ∗ﬁxed hourly

charges regardless of what pricing scheme has been

adopted.

When a customer chooses a pricing scheme like RTP, it means

that the user is saving amount (Ph−Ws)4QH, where Ph

is the energy rate an applicant requests, QHis the unit of

electricity. The RTP energy rate PRTP shown in Equation 20

is set between cmarket price and standard energy tariff’s

charges Ws. The standard of the RTP deﬁnes when the energy

rate is PLand customer wants to upturn the electricity usage

above the level QL. Such customer has to pay Wsfor each unit

up to Q∗, moreover will pay variable costs PLfor each unit

after Q∗[40].

PRTP =(WQ∗if ELoad ≤Q∗,

WQ∗+PLotherwise.(20)

2) TOU

TOU is known as the time based pricing scheme, prices are

set by [41] for the On-peak and Off-peak hours, where a

day is divided into multiple blocks and price for a particular

block remains ﬁxed. DTOU represents the total amount of

saving shared between Local Distribution Company (LDC)

and customer. Cost reduction (σ0−σ1) is achieved by shifting

a maximum load demand and the total cost ζsaving fraction

that LDC passes. This is applicable for those customers who

consume cost QTOU after taking the option.

DTOU =ζ(σ0−σ1)QTOU .(21)

3) CPP

Critical events may occur during a speciﬁc period of time

when utilities observe high market price rate or during the

system emergency conditions that usually occur in hot sum-

mer weekdays. The electricity rates during this time period

are usually high. Two variants of CPP have been deﬁned:

one where the time and duration of peak price are prede-

ﬁned and second, when the increase in price may depend on

the electricity need to reduce the load. These critical hours

are not allowed to occur more than ﬁfteen times during a

season [40].

VOLUME 6, 2018 19521

FIGURE 7. Per hour scheduled load before coordination along price tariff

and objective load line. (a) RTP. (b) TOU. (c) CPP.

The simulation results are discussed in two subsections:

the effect of scheduling on electricity cost and PAR before

and after coordination. Unscheduled values represent user

demand and its consequences on daily electricity charges

and PAR.

FIGURE 8. Effect of coordination during real-time scheduling on electric

load profile. (a) RTP. (b) TOU. (c) CPP.

B. RESULTS BEFOR E COORDINATION

To evidently analyze the generic behavior of the proposed

solution, three different pricing rates: RTP, TOU and CPP are

tested. Fig. 11 and Fig. 12 show that price for unscheduled

19522 VOLUME 6, 2018

FIGURE 9. Electricity cost before coordination with detail price signals.

(a) RTP. (b) TOU. (c) CPP.

load is high for all three price tariffs. Fig. 11 and Fig. 12

depict the total unscheduled electricity cost 1840 cents for the

RTP rate, 1790 cents for TOU and 7190 cents for a particular

critical day using CPP.

FIGURE 10. Electricity cost of each hour during a day after coordination

with price signals. (a) RTP. (b) TOU. (c) CPP.

The simulation results before coordination are clear from

Figs. 7,9,11 and 13. The electricity load before and after

scheduling for 24 hours is revealed in Fig. 7which affect the

results in Fig. 9, Fig. 11 and Fig. 13. Where implemented

VOLUME 6, 2018 19523

TABLE 3. Performance trade-offs of scheduling techniques before coordination.

FIGURE 11. Total electricity cost before coordination for a day.

FIGURE 12. Impact of coordination on total electricity for a day.

optimization approaches help in shifting the load as shown in

Fig. 7which directly affects the cost. HBG shows relatively

low price signals for high peak hours. Another observation is

worth mentioning that the scheduled load curve is almost near

to the objective load curve. Fig. 9is a graphical representation

of per hour cost for an unscheduled and HBG proposed

approach along with GA and BFA. The results demonstrate

that the cost payed during On-peak hours is low compared to

an unscheduled load, because the load during the On-peak

hours has been shifted to Off-peak hours without creating

peak.

The trade-off between the cost and the PAR is elucidated

in Table 3. The RTP signal has a minimum PAR 1.88 for

the HBG which is 58.45% less as compared to unscheduled

PAR, where it has reduced the cost by 14% for HBG. On

the other hand, the waiting time for the HBG scheduler is

comparatively less as compared to the other three techniques

as shown in Fig. 16(a). For the TOU tariff, the HBG performs

better as compared to the other two approaches as it has

reduced 50% PAR and 18% cost. Though, the cost reduction

percentage of BFA is the same as HBG, on the other hand

its PAR and waiting time are comparatively higher than the

HBG. Where for the CPP, HBG again outperformed and

reduced 44% PAR and 42% cost. Though, PAR reduction

of GA is 59%, however, the cost and waiting time reduction

ratio of HBG is good. The overall results show that, HBG has

inﬂuence on the two approaches, where it shows minimum

cost and high PAR reduction with low convergence rate as

well as overall less waiting time as compared to BFA and GA.

C. RESULTS AFTER COORDI NATION

After coordination, the real-time rescheduling algorithm just

takes 0.0096 second(s) to complete the task. This reveals that

switching of appliances takes only 0.0096 second(s). Due to

the random user’s behavior, we have different coordination

loads for distinct adopted approaches. As discussed earlier,

Fig. 8right y-axis shows the price signals. It is clearly demon-

strated from Fig. 7and Fig. 8that any change during coordi-

nation did not affect the bonding between the objective load

curve and the scheduled load curves. Fig. 10 illustrates that

the electricity cost is relatively high during On-peak hours.

The unscheduled cost is high for all three pricing schemes

during On-peak hours. Fig. 8shows the load on the grid for a

single home using three pricing tariffs for a day. This shifted

load from On-peak to Off-peak hours reﬂect the effect on

the total cost as represented in Fig. 12 and on PAR as shown

in Fig. 14.

Regardless of adopted electricity price, Fig. 12 shows that

a swarm based approach has low price and PAR as com-

pared to evolutionary one’s, where their hybrid outperformed

both techniques. Fig. 12 evidently revealed 5%, 8% and 8%

less cost than the without coordination scheduled for GA,

BFA and HBG, respectively, using RTP. Where 5% max-

imum cost is reduced by HBG with 9% increase in PAR

and 15% decreased waiting time. The maximum reduction

in waiting time is observed 42% using HBG and BFA as

19524 VOLUME 6, 2018

TABLE 4. Performance trade-offs of scheduling techniques after coordination.

FIGURE 13. PAR for all proposed and adopted approaches without

coordination.

illustrated in Fig. 16. The overall graphs clearly illustrate the

difference between before and after coordination because of

reduction in the total demanded load and increase in the peak

load.

During coordination, the load curtailment occur which

reduced the cost, however, the PAR increases because some-

time it passes heavy load appliances which show the trade-

off between cost and PAR. Fig. 15 and Fig. 16 illustrate the

waiting time of appliances. It is envisioned that the waiting

time after coordination is less as compared to before coordi-

nation. This effect can be observed clearly for interruptible

load because the called appliances belong to the category of

interruptible loads and we consider the waiting time of called

appliances as zero.

D. DISCUSSION

Results demonstrate that a deﬁned Ffnot only reduced

the electricity cost, but it has also reduced PAR during

day-ahead scheduling which also helps in avoiding during

real-time rescheduling. Further, results show that there is a

trade-off among different performance parameters, which are

comfort (rescheduling), electricity cost and PAR. In addition,

our proposed algorithm enables the coordination mechanism

among scheduler and user, and between the appliances to

maximize the user comfort. However, this effects the cost and

PAR in some extent as shown in Table 3and 4.

FIGURE 14. PAR for all proposed and adopted approaches with

coordination.

TABLE 5. After coordination effects on different performance parameters.

Our proposed algorithm develops the coordination to max-

imize the user comfort. Table 5shows the affect on elec-

tricity cost, PAR and waiting time after coordination. From

these results, it is analyzed that after coordination, elec-

tricity cost and the waiting time is reduced where PAR is

increased. In the example scenario, before and after wait-

ing time difference is calculated for base load interruptible

appliances only because, listed re-schedulable appliances

belong to this category. The waiting time of rescheduled

appliances is calculated and is zero after dynamic scheduling

which shows the considerable difference between the wait-

ing time of appliances before and after the coordination as

VOLUME 6, 2018 19525

FIGURE 15. Average waiting time of appliances with respect to

categorization. (a) RTP. (b) TOU. (c) CPP.

illustrated in Table 5. The simulation results revealed the

high performance of HBG compared to the other two

approaches as it does not have much difference for all pricing

schemes.

FIGURE 16. Effect of real-time rescheduling on waiting time of

appliances. (a) RTP. (b) TOU. (c) CPP.

The performance of an optimization technique is not only

measured on the basis of output especially when dealing with

random input, because each time the system shows different

results. As discussed in the day-ahead scheduling section, the

19526 VOLUME 6, 2018

TABLE 6. Performance analysis of optimization techniques.

BFA and GA get trapped in local minima and global mimina,

respectively. For this purpose, to evaluate the system perfor-

mance, the conﬁdence interval is calculated for the average

results to check the variation and convergence percentage.

Table 6shows the conﬁdence interval of 95% between lower

and upper endpoints for an average of ﬁve iterations. HBG

has shown 3.5% least percentage difference between lower

and upper cost and only 10% for PAR using RTP where

GA has highest difference for cost about 73%. On the other

hand, for TOU, this difference is 2% and 35% for cost and

PAR, respectively. For CPP, HBG again outperforms with the

minimum difference of 17% for cost and 0% for PAR where

this difference comparatively high for simple GA and BFA.

These results show that the conﬁdence interval of HBG is

high compared to the GA as there is less ﬂuctuation between

the lower and upper output even in case of random input,

i.e., the performance level of a hybrid approach is compara-

tively good. From the above discussion, we conclude that our

proposed technique outperforms other techniques in terms of

electricity cost, PAR ratio and waiting time reduction.

Regardless of the optimization techniques used, and in

terms of price tariffs, the TOU is more economical than the

other two discussed price tariffs. The CPP tariff shows a

maximum cost and PAR reduction ratio than the other two

tariffs because its On-peak hours duration is relatively very

high.

VI. CONCLUSION AND FUTURE WORK

In this work, a HEMS is proposed, in which the load shift-

ing strategy of DSM is implemented to achieve the desired

objectives. This study considers a single home which con-

sists of multiple home appliances. Each appliance in the

smart home is scheduled using the proposed optimization

technique, HBG. The proposed technique helps to ﬁnd the

most optimum schedule of each home appliance considering

system constraints. The scheduling is done based on day-

ahead and real-time basis. The real-time rescheduling pro-

cedure helps to handle interrupts generated by the energy

consumer to turn on some other home appliance. Therefore,

the most feasible solution is to allow dynamic scheduling

through the coordination of appliances. For this purpose, we

have incorporated a coordination among home appliances

using dynamic programming techniques. Whereas, the per-

formance of the HEMS is evaluated using different pricing

schemes. From the simulation results we conclude that the

coordination in real-time rescheduling does not effect the

electricity cost and PAR signiﬁcantly. Moreover, we compare

the results of the proposed approach with the GA and the

BFA to check its efﬁciency. Results show that the PAR and

electricity costs are reduced upto 50% and 40%, respec-

tively. Further, we analyze the behavior of RTP, TOU and

CPP to check the performance of HEMS. However, these

price signals do not affect the performance of the scheduler

as we analyze the behavior of these pricing schemes. This

shows that our proposed approach efﬁciently schedules home

appliances using all the pricing signals. However, TOU is

economical as compared to the rest of other techniques.

In the future, we will investigate the relationship of the

electricity cost, PAR, and waiting time in order to optimize

the performance of the system. In addition, to make the

scheduling dynamic, we have planned to incorporate the

concept of coordination among the homes to maximize the

user comfort and to minimize the electricity cost.

REFERENCES

[1] M. S. Gul and S. Patidar, ‘‘Understanding the energy consumption and

occupancy of a multi-purpose academic building,’’ Energy Buildings,

vol. 87, pp. 155–165, Jan. 2015.

[2] United States Department of Energy, Washington. Energy Informa-

tion Administration. Accessed: Dec. 17, 2015. [Online]. Available:

https://www.eia.gov/todayinenergy/detail.cfm?id=12251

[3] C. W. Gellings, ‘‘The concept of demand-side management for electric

utilities,’’ Proc. IEEE, vol. 73, no. 10, pp. 1468–1470, Oct. 1985.

[4] J. H. Broehl et al., ‘‘Demand-side management. Volume 1. Overview

of key issues,’’ Synergic Resour. Corp., Bala-Cynwyd, PA, USA,

Final Rep. EA/EM-3597, Aug. 1984.

[5] J. H. Broehl et al., ‘‘Demand-side management. Volume 3. Technology

alternatives and market implementation methods,’’ Electr. Power Res. Inst.,

Palo Alto CA, USA, Final Rep. EPRIIAVEM-3597, 1984.

[6] B. Davito, H. Tai, and R. Uhlaner, ‘‘The smart grid and the promise

of demand-side management,’’ McKinsey Smart Grid, vol. 3, pp. 8–44,

Jan. 2010.

[7] L. Gelazanskas and K. A. Gamage, ‘‘Demand side management in smart

grid: A review and proposals for future direction,’’ Sustain. Cities Soc.,

vol. 11, pp. 22–30, Feb. 2014.

[8] T. Logenthiran, D. Srinivasan, and T. Z. Shun, ‘‘Demand side management

in smart grid using heuristic optimization,’’ IEEE Trans. Smart Grid, vol. 3,

no. 3, pp. 1244–1252, Sep. 2012.

[9] S. Elham and J. Shahram, ‘‘Optimal residential appliance scheduling

under dynamic pricing scheme via HEMDAS,’’ Energy Buildings, vol. 93,

pp. 40–49, Apr. 2015.

[10] C. O. Adika and L. Wang, ‘‘Smart charging and appliance scheduling

approaches to demand side management,’’ Int. J. Elect. Power Energy Syst.,

vol. 57, pp. 232–240, May 2014.

[11] Z. Bradac, V. Kaczmarczyk, and P. Fiedler, ‘‘Optimalscheduling of domes-

tic appliances via milp,’’ Energies, vol. 8, no. 1, pp. 217–232, 2014.

[12] R. Jovanovic, A. Bousselham, and I. S. Bayram, ‘‘Residential demand

response scheduling with consideration of consumer preferences,’’ Appl.

Sci., vol. 6, no. 1, pp. 1–16, 2016.

[13] B. Gao, X. Liu, W. Zhang, and Y. Tang, ‘‘Autonomous household energy

management based on a double cooperative game approach in the smart

grid,’’ Energies, vol. 8, no. 7, pp. 7326–7343, 2015.

[14] Q. Qdr, ‘‘Beneﬁts of demand response in electricity markets and recom-

mendations for achieving them,’’ U.S. Dept. Energy, Washington, DC,

USA, Tech. Rep., Feb. 2006.

[15] B. Gao, W. Zhang, Y. Tang, M. Hu, M. Zhu, and H. Zhan, ‘‘Game-

theoretic energy management for residential users with dischargeable

plug-in electric vehicles,’’ Energies, vol. 7, no. 11, pp. 7499–7518,

2014.

[16] P. Mesaric and S. Krajcar, ‘‘Home demand side management integrated

with electric vehicles and renewable energy sources,’’ Energy Buildings,

vol. 108, pp. 1–9, Dec. 2015.

[17] J. S. Vardakas, N. Zorba, and C. V. Verikoukis, ‘‘Power demand control

scenarios for smart grid applications with ﬁnite number of appliances,’’

Appl. Energy, vol. 162, pp. 83–98, Jan. 2016.

VOLUME 6, 2018 19527

[18] J. Abushnaf, A. Rassau, and W. Gornisiewicz, ‘‘Impact on electricity use of

introducing time-of-use pricing to a multi-user home energy management

system,’’ Int. Trans. Elect. Energy Syst., vol. 26, no. 5, pp. 993–1005,

2015.

[19] P. Chavali, P. Yang, and A. Nehorai, ‘‘A distributed algorithm of appliance

scheduling for home energy management system,’’ IEEE Trans. Smart

Grid, vol. 5, no. 1, pp. 282–290, Jan. 2014.

[20] M. H. Elkazaz, A. Hoballah, and A. M. Azmy, ‘‘Artiﬁcial intelligent-based

optimization of automated home energy management systems,’’ Int. Trans.

Elect. Energy Syst., vol. 26, no. 9, pp. 2038–2056, 2016.

[21] Z. Wen, D. O’Neill, and H. Maei, ‘‘Optimal demand response using device-

based reinforcement learning,’’IEEE Trans. Smart Grid, vol. 6, no. 5,

pp. 2312–2324, Sep. 2015.

[22] A. Rabiee, M. Sadeghi, J. Aghaeic, and A. Heidari, ‘‘Optimal operation

of microgrids through simultaneous scheduling of electrical vehicles and

responsive loads considering wind and PV units uncertainties,’’ Renew.

Sustain. Energy Rev., vol. 57, pp. 721–739, May 2016.

[23] S. Rahim et al., ‘‘Exploiting heuristic algorithms to efﬁciently utilize

energy management controllers with renewable energy sources,’’ Energy

Buildings, vol. 129, pp. 452–470, Oct. 2016.

[24] M. B. Rasheed, N. Javaid, A. Ahmad, Z. A. Khan, U. Qasim, and

N. Alrajeh, ‘‘An efﬁcient power scheduling scheme for residential load

management in smart homes,’’ Appl. Sci., vol. 5, no. 4, pp. 1134–1163,

2015.

[25] A. Ahmad, N. Javaid, N. Alrajeh, Z. A. Khan, U. Qasim, and

A. Khan, ‘‘A modiﬁed feature selection and artiﬁcial neural network-based

day-ahead load forecasting model for a smart grid,’’ Appl. Sci., vol. 5, no. 4,

pp. 1756–1772, 2015.

[26] Y.-S. Son, T. Pulkkinen, K.-D. Moon, and C. Kim, ‘‘Home energy manage-

ment system based on power line communication,’’ IEEE Trans. Consum.

Electron., vol. 56, no. 3, pp. 1380–1386, Aug. 2010.

[27] A. G. Azar and R. H. Jacobsen, ‘‘Appliance scheduling optimization for

demand response,’’ Int. J. Adv. Intell. Syst., vol. 9, nos. 1–2, pp. 50–64,

2016.

[28] A. Khalid, N. Javaid, A. Mateen, B. Khalid, Z. A. Khan, and

U. Qasim, ‘‘Demand side management using hybrid bacterial forag-

ing and genetic algorithm optimization techniques,’’ in Proc. 10th

Int. Conf. Complex, Intell., Softw. Intensive Syst. (CISIS), Jul. 2016,

pp. 494–502.

[29] Y. Zhang, P. Zeng, S. Li, C. Zang, and H. Li, ‘‘A novel multiobjective

optimization algorithm for home energy management system in smart

grid,’’ Math. Problems Eng., vol. 2015, Jan. 2015, Art. no. 807527.

[30] Z. Baharlouei and M. Hashemi, ‘‘Demand side management challenges

in smart grid: A review,’’ in Proc. Smart Grid Conf. (SGC), Dec. 2013,

pp. 96–101.

[31] M. J. Kuby, W. F. Fagan, C. S. ReVelle, and W. L. Graf, ‘‘A multiobjective

optimization model for dam removal: An example trading off salmon

passage with hydropower and water storage in the Willamette basin,’’ Adv.

Water Resour., vol. 28, no. 8, pp. 845–855, 2005.

[32] M. A. Zehir, A. Batman, and M. Bagriyanik, ‘‘Review and comparison

of demand response options for more effective use of renewable energy

at consumer level,’’ Renew. Sustain. Energy Rev., vol. 56, pp. 631–642,

Apr. 2016.

[33] X. S. Yang, Z. Cui, R. Xiao, A. H. Gandomi, and M. Karamanoglu, Eds.,

Swarm Intelligence and Bio-inspired Computation: Theory and Applica-

tions. Newnes, NSW, Australian: Elsevier, 2013, pp. 3–12.

[34] M. Beaudin and H. Zareipour, ‘‘Home energy management systems:

A review of modelling and complexity,’’ Renew. Sustain. Energy Rev.,

vol. 45, pp. 318–335, May 2015.

[35] T.-C. Chen, P.-W. Tsai, S.-C. Chu, and J.-S. Pan, ‘‘A novel optimization

approach: Bacterial-GA foraging,’’ in Proc. 2nd Int. Conf. Innov. Comput.,

Inf. Control (ICICIC), Sep. 2007, p. 391.

[36] D. Whitley, ‘‘A genetic algorithm tutorial,’’ Statist. Comput., vol. 4, no. 2,

pp. 65–85, 1994.

[37] K. M. Passino, ‘‘Biomimicry of bacterial foraging for distributed optimiza-

tion and control,’’ IEEE Control Syst., vol. 22, no. 3, pp. 52–67, Jun. 2002.

[38] R. Bellman, Dynamic Programming. Princeton, NJ, USA: Princeton Univ.

Press, 1957.

[39] Brattle Group. Clarity in the Face of Complexity, That’s the Power of Eco-

nomics. Accessed: May 20, 2016. [Online]. Available: http://brattle.com/

[40] Waterloo North Hydro Inc. Residential Charges and Rates. Accessed:

May 20, 2016. [Online]. Available: https://www.wnhydro.com/en/your-

home/time-of-use-rates.asp

[41] I. Horowitz and C.-K. Woo, ‘‘Designing Pareto-superior demand-response

rate options,’’ Energy, vol. 31, no. 6, pp. 1040–1051, 2006.

ADIA KHALID received the bachelor’s and master’s degree from the Univer-

sity of Azad Jammu and Kashmir, Muzaffarabad, in 2007 and 2010, respec-

tively, and the master’s degree from Pir Mehr Ali Shah Arid Agriculture

University, Rawalpindi. She is currently pursuing the Ph.D. degree in com-

puter science, under the supervision of Dr. N. Javaid and Dr. M. Ilahi, with

the Department of Computer Science, COMSATS Institute of Information

Technology, Islamabad. Her research interests include energy optimization

in micro and smart grid clouds, big data analytics in smart grids, and so on.

NADEEM JAVAID (S’8–M’11–SM’16) received

the bachelor’s degree in computer science from

Gomal University, D. I. Khan, Pakistan, in 1995,

the master’s degree in electronics from Quid-i-

Azam University, Islamabad, Pakistan, in 1999,

and the Ph.D. degree in computer science from

the University of Paris-Est, France, in 2010. He is

currently an Associate Professor and the Found-

ing Director of the Communications over Sensors

Research Lab, Department of Computer Science,

COMSATS Institute of Information Technology, Islamabad, Pakistan. He has

supervised seven Ph.D. and 75 master’s theses. He has authored over

500 papers in technical journals and international conferences. His research

interests include energy optimization in smart/micro grids, cloud computing

for smart grids, IoT enabled wireless sensor networks, big data analytics in

smart grids, and so on. He received the Best University Teacher Award for

2016 from the Higher Education Commission of Pakistan and the Research

Productivity Award in 2017 from the Pakistan Council for Science and

Technology. He is an Associate Editor of the IEEE ACCESS Journal and an

Editor of the International Journal of Space Based and Situated Computing.

MOHSEN GUIZANI (S’85–M’89–SM’99–F’09)

received the B.S. (Hons.) and M.S. degrees in elec-

trical engineering, and the M.S. and Ph.D. degrees

in computer engineering from Syracuse Univer-

sity, Syracuse, NY, USA, in 1984, 1986, 1987, and

1990, respectively. He served as the Associate Vice

President of Graduate Studies with Qatar Univer-

sity, the Chair of the Computer Science Depart-

ment, Western Michigan University, and the Chair

of the Computer Science Department, University

of West Florida. He also served in academic positions at the University of

Missouri–Kansas City, University of Colorado Boulder, Syracuse University,

and Kuwait University. He is currently a Professor and the ECE Department

Chair with the University of Idaho, USA. He is the author of nine books

and over 500 publications in refereed journals and conferences. His research

interests include wireless communications and mobile computing, computer

networks, mobile cloud computing, security, and smart grid. He is a Senior

Member of ACM. He also served as a member, the chair, and a general

chair of a number of international conferences. He received the Teaching

Award multiple times, the Best Research Award three times, and the Wireless

Technical Committees Recognition Award in 2017. He was the chair of the

IEEE Communications Society Wireless Technical Committee and the chair

of the TAOS Technical Committee. He served as the IEEE Computer Society

Distinguished Speaker from 2003 to 2005. He guest edited a number of

special issues in IEEE journals and magazines. He is currently the Editor-in-

Chief of IEEE Network, serves on the editorial boards of several international

technical journals, and the Founder and the Editor-in-Chief of Wireless

Communications and Mobile Computing journal from 2000 to 2016.

19528 VOLUME 6, 2018

MUSAED ALHUSSEIN was born in Riyadh,

Saudi Arabia. He received the B.S. degree in

computer engineering from King Saud University,

Riyadh, in 1988, and the M.S. and Ph.D. degrees

in computer science and engineering from the

University of South Florida, Tampa, FL, USA,

in1992 and 1997, respectively. Since 1997, he has

been on the Faculty of the Computer Engineering

Department, College of Computer and Information

Science, King Saud University. He is currently the

Founder and the Director of the Embedded Computing and Signal Processing

Research Laboratory. His research activity is focused on typical topics of

computer architecture and signal processing, with an emphasis on VLSI

testing and veriﬁcation, embedded and pervasive computing, cyber-physical

systems, mobile cloud computing, big data, eHealthcare, and body area

networks.

KHURSHEED AURANGZEB received the B.S.

degree in computer engineering from the

COMSATS Institute of Information Technology

Abbottabad, Pakistan, in 2006, the M.S. degree

in electrical engineering (system-on-chip) from

Linkoping University, Sweden, in 2009, and

the Ph.D. degree from Mid Sweden University,

Sundsvall, Sweden, in 2013. From 2013 to 2016,

he was an Assistant Professor/HoD with the Elec-

trical Engineering Department, Abasyn Univer-

sity, Peshawar, Pakistan. He is currently an Assistant Professor with the

College of Computer and Information Science, King Saud University,

Riyadh, Saudi Arabia. His research interests include wireless visual sensor

networks, the design methods and implementation of embedded systems,

applied image/signal processing, image compression, cloud computing,

Internet of Things, smart grids, smart buildings, and trafﬁc monitoring.

MANZOOR ILAHI received the master’s degree

in computer science from Gomal University,

D.I Khan, in 1998, and the Ph.D. degree in com-

puter science from the Intelligence Engineer-

ing Laboratory, Institute of Software, Chinese

Academy of Sciences, Beijing, China. His Ph.D.

thesis was on Detecting Outliers for Data Stream

Under Limited Resources under the supervision

of Prof. H. Wang. After completion of his Ph.D.

degree, he rejoined CIIT as an Assistant Professor

with the Department of Computer Science in 2009, where he is currently

an Associate Professor. His major areas of interest are mining data streams,

ubiquitous data mining, intrusion detection, distributed data mining, machine

learning and data mining, real-time systems, publish/subscribe systems,

wireless sensor networks, and active databases ECA rules. In 2005, he

received the CIIT Scholarship for his Ph.D. degree from GSCAS.

VOLUME 6, 2018 19529

MATLAB Source Code for paper

Towards Dynamic Coordination Among Home Appliances Using Multi-Objective

Energy Optimization for Demand Side Management in Smart Buildings

Authors: Adia Khalid, Nadeem Javaid, Mohsen Guizani, Musaed Alhussein,

Khursheed Aurangzeb and Manzoor Ilahi

For further queries you can contact on following email IDs: adia.khalid@gmail.com,

nadeemjavaidqau@gmail.com.

Note: This code contains two scenarios, Scheduling with-out Coordination (proposed hybrid

of Bacterial foraging and Genetic algorithm) and Scheduling with Coordination using Dynamic

programing. Moreover, we have tested the proposed scheme for three different pricing

schemes.

Link of the paper: https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8252710

Citation: Adia Khalid, Nadeem Javaid, Mohsen Guizani, Musaed Alhussein, Khursheed

Aurangzeb and Manzoor Ilahi, "Towards dynamic coordination among home appliances using

multi-objective energy optimization for demand side management in smart buildings", IEEE

Access, Volume: 6, Pages: 19509-19529, Published: April 2018, ISSN: 2169-3536, DOI:

https://dx.doi.org/10.1109/ACCESS.2018.2791546.

1%% Before going for the code must read the orignal algorithms of BFA and GA

2close all;

3clear;

4clc;

5% The original code is written in MATLAB 2015b version. Code is created and

6% modified by Adia Khalid. You may fnd the difference in the load also in

7% other value. Due to the random input values of Diswasher and vaccume

8% cleaner

9for Tprice=1:3 % we run this loop to execute results for three pricing schemes

10 %% initalization of price signals %%% for different price signals each time uncommet the

11 %%%%% price list and run the code for price list detail check the paper

12 %https://www.wnhydro.com/en/your-home/time-of-use-rates.asp

13 % The hourly pricing data for the CPP was taken from the Scandinavian electricity market Nordpoolspot

14 if Tprice==1

15 %%%%%%%%%%%%% Day ahead price RTP Signal %%%%%%%%%%%%%%%%%%%

16 EP=[9.83 8.63 8.87 12 9.19 12.27 20.69 26.82 27.35 17.31 16.42 16.44 16.19 13.81 8.87 8.35 8.65 ...

9.35 8.11 8.25 8.10 8.14 8.13 8.34];

17 end

18

19 if Tprice==2

20 %%%%%%%%%%%%% TOU %%%%%%%%%%%%%%%%%%%

21 EP=[8.7 8.7 8.7 8.7 8.7 8.7 13.2 13.2 13.2 13.2 18 18 18 18 18 18 13.2 13.2 8.7 8.7 8.7 8.7 8.7 8.7];

22 end

23

24 if Tprice==3

25 %%%%%%%%%%%%% CPP %%%%%%%%%%%%%%%%%%%

26 EP=[11.4 11.4 11.4 11.4 11.4 11.4 11.4 11.4 11.4 11.4 123.4 123.4 123.4 123.4 123.4 123.4 11.4 11.4 ...

11.4 11.4 11.4 11.4 11.4 11.4];

27 end

28 %% Off pe ak hour and On pea k hour

29 k=0; l=0;

30 for j=1:length(EP)

31 if EP(j)<mean(EP)

32 k=k+1;

33 Off Peak hour(k)=EP(j);

34 end

35 if EP(j)≥mean(EP)

36 l=l+1;

37 On pe ak ho ur(l)=EP(j);

38 end

39 end

40

41 %%

42 %%%%%%%%%% States of appliances %%%%%%%%%%%

43 %% BrustLoad shift able appliances

44 Vacumcleaner=[000011000011000011000000];

45 %% Add the user random bhaviour to allocat the time slots in mints without any limit of max and min ...

... but user will provide the accpected working hours

46 WaterHeater= [000000111000011110011100];

47 A i=1;

48 count=0;

49 %% Randomly select the time for vacume cleaner ..... and Dish Washer

50

51 for k k=1:6

52 One rang1 =1; %

53 One rang = 60;

54 Timer On = (One rang-One rang1).*rand(1) + One rang 1;

55 Time r On=round(T imer O n);% Time interval (total mints) within hour user want to allocate to ...

specific appliances

56 Time hours1( A i )=Ti mer On;

57 Time r On=T imer O n/60; %

58 Time r On=round(T imer O n*100)/100;

59 allocated time1( A i )= Timer On ;

60 A i= A i+1;

61 end

62

63 unSch time1=find(Vacum cleaner); %(24,length(allocate d time1));

64 unSch time1=sort(unSch time1);

65 Vacum cleaner=zeros(1,24);

66 for i=1:length(allocated time1)

67 Vacum cl eaner( unSch tim e1(i))=all ocated ti me1(i);

1

68 Vacum cleaner1( unSch t ime1(i))= Time ho urs1(i);

69 end

70

71 A i=1;

72 for j j=1:8

73 One rang1 =1; %

74 One rang = 60;

75 Timer On = (One rang-One rang1).*rand(1) + One rang 1;

76 Time r On=round(T imer O n);% Time interval (total mints) within hour user want to allocate to ...

specific appliances

77 Time hours2( A i )=Ti mer On;

78 Time r On=T imer O n/60; %

79 Time r On=round(T imer O n*100)/100;

80 allocated time2( A i )= Timer On ;

81 A i= A i+1;

82 end

83 Dishwasher= [000011011000110000110000];

84 unSch time=find(Dish washer);

85 unSch t ime=sort(u nSch time);

86 Dish washer=zeros(1,24);

87 for i=1:length(allocated time2)

88 Dish wa sher( unSch time(i))=allocated time2(i);

89 Dish washer1( unSch ti me(i))=allocated ti me2(i);

90 end

91 %WaterHeater= [001000111000001110011100];

92 WaterPump= [000011001100000110000110];

93 %Dishwasher= [110011011001100000000011];

94 %% BrustLoad Non-intrubable %Cloth dryer will be on immediately after washing machine stop working ...

95 WashingMachine=[000000011111000000000000];

96 ClothDryer= [000000000000111100000000];

97 %% Elastic base Appliances

98 Refrigerator= [111110111111011001110110];

99 AC= [000011011111110000111111];

100 Oven= [000001110001100000011000];

101 Intrupt appliances=[Vacum cleaner',Water Heater',Water Pump',D ish was her'];

102 Non intru ptable= [ Washing Machine', Clot h Dryer '];

103 Base Appliances= [Refrigerator' , AC', Oven'];

104 Appliances= [Intrupt appliances Non intrup table Base Appliances];

105 %% Smart Grid Parameters intialization

106 time slots Intrupt=[6 10 8 8]; % hours for appliances brustload intruptable

107 time slotFixed= [18 15 7];

108 time slots nonIntr=[5 4];

109 time slots=[t ime sl ots In trupt time slots nonIntr tim e slotFixed];

110 pIntr= [0.7 5 1 1.8]; % power ratings of App's in that are to be schedule

111 pNonTntr= [0.7 5];

112 pFixed= [0.225 1.5 2.15];

113 p=[pIntr pNonTntr pFixed];

114 maxAvg=3;

115

116 %% Find the location of Appliances who have minimum waiting time

117 tV1=find(Vacum cleaner); % return the location of string

118 tWH1=find(Water H eater);

119 tWP1=strfind(Water Pump,(1));

120 tDW1=find(Dish washer);

121 tRF1=strfind(Refrigerator,(1));

122 tAC1=strfind(AC,(1));

123 tO1=strfind(Oven,(1));

124 tWM1=strfind(Washing Machine,[1 1 1 1 1]);

125 tCD1=strfind(Cloth Dry er,[1 1 1 1]);

126 NoN IntruPt=[7]; % cannot be intrupted

127 App li Ca n On=[1 4]; % Appliances that can be On during extra time

128 InTruPt App=[2 3 5 6 8 9]; % Appliances that user can swithed Off during an hour

129 %% %%%%%%%%%%%%%%%%%%%%%%%%%Contraints%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

130 for hour=1:24

131 Electricity cost=[EP(hour)*p(1) EP(hour)*p(2) EP(hour)*p(3) EP(hour)*p(4) EP(hour)*p(5) ...

EP(hour)*p(6) EP(hour)*p(7) EP(hour)*p(8) EP(hour)*p(9)];%coefficients of objective function ...

132 unscheduledload(hour)=Appliances(hour,:)*p';

133 unschedulecost(hour)=Appliances(hour,:)*Electricity cost';

134 end

2

135 sum unscheduledload(Tprice)=sum(unscheduledload);

136 sum uns cheduled co st(Tprice)=sum(unschedulecost);

137 PAR=max(unscheduledload)ˆ2/(sum(unscheduledload)/24)ˆ2;

138 PAR unschedu led(Tprice) = PAR;

139 %% On-peak and Off-peak

140

141 D EP=round(mean(EP));

142 %% Normalized load for fitness function

143 loa d (1:length(unscheduledload))=(unscheduledload(1:length(unscheduledload))-min(unscheduledload))/(max(unscheduledload)-min(unscheduledload));

144 t load=sum(l oad );

145

146 %% Objective Load Curve

147 for hour=1:24

148 if EP(hour)≤D EP

149 obj Load(hour)=t l oad -std(unscheduledload);

150 end

151 if EP(hour)>D EP

152 obj Load(hour)= ...

(std(unscheduledload)+2*(min(unscheduledload))+(mean(unscheduledload)-min(unscheduledload)))/2;

153 end

154 end

155 %%

156 %% %%%%%%%%%%------------------------Scheduling------------------------%%%%%%%%%%%%

157 %% Scheduling For the Appliances just to minimize the cost and PAR...

158 %% ----------------------------Parameters Initialization ---------------------- %%

159 Ne=24; %The number of elimination steps

160 Nr=50; %The number of reproduction steps

161 Nc=5; %The number of chemotactic steps

162 Np=50; %The number of population steps

163 Ns=2; %Swiming Length

164 D=9; %Dimension of a search space number of appliances to schedule

165 C=0.1; %Size of the step taken in the random direction specified by the tumble

166 theta=0.5;

167 Pro Ge n=0.55;

168 Ped=0.5;%0.9;%Elimination dispersion probability

169 su m E Co st S S B =0;

170 sum scheduled load B=0;

171 maxgen=200; %%% for crossover and mutation

172 popSize=50;

173 %% %%% To check the extra load during coordination ...

174 er1=1;

175 count1=0;

176 er2=1;

177 count2=0;

178 er3=1;

179 count3=0;

180 errorB=inf;

181 %% %% Variable used for Average Calculation

182 %% for BFA without coordination

183 app S chA vg B=zeros(24,9);

184 sch edu le lo ad Av g B=zeros(1,24);

185 E Co st S S Av g B =zeros(1,24);

186 sum s che duled l oad A vg B=0;

187 sum E Cost SS Avg B=0;

188 PAR scheduled Avg B=0;

189 PAR Avg B =0;

190 PAR reduction Avg B=0;

191 %% HYbrid BFA GA

192 app SchAvg BG=zeros(24,9);

193 schedule load Avg BG=zeros(1,24);

194 E Co st S S Av g BG =zeros(1,24);

195 sum scheduled load Avg BG=0;

196 sum E Cost SS Avg BG=0;

197 PAR scheduled Avg BG=0;

198 PAR A vg B G=0;

199 PAR reduction Avg BG=0;

200

201 %% GA

202 app S chA vg G=zeros(24,9);

203 sch edu le lo ad Av g G=zeros(1,24);

204 E Co st S S Av g G =zeros(1,24);

3

205 sum s che duled l oad A vg G=0;

206 sum E Cost SS Avg G=0;

207 PAR scheduled Avg G=0;

208 PAR Avg G =0;

209 PAR reduction Avg G=0;

210 su m E Co st S S G =0;

211 sum scheduled load G=0;

212 %% HSM

213 app S chA vg H=zeros(24,9);

214 sch edu le lo ad Av g H=zeros(1,24);

215 E Co st S S Av g H =zeros(1,24);

216 sum s che duled l oad A vg H=0;

217 sum E Cost SS Avg H=0;

218 PAR scheduled Avg H=0;

219 PAR Avg H =0;

220 PAR reduction Avg H=0;

221 su m E Co st S S H =0;

222 sum scheduled load H=0;

223 %% Variable to claculate the values for the coordination

224 %% BFA

225 app SchAvg B1=zeros(24,9);

226 schedule load Avg B1=zeros(1,24);

227 E Co st S S Av g B1 =zeros(1,24);

228 sum scheduled load Avg B1=0;

229 sum E Cost SS Avg B1=0;

230 PAR scheduled Avg B1=0;

231 PAR A vg B 1=0;

232 PAR reduction Avg B1=0;

233 %% Hybrid BFA GA

234 app SchAv g BG1 =zeros(24,9);

235 schedul e loa d Avg B G1=zeros(1,24);

236 E Co st S S Av g BG 1=zeros(1,24);

237 sum s che dul ed lo ad Av g BG1 =0;

238 su m E Co st S S Av g BG 1=0;

239 PAR sched ule d Avg B G1=0;

240 PAR Avg BG1=0;

241 PAR reduc tio n Avg B G1=0;

242 %% GA

243 app SchAvg G1=zeros(24,9);

244 schedule load Avg G1=zeros(1,24);

245 E Co st S S Av g G1 =zeros(1,24);

246 sum scheduled load Avg G1=0;

247 sum E Cost SS Avg G1=0;

248 PAR scheduled Avg G1=0;

249 PAR A vg G 1=0;

250 PAR reduction Avg G1=0;

251 su m E Co st S S G1 =0;

252 sum sched ule d loa d G1=0;

253 %%

254 x=(rand(Np,D));%-theta)*60; % x lies in [-30 30]

255 for j=1:Np

256 for i=1:D

257 if x(j,i)>Pro Gen%std(unscheduledload) % rand(1) means 1*1 matrix

258 x(j,i)=1;

259 else

260 x(j,i)=0;

261 end

262 end

263 end

264 tic

265 for avg1= 1:10

266 t x=0;

267 l x=0;

268 t AC= 0;

269 l AC= 0;

270 VAR1=1;

271 VAR2=1;

272 PAR scheduled Avg B=0;

273 PAR scheduled Avg B1=0;

274

275 %% %% Calculate the fitness according to the initial location of bactaria

4

276 J=zeros(Np,1);

277 for k=1:Np %k=reproduction

278 for i=1:D-1

279 J(k)=sum(100*(x(k,i+1)-x(k,i)ˆ2)ˆ2+(x(k,i)-1)ˆ2); % initial fitness calculation

280 end

281 end

282 Fgbest=inf;

283 %% Swarm behaviour to save the value ... as we may find a better cost via a run

284 JLast=J;

285 Jlast=J;

286 best=inf;

287 gbest=inf;

288 Fbest=inf;

289 app Sch B =zeros(24,9);

290 B ap p Sc h B=zeros(24,9);

291 sum scheduled load B=0;

292 B time sl ots=[time slots Intrupt time s lots n onIn tr time slotFix ed];

293 ECo st S S B=zeros(1,24);

294 su m E Co st S S B =0;

295 PAR scheduled B=0;

296 PAR schedu led Av g=0;

297 sche dule load B =zeros(1,24);

298

299

300 app S ch B 1=zeros(24,9);

301 sum sched ule d loa d B1=0;

302 B time sl ots=[time slots Intrupt time s lots n onIn tr time slotFix ed];

303 E Co st S S B1 =zeros(1,24);

304 su m E Co st S S B1 =0;

305 PAR scheduled B1=0;

306 PAR scheduled Avg1=0;

307 sche dule l oad B1=zeros(1,24);

308 time=zeros(hour,9);

309 Vacuum cleaner=Vacum cleaner;

310 %% Sectio IV-A

311 %% BFA Algorithm

312 for hour=1:24 % l=elimination of dispersal step(for l=1:Ne)

313

314 Fgbest=inf;

315 %% %%%%%%%%%%%% Working %%%%%%%%%%%% %%

316 %% START 2

317 electricity cost=[EP(hour)*p(1) EP(hour)*p(2) EP(hour)*p(3) EP(hour)*p(4) EP(hour)*p(5) ...

EP(hour)*p(6) EP(hour)*p(7) EP(hour)*p(8) EP(hour)*p(9)];%coefficients of objective function ...

318 Lbest=inf;

319 gbest=inf;

320 Fbest=inf;

321 D11=inf;

322 size(x);

323 for k=1:Nr %k=reproduction

324 Jchem=J;

325 for j=1:Nc %Chemotaxis Loop %

326 for i=1:Np %Take a chemotaxis Step

327 del=(rand(1,D)-Ped)*2;

328 x(i,:)=x(i,:)+(C/sqrt(del*del'))*del; %Direction of Tumble i.e. new position of bactarium

329 for d=1:D-1

330 J(i)=sum(100*(x(i,d+1)-x(i,d)ˆ2)ˆ2+(x(i,d)-1)ˆ2); %Fitness Function

331 end

332 for m=1:Ns

333 if J(i)<Jlast(i)%Elimination and Dispersal Check

334 Jlast(i)=J(i);

335 x(i,:)=x(i,:)+C*(del/sqrt(del*del')); %Direction of Tumble i.e. new position of bactarium

336 for d=1:D-1

337 J(i)=sum(100*(x(i,d+1)-x(i,d)ˆ2)ˆ2+(x(i,d)-1)ˆ2); %Fitness Function

338 end

339 else

340 del=(rand(1,D)-Ped)*2;%Vector with random Direction

341 x(i,:)=x(i,:)+C*(del/sqrt(del*del'));

342 for d=1:D-1

343 J(i)=sum(100*(x(i,d+1)-x(i,d)ˆ2)ˆ2+(x(i,d)-1)ˆ2);

344 end

5

345 end

346 end

347 end

348 Jchem=[Jchem J];

349 end % End of Chemotaxis %

350 % for i=1:Np

351 % Jhealth(i)=sum(Jchem(i,:)); % sum of cost function of all chemotactic loops for a ...

given k & l

352 % end

353 Xnew=x;

354 for j=1:Np

355 for i=1:D

356 if Xnew(j,i)>Pro Gen%std(unscheduledload) % rand(1) means 1*1 matrix

357 Xnew(j,i)=1;

358 else

359 Xnew(j,i)=0;

360 end

361 end

362 end

363 %% just a check if maximum bactarias going to be dead

364

365 % % if (sum(sum(Xnew))≤Np)

366 % % x=(rand(Np,D));%-theta)*60; % x lies in [-30 30]

367 % % for j=1:Np

368 % % for i=1:D

369 % % if x(j,i)>Pro Ge n%std(unscheduledload) % rand(1) means 1*1 matrix

370 % % x(j,i)=1;

371 % % else

372 % % x(j,i)=0;

373 % % end

374 % % end

375 % % end

376 % % for k=1:Np %k=reproduction

377 % % for i=1:D-1

378 % % J(k)=sum(100*(x(k,i+1)-x(k,i)ˆ2)ˆ2+(x(k,i)-1)ˆ2); % initial fitness calculation

379 % % end

380 % % end

381 % % Xnew=x;

382 % % end

383

384 %% check for the appliance 5 and 6 to run them in series without intrupt

385 lhour=25-hour;

386 if lhour≤(B time slots(1,5)+B time slots(1,6))

387 for a=1:Np

388 Xnew(a,5)=1;

389 if B time slots(1,5)≤0

390 Xnew(a,6)=1;

391 elseif B time slots(1,5)>0

392 Xnew(a,6)=0;

393 end

394 end

395 elseif hour>1

396 for a=1:Np

397 if app Sch B (hour-1,5)==1

398 Xnew(a,5)=1;

399 end

400 if B time slots(1,5)>0

401 Xnew(a,6)=0;

402 end

403 if B time slots(1,5)≤0

404 Xnew(a,6)=1;

405 end

406 end

407 end

408 for a=1:Np

409 if B time slots(1,5)>0

410 Xnew(a,6)=0;

411 end

412 end

413 %% check for the appliances maximum waiting time.. each appliance must fufill its operational time

414 for a=1:Np

6

415 for b=1:D

416 if B time slots(1,b)≤0

417 Xnew(a,b)=0;

418 elseif (lhour≤B time s lot s(1,b)&& B time s lots(1,b)>0)

419 Xnew(a,b)=1;

420 end

421 end

422 end

423 B time slots;

424 %% sum of cost function of all chemotactic loops for a given k & l

425 F1=(electricity cost*Xnew');

426 E Cost=(electricity cost*Xnew');

427 F=F1;

428 %% Selection and Calculation %%

429 Load=p*Xnew';

430

431 %% Off peak hour

432 if EP(hour)≤D EP

433 for i = 1:Np

434 if (F1(1,i)<D11)&& Load(1,i)≥t load-std(unscheduledload) %normalize load- mean(unscheduledload)+ ...

std(unscheduledload)%(mean(unscheduledload)+std(unscheduledload)+min(unscheduledload)) % && ...

Load(1,i) <max(unscheduledload) %min(unscheduledload) && Load(1,i)≤mean(unscheduledload)

435 D11 = F1(1,i); %mean(unscheduledload)

436 lbest = Xnew(i,:); % gbest position achieved here.

437 ij=i;

438 Fbest=D11;

439 ds= E Cost(1,i);

440 end

441 end

442 end

443 %% On peak hour

444 if EP(hour)>D EP

445 for i = 1:Np

446 if (F1(1,i)<D11 && Load(1,i)>(std(unscheduledload)+2*(min(unscheduledload))))&&(Load(1,i)<...

mean(unscheduledload)-min(unscheduledload)) %+min(unscheduledload))) && ...

Load(1,i)<mean(unscheduledload) %-min(unscheduledload)%clc&& ...

Load(1,i)<(max(unscheduledload)-min(unscheduledload))&& ...

Load(1,i)>(mean(unscheduledload)-min(unscheduledload))% && Load(1,i)≤mean(unscheduledload))% ...

&& load(1,i) ≥min(EP)) % Compare fitness value with D11.

447 D11 = F1(1,i);

448 lbest = Xnew(i,:); % gbest position achieved here.

449 Fbest=D11;

450 ij=i;

451 ds= E Cost(1,i);

452 end

453 end

454 end

455 %% Extra check to avoid loop hole that can occur if above conditions do not meet

456 if EP(hour)≤D EP && D11==inf

457

458 for i = 1:Np

459 if (F1(1,i)<D11 && Load(1,i)>min(unscheduledload))

460 D11 = F1(1,i);

461 lbest(1,:) = Xnew(i,:); % gbEst position achieved here.

462 Fbest=D11;

463 ds= E Cost(1,i);

464 ij=i;

465 end

466 if (F1(1,i)>D11 && Load(1,i)>min(unscheduledload))

467 D11 = F1(1,i);

468 lbest(1,:) = Xnew(i,:); % gbEst position achieved here.

469 Fbest=D11;

470 ds= E Cost(1,i);

471 ij=i;

472 end

473 end

474 end

475 if D11==inf

476 for i = 1:Np

477 if (F1(1,i)<D11 && Load(1,i)>min(unscheduledload))

478 D11 = F1(1,i);

7

479 lbest =Xnew(i,:); % gbest position achieved here.

480 Fbest=D11;

481 ij=i;

482 ds= E Cost(1,i);

483 end

484 end

485 end

486 if D11==inf

487 for i = 1:Np

488 if (F1(1,i)<D11)

489 D11 = F1(1,i);

490 lbest =Xnew(i,:); % gbest position achieved here.

491 Fbest=D11;

492 ij=i;

493 ds= E Cost(1,i);

494 end

495 end

496 end

497 end

498 %% Coordination among appliances

499 gbest=lbest;

500 gb=0;

501 gbb=0;

502 gbest1=gbest;

503 NoN IntruPt;

504 allocated time1=find( Vacum cl eaner);

505 allocated time2=find( Dish washer);

506 if gbest(1,1)==1

507 gbest(1,1)=Vacum c leaner(alloca ted time1 (VAR1));

508 VAR1= VAR1+1;

509 end

510 if gbest(1,4)==1

511 gbest(1,4)=Dish w asher(alloca ted time2 (VAR2));

512 VAR2= VAR2+1;

513 end

514 time(hour,:)=B ti me sl ots ;

515 EP x AppStatus= gbest;

516 size(EP x AppStatus);

517 schedule load B(hour)=p*gbest';

518 E C o st SS B (hour)=electricity cost*gbest';

519 sum scheduled load B=sche dule load B(hour)+sum sche dul ed lo ad B;

520 sum E Cost SS B=E Cost SS B(hour)+sum E Cost SS B;

521 app Sch B (hour,:)=gbest(1,:);

522 for LL=1:length(gbest)

523 if gbest(1,LL)>0

524 gbest(1,LL) = 1;

525 end

526 if gbest(1,LL)== 0

527 gbest(1,LL) = 0;

528 end

529 end

530 for b=1:D

531 if (gbest(1,b)>0)

532 B tim e slo ts(1,b)= B time slots (1,b)-1;

533 elseif (gbest(1,b)==0)

534 B time slots(1,b)=B time slots(1,b);

535 end

536 end

537 B ap p Sc h B(hour,:)=gbest(1,:); % for scheduling waiting time

538

539 %% %% Elimination or despersal(kill all previous swarms and generate new)

540

541 for i=1:Np

542 r=rand;

543 if r≥Ped

544 x(i,:)=(rand(1,D)-Pro G en);

545 for d=1:D-1

546 J(i)=sum(100*(x(i,d+1)-x(i,d)ˆ2)ˆ2+(x(i,d)-1)ˆ2);

547 end

548 end

549 end

8

550 end

551 PAR sc heduled B =max(sc hedule lo ad B)ˆ2/((sum s che duled lo ad B)/24)ˆ2;

552 count1=count1+1;

553 PoPulation(count1)=Np;

554 %% Average Calculation

555 app SchAvg B =app Sch B+app SchAvg B;

556 schedule load Avg B =schedule load Avg B+schedule load B;

557 E Cost SS Avg B =E Cost SS Avg B+E Cost SS B;

558 sum s che duled l oad A vg B =sum schedul ed lo ad B+ sum s chedu led l oad A vg B;

559 sum E Cost SS Avg B =sum E Cost SS Avg B+sum E Cost SS B;

560 PAR scheduled Avg B =PAR scheduled Avg B+PAR scheduled B;

561

562 %% Cofidence Interval Parameters

563 BFA PA R(avg1,:) =PA R sch edu led Avg B ;

564 BFA E Cost SS(avg1,:) = E Co st SS B ;

565 BFA s chedu le load (avg1,:) = schedul e load B;

566 BF A su m E Co st S S(avg1,:) = su m E C os t S S B;

567 BFA app S ch(:,:,avg1) =ap p Sch B;

568 BFA Su m Sch eduled load(avg1,:)= sum s che dul ed load B;

569 BFA a pp S ch B FA(:,:,avg1) = B a pp Sc h B ;

570 app S ch B 1=app Sch B ;

571 app S ch B11= ap p Sc h B;

572 w time=time slo ts;

573

574 Vacu um Cle aner B 1=zeros(1,24);

575 Dish wash er B1 =zeros(1,24);

576 wate r Heater B1 =zeros(1,24);

577 water Pump B1=zeros(1,24);

578 Washing machine B1=zeros(1,24);

579 Cloth dry er B1 =zeros(1,24);

580 refrigerator B1=zeros(1,24);

581 AC B1 =zeros(1,24);

582 oven B 1=zeros(1,24);

583 Vacum cleaner Un BFA=Vacu m cleane r;

584 Dis h wa she r Un BF A=Dish washer;

585 Var VC=0;

586 Var DW=0;

587 VC si ze=(length(find(Vacum cleaner)));

588 DW si ze=(length(find(Dish washer)));

589 %% Sectio IV-b REAL-TIME SCHEDULING

590 %% Algorihtm 2

591 for hr=1:24

592

593 gbes t 1=[];

594 gbes t 1(1,:)=a pp S ch B 1(hr,:);

595

596 % possible hour=[];

597 Appli Can On;

598 % List Off App=[];

599 % List O n App=[];

600 gb=0;

601 gbb=0;

602 List Off App=[];

603 List On App=[];

604 for b=1:D

605 if (gbe st 1(1,b)==0)

606 gb=gb+1;

607 Lis t Off A pp(gb)=b;

608 end

609 if (gbe st 1(1,b)>0)

610 gbb=gbb+1;

611 Lis t On App(gbb)=b;

612 end

613 end

614 Off Ap p=[];

615 App C an Off=I nTruP t App;

616 w=0;

617 flag1=0;

618 flag2=0;

619 for ll=1:length(Li st On App )

620 app=0;

9

621 app= find(App Ca n Off==L ist O n Ap p(ll));

622 if app>0

623 w=w+1;

624 Off Ap p(w)=A pp C an O ff(app);

625 end

626 end

627 appli Off=inf;

628 F App =0;

629 App On=0;

630 if Off App >0% Check if user want to switched off an appliance

631 U In t On e = randi([0 1], 1); % if user want to intrupt

632 if U Int One == 1

633 if length(Off A pp)>1

634 appli Off= randsample(Of f App,1); % Appliance that user have switched off

635 else

636 appli Off = Off A pp;

637 end

638 end

639 end

640 %%

641 %%%%%%%%%%%%%%%%%ˆˆˆˆˆˆˆˆˆˆˆˆTIMEˆˆˆˆˆˆˆˆˆˆˆˆ%%%%%%%%%%%%%%%%%

642 if appli Off 6=inf

643 One rang1 =1; % decide the time to off the appliance

644 One rang = 60;

645 r One = (One rang-One rang1).*rand(1) + One rang1;

646 r One =round(r One);%*100) / 100; % when appliance will me closed

647 T al =60-r On e; % 60 total mint with in hour where T al will be allocated time for oven

648 T a l B =T a l;

649 % % % % % %%% Convert T a l mint into hour

650 % % % % % r On e=r One /60; % Time of Appliance that have been closed

651 % % % % % T a l= T al /60; % Closed Appliance pass time to another appliance

652 time Ex tra =T a l;

653 jll=0;

654 Z App =0;

655 % Appl i Can O n=A ppl i Can On(randperm(length(App li Ca n On)))

656 On App=0;

657 appl i On=inf; % select the appliance feasibility to on

658 % W LO T =[]; % weigth in our case it will be length of operational time

659 % V Cost=[]; % volume in our case will be cost during specific hour

660 Z App =strfind(ismember(List Off App,Appli Ca n On),1); % this will return the index

661 Z App =List Off Ap p(Z A pp); % appliances

662 W LOT1={}; W LOT hour1={};

663 app identity1=[]; W LOT=[]; W L OT h our =[]; V C OST = []; Sch S elc app=[];

664 if Z App>0

665

666 j j=1;

667 for k=1:length(Z Ap p)

668 if w time(1,Z A pp(k))>0

669

670 Sch S elc a pp= ap p Sc h B1 (hr:end,Z Ap p(k));

671 Sch S elc a pp=Sch Selc app ';

672 [vale indx]=find((a pp Sch B1(hr:end,Z A pp(k)))'6=0);

673 vale=Sc h Sel c app (indx);

674 indx=indx+hr-1;

675 W LOT1{k}=vale;

676 W LOT hour1{k}=indx;

677 app identity1(k)=length(vale);

678 end

679 end

680 d d=1;

681 for k=1:length(W LOT1)

682 new Value=W LOT 1{k};

683 new Val ue2= W LO T hour 1{k};

684 for j=1:length(new Value)

685 W LO T( d d )=new Value(j);

686 W LO T h our(d d )=new V alue2(j);

687 V COST(d d)=EP(hr)*p(Z App (k));

688 d d= d d+1;

689 end

690 end

691

10

692 EP hr =EP(hr);

693 [sol] = Dynamic Programing(D EP , EP h r, W L OT ,V COS T, time Extra);

694 if sum(sol)≥1

695 sol sub1= mat2cell(sol,1,[app identity1]);

696 for k=1:length(sol s ub1)

697 sol sub= sol sub1{k};

698 Time hour=strfind(s ol sub,1);

699 w time (1,Z App(k)) = w tim e(1,Z A pp (k))-length(Time hour);

700 if w time(1,Z A pp(k))≥0

701 LOT W=W LOT hour1{k};

702 selected hours= LOT W( Time hour); % selected hour to shift from schedule

703 Total mints= W LOT1{k};

704 Operational time= Total mints(Time ho ur); % operational time of appliance during that hour

705

706 app S ch B11(hr, Z App (k))=sum(Operational time);

707 app S ch B 1(hr,Z A pp(k))=0;

708 for j j j=1:length(selected hours)

709 app Sch B 11(selected hours(j j j),Z Ap p(k))=0;

710 app S ch B 1(selected hours(j jj),Z A pp(k))=0;

711

712 app S ch B11(hr,appli Off)= r O ne/60;

713 if Z App (k)==1

714 Vacu um Cleaner B1(1,s elected hours( j j j))=hr;

715 Val1= strfind( V acu m cl eaner Un BFA,Operational time( j j j));

716 Vacum cleaner Un BFA(Val1)=hr;

717 Val1=0;

718 flag1=1;

719 end

720 if Z App (k)==4

721 Dish was her B1(1,selected hours(j jj))=hr;

722 Val1= strfind( D ish w asher Un BF A,Operational time( j j j));

723 Dis h was her Un BF A(Val1)=hr;

724 Val1=0;

725 flag2=1;

726 Var DW=0;

727 end

728 end

729 end

730 if w time(1,Z A pp(k))<0| | sum(sol)==0

731 app S ch B11(hr,appli Off)= r O ne/60;

732 end

733 end

734 end

735 end

736 end

737

738 gBsT(1,:)=ap p Sch B11 (hr,:);

739

740 for b=1:D

741 if (gBsT(1,b)>0) && b 6=1 && b6=4

742 w time(1,b) = w time (1,b)-1;

743 elseif (gBsT(1,b) == 0)

744 w time(1,b)= w time(1,b);

745 end

746 if (gBsT(1,b)>0) && (b ==1 && flag1==0)

747 w time(1,b) = w time (1,b)-1;

748 end

749 if (gBsT(1,b)>0) && (b ==4 && flag2==0)

750 w time(1,b) = w time (1,b)-1;

751 end

752 end

753 gBsT(1,:)=ap p Sch B11 (hr,:);

754 %% Appliances Scheduled hours

755 value1= strfind(Vacuum Cleaner B1,[hr]);

756 if length(value1)==0

757 if (gBsT(1,1)>0)

758 Vacu um Cle aner B 1(:,hr)=hr;

759 Val1= strfind( V acu m cle aner Un BFA,gBsT(1,1));

760 Vacum cleaner Un BFA(Val1)=Val1;

761 Val1=0;

762 end

11

763 end

764 if gBsT(1,2)>0

765 wate r Heater B1 (:,hr)=hr;

766 end

767 if gBsT(1,3)>0

768 water Pump B1(:,hr)=hr;

769 end

770 value11= strfind(Di sh washer B 1,[hr]);

771 if length(value11)==0

772 if (gBsT(1,4)>0)

773 Dish wash er B1 (:,hr)=hr;

774 Val1= strfind( D ish w asher Un BFA ,gBsT(1,4));

775 Dis h was her Un BF A(Val1)=Val1;

776 Val1=0;

777 end

778 end

779 if gBsT(1,5)>0

780 Washing machine B1(:,hr)=hr;

781 end

782 if gBsT(1,6)>0

783 Cloth dry er B1 (:,hr)=hr;

784 end

785 if gBsT(1,7)>0

786 refrigerator B1(:,hr)=hr;

787 end

788 if gBsT(1,8)>0

789 AC B1 (:,hr)=hr;

790 end

791 if gBsT(1,9)>0

792 oven B 1(:,hr)=hr;

793 end

794 end

795 %% Section IV B

796 for hrr = 1:24

797 gBsT(1,:)=ap p Sch B11 (hrr,:);

798 %%

799 electricity cost=[EP(hrr)*p(1) EP(hrr)*p(2) EP(hrr)*p(3) EP(hrr)*p(4) EP(hrr)*p(5) EP(hrr)*p(6) ...

EP(hrr)*p(7) EP(hrr)*p(8) EP(hrr)*p(9)];%coefficients of objective function

800 sche dule l oad B1(hrr)=p*gBsT(1,:)';

801 E C os t S S B 1(hrr)=electricity cost*gBsT(1,:)';

802 sum sched ule d loa d B1=sche dule l oad B1 (hrr)+su m scheduled lo ad B1 ;

803 su m E Co st S S B1 =E C ost SS B1(hrr)+s um E C os t SS B 1;

804 for g g = 1: length(gBsT)

805 if gBsT(1,g g )>0

806 gBsT(1,g g )=1;

807 end

808 if gBsT(1,g g )==0

809 gBsT(1,g g )=0;

810 end

811 end

812 B ap p Sch B 1(hrr,:) = gBsT(1,:);

813 end

814 PAR sc hedu led B1=max(sc hedu le load B1)ˆ2/(sum( sche dule load B 1)/24)ˆ2;

815 count1=count1+1;

816 PoPulation(count1)=Np;

817 %% Average Calculation

818 app SchAvg B1 =ap p Sc h B1 +app SchAvg B1;

819 schedule load Avg B1 =schedule load Avg B1+s chedule load B1;

820 E Co st S S Av g B1 =E C os t SS A vg B 1+ E Cost SS B1;

821 sum scheduled load Avg B1 =sum scheduled load B1+sum scheduled load Avg B1;

822 sum E Cost SS Avg B1 =sum E Cost SS Avg B1+sum E Cost SS B1;

823 PAR scheduled Avg B1 =PAR scheduled Avg B1+P AR sch eduled B1;

824

825 %% Cofidence Interval Parameters

826 BFA PAR1(avg1,:) =PA R sch edu led A vg B1;

827 BFA E Cos t SS 1(avg1,:) = E Co st SS B 1;

828 BFA s che dule lo ad 1(avg1,:) =sch edul e load B1;

829 BFA sum E Cost SS1(avg1,:) = sum E C os t S S B1 ;

830 BFA a pp Sc h1(:,:,avg1) = app Sch B 11 ;

831 BFA Su m Schedul ed lo ad1(avg1,:)=sum s che duled load B1;

832 Vacuum Cleaner B11(:,:,avg1)=Vacuum Cleaner B1 ;

12

833 Dish w asher B11 (:,:,avg1)=Di sh wa sher B1;

834 wate r Heat er B11(:,:,avg1)=wa ter H eate r B1;

835 water Pum p B11 (:,:,avg1)=wa ter P ump B 1;

836 Washing mac hine B11(:,:,avg1)=Washing machine B1;

837 Clot h dryer B11 (:,:,avg1)=Cl oth d ryer B1;

838 refrigerator B11(:,:,avg1)= refrige rator B1;

839 AC B11(:,:,avg1)=A C B1;

840 oven B 11(:,:,avg1)=o ven B 1;

841 Vacum cleaner CBFA(:,:,avg1)= Vacu m cle ane r Un B FA;

842 Dish w ashe r CBFA(:,:,avg1)=Dish w ash er U n BF A;

843 end

844 toc

845 %%

846 %% ---------------------- Genetic Algorithms ------------------------ %%

847 %% Section IV-b

848 %% Parameters Initialization

849 G time sl ots=[time slots Intrupt time s lots n onIn tr time slotFix ed];

850 p=[pIntr pNonTntr pFixed];

851 pop=(rand(popSize,D));%-theta)*60; % x lies in [-30 30]

852 for j=1:popSize

853 for i=1:D

854 if pop(j,i)>Ped%std(unscheduledload) % rand(1) means 1*1 matrix

855 pop(j,i)=1;

856 else

857 pop(j,i)=0;

858 end

859 end

860 end

861 tic

862 for avg2=1:5

863 t AC= 0;

864 l AC= 0;

865 t x=0;

866 l x=0;

867 VAR1=0;

868 VAR2=0;

869 PAR scheduled Avg G1 =0;

870

871 ind=popSize;

872 tbits=9;

873 insite=2; %

874 pc=0.9; % Probability of crossover

875 pm=1-pc; % Probability of mutation

876 count=0;

877 %% %% Average Calculation

878 popnew=pop;

879 best=inf;

880 gbest=inf;

881 Fbest=inf;

882 %% before coordination parametres for claculation

883 app Sch G =zeros(24,9);

884 sum scheduled load G=0;

885 G time sl ots=[time slots Intrupt time s lots n onIn tr time slotFix ed] ;

886 E Co st S S G=zeros(1,24);

887 su m E Co st S S G =0;

888 sche dule load G =zeros(1,24);

889 %% After coordination parametres for claculation

890 app S ch G 1=zeros(24,9);

891 sum sched ule d loa d G1=0;

892 E Co st S S G1 =zeros(1,24);

893 su m E Co st S S G1 =0;

894 sche dule l oad G1=zeros(1,24);

895 errorG=inf;

896 pop=(rand(popSize,D));%-theta)*60; % x lies in [-30 30]

897 for j=1:popSize

898 for i=1:D

899 if pop(j,i)>Pro Gen%std(unscheduledload) % rand(1) means 1*1 matrix

900 pop(j,i)=1;

901 else

902 pop(j,i)=0;

903 end

13

904 end

905 end

906 popnew=pop;

907 w time=time slo ts;

908 %% Sceduling Using GA

909 for hour=1:24 % gen=24

910 electricity cost=[EP(hour)*p(1) EP(hour)*p(2) EP(hour)*p(3) EP(hour)*p(4) EP(hour)*p(5) ...

EP(hour)*p(6) EP(hour)*p(7) EP(hour)*p(8) EP(hour)*p(9)];%coefficients of objective function ...

911

912 %% %%%% Evalution of population %%%%

913 lhour=25-hour;

914 if lhour≤(G time slots(1,5)+G time slots(1,6))

915 for a=1:popSize

916 popnew(a,5)=1;

917 if G time slots(1,5)≤0

918 popnew(a,6)=1;

919 elseif G time slots(1,5)>0

920 popnew(a,6)=0;

921 end

922 end

923 elseif hour>1

924 for a=1:popSize

925 if app Sch G (hour-1,5)==1

926 popnew(a,5)=1;

927 end

928 if G time slots(1,5)>0

929 popnew(a,6)=0;

930 end

931 if G time slots(1,5)≤0

932 popnew(a,6)=1;

933 else

934 popnew(a,b)=0;

935 end

936 end

937 end

938 for a=1:popSize

939 if G time slots(1,5)>0

940 popnew(a,6)=0;

941 end

942 end

943

944 for a=1:popSize

945 for b=1:D

946 if G time slots(1,b)≤0

947 popnew(a,b)=0;

948 elseif (lhour≤G time s lot s(1,b)&& G time s lots(1,b)>0)

949 popnew(a,b)=1;

950 end

951 end

952 end

953

954 %% Selection and Calculation %%

955

956 F1=(electricity cost*popnew');

957 E Cost=(electricity cost*popnew');

958 F=F1;

959 Load=p*popnew';

960 gbest=inf;

961 Lbest=inf;

962 D11=inf;

963 if EP(hour)≤D EP

964 for i = 1:popSize

965 if (F1(1,i)<D11)&& Load(1,i)≥t load-std(unscheduledload)% normali ze load- mean(unscheduledload)+ ...

std(unscheduledload)%(mean(unscheduledload) +std(unscheduledload) + min(unscheduledload)) %&& ...

Load(1,i) <max(unscheduledload) %min(unscheduledload) && Load(1,i)≤mean(unscheduledload)

966 D11 = F1(1,i); %mean(unscheduledload)

967 Lbest = popnew(i,:); % gbest position achieved here.

968 Fbest=D11;

969 ds= E Cost(1,i);

970 ij=i;

14

971 end

972 end

973 end

974 if EP(hour)>D EP

975 for i = 1:popSize

976 if (F1(1,i)<D11 && Load(1,i)>(std(unscheduledload)+2*(min(unscheduledload))))&&(Load(1,i)<...

mean(unscheduledload)-min(unscheduledload)) %&& Load(1,i)<mean(unscheduledload) %clc&& ...

Load(1,i)<(max(unscheduledload)-min(unscheduledload))&& ...

Load(1,i)>(mean(unscheduledload)-min(unscheduledload))% && Load(1,i)≤mean(unscheduledload))% ...

&& load(1,i) ≥min(EP)) % Compare fitness value with D11.

977 D11 = F1(1,i);

978 Lbest = popnew(i,:); % gbest position achieved here.

979 Fbest=D11;

980 ds= E Cost(1,i);

981 ij=i;

982 end

983 end

984 end

985 if EP(hour)≤D EP && D11==inf

986

987 for i = 1:popSize

988 if (F1(1,i)<D11 && Load(1,i)>min(unscheduledload))

989 D11 = F1(1,i); %mean(unscheduledload)

990 Lbest = popnew(i,:); % gbest position achieved here.

991 Fbest=D11;

992 ds= E Cost(1,i);

993 ij=i;

994 end

995 if (F1(1,i)>D11 && Load(1,i)>min(unscheduledload))

996 D11 = F1(1,i); %mean(unscheduledload)

997 Lbest = popnew(i,:); % gbest position achieved here.

998 Fbest=D11;

999 ds= E Cost(1,i);

1000 ij=i;

1001 end

1002 end

1003 end

1004 if D11==inf

1005 for i = 1:popSize

1006 if (F1(1,i)<D11 && Load(1,i)>min(unscheduledload))

1007 D11 = F1(1,i);

1008 Lbest = popnew(i,:); % gbest position achieved here.

1009 Fbest=D11;

1010 ds= E Cost(1,i);

1011 ij=i;

1012 end

1013 end

1014 end

1015 if D11==inf

1016 for i = 1:popSize

1017 if (F1(1,i)<D11)% && Load(1,i)>min(unscheduledload))

1018 D11 = F1(1,i);

1019 Lbest = popnew(i,:); % gbest position achieved here.

1020 Fbest=D11;

1021 ds= E Cost(1,i);

1022 ij=i;

1023 end

1024 end

1025 end

1026 gbest=Lbest(1,:);

1027 popnew(ij,:)=0;

1028 allocated time1=find( Vacum cl eaner);

1029 allocated time2=find( Dish washer);

1030 if gbest(1,1)==1

1031 VAR1= VAR1+1;

1032 gbest(1,1)=Vacum c leaner(alloca ted time1 (VAR1));

1033 end

1034 if gbest(1,4)==1

1035 VAR2= VAR2+1;

1036 gbest(1,4)=Dish w asher(alloca ted time2 (VAR2));

1037 end

15

1038 for b=1:D

1039 if (gbest(1,b)>0)

1040 G tim e slo ts(1,b)= G time slots (1,b)-1;

1041 elseif (gbest(1,b)==0)

1042 G time slots(1,b)=G time slots(1,b);

1043 end

1044 end

1045 G time slots;

1046 hour;

1047 %%%%%%%check

1048 %% Next Generation

1049 %¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬ ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬%

1050 %----------------Genereate new population---------------------------------%

1051 for j=1:maxgen

1052 %------- Select Crossover pair -------------%

1053 ii=floor(ind*rand);

1054 jj=floor(ind*rand);

1055 if ii==0

1056 ii=randi(ind,1,1);

1057 end

1058 if jj==0

1059 jj=randi(ind,1,1);

1060 end

1061 %------- Crossover pair selected -----------%

1062 %------ Crossover -----------%

1063 if pc>rand

1064 [popnew(ii,:),popnew(jj,:)]= crossover(pop(ii,:),pop(jj,:));

1065 count=count+2;

1066 end

1067 %-------- Crossover done -----%

1068 %-------------------------Do Mutation at n sites ------------%

1069 if pm>rand

1070 kk=floor(ind*rand);

1071 if kk==0

1072 kk=randi(ind,1,1);

1073 end

1074 count=count+1;

1075 popnew(kk,:)=mutate(popnew(kk,:),insite);

1076 end

1077 %------------------------- Mutation done ----------------------%

1078

1079 %-------------------------- New population generated ---------------------%

1080 %-------------------------------------------------------------------------%

1081 popnew;

1082 end

1083 gbest;

1084

1085 gbest1=gbest;

1086

1087 gb=0;

1088 gbb=0;

1089

1090 NoN IntruPt;

1091 %% Start of Coordination %%

1092 EP x AppStatus= gbest;

1093 size(EP x AppStatus);

1094 app Sch G (hour,:)=gbest(:,:);

1095 schedule load G(hour)=p*gbest';

1096

1097 E C o st SS G (hour)=electricity cost*gbest';

1098 sum scheduled load G=sche dule load G(hour)+sum schedul ed lo ad G;

1099 sum E Cost SS G=E Cost SS G(hour)+sum E Cost SS G;

1100 PAR sc heduled G =max(sc hedule lo ad G)ˆ2/((sum s che duled lo ad G)/24)ˆ2;

1101

1102 for LL=1:length(gbest)

1103 if gbest(1,LL)>0

1104 gbest(1,LL) = 1;

1105 end

1106 if gbest(1,LL)== 0

1107 gbest(1,LL) = 0;

1108 end

16

1109 end

1110

1111 G ap p Sc h G(hour,:)=gbest(1,:);

1112 %% Appliances Scheduled hours

1113 Vacu um Cle aner G(:,hour)=a pp S ch G(hour,1);

1114 water Hea ter G (:,hour)=app S ch G(hour,2);

1115 wat er Pu mp G(:,hour)= ap p Sch G (hour,3);

1116 dish washer G(:,hour)=ap p S ch G (hour,4);

1117 Wash ing ma chin e G(:,hour)=a pp Sch G (hour,5);

1118 Cloth dryer G(:,hour)=ap p S ch G (hour,6);

1119 refrigerator G(:,hour)= ap p S ch G(hour,7);

1120 AC G(:,hour)=ap p Sc h G(hour,8);

1121 oven G(:,hour)=a pp Sch G (hour,9);

1122

1123 end

1124 old fxCG(er2)= su m E Cost SS G ;

1125 old fxPG(er2)=P AR sc heduled G ;

1126 if er2>1

1127 errorG=abs(old f xCG(er2-1) - old f xCG(er2));

1128 errorGP=abs(old f xPG(er2-1) - old f xPG(er2));

1129 errorG1(count2)=errorG;

1130 errorG2(count2)=errorGP;

1131 end

1132 count2=count2+1;

1133 PoPulationG(count2)=popSize;

1134 er2=er2+1;

1135 %% Average Calculation

1136 app SchAvg G =app Sch G+app SchAvg G;

1137 schedule load Avg G =schedule load Avg G+schedule load G;

1138 E Cost SS Avg G =E Cost SS Avg G+E Cost SS G;

1139 sum s che duled l oad A vg G =sum schedul ed lo ad G+ sum s chedu led l oad A vg G;

1140 sum E Cost SS Avg G =sum E Cost SS Avg G+sum E Cost SS G;

1141 PAR scheduled Avg G =PAR scheduled Avg G+PAR scheduled G;

1142

1143 %% Cofidence Interval Parameters

1144 GA PA R(avg2,:)=PAR sch eduled G;

1145 GA E C os t SS (avg2,:)=E C ost S S G;

1146 GA sche dul e lo ad (avg2,:)= schedul e load G;

1147 GA s um E C os t SS (avg2,:)=su m E Co st SS G ;

1148 GA ap p Sc h(:,:,avg2)=app Sch G;

1149 GA Sum Sche dul ed lo ad(avg2,:)= sum s che dul ed lo ad G;

1150 GA app Sch GA(:,:,avg2)= G ap p S ch G ;

1151 % avg2=avg2+1;

1152 if avg2>1

1153 MSEtst(avg2-1,:) = mse(GA PAR(avg2-1,:)-GA PAR (avg2,:));

1154 end

1155

1156 app S ch G 1=app Sch G ;

1157 app S ch G11= ap p Sc h G;

1158 w time=time slo ts;

1159

1160 Vacu um Cle aner G 1=zeros(1,24);

1161 Dish wash er G1 =zeros(1,24);

1162 wate r Heater G1 =zeros(1,24);

1163 water Pump G1=zeros(1,24);

1164 Washing machine G1=zeros(1,24);

1165 Cloth dry er G1 =zeros(1,24);

1166 refrigerator G1=zeros(1,24);

1167 AC G1 =zeros(1,24);

1168 oven G 1=zeros(1,24);

1169 Vac um c lea ner U n GA =Vacu m cleane r;

1170 Dis h wash er U n GA=Dish washer;

1171 for hr=1:24

1172 gbes t 1=[];

1173 gbes t 1(1,:)=a pp S ch G 1(hr,:);

1174

1175 % possible hour=[];

1176 Appli Can On;

1177 % List Off App=[];

1178 % List O n App=[];

1179 gb=0;

17

1180 gbb=0;

1181 List Off App=[];

1182 List On App=[];

1183 for b=1:D

1184 % if b 6=4| | b6=5| | b6=8| | b6=9

1185 if (gbe st 1(1,b)==0)

1186 gb=gb+1;

1187 Lis t Off A pp(gb)=b;

1188 end

1189 if (gbe st 1(1,b)>0)

1190 gbb=gbb+1;

1191 Lis t On App(gbb)=b;

1192 end

1193 % end

1194 end

1195 Off Ap p=[];

1196 App C an Off=I nTruP t App;

1197 w=0;

1198 flag1=0;

1199 flag2=0;

1200 for ll=1:length(Li st On App )

1201 app=0;

1202 app= find(App Ca n Off==L ist O n Ap p(ll));

1203 if app>0

1204 w=w+1;

1205 Off Ap p(w)=A pp C an O ff(app);

1206 end

1207 end

1208 appli Off=inf;

1209 F App =0;

1210 App On=0;

1211 if Off App >0% Check if user want to switched off an appliance

1212 U In t On e = randi([0 1], 1); % if user want to intrupt

1213 if U Int One == 1

1214 if length(Off A pp)>1

1215 appli Off= randsample(Of f App,1); % Appliance that user have switched off

1216 else

1217 appli Off = Off A pp;

1218 end

1219 end

1220 end

1221 %%

1222 %%%%%%%%%%%%%%%%%ˆˆˆˆˆˆˆˆˆˆˆˆTIMEˆˆˆˆˆˆˆˆˆˆˆˆ%%%%%%%%%%%%%%%%%

1223 if appli Off 6=inf

1224 One rang1 =1; % decide the time to off the appliance

1225 One rang = 60;

1226 r One = (One rang-One rang1).*rand(1) + One rang1;

1227 r One =round(r One);%*100) / 100; % when appliance will me closed

1228 T al =60-r On e; % 60 total mint with in hour where T al will be allocated time for oven

1229 T a l G =T a l;

1230 % % % % % %%% Convert T a l mint into hour

1231 % % % % % r On e=r One /60; % Time of Appliance that have been closed

1232 % % % % % T a l= T al /60; % Closed Appliance pass time to another appliance

1233 time Ex tra =T a l;

1234 jll=0;

1235 Z App =0;

1236 % Appl i Can O n=A ppl i Can On(randperm(length(App li Ca n On)))

1237 On App=0;

1238 appl i On=inf; % select the appliance feasibility to on

1239 % W LO T =[]; % weigth in our case it will be length of operational time

1240 % V Cost=[]; % volume in our case will be cost during specific hour

1241 Z App =strfind(ismember(List Off App,Appli Ca n On),1); % this will return the index

1242 Z App =List Off Ap p(Z A pp); % appliances

1243 W LOT1={}; W LOT hour1={};

1244 app identity1=[]; W LOT=[]; W L OT h our =[]; V C OST = []; Sch S elc app=[];

1245 if Z App>0

1246

1247 j j=1;

1248 for k=1:length(Z Ap p)

1249 if w time(1,Z A pp(k))>0

1250

18

1251 Sch S elc a pp= ap p Sc h G1 (hr:end,Z Ap p(k));

1252 Sch S elc a pp=Sch Selc app ';

1253 [vale indx]=find((a pp Sch G1(hr:end,Z A pp(k)))'6=0);

1254 vale=Sc h Sel c app (indx);

1255 indx=indx+hr-1;

1256 W LOT1{k}=vale;

1257 W LOT hour1{k}=indx;

1258 app identity1(k)=length(vale);

1259 end

1260 end

1261 d d=1;

1262 for k=1:length(W LOT1)

1263 new Value=W LOT 1{k};

1264 new Val ue2= W LO T hour 1{k};

1265 for j=1:length(new Value)

1266 W LO T( d d )=new Value(j);

1267 W LO T h our(d d )=new V alue2(j);

1268 VCOST(d d )=EP(hr)*p(Z A pp(k));

1269 d d= d d+1;

1270 end

1271 end

1272

1273 EP hr =EP(hr);

1274 [sol] = Dynamic Programing(D EP , EP h r, W L OT ,V COS T, time Extra);

1275 if sum(sol)≥1

1276 sol sub1= mat2cell(sol,1,[app identity1]);

1277 for k=1:length(sol s ub1)

1278 sol sub= sol sub1{k};

1279 Time hour=strfind(s ol sub,1);

1280 w time (1,Z App(k)) = w tim e(1,Z A pp (k))-length(Time hour);

1281 if w time(1,Z A pp(k))≥0

1282 LOT W=W LOT hour1{k};

1283 selected hours= LOT W( Time hour); % selected hour to shift from schedule

1284 Total mints= W LOT1{k};

1285 Operational time= Total mints(Time ho ur); % operational time of appliance during that hour

1286

1287 app S ch G11(hr, Z App (k))=sum(Operational time);

1288 app S ch G 1(hr,Z A pp(k))=0;

1289 for j j j=1:length(selected hours)

1290 app S ch G11(selected hours(j j j), Z App(k))=0;

1291 app S ch G 1(selected hours(j jj),Z A pp(k))=0;

1292

1293 app S ch G11(hr,appli Off)= r O ne/60;

1294 if Z App (k)==1

1295 Vacu um Cleaner G1(1,s elected hours( j j j))=hr;

1296 flag1=1;

1297 Val1= strfind( V acu m cl ean er Un G A,Operational time( j j j));

1298 Vac um cl ean er Un G A(Val1)=hr;

1299 Val1=0;

1300 end

1301 if Z App (k)==4

1302 Dish was her G1(1,selected hours(j jj))=hr;

1303 flag2=1;

1304 Val1= strfind( D ish wa she r U n GA ,Op erational time( j j j));

1305 Dis h washe r Un GA (Val1)=hr;

1306 Val1=0;

1307 end

1308 end

1309 end

1310 if w time(1,Z A pp(k))<0| | sum(sol)==0

1311 app S ch G11(hr,appli Off)= r O ne/60;

1312 end

1313 end

1314 end

1315 end

1316 end

1317

1318 gBsT(1,:)=ap p Sch G11 (hr,:);

1319

1320 for b=1:D

1321 if (gBsT(1,b)>0) && b 6=1 && b6=4

19

1322 w time(1,b) = w time (1,b)-1;

1323 elseif (gBsT(1,b) == 0)

1324 w time(1,b)= w time(1,b);

1325 end

1326 if (gBsT(1,b)>0) && (b ==1 && flag1==0)

1327 w time(1,b) = w time (1,b)-1;

1328 end

1329 if (gBsT(1,b)>0) && (b ==4 && flag2==0)

1330 w time(1,b) = w time (1,b)-1;

1331 end

1332 end

1333 gBsT(1,:)=ap p Sch G11 (hr,:);

1334 %% Appliances Scheduled hours

1335 value1= strfind(Vacuum Cleaner G1,[hr]);

1336 if length(value1)==0

1337 if (gBsT(1,1)>0)

1338 Vacu um Cle aner G 1(:,hr)=hr;

1339 Val1= strfind(Vacum clea ner U n GA ,gBsT(1,1));

1340 Vac um cl ean er Un G A(Val1)=Val1;

1341 Val1=0;

1342 end

1343 end

1344 if gBsT(1,2)>0

1345 wate r Heater G1 (:,hr)=hr;

1346 end

1347 if gBsT(1,3)>0

1348 water Pump G1(:,hr)=hr;

1349 end

1350 value11= strfind(Di sh washer G 1,[hr]);

1351 if length(value11)==0

1352 if (gBsT(1,4)>0)

1353 Dish wash er G1 (:,hr)=hr;

1354 Val1= strfind(Dish w ash er Un GA,gBsT(1,4));

1355 Dis h washe r Un GA (Val1)=Val1;

1356 Val1=0;

1357 end

1358 end

1359 if gBsT(1,5)>0

1360 Washing machine G1(:,hr)=hr;

1361 end

1362 if gBsT(1,6)>0

1363 Cloth dry er G1 (:,hr)=hr;

1364 end

1365 if gBsT(1,7)>0

1366 refrigerator G1(:,hr)=hr;

1367 end

1368 if gBsT(1,8)>0

1369 AC G1 (:,hr)=hr;

1370 end

1371 if gBsT(1,9)>0

1372 oven G 1(:,hr)=hr;

1373 end

1374 end

1375

1376 for hrr = 1:24

1377 gBsT(1,:)=ap p Sch G11 (hrr,:);

1378

1379 % Fi nd n Z h r=find(Vacuum cleaner);

1380 % Find Time=Vacuum cleaner(Fi nd n Z h r);

1381 %%

1382 electricity cost=[EP(hrr)*p(1) EP(hrr)*p(2) EP(hrr)*p(3) EP(hrr)*p(4) EP(hrr)*p(5) EP(hrr)*p(6) ...

EP(hrr)*p(7) EP(hrr)*p(8) EP(hrr)*p(9)];%coefficients of objective function

1383 sche dule l oad G1(hrr)=p*gBsT(1,:)';

1384 E C os t S S G 1(hrr)=electricity cost*gBsT(1,:)';

1385 sum sched ule d loa d G1=sche dule l oad G1 (hrr)+su m scheduled lo ad G1 ;

1386 su m E Co st S S G1 =E C ost SS G1(hrr)+s um E C os t SS G 1;

1387 for g g = 1: length(gBsT)

1388 if gBsT(1,g g )>0

1389 gBsT(1,g g )=1;

1390 end

1391 if gBsT(1,g g )==0

20

1392 gBsT(1,g g )=0;

1393 end

1394 end

1395 G ap p Sch G 1(hrr,:) = gBsT(1,:);

1396 end

1397 %%

1398 PAR sc hedu led G1=max(sc hedu le load G1)ˆ2/(( sum s che dul ed lo ad G1 )/24)ˆ2;

1399 count1=count1+1;

1400 PoPulation(count1)=Np;

1401 %% Average Calculation

1402 app SchAvg G1 =ap p Sc h G1 +app SchAvg G1;

1403 schedule load Avg G1 =schedule load Avg G1+s chedule load G1;

1404 E Co st S S Av g G1 =E C os t SS A vg G 1+ E Cost SS G1;

1405 sum scheduled load Avg G1 =sum scheduled load G1+sum scheduled load Avg G1;

1406 sum E Cost SS Avg G1 =sum E Cost SS Avg G1+sum E Cost SS G1;

1407 PAR scheduled Avg G1 =PAR scheduled Avg G1+P AR sch eduled G1;

1408

1409

1410 %% Cofidence Interval Parameters

1411 GA PAR 1(avg2,:) =PAR sch edu led A vg G1 ;

1412 GA E Cost SS1(avg2,:) =E Co st S S G1 ;

1413 GA schedul e load 1(avg2,:) =sch edul e load G1;

1414 GA sum E C os t SS 1(avg2,:) = su m E Cost SS G 1;

1415 GA app Sch1 (:,:,avg2) =G a pp S ch G 1;

1416 GA Sum Sche duled load1(avg2,:)= sum s che duled load G1;

1417 Vacuum Cleaner G11(:,:,avg2)=Vacuum Cleaner G1 ;

1418 Dish w asher G11 (:,:,avg2)=Di sh wa sher G1;

1419 wate r Heat er G11(:,:,avg2)=wa ter H eate r G1;

1420 water Pum p G11 (:,:,avg2)=wa ter P ump G 1;

1421 Washing mac hine G11(:,:,avg2)=Washing machine G1;

1422 Clot h dryer G11 (:,:,avg2)=Cl oth d ryer G1;

1423 refrigerator G11(:,:,avg2)= refrige rator G1;

1424 AC G11(:,:,avg2)=A C G1;

1425 oven G 11(:,:,avg2)=o ven G 1;

1426 Vacu m clea ner CG A(:,:,avg2)= Vacu m cleaner Un G A;

1427 Dish w asher CGA (:,:,avg2)=Dish w asher U n GA ;

1428 end

1429 toc

1430 NP=popSize;

1431 ind=popSize;

1432 Re Ap p Time=zeros(1,D);

1433 tbits=9;

1434 % maxgen=1000;

1435 insite=2; %

1436 pc=0.9; % Probability of crossover

1437 pm=1-pc; % Probability of mutation

1438 count=0;

1439 ss=zeros();

1440 av3=0;

1441 a3=0;

1442 PoP=(rand(NP,D));

1443 for j=1:NP

1444 for i=1:D

1445 if PoP(j,i)>Pro Gen%std(unscheduledload) % rand(1) means 1*1 matrix

1446 PoP(j,i)=1;

1447 else

1448 PoP(j,i)=0;

1449 end

1450 end

1451 end

1452 tic

1453 for avg3=1:5

1454 % x lies in [-30 30]

1455 t x=0;

1456 l x=0;

1457 t AC=0;

1458 l AC=0;

1459 VAR1=0;

1460 VAR2=0;

1461 PAR sched ule d Avg B G1=0;

1462

21

1463 J=zeros(NP,1);

1464 PoPnEw=PoP;

1465 for k=1:NP %k=reproduction

1466 for i=1:D-1

1467 J(k)=sum(100*(PoP(k,i+1)-PoP(k,i)ˆ2)ˆ2+(PoP(k,i)-1)ˆ2); % initial fitness calculation

1468 end

1469 end

1470 FgbEst=inf;

1471 % gbEst=inf;

1472 %% Swarm behaviour to save the value ... as we may find a better cost via a run

1473

1474 c electricity cost=-[p(1) p(2) p(3) p(4) p(5) p(6) p(7) p(8) p(9)]; %coefficients of constraint

1475 errorBG=inf;

1476

1477 % while (NP<600)

1478 best=inf;

1479 gbEst=inf;

1480 Fbest=inf;

1481 app S ch B G=zeros(24,9);

1482 sum sched ule d loa d BG=0;

1483 BG ti me slots=[ti me slots Intrupt time s lots n onIn tr time slotFixed];

1484 E Co st S S BG =zeros(1,24);

1485 su m E Co st S S BG =0;

1486 PAR scheduled BG=0;

1487 PAR schedu led Av g=0;

1488 sche dule l oad BG=zeros(1,24);

1489 E Co st S S BG =zeros(1,24);

1490 su m E Co st S S BG =0;

1491 PAR scheduled BG=0;

1492 PAR schedu led Av g=0;

1493 sche dule l oad BG=zeros(1,24);

1494

1495 app S ch BG1=zeros(24,9);

1496 sum sc hed uled load BG1=0;

1497 E Co st S S B1 =zeros(1,24);

1498 su m E Co st S S BG 1=0;

1499 PAR schedu led BG 1=0;

1500 PAR scheduled Avg1=0;

1501 sche dule l oad BG 1=zeros(1,24);

1502 E Co st S S B1 =zeros(1,24);

1503 su m E Co st S S BG 1=0;

1504 PAR schedu led BG 1=0;

1505 PAR scheduled Avg1=0;

1506 sche dule l oad BG 1=zeros(1,24);

1507

1508

1509 PoP=(rand(NP,D)); % x lies in [-30 30]

1510 for j=1:NP

1511 for i=1:D

1512 if PoP(j,i)>Pro Gen%std(unscheduledload) % rand(1) means 1*1 matrix

1513 PoP(j,i)=1;

1514 else

1515 PoP(j,i)=0;

1516 end

1517 end

1518 end

1519 J=zeros(NP,1);

1520 PoPnEw=PoP;

1521 for k=1:NP %k=reproduction

1522 for i=1:D-1

1523 J(k)=sum(100*(PoP(k,i+1)-PoP(k,i)ˆ2)ˆ2+(PoP(k,i)-1)ˆ2); % initial fitness calculation

1524 end

1525 end

1526 JLast=J;

1527 Jlast=J;

1528 counts App=0;

1529 w time=time slo ts;

1530 %% Section IV-B

1531 for hour=1:24 % l=elimination of dispersal step

1532 FgbEst=inf;

1533 %% %%%%%%%%%%%% Working %%%%%%%%%%%% %%

22

1534 %% START 2

1535 electricity cost=[EP(hour)*p(1) EP(hour)*p(2) EP(hour)*p(3) EP(hour)*p(4) EP(hour)*p(5) ...

EP(hour)*p(6) EP(hour)*p(7) EP(hour)*p(8) EP(hour)*p(9)];%coefficients of objective function ...

1536

1537 % for j=1:NE % l=elimination of dispersal step

1538

1539 for k=1:Nr %k=reproduction

1540

1541 Jchem=J;

1542

1543 for ji=1:Nc %ChemotaPoPnEwis Loop %

1544 for i=1:NP %Take a chemotaPoPnEwis Step

1545 del=(rand(1,D)-Ped)*2;

1546 PoP(i,:)=PoP(i,:)+(C/sqrt(del*del'))*del; %Direction of Tumble i.e. new position of bactarium

1547 for d=1:D-1

1548 J(i)=sum(100*(PoP(i,d+1)-PoP(i,d)ˆ2)ˆ2+(PoP(i,d)-1)ˆ2); %Fitness Function

1549 end

1550 for m=1:Ns

1551 if J(i)<Jlast(i)%Elimination and Dispersal Check

1552 Jlast(i)=J(i);

1553 PoP(i,:)=PoP(i,:)+C*(del/sqrt(del*del')); %Direction of Tumble i.e. new position of bactarium

1554 for d=1:D-1

1555 J(i)=sum(100*(PoP(i,d+1)-PoP(i,d)ˆ2)ˆ2+(PoP(i,d)-1)ˆ2); %Fitness Function

1556 end

1557 else

1558 del=(rand(1,D)-Ped)*2;%Vector with random Direction

1559 PoP(i,:)=PoP(i,:)+C*(del/sqrt(del*del'));

1560 for d=1:D-1

1561 J(i)=sum(100*(PoP(i,d+1)-PoP(i,d)ˆ2)ˆ2+(PoP(i,d)-1)ˆ2);

1562 end

1563 end

1564 end

1565 end

1566 Jchem=[Jchem J];

1567 end % End of ChemotaPoPnEwis %

1568 PoPnEwnew=PoP;

1569

1570 %------------------------- Mutation done ----------------------%

1571

1572 %-------------------------- New population generated ---------------------%

1573 %-------------------------------------------------------------------------%

1574

1575 % end

1576

1577 for j=1:popSize

1578 for i=1:D

1579 if PoPnEwnew(j,i)>Pro Gen % rand(1) means 1*1 matrix

1580 PoPnEwnew(j,i)=1;

1581 else

1582 PoPnEwnew(j,i)=0;

1583 end

1584 end

1585 end

1586 lhour=25-hour;

1587 if lhour≤(BG time slot s(1,5)+B G tim e slo ts(1,6))

1588 for a=1:popSize

1589 PoPnEwnew(a,5)=1;

1590 if BG time slots(1,5)≤0

1591 PoPnEwnew(a,6)=1;

1592 elseif BG time slots(1,5)>0

1593 PoPnEwnew(a,6)=0;

1594 end

1595 end

1596 elseif hour>