An Approach Towards Efficient Energy Distribution

2 downloads 0 Views 1MB Size Report
proved that GA-EMC worked more efficiently as compared to the binary parti- ..... In this chapter, an EMC is proposed with an objective to minimize the energy.
An Approach Towards Efficient Energy Distribution and Power Flow Management in Smart Grid using Various Meta Heuristic Techniques

By

Sundus Shafiq CIIT/FA16-RSE-018/ISB

MS Thesis In Software Engineering

COMSATS University Islamabad, Islamabad, Pakistan

Spring, 2018 i

COMSATS University Islamabad

An Approach Towards Efficient Energy Distribution and Power Flow Management in Smart Grid using Various Meta Heuristic Techniques

A Thesis Presented to

COMSATS University Islamabad, Islamabad, Pakistan

In partial fulfillment of the requirement for the degree of

MS (Software Engineering)

By

Sundus Shafiq CIIT/FA16-RSE-018/ISB

Spring, 2018 ii

An Approach Towards Efficient Energy Distribution and Power Flow Management in Smart Grid using Various Meta Heuristic Techniques

A Post Graduate Thesis submitted to the Department of Computer Science as partial fulfillment of the requirement for the award of Degree of MS (Software Engineering).

Name

Registration Number

Sundus Shafiq CIIT/FA16-RSE-018/ISB

Supervisor: Dr. Nadeem Javaid, Associate Professor, Department of Computer Science, COMSATS University Islamabad, Islamabad, Pakistan.

Co-Supervisor: Dr. Syed Hassan Ahmed, Assistant Professor (Tenure-Track), Department of Computer Science, Georgia Southern University, Statesboro, GA, USA. iii

Final Approval This thesis titled

An Approach Towards Efficient Energy Distribution and Power Flow Management in Smart Grid using Various Meta Heuristic Techniques By Sundus Shafiq CIIT/FA16-RSE-018/ISB has been approved For the COMSATS University Islamabad, Islamabad, Pakistan External Examiner: Dr. Muhammad Hasan Islam Associate Professor, CASE, Islamabad, Pakistan Supervisor: Dr. Nadeem Javaid Associate Professor, Department of Computer Science, COMSATS University Islamabad, Islamabad, Pakistan Co-Supervisor: Dr. Syed Hassan Ahmed Assistant Professor (Tenure-Track), Department of Computer Science, Georgia Southern University, Statesboro, GA, USA

HoD: Dr. Majid Iqbal Khan Associate Professor, Department of Computer Science, COMSATS University Islamabad, Islamabad, Pakistan iv

Declaration I Sundus Shafique (Registration No. CIIT/FA16-RSE-018/ISB) hereby declare that I have produced the work presented in this thesis, during the scheduled period of study. I also declare that I have not taken any material from any source except referred to wherever due that amount of plagiarism is within acceptable range. If a violation of HEC rules on research has occurred in this thesis, I shall be liable to punishable action under the plagiarism rules of the HEC.

Date: 21st May, 2018 Sundus Shafiq CIIT/FA16-RSE-018/ISB

v

Certificate It is certified that Sundus Shafique (Registration No. CIIT/FA16-RSE-018/ISB) has carried out all the work related to this thesis under my supervision at the Department of Computer Science, COMSATS University Islamabad, Islamabad and the work fulfills the requirement for award of MS degree.

Date: 21st May, 2018

Supervisor:

Dr. Nadeem Javaid Associate Professor, COMSATS University Islamabad, Islamabad

Co-Supervisor:

Dr. Syed Hassan Ahmed Assistant Professor (Tenure-Track), Georgia Southern University, Statesboro Head of Department:

Dr. Majid Iqbal Khan Associate Professor, Department of Computer Science COMSATS University Islamabad, Islamabad

vi

DEDICATION

Dedicated to my very best teacher Dr. Nadeem Javaid and loving Parents, who equipped me with pearls of knowledge and showed me the way of spiritual and personal enlightenment in this world and the world hereafter.

vii

ACKNOWLEDGEMENT All praises to Allah Almighty, the most merciful, beneficial and most gracious for blessing me with strength and confidence to complete my research work.

Foremost, I would like to express my sincere gratitude to my advisor Dr. Nadeem Javaid for the continuous support of my MSSE study and research, for his patience, motivation, enthusiasm, and immense knowledge. His guidance helped me in all the time of research and writing of this thesis. I could not have imagined having a better advisor and mentor for my MS study.

Besides my advisor, I would like to thank the rest of my thesis committee for their encouragement, insightful comments, and hard questions. I thank my fellow labmates in Comsense Group, for the stimulating discussions, we were working together before deadlines, and for all the fun we have had in the last one years. In particular, I am grateful to Dr. Nadeem Javaid for enlightening me the first glance of research.

viii

ABSTRACT Smart grid is an innovative and novel technology successfully implemented by the use of different communication methods. Demand side management (DSM) plays a significant role in the management of load and energy consumption in order to reduce cost in the smart grids. Smart buildings and smart homes are usually considered important for reducing the electricity consumption by home energy management controllers (HEMC). Within the research community, different optimization techniques have been designed for home energy management system (HEMS). In this work, the performance of few heuristic algorithms, i.e., genetic algorithm (GA), harmony search algorithm (HSA), enhanced differential evolution (EDE), tabu search (TS) and backtracking search optimization algorithm (BSOA) is evaluated for optimization in residential area. Also, an optimal power flow (OPF) problem is formulated for economic operation of electrical system while incorporating stochastic and intermittent nature of solar photovoltaic (PV) and wind generators. Proposed techniques are used for efficient scheduling of smart appliances in smart homes on the customer side as well as for the optimal setting of control variables on the supply side. Besides, minimization of power generation cost, concern on environment is also taken into account and reduction of carbon emission factor is included into the objective function. Simulations were performed in MATLAB by using real time pricing (RTP) tariff and IEEE standard bus test systems. Evaluated results proved that our defined goals of cost reduction, improvement of user comfort (UC) level and minimization of peak to average ratio (PAR) are achieved.

ix

Conference Proceedings Dr. Nadeem Javaid, Associate Professor (Supervisor) Dr. Syed Hassan Ahmed, Associate Professor (Co-Supervisor) Sundus Shafiq (MS Scholar)

1 Sundas Shafiq, Iqra Fatima, Samia Abid, Sikandar Asif, Sajeeha Ansar, Zain Ul Abideen, and Nadeem Javaid, “Optimization of Home Energy Management System through Application of Tabu Search”, 12th International Conference on P2P, Parallel, Grid, Cloud and Internet Computing (3PGCIC), 2017, pp. 37-49.

2 Sundas Shafiq, Sikander Asif, Iqra Fatima, Kubra Yousaf, Wajiha Safat, and Nadeem Javaid, “An approach towards efficient scheduling of home energy management system using backtracking search optimization and tabu search”, in 32nd IEEE international Conference on Advanced Information Networking and Applications (AINA-2018).

3 Sundas Shafiq, Nadeem Javaid, and Sheraz Aslam, “Optimal power flow control in a smart micro-grid using bird swarm algorithm”, in 5th International Multi-Topic ICT Conference (IMTIC-2018).

4 Sundas Shafiq, Sikandar Asif, Nadeem Javaid, Farwa Ali, Nasir Hussain Chughtai, and Nouman Khurshid, “An optimal power flow approach for stochastic wind and solar energy integrated power systems”, in 12th International Conference on Complex, Intelligent, and Software Intensive Systems (CISIS-2018).

5 Iqra Fatima, Sikandar Asif, Sundas Shafiq, Ch Anwar ul Hassan, Sajeeha Ansar, and Nadeem Javaid, “Load Scheduling Optimization using Heuristic Techniques and Combined Price Signal”, 20th International Conference on Network Based Information Systems (NBiS), 2017, pp. 822-832.

x

6 Sikandar Asif, Sundas Shafiq, Iqra Fatima, CH Anwar ul Hassan, Zain Ul Abideen, and Nadeem Javaid, “A Heuristic Scheduling Approach for Demand Side Energy Management”, 20th International Conference on Network Based Information Systems (NBiS), 2017, pp. 995-1003.

7 Iqra Fatima, Nadeem Javaid, Sundas Shafiq, Sikandar Asif, Muhammad Hassan Rahim, and Sheraz Aslam, “Comparative study of meta-heuristic approaches towards utilization of home energy management”, in 2018 International Conference on Computing, Mathematics and Engineering Technologies (iCoMET-2018).

8 Iqra Fatima, Sikandar Asif, Sundas Shafiq, Itrat Fatima, Muhammad Hassan Rahim, and Nadeem Javaid, “Efficient Demand Side Management using Hybridization of Elephant Herding Optimization and Firefly Optimization”, in 32nd IEEE international Conference on Advanced Information Networking and Applications (AINA-2018).

9 Anila Yasmeen, Nadeem Javaid, Saman Zahoor, Hina Iftikhar, Sundas Shafiq, and Zahoor Ali Khan, “Optimal Energy Management in Microgrids using Meta-heuristic Technique”, in 6th International Conference on Emerging Internet working, Data and Web Technologies (EIDWT-2018).

10 Muhammad Hassan Rahim, Nadeem Javaid, Sundas Shafiq, Muhammad Nadeem Iqbal, Muhammad Umair Khalid, and Ubed Memon, “Exploiting heuristic techniques for efficient energy management system in smart grid”, in 14th IEEE International Wireless Communications and Mobile Computing Conference (IWCMC-2018).

11 Manzoor Ahmed, Nadeem Javaid, Iftikhar Azim Niaz, Sundas Shafiq, Obaid Ur Rehman, and Hafiz Majid Hussain, “Application of Bird Swarm Algorithm for Solution of Optimal Power Flow Problems”, in 12th International Conference on Complex, Intelligent, and Software Intensive Systems (CISIS2018).

xi

TABLE OF CONTENTS Dedication

vii

Acknowledgements

viii

Abstract

ix

Conference Proceedings

x

List of Figures

xiv

List of Tables

xv

List of Algorithms

xvi

1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 2

2.1

Literature Review . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7 8

3.1 3.2

Summary of Chapter . . . . . . . . . . . . . Proposed System . . . . . . . . . . . . . . . 3.2.1 HSA . . . . . . . . . . . . . . . . . . 3.2.2 TS . . . . . . . . . . . . . . . . . . . 3.2.3 Electricity Consumption Pattern . . 3.2.4 Proposed Mathematical Formulation Performance Evaluation and Analysis . . . . Conclusion of Chapter . . . . . . . . . . . .

1.1 2

3

3.3 3.4

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

16 17 17 17 17 18 18 21 24

. . . . . . . .

26 27 27 28 29 29 33 35 36

. . . .

37 38 38 39 40

4 4.1 4.2 4.3

4.4 4.5

Summary of Chapter . . . . . . . . . . System Model . . . . . . . . . . . . . . 4.2.1 Smart Appliances . . . . . . . . Evolutionary Algorithms . . . . . . . . 4.3.1 BSOA . . . . . . . . . . . . . . 4.3.2 TS . . . . . . . . . . . . . . . . Computational Results and Discussion Conclusion of Chapter . . . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

5 5.1 5.2

Summary of Chapter Proposed System . . 5.2.1 HSA . . . . . 5.2.2 EDE . . . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . . xii

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

5.3 5.4

5.2.3 TS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Simulation Results . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Conclusion of Chapter . . . . . . . . . . . . . . . . . . . . . . . . . 45

6 6.1 6.2

6.3

7.1 7.2

59 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

7

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

47 48 48 48 49 49 50 51 52 52 58

Summary of Chapter . . . . . . . . . . . . . . . . . . . . . . Mathematical Modeling . . . . . . . . . . . . . . . . . . . . 6.2.1 Cost Model for Thermal Generators . . . . . . . . . . 6.2.2 Direct Cost Model of Solar PV and Wind Generators 6.2.3 Equality Constraints . . . . . . . . . . . . . . . . . . 6.2.4 Inequality Constraints . . . . . . . . . . . . . . . . . 6.2.5 Power Model for Wind and Solar Energy System . . 6.2.6 Probabilistic Modeling of Wind and Solar PV . . . . 6.2.6.0.1 O . . . . . . . . . . . . . . . . . . Conclusion of Chapter . . . . . . . . . . . . . . . . . . . . .

8 Ref. Appendices .1 Appendix .2 Appendix .3 Appendix .4 Appendix .5 Appendix

61

A B C D E

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

xiii

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

70 71 72 96 118 133

LIST OF FIGURES 1.1 1.2

Architecture of SG . . . . . . . . . . . . . . . . . . . . . . . . . . . Smart home with smart appliances . . . . . . . . . . . . . . . . . .

3.1 3.2 3.3 3.4 3.5 3.6

Proposed system model RTP price signal . . . PAR. . . . . . . . . . . User comfort . . . . . Cost . . . . . . . . . . Load . . . . . . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

21 22 22 23 23 23

4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8

General steps for BSOA algorithm . RTP price signal . . . . . . . . . . PAR. . . . . . . . . . . . . . . . . . Total cost . . . . . . . . . . . . . . Total load . . . . . . . . . . . . . . Waiting time . . . . . . . . . . . . Hourly cost . . . . . . . . . . . . . Hourly load . . . . . . . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

30 31 31 32 32 33 33 34

5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8

Home energy management system Combined price signal . . . . . . Total cost . . . . . . . . . . . . . Hourly cost . . . . . . . . . . . . User comfort . . . . . . . . . . . PAR reduction . . . . . . . . . . Total load . . . . . . . . . . . . . Hourly load . . . . . . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

40 42 42 43 43 44 44 45

6.1 6.2 6.3

Solution procedure flow chart of optimal scheduling. . . . . . . . . . 53 Active power generation of all cases. . . . . . . . . . . . . . . . . . 56 Reactive power generation of all cases. . . . . . . . . . . . . . . . . 57

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

xiv

. . . . . . . .

4 6

LIST OF TABLES 3.1

Parameters used in simulation process . . . . . . . . . . . . . . . . 21

4.1

Parameters used in simulation process . . . . . . . . . . . . . . . . 29

5.1 5.2

Fixed parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Shiftable parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 41

6.1 6.2 6.3 6.4 6.5 6.6

Cost coefficients of thermal generators. . . . . . . . . . . . Emission coefficients of thermal generators. . . . . . . . . . Cost coefficients of thermal generator 1 and 2 for multi fuel PDF parameters for wind power generation plant. . . . . . Main characteristics of IEEE 30 bus test system. . . . . . . Cost coefficients of thermal generators. . . . . . . . . . . .

xv

. . . . . . . . . . function. . . . . . . . . . . . . . . .

54 54 54 55 56 58

List of Algorithms

1 2 3

HSA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 TS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 EDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

xvi

Chapter 1 Introduction

1

CHAPTER 1.

1.1

1.1. INTRODUCTION

Introduction

The world is getting more and more advanced with the emergence of new technologies and their innovative use. Electricity is an important and necessary need in today´s world. For the purpose of efficient use of energy with minimum cost and maximum user comfort (UC), home energy management is done. Electricity is generated in power grid stations and distributed through different utility companies. In today´s world, electricity crisis in form of blackouts, load shedding, voltage instability and frequency drop are the major issues faced by people [1]. To deal with these issues, two different approaches are used. In the first one, electricity generation is increased by means of installing renewable energy resources (RERs) other than the traditional sources like thermal generators, fuel cells etc. The second one is to control the load demand from customers with the proper scheduling. The one way electricity transmission and communication in the traditional grids is unable to meet electricity demand. For this purpose, instead of traditional grids, smart grids (SGs) are introduced. SG is a network that introduces a physical power system which integrates information control and communication technologies to form a customer satisfied platform [2]. It is a modern system which provides energy to residential, commercial and industrial areas while allowing two-way communication between utility and electricity consumers. Electricity can be generated through variety of ways like hydro power, solar energy, biogas and wind energy. This simple architecture for SG is shown in Fig. 1.1 and the smart home with smart appliances is shown in Fig. 1.2. Through SG, consumers can easily manage their electricity usage pattern and reduce their electricity bills. Consumption of electricity can be reduced by controlling the demand of electricity efficiently. Demand side management (DSM) is one of the most important aspect of SG that maintains the balance between load and demand by allowing customers to take wise decisions regarding their electricity usage patterns [3]. Various activities are performed for management of resources and scheduling of appliances on both supply and demand side. Both utility and consumer sides actively co-operate and participate in various demand response (DR) programs in order to minimize the electricity consumption. DR can be defined as the action taken by the users from consumer side in response of an offered pricing models [4]. DR is useful for both utility and consumers as for utility there will be no excessive load demand and the chances of blackout will be decreased. On the other hand, consumers will get benefit in the form of reduced electricity bill with high level of ease and comfort. For supply side management, production of electricity and its distribution is handled 2

CHAPTER 1.

1.1. INTRODUCTION

whereas, in DSM consumers reschedule their appliances against the pricing tariff in order to reduce the peak to average ratio (PAR). For this purpose, a modified and updated energy management system (EMS) is required to consume electricity wisely. The importance of such a system is reflected by the achieved assistances like maximum bill reduction, minimum PAR and maximum user satisfaction. Moreover, it also provides solution regarding security, reliability and stability of the system. According to the literature review, till now, there are alot of techniques which were proposed for the optimization of home energy management system (HEMS). These techniques performed efficiently in case of PAR and cost reduction. In [5], authors presented an EMS to tackle DR while using time of use (ToU) price signal. The objective behind using DR approach was to handle and shift the on-peak load to off-peak load. In this presented work, authors efficiently considered the user satisfaction element. Whereas, in [6], authors presented a framework of load profile management to include DSM. Moreover, they mentioned the concept that if customer faces any issue related to the priorities of running appliances they set already, a feedback is send back to the utility. Similarly, authors in [7], achieved the minimization of electricity bill while presenting the results using heuristic evolutionary techniques, however, they completely ignored user satisfaction element.

As authors in research work [8], proposed a general DSM model for residential users based on the same objectives for cost reduction, PAR reduction and enhancing UC level. Genetic algorithm (GA) is used with real time pricing (RTP) tariff. Results show that UC is achieved to some level in terms of waiting time. Two types of price signals are used in HEMS; dynamic and static. DSM is mostly affected by dynamic price signal as they change from time to time. Main goal of DSM is to achieve maximum UC with minimum cost. In this regard, many DSM techniques were introduced in previous years. As in article [9], wind driven optimization (WDO) technique is used along with the ToU price tariff. The purpose was to achieve minimum cost and maximum UC. In [10], a review of different DR schemes is presented. These DR schemes are classified into different categories. Various models for optimal control of DR strategies have also been presented. In [11], the authors proposed a cost efficient solution for load scheduling. Fractional programming (FP) approach is used along with day ahead and RTP pricing tariff. With the goal to reduce cost, user can manage their electricity consumption pattern. Simulation results prove that the proposed technique significantly achieve 3

CHAPTER 1.

1.1. INTRODUCTION

Solar

Wind

Smart Grid

Traditional Grid

Hydrolic

Bio-gas

Figure 1.1: Architecture of SG

the cost-effective energy consumption pattern. However, cost minimization is still somehow compromised. UC and PAR are not discussed in this work.

On the other hand, while dealing with the basic optimal power flow (OPF) problem, prime objective is the optimal distribution of generated power with optimal settings of control variables so that a certain stated objective function can be solved [12]. The electrical energy demand is increasing globally on a daily basis, and fossil fuels are limited and being exhausted [13]. Classic OPF problem is based on thermal generators only that consume fossil fuel mainly. However, with the increase in energy demand and environmental concerns, RERs are incorporated to reduce the use of fossil fuel as they play a crucial part in carbon emission and global warming [9]. The use of green energy has rapidly increased penetration of RERs in the power system. Integration of RERs such as wind turbines and solar photovoltaic (PV) panels is a complicated task, as they possess uncertainty in their production due to dependency of these resources on wind speed and solar irradiance, respectively. RERs puts a challenge for system operators or planners not only because of variability in their output power, but also due to the reason that output power from these resources cannot be scheduled like normal thermal

4

CHAPTER 1.

1.1. INTRODUCTION

generators. With increasing penetration of RERs, it became necessary to incorporate these resources optimally into the electricity generation system. Classic OPF problem with thermal generators has been extensively studied and many different techniques were applied to solve this problem however, researchers in recent literature have included RERs in OPF. In [12], authors addressed OPF problem with integration of renewable power sources and modeled the uncertainties of these sources through probability density functions (PDF). Emission and cost reduction were taken as objective function with penalty and reserve cost due to over and under estimation of renewable resources. However, authors did not consider the use of energy storage system and multi fuel option. In [14], authors addressed OPF problem and modeled uncertainty of wind, solar and load demand with the usage of PDF. Mean adjustment cost which is an additional cost due to uncertainty of RERs is also incorporated. Battery storage system is used to address uncertainty due to RERs, to stabilize the power flow and to store the surplus energy. However, authors ignored emission calculation of thermal generators. In [15], minute to minute variability for the load demand and generation from solar photo-voltaic (PV) and wind farms is handled. Every 15 minute variability in day ahead OPF is calculated for scheduling of resources and tackling uncertainties. However, authors have ignored multi fuel option, valve point loading effect, carbon emission of thermal generators and use of storage devices. Our contribution is the efficient management of load by reducing PAR, minimizing cost and enhancing UC in terms of reduced waiting time. For this purpose, we used few heuristic algorithms tabu search (TS), backtracking search optimization algorithm (BSOA) and harmony search algorithm (HSA) along with RTP pricing tariff. GA is used for the optimal settings of generated power from grid.

OPF problem is solved for both single objective optimization and multi objective optimization. [12], [16], [17], [18], [19], [20], [21], [22], [23], [24], [25], [26], [27] and [28] solved the OPF problem for single objective optimization including cost reduction, power loss reduction and emission minimization. As observed from the literature, an OPF problem is solved for various single and combined objectives. Single objective is being implemented by various authors; however, in realistic scenarios more than one objective needs to be optimized simultaneously. The objectives for the mutiobjective scenario might be similar to the basic objectives for an OPF problem, therefore, solving them simultaneously might give different results. OPF problem is solved for multi-objective scenario in [29], [30], [31], [32], [33], [34], [35], [36], [37] and [38]. Reduction of emission, voltage deviation and 5

CHAPTER 1.

1.1. INTRODUCTION

fuel cost is considered in [29]. Three different scenarios are considered in [38]: minimization of power loss along with the voltage deviation and fuel cost reduction, minimization of power loss with voltage deviation and emission reduction, minimization of power loss and cost reduction. Rest of the thesis is organized as follows: Chapter 2 includes state of the art work. Chapter 3 contains optimization of HEMS through application of TS. Chapter 4 summarizes an approach towards efficient scheduling of HEMS using BSOA and TS. Chapter 5 illustrates the findings for comparative study of meta-heuristic approaches towards utilization of home energy management. Chapter 6 discusses an optimal power flow approach for stochastic wind and solar energy integrated power system while the thesis is concluded in Chapter 7.

Shiftable Appliances

Fixed Appliances

Figure 1.2: Smart home with smart appliances

6

Chapter 2 Literature Review

7

CHAPTER 2.

2.1

2.1. LITERATURE REVIEW

Literature Review

Around the globe, many researchers are working to optimally schedule the smart appliances in HEMS. In this regard, some of the research work reviewed is discussed below. The authors in article [2], [3], and [39], proposed different optimization techniques to efficiently reduce cost and enhance UC level with reduced PAR. Authors in [2], presented a GA based DSM model to reduce the cost and avoid peak formation. GA based technique is used for optimization of this non-linear problem. RTP with the combination of inclined block rates (IBR) is used as a pricing model. Simulation results proved that the presented model achieved the efficiency levels to reduce PAR and cost. However, congestion problem and UC level is ignored. In research article [3], Sahar et al. investigated the comparative functionality and performance of heuristic algorithms to present an efficient state of art energy management controller (EMC) model with integration of RERs. In this presented work, it was proved that GA-EMC worked more efficiently as compared to the binary particle swarm optimization (BPSO) EMC and ant colony optimization (ACO) EMC. Through Monte Carlos simulations, randomness was handled to smartly meet the non-functional requirements regarding grid, i.e., reliability, stability and robustness. It was also presented through graphs that RERs are integrated efficiently to attain the objective function. In this article, dual reduction of cost and PAR, consumer satisfaction and integration of RERs were attained. However, the UC level is compromised in scheduled case upto 50%. In [39], DSM controller is designed by using five heuristic algorithms i.e., GA, BPSO, WDO, bacterial foraging optimization algorithm (BFOA) and the proposed hybrid algorithm as genetic wind driven (GWD). Simulations are performed to compare the results according to cost reduction, energy consumed, PAR reduction and UC. RTP tariff model is used for bill calculation. Results proved that proposed hybrid technique performed better than the other techniques. However, the user discomfort is enhanced 50%. In research articles [40], [41], and [42], authors used integer linear programming (ILP) to achieve the objectives of cost reduction with maximum UC. In article [40], authors describe the scheduling problems of the residential areas. Two types of appliances are assumed. Starting time of first type can be adjusted and the power consumption of second type can be reduced, which will cause discomfort to the user. So, day ahead price signal is used along with ILP to achieve tradeoff between payments and discomfort. For simulations, it is assumed that the price signals 8

CHAPTER 2.

2.1. LITERATURE REVIEW

are announced day ahead of time. User can select between minimum discomfort with maximum cost, its vice versa or tradeoff between both. Though PAR is not efficiently managed. In article [41], there are two main objectives, i.e., to reduce the daily energy cost and also CO2 emissions created through energy consumption. Both of the objectives conflict with each other. A model is designed to schedule the energy consumption using mixed ILP. For simulations, three different price signals are used, i.e., RTP, critical peak price (CPP) from Canada and CPP from US. Results obtained are quiet optimum, however, still there is a tradeoff between cost and emission. Management of UC and PAR is also neglected. The authors in [42], proposed a scheduling technique for SG to manage the load through ILP. The objective is to reduce load per hour to achieve balanced load schedule for daily. The designed technique is able to schedule the power consumption as well as operational time interval (OTI) for shiftable appliances, according to the power consumption patterns of all the individual appliances. When the simulations are done, there is a load reduction in per hour. Its drawback is that reduced PAR and UC is not achieved. Research work [43], [44], and [45] are evaluated on the basis of dynamic programming. In [43], the main purpose was to schedule the load and deal with power trading issues. RERs are also integrated into the system. Interaction between users when they exchange excessive energy locally within themselves is discussed in this work. For this purpose, a dynamic approach is used for optimization. Simulation results prove that the proposed technique minimizes energy cost. Also, it proves that using the extra energy locally is quite beneficial as compared to sending it back to the utility companies. In [44], a demand queuing-based EMS is presented. Simulations are done by taking the data from residential areas. For energy optimization, a centralized algorithm is presented. Results show that cost minimization and delay reduction are achieved. However, a tradeoff is noticed between delay and energy consumption. Another methodology is proposed by using dynamic pricing scheme for minimizing the energy price. In [45], RTP tariff model is used to avoid peak hours (PHs) and adjust maximum load in off peak hours (OPHs). The purpose is to achieve the tradeoff between electricity bill and user satisfaction. Results show that there is reduction in electricity cost and maximization of UC level, although PAR is neglected. In [46] and [47], authors proposed a HEMS to reduce the electricity cost, waiting time and PAR. In [46], authors proposed a hybrid scheme of bacterial foraging algorithm (BFA) and GA. Hybrid scheme outperformed the existing techniques in terms of cost reduction. The proposed HEMS reduced the electricity cost without 9

CHAPTER 2.

2.1. LITERATURE REVIEW

using any energy storage system or renewable energy sources. In addition, user interrupts are tackled in a real-time situation. In [47], the authors presented GA based evolutionary creative comfort algorithm (EACA) to increase the UC in three budget scenarios. Simulation results show that the comfort is maximized by 57%; however, cost per unit comfort indexed is increased. In [48] , authors proposed a HEMS for electricity cost minimization and UC maximization. They proposed a hybrid technique of BFA and HSA. UC maximization is achieved by coordination among appliances through dynamic programming and cooperative game theory. Simulation results proved that hybrid technique and coordination among appliances reduced the electricity cost and maximized the UC; however, there is a tradeoff between these objectives. Authors in [49], [50] and [51] reduced the electricity cost using different metaheuristic optimization techniques. They also proposed hybrids of existing techniques. Appliances are scheduled using different pricing schemes such as RTP, ToU, CPP, etc. Simulation results show that the electricity cost is reduced; however, they didn’t consider real time user interrupts. Asif et al. [52] present priority induced DSM strategy based on load shifting techniques to reduce the electricity cost. Authors achieved the objective of cost reduction; however, they considered a limited number of home appliances for scheduling. Zafar et al. [53] used metaheuristic optimization techniques to reduce the electricity cost and maximize UC. Moreover, a grid-connected MG is considered for cheaper electricity generation. Authors in [54] used Jaya algorithm to reduce the production and fuel costs and maximize the selling revenue. In [55], a smart home with grid-connected MG is considered in order to decrease the electricity cost using heuristic techniques. In addition, the authors proposed a power trading model to exchange the power among smart homes. As stated in article [56], the authors here are discussing about the user privacy while scheduling of appliances. The drawback of distributed DSM protocols is that they involve every user to communicate and share their energy usage patterns. which may leak the personal information. Distributed privacy friendly DSM is presented by Cristina et al. which maintains privacy by integrating data aggregation and perturbation. Simulation result show that there is electricity bill minimization and PAR reduction along with the maintained user privacy. However, the total bill reduction is neglected. As in [57], a heuristic approach is proposed for scheduling of appliances in a residential area. Comparison of heuristic algorithm is done with an exact algorithm in terms of computational time and cost. Different energy pricing tariffs are used. Results show that the cost achieved is within 5% of the cost achieved from exact algorithm. However, UC level is neglected. 10

CHAPTER 2.

2.1. LITERATURE REVIEW

As, SG is an emerging technology, number of authors targeted the issue of scheduling in order to attain minimum cost with maximum user comfort. A DSM approach is proposed in [58], to find an optimum solution for PAR and cost reduction. GA, cuckoo search (CS) and crow search algorithm (CSA) were used with RTP and CPP. Energy storage systems were also introduced in order to provide more efficiency. Simulations were performed on both single and multiple homes. However, results prove that a minimized trade-off still exists between PAR reduction and improvement of user comfort. A DR scheduling model is presented in [59], for the residential community with an aim of cost reduction and PAR minimization. Load demand is classified into different categories based upon DR programs. Simulations were performed for different cases with various pricing schemes and results prove that in some cases, waiting time for some appliances increased. For efficient energy consumption, RTP and CPP programs were required to be improved. For the scheduling of charge and discharge of electrical vehicles (EVs) in a building energy management system, a linear programming based heuristic technique was proposed in [60]. Two staged algorithm was used in order to check the effect on PAR and to tackle with the uncertain load demands. Computational results prove that the mentioned objectives were achieved however, due to ILP computational time was increased. To balance the demand and supply of energy in smart homes, authors in article [61] performed optimization through metaheuristic algorithms of HSA, enhanced differential evolution (EDE) and their hybrid harmony search differential evolution (HSDE) was proposed. In order to reduce the peak creation, RERs were also introduced in the system. Simulations were performed on internet of things (IoT) enabled smart homes and the computational results show trade-off between these techniques. HSA provides minimum cost with maximum waiting time whereas, EDE performed its vice versa. Therefore, proposed HSDE was considered as the best approach because it gives both minimum cost and maximum user comfort up to some extent in between HSA and EDE. Authors in [62], developed an optimized HEMS with the integration of RERs and energy storage systems. Scheduling problem was formulated using multiple knapsack problems and optimization was done using GA, BPSO, WDO, BFOA and hybrid genetic algorithm particle swarm optimization (GA-PSO). Simulation results prove that electricity bill and PAR is reduced in an efficient way and the proposed hybrid technique outperformed other techniques. For curtailment of load demand and reduction in peak formation, an EMC was designed in article [1]. Four heuristic techniques GA, BFOA, BPSO, WDO and a hybrid genetic binary particle swarm optimization (G-BPSO) were proposed to 11

CHAPTER 2.

2.1. LITERATURE REVIEW

control the load management. Residential load demand was considered by authors and RTP price tariff was used. After execution, results proved that each technique helped in cost reduction as compared to the unscheduled scenario. However, on the basis of trade-off between UC and electricity cost, G-BPSO controller outperformed other heuristic techniques. Muqaddas et al. [63] proposed a method for efficient scheduling in smart homes by using grey wolf, EDE and their hybrid as gray wolf differential evolution (HGWDE). Individual results were recorded by taking price signals of RTP and CPP. Also the time interval for operation was kept variant upto 15, 30 and 60 minutes. Simulations were carried out in MATLAB and results proved that in both the pricing tariffs, proposed HGWDE outperforms the remaining two techniques. However, a slight trade-off is noticed between UC and cost. In article [9], authors aimed to optimize HEMS0 s through cost minimization and waiting time reduction of consumers, while they also focused on user satisfaction. However, ToU is used for calculation of electricity bill. Authors used a min-max regret-based knapsack problem along with wind driven optimization (K-WDO) as scheduling technique, where the tariff is implemented without any combination with one of the other tariffs. Whereas, authors in [7] used dynamic programming to deal with the reduction of payment bills for power traders. In this research article, the problem of scheduling load was addressed. The users discussed in this study were those who took interest in selling and buying the extra energy generations through RERs to maximize the profits. It is concluded that the power trader consumers save electricity cost more than that of normal consumers. This study is limited to attain minimum cost while ignoring the PAR reduction. Micro grid installation in homes enable its users to get rid of the long distance transmission cost. In article [64], microgrid implementation was proposed to enhance the efficiency of mathematical based model. In the proposed scenario, application is depending on the area of residents only, while ignoring the commercial and industrial areas. In [11] and [65], work has been done in the domain of smart grid which is used to distribute the electricity in a smart way. SG uses advanced technologies, control methodologies and communication pathways to ease the way for both utility and its consumers. Over the past few decades, various methods and techniques are used for solving an OPF problem. In 1968, Dommel and Tinney present a simplified gradient method; the first algorithm to solve an OPF problem [66]. Optimization solution for an OPF problem is then provided by using many conventional methods such as 12

CHAPTER 2.

2.1. LITERATURE REVIEW

Newton method [67], quadratic programming [68], reduced gradient method [69], lagrangian relaxation [70], interior point method [71], semi-definite programming [72] and linear programming [73]. However, these classical methods do not ensure an appropriate solution because of the nonlinear characteristics of the objective functions. In addition, large number of computation and increased execution time enhance the complexity of conventional methods. Therefore, it becomes necessary to overcome these problems via optimization techniques that are scalable to handle the complex and constrained nature of OPF problem. Classic OPF problem with thermal generators has been extensively studied and many different techniques were applied to solve this problem however, researchers in recent literature have included RERs in OPF. In [74], basic OPF problem is addressed with a complicated non-smooth cost function with multi fuel option, valve point loading effect and emission reduction function. However, this study is only based on thermal generators, RERs and storage systems are not considered in this work. Gravitational search algorithm (GSA) is implemented in [75] for solving the power flow optimization problem. The OPF problem is formulated as a non-linear optimization problem with equality and inequality constraints. Stated objectives of this study are almost similar as considered in the general OPF problem. GSA is applied on IEEE 30-bus and 57-bus systems to get the optimal settings of control variables along with minimized value of cost and power loss. Other than heuristic and meta-heuristic approaches, fuzzy logic approach is also employed with the combination of different techniques to get the optimized settings for OPF problem. OPF problem is formulated and solved by integration of fuzzy technique with GA and PSO [76]. Control variables are adjusted in a way to achieve the minimized cost and reduced power loss with an improved voltage profile. Linear and nonlinear constraints are fulfilled while testing the proposed approaches upon IEEE 30-bus system. Results prove the effectiveness and robustness of the proposed solution. In [77], adaptive fuzzy logic controllers are implemented for the optimal dispatch of generated reactive power. This proposed method is implemented on IEEE 30-bus system and the obtained results are compared with those of static fuzzy logic controller. Hence, the system is proved as a useful operator to optimize the values of control variables. A mathematical model is proposed for solving multi-objective OPF problem by using GA integrated with fuzzy decisions [78]. The proposed model is tested upon 59-bus system form the Algerian electrical network to attain the objectives of generation cost minimization, emission reduction and improvement in the voltage profile index. This optimization problem is solved 13

CHAPTER 2.

2.1. LITERATURE REVIEW

for three different scenarios and the evaluated results depict trade-off between environmental dispatch and voltage constraints. Teaching learning based optimization (TLBO) algorithm is implemented by [79] to find the optimal solution for a multi-objective OPF problem while satisfying the system constraints. To further enhance the convergence rate, quasi-oppositional based learning (QOBL) is combined with the basic TLBO algorithm. The proposed methodology is applied on IEEE 30-bus, IEEE 118-bus and Indian utility 62-bus test system. To prove the effectiveness of hybrid quasi-oppositional teaching learning based optimization (QOTLBO), different objectives are formulated and solved. Their results verify that QOTLBO is more efficient in terms of finding optimal solution. In power system, optimization of different objective functions is done using adaptive real coded biogeography-based optimization (ARCBBO) [80] to solve an OPF problem. Standard IEEE 30-bus and 57-bus systems are used to verify the authenticity of proposed algorithm. Obtained results are compared with literature and ARCBBO proved to be more effective and robust in terms of fulfilling the physical and operational constraints. Improved colliding bodies optimization (ICBO) is proposed in [81], to provide an efficient OPF solution. Various objectives and constraints were used to model the problem. Simulations were done on the standard IEEE bus test systems and results were compared with those of existing algorithms in the literature. The proposed techniques outperformed in various parameters. OPF problem is dealt by using a novel technique of moth swarm algorithm (MSA) by authors in [82]. The proposed approach is tested on IEEE 30, 57 and 118 bus system and compared with the existing four heuristic techniques. Simulations results proved that MSA performed better and is considered as effective in terms of speed and quick convergence. Differential search algorithm (DSA) for solving multi-objective OPF problem is proposed by authors in [83]. Power system optimization is done on various single and multi-objective functions. Proposed algorithm is tested upon three IEEE standard bus systems and the results proved that DSA is efficient for solving nonlinear and non-convex problems in power systems. OPF problem is solved by many meta-heuristic algorithms with successful results. In [84], chaotic krill herd algorithm is used for solving three different objectives of cost minimization, active power loss reduction and improved voltage deviation. In [85], a chaotic artificial bee colony algorithm is used to solve multi-objective optimization problem along with handling security of the system. In [86], a multi objective minimization of operation cost and the total emission problem in OPF is solved by adaptive group search optimization algorithm. Gbest guided artificial bee colony algorithm for solving an OPF problem with stochastic wind system is studied in [17]. In [87], multi objective 14

CHAPTER 2.

2.1. LITERATURE REVIEW

backtracking search algorithm (MOBSA) is used to optimally adjust the control variables of the OPF problem.

15

Chapter 3 Optimization of Home Energy Management System through Application of Tabu Search

16

CHAPTER 3.

3.1

3.1. SUMMARY OF CHAPTER

Summary of Chapter

In the past few years, a number of optimization techniques have been designed for HEMS. In this section, we evaluated the performance of two heuristic algorithms, i.e., HSA and TS for optimization in residential area. These algorithms are used for efficient scheduling of smart appliances in smart homes. Evaluated results show that TS performed better than HSA in achieving our defined goals of cost reduction, improving UC level and minimization of PAR. However, there remains a trade-off between electricity cost and waiting time.

3.2

Proposed System

In this section, proposed scheme for scheduling of appliances is discussed. RTP pricing is used for getting optimum results by applying HSA and TS on a set of data from residential area. The main objectives are to reduce cost, minimize PAR and to maximize UC. For this purpose, two heuristic algorithm are used. In the subsection below, HSA and TS are discussed in detail.

3.2.1

HSA

Harmony search is a population based algorithm which is proposed by GEEM et al. in 2001. This algorithm depicts musicians behaviour. To find the optimum solution, HSA follows the following steps mentioned below: 1. Initialize harmony search memory (HSM) by random generation. 2. Improvise new harmony . 3. Update harmony memory (HM) by comparing the new solution from the step 2 with the worst number in the HM. 4. Repeat step 3 and 4 until termination criteria is satisfied.

3.2.2

TS

TS is basically global optimization algorithm that uses local or neighbourhood search methods. TS steps are given as follows: 17

CHAPTER 3.

3.2. PROPOSED SYSTEM

1. Generate neighbourhood solution from current solution. 2. Generate tabu list (TL) that records forbidden moves. 3. Set aspiration criteria (AC). 4. Perform TS. 5. Update TL after each iteration. 6. If not in TL, update in AC. 7. Check stopping criteria to terminate.

3.2.3

Electricity Consumption Pattern

Electricity is generated in SG and further distributed to the residential area via different utility companies. Each home is considered to be a smart home having smart meters and smart appliances. For achieving the level of UC, user has to set the length of operational time LOT and OTI for each appliance, mentioning the starting time and ending time of each appliance. This pattern is set on the smart appliance controller (SAC) connected to the smart meter. The proposed system is shown in Fig.3-1.

3.2.4

Proposed Mathematical Formulation

Single smart home having smart meter and smart appliances is considered for the purpose of simulation. Let T denotes the total time interval of 24 hours for a single day such that t ∈ T and t=1hour then: T = {1hour, 2hour, 3hour......24hour}

(3.1)

Smart meter is considered having 13 appliances divided into three sub-categories [1]. Fixed appliances are those appliances whose LOT and OTIs cannot be modified like fans, toaster, lights etc. Load categorization and parameter initialization of appliances is shown in Table 3.1. Let F denotes the set of fixed appliances and f ∈ F for each appliance. Let Pf be the total power consumption of each appliance for 24 hours then: Pf = {Pf11 , Pf21 , Pf31 ..........Pf241 } 18

(3.2)

CHAPTER 3.

3.2. PROPOSED SYSTEM

Algorithm 1 HSA 1: Initialize all parammeters 2: for all appliances aA 3: for all time slots tT 4: Generate new population 5: for j = 1:MaxItr 6: P A ← (P Amax − P Amin)/(M axItr) ∗ j + P Amin 7: for pp = 1:NVAR 8: BW (pp) ← bwmax ∗ exp(coef ∗ j) 9: end for 10: Improvise new harmony 11: for i=1:NVAR 12: if (ran < HM CR)then 13: Do memory consideration 14: if (ran < P A)then 15: Do pitch adjustment 16: if (pvbRan1 < 0.5)then 17: result ← result + rand(1) ∗ BW (i) 18: else 19: result ← result − rand(1) ∗ BW (i) 20: end if 21: end if 22: else 23: N CHV (i) ← xl + rand(1) ∗ (xu − xl) 24: end if 25: end for 26: Update harmony 27: for i=1:NVAR 28: if new > 0.5 29: new ← 1 30: else 31: new ← 0 32: end if 33: end for 34: Termination criteria 35: while criteria not satisfied 36: repeat step 3 and 4 37: end for

19

CHAPTER 3.

3.2. PROPOSED SYSTEM

Algorithm 2 TS Initialize all parameter 2: x’=best solution among trails S(x) sample of neighborhood S(x)N (x) 4: Current solution x0 X Set tabu list TL=150 6: Set aspiration criteria AC=0 Set iteration counter K = 0 8: Randomly generate initial solution Randomly generate trail solutions S(x)N (x) and sort them in ascending order to obtain SS(X). 10: Let x’ be the best trail solution in SS(X) if x0 > x 12: X 00 = x else 14: X”=x’ end while k¡= number of iterations 16: For i=1:TL Perform tabu search 18: If X 00 > X 0 Update X” in tabu list 20: Else X” not present in tabu list update X” in aspiration criteria 22: end end end If stopping criteria is satisfied 24: perform termination else k=k+1 26: end Shiftable appliances are those appliances whose LOT can be shifted without having an effect on their OTIs like washing machine, dish washer etc. Let S denotes the set of shiftable appliances and s ∈ S for each appliance. If each shiftable appliance s has a power consumption Ps in each hour, then it is denoted as: 1 2 3 24 Ps = {Ps1 , Ps1 , Ps1 ..........Ps1 }

(3.3)

Base appliances are those appliances whose LOT and OTIs both are manageable and can be interrupted or shifted like air conditioner, refrigerators, water heater etc. Let B denotes the set of base appliances and b ∈ B for each appliance. Let Pb be the total power consumption of each appliance for 24 hours then: 1 2 3 24 Pb = {Pb1 , Pb1 , Pb1 ..........Pb1 }

. 20

(3.4)

CHAPTER 3.

3.3. PERFORMANCE EVALUATION AND ANALYSIS

Smart Grid Smart Home

Smart Meter

Smart Appliances

Utility

Figure 3.1: Proposed system model Table 3.1: Parameters used in simulation process

Appliances Lights Fans Clothes Iron Oven Toaster Coffee Maker Washing Machine Cloth Dryer Dish Washer AC Refrigerator Water Heater Space Heater

3.3

Power(kWh) 0.6 0.75 1.5 1.18 0.5 0.8 0.78 4.40 3.60 1.44 0.73 4.45 1.50

LOT 12 16 06 07 02 02 05 04 03 15 14 10 12

OTI 18:00-08:00 14:00-06:00 14:00-23:00 06:00-22:00 06:00-10:00 06:00-22:00 08:00-16:00 06:00-18:00 07:00-12:00 06:00-24:00 06:00-24:00 06:00-24:00 06:00-24:00

Category Fixed Fixed Fixed Fixed Fixed Fixed Shiftable Shiftable Shiftable Elastic Elastic Elastic Elastic

Performance Evaluation and Analysis

In this section, the simulations results are presented to evaluate the better performance of our proposed scheme TS in comparison with HSA and unscheduled. The algorithms are compared on the basis of stated objectives of cost reduction, 21

CHAPTER 3.

3.3. PERFORMANCE EVALUATION AND ANALYSIS

28 RTP prices

26 24

Cost (cent)

22 20 18 16 14 12 10 8 1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

Time (hours)

Figure 3.2: RTP price signal

Peak to Average Ratio

2.5 2 1.5 1 0.5 0 Unscheduled

TS

HSA

Figure 3.3: PAR.

minimization of PAR, enhanced UC level and to observe the electricity usage pattern among the PHs and OPHs. Simulations are conducted in MATLAB. A single home is considered having 13 appliances divided into three sub-categories [3], i.e., fixed, shiftable and base appliances. This categorization is shown in Table 3.1. RTP tariff model is used for the bill calculation. As, depicted in Fig. 3.2. there is a peak formation due to high prices from 7AM to 11AM approximately and the prices are low from 2PM to 12AM. Fig. 3.3 illustrates the comparison of achieved PAR between unscheduled, HSA and TS. Our results show that PAR is reduced in case of TS. PAR is the reduction of the peak formation during 24 hours. It is not only beneficial for customers but also to the utility companies as it reduces the chances of load shedding. Here, 22

CHAPTER 3.

3.3. PERFORMANCE EVALUATION AND ANALYSIS

Waiting Time (Hours)

4

3

2

1

0 TS

HSA

Figure 3.4: User comfort 450 Unscheduled TS HSA

400 350

Cost (cent)

300 250 200 150 100 50 0 1

2

3

4

5

6

7

8

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Time (hours)

Figure 3.5: Cost 15 Unscheduled TS HSA

Load (kWh)

10

5

0 1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Time (hours)

Figure 3.6: Load

23

CHAPTER 3.

3.4. CONCLUSION OF CHAPTER

the TS algorithm efficiently reduces PAR by avoiding peak creation through equal distribution of load in OPHs. Fig. 3.4 shows the waiting time in terms of UC as this is the time user has to wait for an appliance to be in working state. Our simulation results show that the waiting time for TS is increased as compared to HSA However, still it is quite acceptable because there exists a tradeoff between waiting time and electricity cost. The waiting time of TS is increased due to the reason that the price signals are getting low towards the end of the day, so scheduler shifts most of the load to the OPHs. Though the waiting time is increased, still appliances are working well within their defined OTIs. The comparison of electric cost per hour is shown in Fig. 3.5. Here, it is clearly illustrated that TS achieved the stated goal of reducing cost as compared to the unscheduled and HSA. This is because the cost during PHs is reduced on a certain level as the maximum amount of load is shifted to the OPHs. The cost of TS during the PHs is reduced upto 72.7% as compared to unscheduled and upto 58.5% as compared to HSA. Energy consumption for each hour is shown in Fig. 3.6. As depicted in the figure, there is a comparison between load pattern among scheduled and unscheduled appliances. Maximum load after optimization, is shifted to OPHs due to which electricity cost and PAR is also reduced. The maximum load of unscheduled case during the peak hour is approximtely 15.001kWh, whereas incase of HSA is 12.56kWh. However, after applying TS algorithm, the load during PHs is reduced to 4.9kWh approximately and the maximum load is shifted to the OPHs.

3.4

Conclusion of Chapter

In this chapter, we presented optimization techniques for load management and power scheduling of residential area. The purpose was to achieve a solution with minimum cost and reduced PAR. We evaluated our results by conducting simulation on different categories of appliances, i.e., fixed, shiftable and elastic appliances. RTP pricing tariff was used and the efficiency of two heuristic techniques (HSA and TS) was analyzed. Results of our proposed system proved that TS outperformed HSA in terms of cost and PAR. Load is efficiently shifted from PHs to OPHs due to which cost is reduced. Though, there exists a trade-off between

24

CHAPTER 3.

3.4. CONCLUSION OF CHAPTER

waiting time and electricity cost. In the upcoming Chapter 4, focus is to further reduce this trade-off and find more efficient scheduling of HEMS.

25

Chapter 4 An Approach Towards Efficient Scheduling of Home Energy Management System Using Backtracking Search Optimization and Tabu Search

26

CHAPTER 4.

4.1

4.1. SUMMARY OF CHAPTER

Summary of Chapter

SG is an emerging technology which is successfully implemented by the use of different communication methods. DSM plays a significant role in the management of load and energy consumption in order to reduce cost in the smart grids. Smart buildings and smart homes are usually considered important for reducing the electricity consumption by home energy management controllers (HEMC). In this chapter, an EMC is proposed with an objective to minimize the energy consumption, curtail load demand, reduce electricity usage and minimize PAR with increased UC level. For this purpose, three evolutionary and iterative techniques were proposed in this chapter as backtracking search optimization algorithm (BSOA), TS and their hybrid as tabu backtracking search optimization (TBSO) algorithm. Simulations were performed in MATLAB by using RTP tariff for bill calculation. 9 household appliances were scheduled and results proved that our proposed hybrid technique outperforms the remaining two in terms of cost minimization.

4.2

System Model

In this section, an optimal approach for power scheduling is proposed in order to minimize the energy consumption. A microgrid system consisting of multiple generation sources, storage device and communication abilities is proposed to fulfill the residential load demand. This system comprises of both RERs and non-RERs. Primary RERs considered in this case include solar photo voltaic cells and wind turbines with a storage battery whereas, diesel generators and fuel cells fall in the category of non-RERs. Electricity is used from the main grid however, RERs and storage systems are considered as a backup source. Generated electricity by the grid is further distributed to the residential area. Each home is considered to be a smart home having smart appliances. For the purpose of load curtailment, a single smart home is considered having 9 smart appliances . This smart home is connected through internet with the smart meter, which sends and receives information from grid. Details and classification of appliances is given in the section below.

27

CHAPTER 4.

4.2.1

4.2. SYSTEM MODEL

Smart Appliances

On the basis of running time and usage preference, two sub-categories of smart appliances are made, i.e., fixed and shiftable appliances. Fixed appliances are those whose LoT and OTI cannot be modified like fans, lights, toaster etc. Shiftable appliances are the appliances whose LoT can be shifted without having an effect on their OTI like washing machine, dish washer etc. There also exists a third category of elastic appliances whose LOT and OTI both are manageable and can be interrupted or shifted, i.e., heating, ventilation and air-conditioning systems fall in the category of elastic systems. However, in our proposed work scheduling of only fixed and shiftable appliances is managed. Parameters used for simulations are specified in Table 4.1. Let F be the set of fixed appliances that consists of n number of smart appliances such that f ∈ F then: F = {f1 , f2 , f3 ......fn } (4.1) Similarly, let S represents the set of shiftable appliances in a way that s ∈ S S = {s1 , s2 , s3 ......sn }

(4.2)

Scheduling of appliances is done for a single day that is for 24 hours. Let T denotes the total time interval for a single day such that: T = {1h, 2h, 3h, ......24h}

(4.3)

For calculation of energy consumption in case of fixed appliances for each time slot, following equation is used: Ef (t) = {Ef,1h + Ef,2h + ...........Ef,24h }

(4.4)

Energy per hour consumed by shiftable appliances can be evaluated through Eq. (4.5). Es (t) = {Es,1h + Es,2h + ...........Es,24h } (4.5) Total energy consumption demand for a single day can be calculated through Eq. 4.6. ET = {ET1 + ET2 } (4.6)

28

CHAPTER 4.

4.3. EVOLUTIONARY ALGORITHMS

where, ET1 =

T X F X

E(f,t)

(4.7)

E(s,t)

(4.8)

t=1 f =1

ET2 =

T X S X t=1 s=1

Table 4.1: Parameters used in simulation process

Appliances Lights Fans Clothes Iron Oven Toaster Coffee Maker Washing Machine Cloth Dryer Dish Washer

4.3

Power (kWh) 0.6 0.75 1.5 1.18 0.5 0.8 0.78 4.40 3.60

LOT 12 16 06 07 02 02 05 04 03

OTI 18:00-08:00 14:00-06:00 14:00-23:00 06:00-22:00 06:00-10:00 06:00-22:00 08:00-16:00 06:00-18:00 07:00-12:00

Category Fixed Fixed Fixed Fixed Fixed Fixed Shiftable Shiftable Shiftable

Evolutionary Algorithms

For the purpose of scheduling in SGs and microgrids, number of different techniques and methods are used. Various authors proposed heuristic techniques, ILP techniques, dynamic programming and evolutionary algorithms. However, still there exists a room for many more scheduling techniques as electricity consumers demand the best with minimized cost and reduced user discomfort. Evolutionary algorithms are the generic population-based metaheuristic optimization algorithms which use the methods inspired by biological evolution, such as reproduction, mutation, recombination, and selection [88]. In this chapter, two evolutionary metaheuristic algorithms are proposed and their execution steps are discussed in the section below.

4.3.1

BSOA

BSOA is a simple metaheuristic iterative population based algorithm. Like other population based algorithms, it has good optimization performance. However, limitation of BSOA is regarding its convergence speed and convergence precision 29

CHAPTER 4.

4.3. EVOLUTIONARY ALGORITHMS

[89]. BSOA follows five main steps for the execution: initialization , selection-I , mutation , crossover and selection-II . The basic flow of algorithm is given in Fig. 4.1.

Initialize P and old P

Apply selection I

Mutate Trial Population Crossover

Apply selection II

Termination criteria satisfied

Yes

No

Produce best solution

Figure 4.1: General steps for BSOA algorithm

In the first step [90], population P of N random numbers for the dimension D is generated by using Eq. (4.9). Pi,j ∼ U (lowj , upj )

(4.9)

Where, i ={1,2,3,...........N } and j ={1,2,3,...........D}. U is the uniform distribution. The second step is the determination of oldP which is a historical population created in a similar way as P. oldP is used to calculate the search direction. Once initialized, oldP can be redefined using if-then rules. After oldP is determined Eq. (4.12). is used to change its order randomly. oldPi,j ∼ U (lowj , upj )

30

(4.10)

CHAPTER 4.

4.3. EVOLUTIONARY ALGORITHMS

28 price

26 24 22

Price

20 18 16 14 12 10 8 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Time (hours)

Figure 4.2: RTP price signal

5 4

PAR

3 2 1 0 Unscheduled BSOA

TS

TBSA

Figure 4.3: PAR.

if a¡b then oldP := P |a, b ∼ U (0, 1)

(4.11)

oldP := permuting(oldP )

(4.12)

Third step is to mutate. In this step a mutant vector is generated using oldP and P in the form of trial population T mentioned in Eq. (4.13). M utant = P + F ∗ (oldP − P ) where, F = 3.rndn is the value of scale factor.

31

(4.13)

CHAPTER 4.

4.3. EVOLUTIONARY ALGORITHMS

1400

1200

Total Cost

1000

800

600

400

200

0 Unscheduled

BSOA

TS

TBSA

Figure 4.4: Total cost 80 70 60

load

50 40 30 20 10 0 Unscheduled

BSOA

TS

TBSA

Figure 4.5: Total load

After mutation, crossover step is used in BSOA which creates the final form of trial population T. Trial values with better fitness are used to generate the target population. A binary integer value matrix (map) of size N ×D is created to indicate the individuals of T to be manipulated by using the relevant individuals of P. The initial value of the binary integer matrix map(n,m) is set to 1, where n ∈ {1, 2, 3, ......N } and m ∈ {1, 2, 3, ......D} The trail population T is updated as follow: Tn,m := Pn,m (4.14)

32

CHAPTER 4.

4.3. EVOLUTIONARY ALGORITHMS

7

6

waiting time

5

4

3

2

1

0 BSOA

TS

TBSA

Figure 4.6: Waiting time

Electricity Cost (cent)

400 Unscheduled BSOA TS TBSA

300

200

100

0 2

4

6

8 10 12 14 16 18 20 22 24

Time (hours) Figure 4.7: Hourly cost

The last step is for selection II. The individuals of the new trial population T are replaced with the individuals in the initial population if the fitness value of T is better than the fitness value of P.

4.3.2

TS

TS is an iterative optimization technique which focuses on the local exploration of search space in order to find out the most optimal solution. Memory adaptation is 33

CHAPTER 4.

4.3. EVOLUTIONARY ALGORITHMS

14 Unscheduled BSOA TS TBSA

Load (kWh)

12 10 8 6 4 2 0 2

4

6

8 10 12 14 16 18 20 22 24

Time (hours) Figure 4.8: Hourly load

the main feature of TS that helps to achieve the most flexible searching strategies from the search space. Tabu take a first move from the initial position of search space, access the best neighborhood which would help to achieve the optimal solution. The closest neighbors will either be already in the tabu list or absent from the tabu list but holds true for the satisfaction criteria. In case, tabu search is unable to find a better solution, different strategies are applied so that more search space can be discovered. The above given steps keep on repeating until a stopping criterion is satisfied. Aforementioned steps of tabu search are summarized as follows: 1. Select a current point as an initial step. 2. Generate neighborhood solutions from the given solution space. 3. From the neighbors, select the best solution. 4. Check if selected neighbor is accessible. 5. If yes, replace the current solution from best neighboring solution. 6. If not, find the next best neighbor.

34

CHAPTER 4.

4.4

4.4. COMPUTATIONAL RESULTS AND DISCUSSION

Computational Results and Discussion

In this section, simulation results are discussed in order to analyze the performance of our proposed algorithms; BSOA, TS and their hybrid TBSO. For simulations, load demand from a single home having 9 appliances is considered and electricity generation from multiple sources is assumed. These proposed algorithms are evaluated on the basis of three parameters, i.e., cost, user satisfaction and PAR. Simulations are performed and calculations are done in MATLAB with the appliances divided into two categories. RTP pricing tariff is used to calculate electric price. The PHs and OPHs for RTP are shown in Fig. 4.2. Fig. 4.3 illustrates the comparison of peaks between our proposed scheduled algorithms and unscheduled case. PAR is basically the minimization of peak creation during 24 hours of a day through shifting of load from on-peak hours to off-peak. Reduction of PAR is beneficial for both the consumers and utility in a way that bill will be minimized for users and there will be less chances of grid breakdown. As, when the load increases up to the maximum limit it will create peaks. Our simulation results proved that in comparison with unscheduled, all of our techniques result in reduced PAR as no peaks are created during OPHs. However, TS outperformed the other two techniques by minimum peak formation. Overall results for total cost and load demand for a single day are represented in Fig. 4.4 and Fig. 4.5 respectively. The difference of cost among unscheduled, BSOA, TS and TBSO shows that our proposed algorithms efficiently reduced cost in comparison with unscheduled case, without minimizing or affecting the load demand. However, proposed TBSO hybrid algorithm shows supremacy in terms of reduced electric cost as compared to BSOA and TS. This is because TBSO combines both the features of mutation and crossover from BSOA with a trial vector of TS. The total load demand fulfilled in case of unscheduled, BSAO, TS and TBSO remains same as shown in Fig. 4.5 User waiting time is shown in Fig. 4.6. Waiting time can be defined in terms of UC. Increased waiting time means that the user has to wait longer for an appliance to start its operation that in return results in minimum UC. On the other hand, minimum waiting time means user has to wait for no long time and the level for UC is increased. In our simulation results, as we can see that TBSO gives increased waiting time as compared to other two because it provides minimum electricity cost. This means that instead of turning on maximum appliances in

35

CHAPTER 4.

4.5. CONCLUSION OF CHAPTER

PHs, through efficient scheduling, TBSO scheduled those appliances during offpeak hours. There exists a trade-off between UC and payment charges. If the users demand for minimum waiting time or maximum UC, BSOA will be a good choice because in that case electricity cost will not be that much high in comparison with TBSO. Fig. 4.7 and Fig. 4.8 presented hourly cost and load consumption per hour for the mentioned three proposed techniques of BSOA, TS and TBSO. During the PHs, i.e., from 7am to 10am, the proposed algorithms shifted maximum load toward off peak hours due to which cost is low during on peak hours. As, the hybrid TBSO shifted most of the load before 7am and after 10am due to which it results in reduced cost.

4.5

Conclusion of Chapter

With the emergence of SGs, DSM is considered as an important factor to maintain the balance between demand and supply. As residential sector is the main target for scheduling, it contains different kinds of appliances with variable power ratings. To cope with such scenarios, DSM needs an efficient method to schedule appliances in a way with minimum electric cost and maximum user comfort. For this purpose, in this chapter three evolutionary algorithms, i.e., BSOA, TS and TBSO are proposed and evaluated in terms of their cost, PAR, load curtailment and waiting time. Simulations were performed to check the effectiveness of proposed techniques and the results proved that TBSO performed better in terms of cost saving. In the upcoming Chapter 5, a comparative study of meta-heuristic approaches is presented towards the utilization of home energy management.

36

Chapter 5 A Comparative Study of Meta-Heuristic Approaches Towards Utilization of Home Energy Management

37

CHAPTER 5.

5.1

5.1. SUMMARY OF CHAPTER

Summary of Chapter

For the purpose of reducing electricity cost and PAR, different electricity consumers have now an opportunity to schedule their electrical tasks. In this chapter, we comparatively evaluated the performance of three meta-heuristic algorithms for our proposed HEMS, i.e., EDE , HSA and TS. The HEMS presented in this work is based on DSM and involvement of electricity consumers of a residential area domain to consider major factor of user satisfaction. In order to tackle the pricing for electricity bill calculation, a combined model of ToU and CPP is used. To deal with the scheduling of appliances a defined classification of appliances is taken from a part of literature. Simulation results verify that the proposed algorithms perform competently in achieving the mentioned objectives.

5.2

Proposed System

In this chapter, HEMS is proposed for efficient scheduling of electrical appliances. Electricity is generated through a SG and further distributed through different utility companies. In our contribution, residential area is considered with smart homes having smart meters and enabled electricity controlled devices (ECD), as depicted in Fig. 5.1. User can input their planned schedules and preferences to the smart meter by using ECD. Whereas, price signals are sent by the utility to the smart meter by using wireless connections. For such kind of communication links, there are a number of wireless solutions like ZigBee, Z-Wave, Wi-Fi, etc. The main purpose for scheduling is to minimize the electricity cost and maximize UC with the use of three meta-heuristic optimization techniques. For simulations, a single home is considered having 16 number of electrical appliances. Each appliance is given power rating in kWh. OTI´s for appliances are also specified by the user while providing starting time α and ending time β for each appliance. On the basis of OTI´s and user preferences, appliances are classified into two categories, i.e., shiftable and fixed appliances. For fixed appliances, their LOT which is the actual time required by an appliance to complete its task, cannot be changed whereas in case of shiftable, these appliances are manageable and their LOT can be shifted in accordance with the pricing tariff for the purpose of peak load reduction. The detail of fixed and shiftable appliances, their OTIs along with the power rating is given in Table 5.1 and Table 5.2, respectively. Price signal for each time slot is announced by the utility company. In our case a combined pricing model of 38

CHAPTER 5.

5.2. PROPOSED SYSTEM

ToU and CPP is used. Each time slot t represents one hour. The total time is represent as T = 24hours and t  T such that: T = {1h, 2h, 3h........24h}

(5.1)

To achieve the above mentioned goal of cost minimization, objective function is stated as: T X A X M inimize Pat × Xat × EP t (5.2) t=1 a=1

Let A denotes the total number of appliances such that a  A where A=16. Power rating of these appliances is denoted by P and EP is the electricity price rates. X is the status of an appliance which is either 1 or 0 incase an appliance is on or off. Total energy consumption is denoted by U and is calculated in equation given below: T X A X U= Uat (5.3) t=1 a=1

By means of this total energy consumption, PAR for residential customers is calculated and is stated in Eq. 5.4. PAR reduction is one of the objective function mentioned below. M aximum(U ) (5.4) PAR = M ean(U ) As, a comparative study is done between EDE, HSA and TS, these algorithms are discussed in below subsections.

5.2.1

HSA

HSA is a meta heuristic technique which is originated through musician´s behavior. This algorithm was first proposed by GEEM et al in 2001. It follows a series of steps to reach the optimal solution in a search space. At first initial HM is created randomly. Two control parameters of this new harmony are HM consideration rate along with pitch adjustment. To chose the value of new harmony from present HM, HMCR must be greater than random number generated. Else, it is chosen randomly. Comparison of the new solution with the worst number in the HM is done until the stopping criteria is satisfied. Pseudo-code for HSA is given in Chapter 3.

39

CHAPTER 5.

5.2. PROPOSED SYSTEM

Appliances

Wifi ECD

Figure 5.1: Home energy management system

5.2.2

EDE

EDE is also a meta heuristic method used in evolutionary computation. It optimizes a problem by trying iterative solution for improvement. It is widely used in many areas for optimization issues. Main steps of EDE are to initialize the random population of target vectors. Next for the application of mutation strategy, three different vectors having a base vector and two difference vectors are randomly chosen from the initialized population. To enhance the diversity factor, the trial vector is generated through crossover in the next step. Further the values of trial and target vectors are compared on the basis of objective function for the selection criteria. If the trial vector gets better fitness as compared to target vector, the target vector is updated until the termination criteria is satisfied. EDE pseudo-code is stated in Algorithm 3 given below.

5.2.3

TS

TS is a mathematical optimization method proposed by Fred W. Glover in 1986. This is a meta heuristic search technique that uses local or neighbourhood search 40

CHAPTER 5.

5.3. SIMULATION RESULTS

method for optimization. It has basically three memory categories, i.e., short term, intermediate and long term. Like other techniques, it also follows a number of steps to reach the best solution. In the first step, neighbourhood solution from current solution is generated. All the forbidden moves are recorded or saved in a list known as TL that is a short term memory structure. Second step is to set an AC and TS is to be performed. TL is updated after every iteration. Check for the highest fitness value in local best as compared to current best, if found it is set as the new best and the local best is added to TL. Process is continued until the user specified stopping criteria is satisfied. Pseudo-code for the defined method is given in chapter 3. Table 5.1: Fixed parameters

Appliances Electric Stove Clothes Dryer Vacuum Cleaner Refrigerator

Power Rating (kWh) 1.5 0.5 1.0 0.125

LOT [06:00-14:00] [14:00-22:00] [06:00-15:00] [06:00-09:00]

Table 5.2: Shiftable parameters

Appliances AC Dish Washer Heater Water Heater Pool Pump Electric Vehicle Lighting TV PC Ironing Appliance Hairdryer Other

5.3

Power Rating (kWh) 1 1 1.5 1.5 2 2.5 0.5 0.25 0.25 1 1 1.5

LOT [12:00-22:00] [15:00-24:00] [15:00-03:00] [06:00-23:00] [12:00-21:00] [16:00-24:00] [16:00-24:00] [16:00-01:00] [08:00-24:00] [06:00-16:00] [06:00-13:00] [06:00-24:00]

Simulation Results

In order to validate the results of proposed algorithms, simulations are carried out in MATLAB software. A combined pricing tariff, i.e., ToU and CPP is used to calculate the electricity cost. Values of combined price signal are shown in Fig. 5.2. According to results, EDE performs better in terms of reducing cost in comparison to other techniques, as shown in Fig. 5.3. The total cost of EDE is 11.27% less 41

CHAPTER 5.

5.3. SIMULATION RESULTS

140 price

120

Price

100 80 60 40 20 0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Time (hours)

Figure 5.2: Combined price signal 7000

Total Cost (Cent)

6000 5000 4000 3000 2000 1000 0

Unscheduled

TS

HSA

EDE

Figure 5.3: Total cost

than the total cost of HSA whereas in case of TS, the EDE total cost is 14.27% less, which shows the efficiency of EDE. The overall electricity cost comparison according to 24 hours individually is shown in Fig. 5.4. It shows explicitly that how appliances are switching their load from PHs to OPHs. The continuous running time of appliances from 11th to 17th hour creates a huge impact on cost as it increases the overall load. But, in order to perform load shifting, only limited appliances time interval was optimized to prevent making OPHs as PHs. As, due to continuous load shifting, system may convert OPHs into PHs. Moreover, this approach disturbs the UC factor and overall stability of the system. In case of UC, TS achieved the best performance in handling waiting time of appliances, i.e., 2.73 hours wait approximately to run the appliance in comparison to others. Whereas, HSA lets the user to wait for 3.28 hours and 3.30 hours in case of EDE to run an 42

CHAPTER 5.

5.3. SIMULATION RESULTS

Electricity Cost (cent)

1400 1200 1000

Unscheduled TS HSA EDE

800 600 400 200 0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Time (hours)

Figure 5.4: Hourly cost 3.5

Waiting Time (Hours)

3 2.5 2 1.5 1 0.5 0

TS

HSA

EDE

Figure 5.5: User comfort

appropriate appliance, as shown in Fig. 5.5. This type of variation among waiting time of appliances is due to the load shifting from PHs. In order to evaluate the performance of algorithms for reducing peak load and to achieve system stability, PAR is also calculated which is shown in Fig. 5.6. In case of unscheduled load, PAR is high in comparison to TS, EDE and HSA. According to the results, TS reduced the ratio more effectively in comparison to HSA and EDE. While comparing the unscheduled PAR with respect to scheduled reduced PAR of TS, HSA and EDE the percentages difference is 46.87%, 38.88% and 17.36% respectively. Fig. ?? shows that overall load of the appliances is balanced whereas Fig. 5.8 shows an overall load for 24 hours. 43

CHAPTER 5.

5.3. SIMULATION RESULTS

3

Peak Aevrage Ratio

2.5 2 1.5 1 0.5 0

Unscheduled

TS

HSA

EDE

Figure 5.6: PAR reduction 100

Load (kWh)

80 60 40 20 0

Unscheduled

TS

HSA

EDE

Figure 5.7: Total load

According to the results, it can be easily observed that in case of reducing overall electricity bill, EDE performs better among all other techniques. Whereas, in terms of achieving best user satisfaction, TS waiting time to run the particular appliance is less than other techniques. To achieve the PAR reduction efficiently, TS performed effectively. While concluding overall scenario, it has been evaluated that TS behavior in comparison to the other techniques proved accurate. The reason behind its perfection among others is that TS enables the optimizer to make a tabu list which contains the infeasible solutions. After that, when a new solution comes having better result than previous one, it discards the infeasible solution and stores the best solution.

44

CHAPTER 5.

5.4. CONCLUSION OF CHAPTER

15 Unscheduled TS HSA

Load (kWh)

10

5

0 1

2

3

4

5

6

7

8

9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Time (hours)

Figure 5.8: Hourly load

5.4

Conclusion of Chapter

DSM for the effectiveness of the proposed system is tested. In this chapter, a comparative study is evaluated between the unscheduled and implemented optimization techniques. To enhance the optimality of power consumption, our proposed system successfully achieved the defined objective function. Results show contrast between the achievements at each level on the basis of cost reduction, UC and reduction in PAR. In case of user satisfaction, TS worked more efficiently as compared to EDE and HSA, as it only wait for 2.73 hours to run next appliance whereas in case of electricity bill reduction, EDE worked more efficiently. However, in the case of PAR reduction, TS has achieved better results than EDE and HSA. In Chapter 6, an OPF problem is formulated for economic operation of electrical system while incorporating stochastic and intermittent nature of RESs.

45

CHAPTER 5.

5.4. CONCLUSION OF CHAPTER

Algorithm 3 EDE 1: Initialize all parameter pop size, D, MaxItr, xl, xu, f, vi 2: Initialize population 3: for j = 1:MaxItr 4: for j = 1:D 5: while termination criteria not satisfied 6: perform mutation 7: for each vector Xi randomly 8: select three vectors 9: Xr1, Xr2, Xr3 10: r11, r21, r31 11: end for mutant vector 12: V i = Xr1 + f (Xr2 − Xr3) 13: end if (G vout   Pw (v) = pwr vv−vin for vin 6 v 6 vr r −vin    p for v < v 6 v wr

r

51

out

(6.17)

CHAPTER 6.

6.2. MATHEMATICAL MODELING

where, rated output power of 3 MW wind turbine is represented with pwr . On the other hand, v, vvr , vin and vout are the actual, rated, cut-in and cut-out wind speeds of the turbine respectively. In this study, vr = 16 m/s, vin = 3 m/s and vout = 25 m/s. The energy conversion function of solar irradiance into solar power is given by [12]:  G2 P sr Gstd Rc for 0 6 G 6 Rc Ps (G) = P G for G > G

(6.18)

sr Gstd

where, G, Gstd , Rc and Psr are fore-casted solar irradiation, solar irradiation in standard environment, certain irradiance point and rated output power of solar PV respectively. In this study, Gstd value is set as 800 W/m2 , Rc is set as 120 W/m2 .

6.2.6

Probabilistic Modeling of Wind and Solar PV

6.2.6.0.1 O utput energy from wind turbine is dependent on wind speed, size of turbine and its power curve and shape. Wind speed is stochastic in nature however, wind speed of a certain site can be estimated through probabilistic models. These models use historical meteorological data of a site to estimate potential of wind energy. From literature [1, 3] it is established that wind speed follows Weibull PDF given as: fv (v) =

 k  v k−1 c

c

h  v k i exp − for 0 < v < ∞ c

(6.19)

h  v k i (6.20) FV (v) = 1 − exp − c where, k and c are Weibull PDF parameters for shape and scale for the wind farms. Values for these parameters are given in Table 6.4 which are taken from [12]. With the assumption that wind speed has a certain distribution like Weibull, it becomes necessary to convert that distribution in power. The equation after transformation for wind distribution to power convergence is given by reference [12] as: " #k−1 " !# hp 1 + hp v khvi 1 = pr vi pr i × exp − (6.21) fp (p) = pr c c c

52

CHAPTER 6.

6.2. MATHEMATICAL MODELING

Probability distribution for solar irradiance is given by lognormal PDF [12] with the standard deviation σ and mean µ. It can be calculated as: ( ) 1 −(lnx − µ)2 √ exp fg (G) = for G > 0 2σ 2 Gσ 2π

Wind Speed

Thermal Generators Data

Wind Power Forcast

(6.22)

Solar Irradiance

Solar Power Forcast Initilize population Set generation count = 0

Run power flow solution Determine violated constraints

Increase Generation counter

Evaluate fitness function

Stopping condition

yes

Selection

Crossover And mutation

Print Output results

Figure 6.1: Solution procedure flow chart of optimal scheduling.

In this chapter, GA is used for the purpose of scheduling RERs and thermal generators to solve the OPF problem. In Fig. 6.1 solution procedure flow chart is given. Where, in the first step wind and solar forecasted power is calculated with thermal generator data. In the second step, power flow algorithm will be executed and after that constraint violation and fitness function is evaluated. If stopping criteria is satisfied then system will halt and print results, otherwise system will 53

CHAPTER 6.

6.2. MATHEMATICAL MODELING

move forward to next step and selection,crossover or mutation will take place. This process will continue until the optimized solution is achieved. The proposed algorithm is written in MATLAB computing environment. It is applied on a 2.50 GHz core i5 personal computer with 4 GB-RAM. IEEE 30 bus test system with RERs is used to test the effectiveness of proposed optimal scheduling approach. IEEE 30 bus system is modified to accommodate generators other than thermal. Originally, this system consists of 6 thermal generators located at bus number 1, 2, 5, 8, 11 and 13. However, this system is replaced by wind farms on bus 8 and 11 and solar PV system on bus 13. The main characteristics of IEEE 30 bus system are given in Table 6.5. In this study, thermal generators are the only schedulable generators. Here, wind and solar generators are considered as non-schedulable as their output is dependent on availability of wind and solar irradiations. Table 6.1: Cost coefficients of thermal generators.

Generator TG1 TG2 TG3

Bus 1 2 8

a 0 0 0

b 2 1.75 3.25

c 0.00375 0.0175 0.00834

d 18 16 12

e 0.037 0.038 0.045

Table 6.2: Emission coefficients of thermal generators.

Generator Bus TG1 1 TG2

2

TG3

8

α β 4.091 5.554 2.543 6.047 5.532 -3.55

γ 6.49

ω µ 0.0002 6.667

5.638 0.0005 3.333 3.38

0.002

2

Table 6.3: Cost coefficients of thermal generator 1 and 2 for multi fuel function.

Generator TG1 TG2 TG1 TG2

Bus 1 2 1 2

a 55 40 82.5 80

b 0.7 0.3 1.05 0.6

c 0.005 0.01 0.0075 0.02

Case 1: OPF by Considering Cost Reduction First case under study is the base case of this chapter that is minimization of generation cost expressed by quadratic function for thermal generators calculated 54

CHAPTER 6.

6.2. MATHEMATICAL MODELING

using Eq. 6.1 and direct cost function for wind and solar PV calculated using Eq. 6.2 and Eq. 6.3. Wind speed and solar irradiation is taken as constant values: 10 m/s and 500 W/m2 respectively. Rated power generation of wind farms is 75 MW and 60 MW whereas, solar farm rated power is 50 MW. For the given wind speed 10 m/s and solar irradiance 500 W/m2 , the output power of wind farm 1 is 37.5 MW and that of wind farm 2 is 30 MW and solar farm is 25 MW. In this case, however, uncertainty is not considered. Results from this case are tabulated in Table 6.6. Active and reactive power generation of case 1 is shown in Fig. 6.2. and Fig. 6.3. respectively.

Case 2: OPF by Considering Multi Fuel Option In this case, multi fuel option is considered. All other values will remain same as in case 1. In practical. the thermal power generating plants may have multi fuel options like natural gas or oil. The cost curve calculation is as follows [15]. M F C(G1 andG2 ) =

2 X

aiz + biz PT Gi + ciz PT2Gi

(6.23)

i=1

where, z=2. The coefficients for fuel cost calculation are given in Table 6.3. The results obtained for this case are also tabulated in Table 6.6. Power generation pattern is shown in Fig. 6.2. and Fig. 6.3. respectively. Table 6.4: PDF parameters for wind power generation plant.

Wind farm

No. of turbines

Rated power

W1(bus 8) W2(bus 11)

25

75

Parameters Weibull of weibull mean PDF c=9, k=2 7.976 m/s

20

60

c=10, k=2

8.862 m/s

Case 3: Valve Point Loading Effect The aim of this case is to achieve a more realistic and effective modeling of thermal generators cost function by including valve point loading effect into quadratic cost function. Multi-valve steam turbine based thermal generators creates a ripple like effect and puts on a greater variation in fuel cost function. Valve point loading 55

CHAPTER 6.

6.2. MATHEMATICAL MODELING

Table 6.5: Main characteristics of IEEE 30 bus test system.

System characteristics Buses Branches Connected load

Quantity Details 30 41 -

Thermal generators

3

Wind generators Solar PV system Load bus voltage range allowed

2 1 24

[12] [12] 283.4 MW, 126.2 Mvar Buses: 1,2 and 3 Buses: 8 and 11 Bus: 13 [0.95-1.05] p.u.

Generators active output power (MW)

140 Case 1 Case 2 Case 3 Case 4

120 100 80 60 40 20 0 TG1

TG2

TG3

WG1

WG2

S-PV

Figure 6.2: Active power generation of all cases.

effect of multi valve steam turbines is modeled as recurring sinusoidal function. Hence, by adding the absolute value of sinusoidal function into basic cost function given in Eq. 6.1. The results from this case are tabulated in Table 6.6 and shown in Fig. 6.2. and Fig. 6.3. respectively. CT G (PT G ) =

N TG X

ai + bi PT Gi + ci PT2Gi +

i=1

|di × sin(ei ×)(PTmin Gi − PT Gi )|

56

(6.24)

CHAPTER 6.

6.2. MATHEMATICAL MODELING

Generators reactive output power (Mvar)

30 Case 1 Case 2 Case 3 Case 4

25

20

15

10

5

0 TG1

TG2

TG3

WG1

WG2

S-PV

Figure 6.3: Reactive power generation of all cases.

Case 4: OPF Cost Reduction with Uncertainties in Renewable Resources The aim of this case is generation cost reduction while incorporating uncertainties from RERs. The penalty cost is included in this case so that if forecasted production is over estimated, the energy supplier is supposed to pay the additional cost for keeping the spinning reserves [12]. In this case, it is assumed that the uncertainty of solar PV is 10% and uncertainty for wind farms is 15%. Results for this case are tabulated in Table 6.6. While considering case 4, it is observed that due to the variation in output power of solar PV and wind farms, amount of carbon emission increases due to higher use of thermal generators in order to fulfill the load demand. This factor leads towards increment in overall cost as carbon tax will also be imposed. The cost in case 4 also increases due to the reason that when uncertainties of RERs are taken into account, forecasting of these resources and generation power difference between actual and forecasted power also adds extra cost into the system. Power generation results for case 4 can be seen in Fig. 6.2. and Fig. 6.3. and are tabulated in Table 6.6. Achieved results are compared with those obtained from [12]. Where, total cost while handling uncertainty of RERs and without carbon tax is 8% less than that of case 3 in article [12]. By using the proposed technique, total cost with carbon tax is 8.08% less that of case 6 from [12]. Voltage profile is also improved as in case 3 and case 6 of [12] voltage magnitude for bus 11 is almost at its maximum limit. However, in our proposed solution voltage magnitude is under maximum limit. The highest magnitude obtained is on bus 11 which is 1.085 p.u.

57

CHAPTER 6.

6.3. CONCLUSION OF CHAPTER Table 6.6: Cost coefficients of thermal generators.

Generator TG1 TG2 TG3 W1 W2 S V1 V2 V5 V8 V11 V13 QG1 QG2 QG5 QG8 QG11 QG13 Cost($/h) Ploss (MW) Emission (ton/h) Carbon tax ($/h)

6.3

Min 50 20 10 0 0 0 0.95 0.95 0.95 0.95 0.95 0.95 -20 -20 -15 -30 -25 -20

Max 140 80 35 75 60 50 1.10 1.10 1.10 1.10 1.10 1.10 150 60 40 35 30 25

Case 1 139.28 39.787 18.665 37.5 30 25 1.06 1.043 1.01 1.01 1.082 1.073 5.4205 25.111 26.321 5.4974 15.263 7.34 641.56 6.8284 1.349

Case 2 134.91 39.688 35 37.5 30 25 1.06 1.045 1.01 1.03 1.082 1.071 6.7261 23.857 20.308 8.8799 15.038 7.0927 483.87 5.7975 1.251

Case 3 134.91 29.793 32 37.5 30 25 1.06 1.043 1.01 1.01 1.082 1.071 6.338 26.935 20.181 5.2495 15.22 7.3342 666.49 5.8009 1.252

Case 4 135 39.230 35 32.45 24.11 23.8 1.06 1.043 1.01 1.01 1.085 1.072 6.8868 24.139 2.325 8.1916 15.067 7.4053 719.39 6.0961 1.299

26.992

25.031

25.064

25.975

Conclusion of Chapter

This work proposed an approach to solve the OPF problem with the integration of uncertain solar and wind power resources into the network. Optimization of cost and emission objectives with optimal power distribution is done. Handling of uncertainties in renewable resources is done with PDF. Proposed approach also handles system security constraints violation so that system can work in its secure limits to prevent malfunctioning, system power losses or failure of the system. The simulation results on IEEE 30 bus test system shows the effectiveness of the proposed solution.

58

Chapter 7 Conclusion and Future Work

59

CHAPTER 7.

7.1

7.1. CONCLUSION

Conclusion

With the emergence of smart grids, DSM is considered as an important factor to maintain the balance between demand and supply. As residential sector is the main target for scheduling, it contains different kinds of appliances with variable power ratings. To cope with such scenarios, DSM needs an efficient method to schedule appliances in a way with minimum electric cost and maximum UC. In this proposed work, optimization techniques for load management and power scheduling of residential area are proposed. The purpose was to achieve a solution with minimum cost and reduced PAR. We evaluated our results by conducting simulation on different categories of appliances, i.e., fixed, shiftable and elastic appliances. RTP pricing tariff was used and the efficiency of proposed techniques was analyzed. Evaluated results proved that our defined goals of cost reduction, improvement of UC level and minimization of PAR are achieved. Load is efficiently shifted from PHs to OPHs due to which cost is reduced. Though, there exists a trade-off between waiting time and electricity cost. On the other hand, for the optimization of generated power, this work proposed an approach to solve the OPF problem with the integration of uncertain solar and wind power resources into the network. Optimization of cost and emission objectives with optimal power distribution is done. Handling of uncertainties in renewable resources is done with PDF. The proposed solution is tested on IEEE 30-bus testing system to obtain the optimal settings while keeping in consideration the stated constraints for active and reactive power, voltage stability and line capacity.

7.2

Future Work

In future, these heuristic algorithms could be implemented with the combination of fuzzy techniques to further enhance their performance. On the other hand, standard bus test systems can be modified with the integration of RERs to further minimize the cost and carbon emissions. Moreover, we will focus on the privacy and security issue of the smart grid

60

Chapter 8 Bibliography

61

Bibliography

[1] Javaid, N., Naseem, M., Rasheed, M.B., Mahmood, D., Khan, S.A., Alrajeh, N. and Iqbal, Z., 2017. A new heuristically optimized home energy management controller for smart grid. Sustainable Cities and Society, 34, pp.211-227. [2] Zhao, Z., Lee, W.C., Shin, Y. and Song, K.B., 2013. An optimal power scheduling method for demand response in home energy management system. IEEE Transactions on Smart Grid, 4(3), pp.1391-1400. [3] Rahim, S., Javaid, N., Ahmad, A., Khan, S.A., Khan, Z.A., Alrajeh, N. and Qasim, U., 2016. Exploiting heuristic algorithms to efficiently utilize energy management controllers with renewable energy sources. Energy and Buildings, 129, pp.452-470. [4] Javaid, N., Ullah, I., Akbar, M., Iqbal, Z., Khan, F.A., Alrajeh, N. and Alabed, M.S., 2017. An intelligent load management system with renewable energy integration for smart homes. IEEE Access, 5, pp.13587-13600. [5] Lu, X., Zhou, K., Chan, F.T. and Yang, S., 2017. Optimal scheduling of household appliances for smart home energy management considering demand response. Natural Hazards, 88(3), pp.1639-1653. [6] Safdarian, A., Fotuhi-Firuzabad, M. and Lehtonen, M., 2016. Optimal residential load management in smart grids: A decentralized framework. IEEE Transactions on Smart Grid, 7(4), pp.1836-1845. [7] Logenthiran, T., Srinivasan, D. and Shun, T.Z., 2012. Demand side management in smart grid using heuristic optimization. IEEE transactions on smart grid, 3(3), pp.1244-1252. [8] Khan, M.A., Javaid, N., Mahmood, A., Khan, Z.A. and Alrajeh, N., 2015. A generic demand-side management model for smart grid. International Journal of Energy Research, 39(7), pp.954-964. [9] Rasheed, M.B., Javaid, N., Ahmad, A., Khan, Z.A., Qasim, U. and Alrajeh, N., 2015. An efficient power scheduling scheme for residential load management in smart homes. Applied Sciences, 5(4), pp.1134-1163. [10] Vardakas, J.S., Zorba, N. and Verikoukis, C.V., 2015. A survey on demand response programs in smart grids: Pricing methods and optimization algorithms. IEEE Communications Surveys and Tutorials, 17(1), pp.152-178. 62

BIBLIOGRAPHY

BIBLIOGRAPHY

[11] Ma, J., Chen, H.H., Song, L. and Li, Y., 2016. Residential load scheduling in smart grid: A cost efficiency perspective. IEEE Transactions on Smart Grid, 7(2), pp.771-784. [12] Biswas, P.P., Suganthan, P.N. and Amaratunga, G.A., 2017. Optimal power flow solutions incorporating stochastic wind and solar power. Energy Conversion and Management, 148, pp.1194-1207. [13] Hafeez, G., Javaid, N., Iqbal, S. and Khan, F.A., 2018. Optimal residential load scheduling under utility and rooftop photovoltaic units. Energies, 11(3), pp.611-624. [14] Reddy, S.S., 2017. Optimal scheduling of thermal-wind-solar power system with storage. Renewable Energy, 101, pp.1357-1368. [15] Reddy, S.S. and Bijwe, P.R., 2016. Day-Ahead and real time optimal power flow considering renewable energy resources. International Journal of Electrical Power & Energy Systems, 82, pp.400-408. [16] Panda, A. and Tripathy, M., 2014. Optimal power flow solution of wind integrated power system using modified bacteria foraging algorithm. International Journal of Electrical Power and Energy Systems, 54, pp.306-314. [17] Roy, R. and Jadhav, H.T., 2015. Optimal power flow solution of power system incorporating stochastic wind power using Gbest guided artificial bee colony algorithm. International Journal of Electrical Power & Energy Systems, 64, pp.562-578. [18] Siavash, M., Pfeifer, C., Rahiminejad, A. and Vahidi, B., 2017, May. An application of grey wolf optimizer for optimal power flow of wind integrated power systems. In 18th International Scientific Conference on Electric Power Engineering (EPE), Kouty nad Desnou, Czech Republic, held on 17-19 May, 2017. [19] Khaled, U., Eltamaly, A.M. and Beroual, A., 2017. Optimal power flow using particle swarm optimization of renewable hybrid distributed generation. Energies, 10(7), pp.1013. [20] Teeparthi, K. and Kumar, D.V., 2018. Security-constrained optimal power flow with wind and thermal power generators using fuzzy adaptive artificial physics optimization algorithm. Neural Computing and Applications, 29(3), pp.855-871. [21] Panda, A., An efficient scenario based optimal generation scheduling of hydrothermal system incorporating wind power. International Journal of Recent Trends in Engineering and Research, 4(4), pp.1-7. [22] Fitiwi, D.Z., Olmos, L., Rivier, M., De Cuadra, F. and Perez-Arriaga, I.J., 2016. Finding a representative network losses model for large-scale transmission expansion planning with renewable energy sources. Energy, 101, pp.343-358.

63

BIBLIOGRAPHY

BIBLIOGRAPHY

[23] Tazvinga, H., Zhu, B. and Xia, X., 2015. Optimal power flow management for distributed energy resources with batteries. Energy Conversion and Management, 102, pp.104-110. [24] HassanzadehFard, H. and Jalilian, A., 2016. A novel objective function for optimal DG allocation in distribution systems using meta-heuristic algorithms. International Journal of Green Energy, 13(15), pp.1615-1625. [25] Sun, G., Li, Y., Chen, S., Wei, Z., Chen, S. and Zang, H., 2016. Dynamic stochastic optimal power flow of wind power and the electric vehicle integrated power system considering temporal-spatial characteristics. Journal of Renewable and Sustainable Energy, 8(5), pp.053309. [26] Reddy, S.S., 2017. Optimal power flow with renewable energy resources including storage. Electrical Engineering, 99(2), pp.685-695. [27] Hemmati, R., Saboori, H., Dehghan, S. and Ghiasi, S.M.S., 2017. Evaluating and comparing profitability of bulk storage systems in unit commitment and optimal power flow operation frameworks. Journal of Renewable and Sustainable Energy, 9(2), pp.024101. [28] Khaled, U., Eltamaly, A.M. and Beroual, A., 2017. Optimal power flow using particle swarm optimization of renewable hybrid distributed generation. Energies, 10(7), pp.1013. [29] Panda, A. and Tripathy, M., 2015. Security constrained optimal power flow solution of wind-thermal generation system using modified bacteria foraging algorithm. Energy, 93, pp.816-827. [30] Kefayat, M., Ara, A.L. and Niaki, S.N., 2015. A hybrid of ant colony optimization and artificial bee colony algorithm for probabilistic optimal placement and sizing of distributed energy resources. Energy Conversion and Management, 92, pp.149-161. [31] Panda, A. and Tripathy, M., 2016. Solution of wind integrated thermal generation system for environmental optimal power flow using hybrid algorithm. Journal of Electrical Systems and Information Technology, 3(2), pp.151-160. [32] Shargh, S., Mohammadi-ivatloo, B., Seyedi, H. and Abapour, M., 2016. Probabilistic multi-objective optimal power flow considering correlated wind power and load uncertainties. Renewable Energy, 94, pp.10-21. [33] Panda, A., Tripathy, M., Barisal, A.K. and Prakash, T., 2017. A modified bacteria foraging based optimal power flow framework for hydro-thermal-wind generation system in the presence of STATCOM. Energy, 124, pp.720-740. [34] Biswas, P.P., Suganthan, P.N., Qu, B.Y. and Amaratunga, G.A., 2018. Multiobjective economic-environmental power dispatch with stochastic wind-solarsmall hydro power. Energy, 150, pp.1039-1057.

64

BIBLIOGRAPHY

BIBLIOGRAPHY

[35] Wang, Z., Shi, Y., Wang, X., Zhang, Q. and Qu, S., 2016. Economic dispatch of power system containing wind power and photovoltaic considering carbon trading and spare capacity variation. International Journal of Green Energy, 13(12), pp.1267-1280. [36] Vaccaro, A., 2016. A reliable methodology for multi-objective voltage regulation in the presence of renewable power generation. Electric Power Components and Systems, 44(12), pp.1357-1370. [37] Kathiravan, R. and Kumudini Devi, R.P., 2017. Optimal power flow model incorporating wind, solar, and bundled solar-thermal power in the restructured Indian power system. International Journal of Green Energy, 14(11), pp.934950. [38] HassanzadehFard, H. and Jalilian, A., 2018. Optimal sizing and siting of renewable energy resources in distribution systems considering time varying electrical/heating/cooling loads using PSO algorithm. International Journal of Green Energy, 15(2), pp.113-128. [39] Javaid, N., Javaid, S., Abdul, W., Ahmed, I., Almogren, A., Alamri, A. and Niaz, I.A., 2017. A hybrid genetic wind driven heuristic optimization algorithm for demand side management in smart grid. Energies, 10(3), pp.319-346. [40] Ma, K., Yao, T., Yang, J. and Guan, X., 2016. Residential power scheduling for demand response in smart grid. International Journal of Electrical Power Energy Systems, 78, pp.320-325. [41] Zhang, D., Evangelisti, S., Lettieri, P. and Papageorgiou, L.G., 2016. Economic and environmental scheduling of smart homes with microgrid: DER operation and electrical tasks. Energy Conversion and Management, 110, pp.113124. [42] Zhu, Z., Tang, J., Lambotharan, S., Chin, W.H. and Fan, Z., 2012, January. An integer linear programming based optimization for home demand-side management in smart grid. In Innovative Smart Grid Technologies (ISGT), Washington DC, USA, held on 16-20 January, 2012, pp. 1-5. [43] Samadi, P., Wong, V.W. and Schober, R., 2016. Load scheduling and power trading in systems with high penetration of renewable energy resources. IEEE Transactions on Smart Grid, 7(4), pp.1802-1812. [44] Liu, Y., Yuen, C., Yu, R., Zhang, Y. and Xie, S., 2016. Queuing-based energy consumption management for heterogeneous residential demands in smart grid. IEEE Transactions on Smart Grid, 7(3), pp.1650-1659. [45] Ahmad, A., Javaid, N., Alrajeh, N., Khan, Z.A., Qasim, U. and Khan, A., 2015. A modified feature selection and artificial neural network-based day-ahead load forecasting model for a smart grid. Applied Sciences, 5(4), pp.1756-1772.

65

BIBLIOGRAPHY

BIBLIOGRAPHY

[46] Khalid, A., Javaid, N., Guizani, M., Alhussein, M., Aurangzeb, K. and Ilahi, M., 2018. Towards dynamic coordination among home appliances using multiobjective energy optimization for demand side management in smart buildings. IEEE Access, 6, pp.19509-19529. [47] Khan, A., Javaid, N. and Khan, M.I., 2018. Time and device based priority induced comfort management in smart home within the consumer budget limitation. Sustainable Cities and Society, 41, pp.538-555. [48] Rahim, M.H., Khalid, A., Javaid, N., Alhussein, M., Aurangzeb, K. and Khan, Z.A., 2018. Energy efficient smart buildings using coordination among appliances generating large data. IEEE Access, 6, pp. 34670-34690. [49] Hussain, H.M., Javaid, N., Iqbal, S., Hasan, Q.U., Aurangzeb, K. and Alhussein, M., 2018. An Efficient Demand side management system with a new optimized home energy management controller in smart grid. Energies, 11(1), p9.190-218. [50] Nadeem, Z., Javaid, N., Malik, A.W. and Iqbal, S., 2018. Scheduling appliances with GA, TLBO, FA, OSR and their hybrids using chance constrained optimization for smart homes. Energies, 11(4), pp.888-918. [51] Javaid, N., Ahmed, A., Iqbal, S. and Ashraf, M., 2018. Day ahead real time pricing and critical peak pricing based power scheduling for smart homes with different duty cycles. Energies, 11(6), pp.1464-1492. [52] Khan, A., Javaid, N., Ahmad, A., Akbar, M., Khan, Z.A. and Ilahi, M., 2018. A priority-induced demand side management system to mitigate rebound peaks using multiple knapsack. Journal of Ambient Intelligence and Humanized Computing, 2018, pp.1-24. [53] Iqbal, Z., Javaid, N., Iqbal, S., Aslam, S., Khan, Z.A., Abdul, W., Almogren, A. and Alamri, A., 2018. A domestic microgrid with optimized home energy management system. Energies, 11(4), pp.1002-1041. [54] Samuel, O., Javaid, N., Ashraf, M., Ishmanov, F., Afzal, M.K. and Khan, Z.A., 2018. Jaya based optimization method with high dispatchable distributed generation for residential microgrid. Energies, 11(6), pp.1-29. [55] Aslam, S., Javaid, N., Khan, F.A., Alamri, A., Almogren, A. and Abdul, W., 2018. Towards efficient energy management and power trading in a residential area via integrating a grid-connected microgrid. Sustainability, 10(4), pp.12451266. [56] Rottondi, C., Barbato, A., Chen, L. and Verticale, G., 2016. Enabling privacy in a distributed game-theoretical scheduling system for domestic appliances. IEEE Transactions on Smart Grid, 8(3), pp.1220 - 1230.

66

BIBLIOGRAPHY

BIBLIOGRAPHY

[57] Ogwumike, C., Short, M. and Denai, M., 2015, March. Near-optimal scheduling of residential smart home appliances using heuristic approach. In International Conference on Industrial Technology (ICIT), Seville, Spain, held on 17-19 March, 2015 2015, pp. 3128-3133. [58] Aslam, S., Iqbal, Z., Javaid, N., Khan, Z.A., Aurangzeb, K. and Haider, S.I., 2017. Towards efficient energy management of smart buildings exploiting heuristic optimization with real time and critical peak pricing schemes. Energies, 10(12), pp.2065-2090. [59] Nan, S., Zhou, M. and Li, G., 2018. Optimal residential community demand response scheduling in smart grid.Applied Energy, 210, pp.1280-1289. [60] Umetani, S., Fukushima, Y. and Morita, H., 2017. A linear programming based heuristic algorithm for charge and discharge scheduling of electric vehicles in a building energy management system. Omega, 67, pp.115-122. [61] Kazmi, S., Javaid, N., Mughal, M.J., Akbar, M., Ahmed, S.H. and Alrajeh, N., 2017. Towards optimization of metaheuristic algorithms for IoT enabled smart homes targeting balanced demand and supply of energy. IEEE Access, 2017, pp.99-114. [62] Ahmad, A., Khan, A., Javaid, N., Hussain, H.M., Abdul, W., Almogren, A., Alamri, A. and Azim Niaz, I., 2017. An optimized home energy management system with integrated renewable energy and storage resources. Energies, 10(4), pp.549-585. [63] Naz, M., Iqbal, Z., Javaid, N., Khan, Z.A., Abdul, W., Almogren, A. and Alamri, A., 2018. Efficient power scheduling in smart homes using hybrid grey wolf differential evolution optimization technique with real time and critical peak pricing schemes.Energies, 11(2), pp.384-585. [64] Sharma, I., Dong, J., Malikopoulos, A.A., Street, M., Ostrowski, J., Kuruganti, T. and Jackson, R., 2016. A modeling framework for optimal energy management of a residential building. Energy and Buildings, 130, pp.55-63. [65] Shirazi, E. and Jadid, S., 2015. Optimal residential appliance scheduling under dynamic pricing scheme via HEMDAS. Energy and Buildings, 93, pp.40-49. [66] Dommel, H.W. and Tinney, W.F., 1968. Optimal power flow solutions. IEEE Transactions on Power Apparatus and Systems, 10, pp.1866-1876. [67] Maria, G.A. and Findlay, J.A., 1987. A Newton optimal power flow program for Ontario Hydro EMS. IEEE Transactions on Power Systems, 2(3), pp.576582. [68] Grudinin, N., 1998. Reactive power optimization using successive quadratic programming method. IEEE Transactions on Power Systems, 13(4), pp.12191225.

67

BIBLIOGRAPHY

BIBLIOGRAPHY

[69] De Carvalho, E.P., Dos Santos Junior, A. and Ma, T.F., 2008. Reduced gradient method combined with augmented Lagrangian and barrier for the optimal power flow problem. Applied Mathematics and Computation, 200(2), pp.529536. [70] Santos, A.J. and Da Costa, G.R.M., 1995. Optimal-power-flow solution by Newton’s method applied to an augmented Lagrangian function. IEEE Proceedings-Generation, Transmission and Distribution, 142(1), pp.33-36. [71] Yan, W., Yu, J., Yu, D.C. and Bhattarai, K., 2006. A new optimal reactive power flow model in rectangular form and its solution by predictor corrector primal dual interior point method. IEEE transactions on power systems, 21(1), pp.61-67. [72] Bai, X. and Wei, H., 2011. A semidefinite programming method with graph partitioning technique for optimal power flow problems. International Journal of Electrical Power & Energy Systems, 33(7), pp.1309-1314. [73] Mota-Palomino, R. and Quintana, V.H., 1986. Sparse reactive power scheduling by a penalty function-linear programming technique. IEEE Transactions on Power Systems, 1(3), pp.31-39. [74] Chaib, A.E., Bouchekara, H.R.E.H., Mehasni, R. and Abido, M.A., 2016. Optimal power flow with emission and non-smooth cost functions using backtracking search optimization algorithm. International Journal of Electrical Power & Energy Systems, 81, pp.64-77. [75] Duman, S., Guvenc, U., Sonmez, Y. and Yorukeren, N., 2012. Optimal power flow using gravitational search algorithm. Energy Conversion and Management, 59, pp.86-95. [76] Kumar, S. and Chaturvedi, D.K., 2013. Optimal power flow solution using fuzzy evolutionary and swarm optimization. International Journal of Electrical Power & Energy Systems, 47, pp.416-423. [77] Abusorrah, A.M., 2013. Optimal power flow using adaptive fuzzy logic controllers. Mathematical Problems in Engineering, 2013, pp. 1-7. [78] Salhi, A., Naimi, D. and Bouktir, T., 2013. Fuzzy multi-objective optimal power flow using genetic algorithms applied to algerian electrical network. Advances in Electrical and Electronic Engineering, 11(6), pp.443-454. [79] Mandal, B. and Roy, P.K., 2014. Multi-objective optimal power flow using quasi-oppositional teaching learning based optimization. Applied Soft Computing, 21, pp.590-606. [80] Kumar, A.R. and Premalatha, L., 2015. Optimal power flow for a deregulated power system using adaptive real coded biogeography-based optimization. International Journal of Electrical Power & Energy Systems, 73, pp.393-399.

68

BIBLIOGRAPHY

BIBLIOGRAPHY

[81] Bouchekara, H.R.E.H., Chaib, A.E., Abido, M.A. and El-Sehiemy, R.A., 2016. Optimal power flow using an improved colliding bodies optimization algorithm. Applied Soft Computing, 42, pp.119-131. [82] Mohamed, A.A.A., Mohamed, Y.S., El-Gaafary, A.A. and Hemeida, A.M., 2017. Optimal power flow using moth swarm algorithm. Electric Power Systems Research, 142, pp.190-206. [83] Abaci, K. and Yamacli, V., 2016. Differential search algorithm for solving multi-objective optimal power flow problem. International Journal of Electrical Power & Energy Systems, 79, pp.1-10. [84] Mukherjee, A. and Mukherjee, V., 2015. Solution of optimal power flow using chaotic krill herd algorithm. Chaos, Solitons & Fractals, 78, pp.10-21. [85] Ayan, K., Kilic, U. and Barakli, B., 2015. Chaotic artificial bee colony algorithm based solution of security and transient stability constrained optimal power flow. International Journal of Electrical Power & Energy Systems, 64, pp.136-147. [86] Daryani, N., Hagh, M.T. and Teimourzadeh, S., 2016. Adaptive group search optimization algorithm for multi-objective optimal power flow problem. Applied Soft Computing, 38, pp.1012-1024. [87] Daqaq, F., Ellaia, R. and Ouassaid, M., 2017, November. Multiobjective backtracking search algorithm for solving optimal power flow. In International Conference on Electrical and Information Technologies (ICEIT), Rabat, Morocco, held on 15-18 November, 2017, pp. 1-6. [88] https://en.wikipedia.org/wiki/Evolutionary-algorithm [89] Zhao, L., Jia, Z., Chen, L. and Guo, Y., 2017. Improved backtracking search algorithm based on population control factor and optimal learning strategy. Mathematical Problems in Engineering 2017, pp.1-13. [90] Civicioglu, P., 2013. Backtracking search optimization algorithm for numerical optimization problems. Applied Mathematics and Computation, 219(15), pp.8121-8144.

69

Appendices

70

.1. APPENDIX A

.1

Appendix A

This code is developed by Sundas Shafiq under the supervision of Dr. Nadeem Javaid for the fulfilment of MS thesis presented to the Department of Computer Science, COMSATS University Islamabad (CUI) in Spring 2018. The presented work is done by using the resources of ComSens (Communication over Sensors) Lab. Email address: [email protected], [email protected] Website: http://www.njavaid.com/, https://sites.google.com/student.comsats.edu.pk/sundas-shafiq/home Institution: COMSATS University Islamabad, Islamabad Campus 44000, Pakistan Mobile: +923005792728 —————————————————————————– The Appendix A contains the details for the implementation of MATLAB code given in the upcoming Appendix B, Appendix C, Appendix D and Appendix E. It also provide the readers with the guidelines how to run the code in Readme.txt file.

• Appendix B provides the MATLAB code of Harmony Search Algorithm and Tabu Search Algorithm. • Appendix C contains the steps of Backtracking Search Optimization Algorithm and Hybrid Backtracking Tabu Search Algorithm. • Appendix D contains code steps for Enhanced Differential Evolution Algorithm. • Appendix E provides the initial input data and code steps for optimal power flow approach using Genetic Algorithm.

71

.2. APPENDIX B

.2

Appendix B

%% ****Appendix B contains the MATLAB code for the Harmony Search Algorithm and Tabu Search Algorithm ****%% %% ****The research paper is published under the title “Optimization of Home Energy Management System through Application of Tabu Search”****%%

%% ****Springer link: https://link.springer.com/chapter/10.1007/978-3\ -319-69835-9_4****%%

%% ****Researchgate link: https://www.researchgate.net/publication/319332275_ Optimization_of_Home_Energy_Management_System_through_Application_of_ Tabu_Search ****%% %% ****MATLAB source code file “Sundas C1.m”is available on the link given below ****%% %% ****Source code link: ****%% %%** Step by step guidelines to run this code are provided in Readme.txt file **%% %% **** Link: ****%% %% *************************************************************** %% %%—- This code is developed by Sundas Shafiq under the supervision of Dr. Nadeem Javaid for the fulfillment of MS thesis—- %% % —- Fall 2017 to Spring 2018—- %% % — ComSens (Communication over Sensors) Lab, Department of Computer Science— %% %—- COMSATS University Islamabad (CUI), Islamabad 44000, Pakistan—-%

% ****************************** Sundas Shafiq ****************************** %% %Website Link: https://sites.google.com/student.comsats.edu.pk/sundas\ -shafiq/home % Email Address: [email protected] % Mobile Number: -

72

.2. APPENDIX B % ***************************** Dr. Nadeem Javaid *************************** %% % Website Link: www.njavaid.com % Email Address: [email protected] % Mobile Number: +92-300-5792728 %% *************************************************************** %% %%%%— Optimization of Home Energy Management System through Application of Tabu Search —%%%% %%— Before going for the code, must read the original algorithms of Harmony Search Algorithm and Tabu Search Algorithm—%%

%% *******************Source Code***************************%% 1 2 3 4 5 6 7

close all ; % Close all the figures clear ; % removes all variables from the current workspace , releasing them from system memory clc ; % Clears all input and output from the Command Window display , giving you a clean screen

8 9 10 11 12 13

%% - - - Initia lization of price signals for different price signals each time uncommet the price list and run the code . For price list detail check the paper % https :// www . wnhydro . com / en / your - home / time - of - use - rates . asp - - -%% % - - - The hourly pricing data for the CPP was taken from the Scandinavian electricity market Nordpoolspot - - -%

14 15

16 17 18 19 20

21 22 23 24 25

26 27 28 29 30

31 32 33

%%—- Day ahead price RTP Signal (Used in this scenario) —-%% 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];

%%—- ToU —-%% % 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];

%%—- CPP —-%% % 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];

———————————– Appliances ———————————-%% %%——————- State of appliances (LOT and OTI) ——————-%% %%——————– Fixed appliances ———————%%

73

.2. APPENDIX B 34 35 36 37 38 39 40 41 42 43 44 45 46 47

48

Lights = [0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0]; % Lights status in 24 hours Fans = [1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1]; % Fans status in 24 hours Clothes_Iron = [0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 0]; % Clothes_Iron status in 24 hours Oven = [0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0]; % Oven status in 24 hours Toaster = [0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % Toaster status in 24 hours Coffee_Maker = [0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % Coffee_Maker status in 24 hours

%%———— Shiftable appliances ———–%%

49 50

%%% Cloth dryrer will be on immediately after washing machine stop working

51

%%%

52

W as hi ng _ Ma ch i ne = [0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0]; % W as hi ng _ Ma ch in e status in 24 hours Cloth_Dryer = [0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0]; % Cloth_Dryer status in 24 hours Dish_washer = [0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % Dish_washer status in 24 hours

53 54 55 56 57 58

59 60 61 62 63 64 65 66 67 68

%%———— Elastic base appliances ———–%% AC = [0 0 0 0 0 1 1 1 1 1 1 1 hours Refrigerator = [0 0 0 0 0 1 1 Refrigerator status in 24 hours Water_Heater = [0 0 0 0 0 1 1 Water_Heater status in 24 hours Space_Heater = [0 0 0 0 0 1 1 Space_Heater in 24 hours

1 1 0 1 1 0 1 1 0 0 1 1]; % AC status in 24 1 1 1 1 0 0 1 1 0 1 1 0 1 0 1 1 1]; % 1 1 1 1 1 1 0 0 0 1 1 0 0 0 0 0 0]; % 1 1 1 0 1 1 0 1 0 1 0 1 0 0 1 1 0]; %

69 70 71

Fixed_appliances = [ Lights ’ , Fans ’ , Clothes_Iron ’ , Oven ’ , Toaster ’ , Coffee_Maker ’]; % Set of all the F i x e d _ a p p l i a n c e s

72 73 74

S h i f t a b l e _ a p p l i a n c e s = [ Washing_Machine ’ , Cloth_Dryer ’ , Dish_washer ’]; % Set of all the S h i f t a b l e _ a p p l i a n c e s

75 76 77

B as e_ Ap p li an c es = [ AC ’ , Refrigerator ’ , Water_Heater ’ , Space_Heater ’]; % Set of all the B a se _A pp l ia nc es

78 79 80

Appliances = [ F ix e d _ a p p l i a n c e s S h i f t a b l e _ a p p l i a n c e s Ba s e_ Ap pl i an ce s ]; % Set of all the appliances

81 82 83 84 85 86 87

%% - - - Smart Grid Parameters Intialization --- %% t im e_ sl o t_ Fi x ed = [12 16 6 7 2 2]; % Operating hours for fixed appliances t i m e _ s l o t _ S h i f t a b l e = [5 4 3]; % Operating hours for the Shiftable_appliances time_ slot_Ba se = [15 14 10 12]; % Operating hours for Base appliances time_slots = [ t im e_ s lo t_ Fi x ed t i m e _ s l o t _ S h i f t a b l e time _slot_Ba se ];

88 89 90

SH_Fixed = [2 1 14 6 6 6]; % Starting hour for fixed appliances SH_Shiftable = [8 6 7]; % starting hour for shiftable appliances

74

.2. APPENDIX B 91 92

SH_Base = [6 6 6 6]; % starting hour for base appliances SH = [ SH_Fixed SH_Shiftable SH_Base ];

93 94 95 96 97

EH_Fixed = [24 24 23 22 10 22]; % ending hour for fixed appliances EH_Shiftable = [16 18 12]; % ending hour for shiftable appliances EH_Base = [24 24 24 24]; % ending hour for base appliances EH = [ EH_Fixed EH_Shiftable EH_Base ];

98 99 100 101 102 103 104

% Power ratings of App ’ s in that are to be schedule pFixed = [0.6 0.75 1.5 1.18 0.5 0.8]; % Power rating of fixed appliances pShiftable = [0.78 4.40 3.60]; % Power rating of shiftable appliances pBase = [1.44 0.73 4.45 1.50]; % Power rating of Base appliances p =[ pFixed pShiftable pBase ]; maxAvg =3;

105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139

%% Find the location of appliances who have minimum waiting time %% - - - Return the location of string where the value is equal to 1 , means the appliance is on - - - %% tL1 = strfind ( Lights ,(1) ) ; tF1 = strfind ( Fans ,(1) ) ; tCI1 = strfind ( Clothes_Iron ,(1) ) ; tO1 = strfind ( Oven ,(1) ) ; tT1 = strfind ( Toaster ,(1) ) ; tCM1 = strfind ( Coffee_Maker ,(1) ) ; tWM1 = strfind ( Washing_Machine ,[1 1 1 1 1]) ; tCD1 = strfind ( Cloth_Dryer ,[1 1 1 1 ]) ; tDW1 = strfind ( Dish_washer ,(1) ) ; tAC1 = strfind ( AC ,(1) ) ; tR1 = strfind ( Refrigerator ,(1) ) ; tWH1 = strfind ( Water_Heater ,(1) ) ; tSH1 = strfind ( Space_Heater ,(1) ) ; %% % % % % % % % % % % % % % % % % % % % % % % % % % Contraints %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% - - - To calculate unscheduled load and unscheduled cost for reference - - -%% for hour =1:24 E l e c t r i c i t y _ c o s t =[ 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) EP ( hour ) * p (10) EP ( hour ) * p (11) EP ( hour ) * p (12) EP ( hour ) * p (13) ];% coefficients of objective function u ns ch ed u le dl oa d ( hour ) = Appliances ( hour ,:) *p ’; % Unscheduled load per hour unsch eduleco st ( hour ) = Appliances ( hour ,:) * Electricity_cost ’; % Unscheduled cost per hour s u m _ u n s c h e d u l e d l o a d = sum ( un sc h ed ul e dl oa d ) ; % Sum of unscheduled load for 24 hours s u m _ u n s c h e d u l e d _ c o s t = sum ( un schedule cost ) ; % Cost of unscheduled load for 24 hours P AR _u ns c he du le d = max ( u ns c he du le d lo ad ) /( s u m _ u n s c h e d u l e d l o a d /24) ; % Calculating PAR of unscheduled case

140 141 142 143 144 145 146 147

%% On - peak and Off - peak D_EP = round ( mean ( EP ) ) ; % Mean electric price signal %% Normalized load for fitness function load_ (1: length ( u ns c he du le d lo ad ) ) =( u ns c he du l ed lo ad (1: length ( u ns ch ed u le dl oa d ) ) - min ( un sc h ed ul ed l oa d ) ) /( max ( un sc h ed ul ed l oa d ) - min ( u ns ch ed u le dl oa d ) ) ; t_load = sum ( load_ ) ;

148

75

.2. APPENDIX B 149 150 151

152 153 154 155

%% %%%%%%%%%% - - - - - - - - - - - - - - - - - Scheduling - - - - - - - - - - - - - - - - - - - - - - - -%%%%%%%%%%%%

%%—Scheduling for the Appliances via HSA just to minimize the cost and PAR— -%% %% - - - - - - - - - - - - - Parameters Initia lization for HSA - - - - - - - - - - - - %%

156 157 158 159 160 161 162 163 164

HMS =30; NVAR =13; HMCR =0.9; PAmin =0.4; PAmax =0.9; bwmin =0.0001; bwmax =1.0; MaxItr =100;

% Population size % Number of appliances % Harmony memory considering rule % Minimum pitch adjusting rate % Maximum pitch adjusting rate % Minimum bandwidth % Maximum bandwidth % Maximum generation

165 166 167

168 169

%% %% Variable used for Average Calculation %% %%

%%——————————– HSA ———————————%% %%———- HSA parameters Initialization ————%%

170 171 172 173

G_time_slots =[ ti me _s l ot _F ix e d t i m e _ s l o t _ S h i f t a b l e t ime_slot _Base ]; p =[ pFixed pShiftable pBase ];

174 175 176 177 178 179

%% %% Average Calculation %% %% G_time_slots =[ ti me _s l ot _F ix e d t i m e _ s l o t _ S h i f t a b l e t ime_slot _Base ]; best = inf ; gbest = inf ; Fbest = inf ;

180 181 182 183 184 185 186 187 188 189

190 191 192 193 194 195 196 197

%% %% Parametres for calculation %% %% app_Sch_G = zeros (24 ,13) ; % Scheduled appliances s u m _ s c h e d u l e d _ l o a d _ G =0; % Sum of scheduled load G_time_slots =[ ti me _s l ot _F ix e d t i m e _ s l o t _ S h i f t a b l e t ime_slot _Base ]; E_Cost_SS_G = zeros (1 ,24) ; % Scheduled electricity cost per hour s um _E _C o st _S S_ G =0; % Total scheduled electricity cost s ch ed ul e _l oa d_ G = zeros (1 ,24) ; % Scheduled electricity load per hour xl =0.1; xu =0.9;

%%——————————– Initialize Population ———————————%% %%—————————— Harmony search memory——————————-%% for i =1: HMS % HMS = Harmony memory size for j =1: NVAR HM (i , j ) = xl + rand (1) *( xu - xl ) ; % Generating random population end end

198 199 200 201 202 203

for hour =1:24 % gen =24 e l e c t r i c i t y _ co s t =[ 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) EP ( hour ) * p (10) EP ( hour ) * p (11) EP ( hour ) * p (12) EP ( hour ) * p (13) ];% coefficients of objective function

76

.2. APPENDIX B 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245

%%%%%% Following loop converts the HM into binary %%%% HM1 = HM ; for i =1: HMS for j =1: NVAR if HM1 (i , j ) >0.5% std ( u n sc he du l ed lo ad ) % rand (1) means 1*1 matrix HM1 (i , j ) =1; else HM1 (i , j ) =0; end end end lhour =25 - hour ; if lhour 1 for a =1: HMS if app_Sch_G ( hour -1 ,7) ==1 HM1 (a ,7) =1; end if G_time_slots (1 ,7) >0 HM1 (a ,8) =0; end if G_time_slots (1 ,7) 0 HM1 (a ,8) =0; end end

246 247 248 249 250 251 252 253 254

%% - - - - - - - - - - - - - - - - - - - - - - - - Scheduling of lights - - - - - - - - - - - - - - - - - - - - - - -%% for a =1: HMS if G_time_slots (1 ,1) >1 && hour >=1 && hour 0.5 HM1 (1 ,1) =1; elseif j 0 && hour >=18 HM1 (a ,1) =1; else HM1 (a ,1) =0; end

77

.2. APPENDIX B 262

end

263 264 265

%% - - - - - - - - - - - - - - - - - - - - - - - - - Scheduling of fans - - - - - - - - - - - - - - - - - - - - - - -%% for a =1: HMS

266 267 268 269 270 271 272 273 274

if G_time_slots (1 ,2) >1 && hour 0 && hour >=14 HM1 (a ,2) =1; else HM1 (a ,2) =0; end end

275 276 277 278 279 280 281 282

%% - - - - - - - - - - - - - - - - - - - - - Scheduling of clothes iron - - - - - - - - - - - - - - - - - -%% for a =1: HMS if G_time_slots (1 ,3) >0 && hour >=14 && hour 0 && hour >6 && hour 0 && hour >6 && hour =1 HM1 (a ,6) =0; elseif G_time_slots (1 ,6) >0 && hour >=6 && hour 0 && hour >7 && hour 0 && hour >=6 HM1 (a ,10) =1; else HM1 (a ,10) =0; end end %% - - - - - - - - - - - - - - - - - - - - - - - - Scheduling of refrigerator - - - - - - - - - - - - - - - - - - - - - - -%% for a =1: HMS if G_time_slots (1 ,11) >0 && hour >6 HM1 (a ,11) =1; else HM1 (a ,11) =0; end end

340 341 342 343 344 345 346 347 348 349 350 351 352 353

%% - - - - - - - - - - - - - - - - - - - - - - - - Scheduling of water heater - - - - - - - - - - - - - - - - - - - - - - -%% for a =1: HMS if G_time_slots (1 ,12) >8 && hour >=6 && hour 0 && hour >=12 if lhour 0 HM1 (a ,12) =1; end else HM1 (a ,12) =0; end end

354 355 356 357 358 359 360 361 362 363 364 365 366 367

%% - - - - - - - - - - - - - - - - - - - - - - - - Scheduling of space heater - - - - - - - - - - - - - - - - - - - - - - -%% for a =1: HMS if G_time_slots (1 ,13) >0 && hour >6 if lhour 0 HM1 (a ,13) =1; end elseif G_time_slots (1 ,1) D11 && Load (1 , i ) > min ( un sc he d ul ed lo a d ) ) D11 = F (1 , i ) ; % mean ( u ns ch e du le dl o ad ) Lbest = HM1 (i ,:) ; % gbest position achieved here Fbest = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end if D11 == inf for i = 1: HMS if ( F (1 , i ) < D11 && Load (1 , i ) > min ( un sc he d ul ed lo a d ) ) D11 = F (1 , i ) ; Lbest = HM1 (i ,:) ; % gbest position achieved here Fbest = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end if D11 == inf for i = 1: HMS if ( F (1 , i ) < D11 ) % && Load (1 , i ) > min ( u ns ch ed u le dl oa d ) ) D11 = F (1 , i ) ; Lbest = HM1 (i ,:) ; % gbest position achieved here Fbest = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end gbest = Lbest (1 ,:) ; HM1 ( ij ,:) =0; for b =1: NVAR if ( gbest (1 , b ) ==1) G_time_slots (1 , b ) = G_time_slots (1 , b ) -1; elseif ( gbest (1 , b ) ==0) G_time_slots (1 , b ) = G_time_slots (1 , b ) ; end end G_time_slots ; hour ; %%%%%%% check gbest %%%%%%%%%

436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480

app_Sch_G ( hour ,:) = gbest (: ,:) ; s ch ed ul e _l oa d_ G ( hour ) = p * gbest ’; % Scheduled electric load per hour E_Cost_SS_G ( hour ) = e l e c t r i c i t y _ c o s t * gbest ’; % scheduled electric cost per

481 482 483 484

hour

485

s u m _ s c h e d u l e d _ l o a d _ G = sc h ed ul e_ l oa d_ G ( hour ) + s u m _ s c h e d u l e d _ l o a d _ G ; % Total sum of scheduled load s um _E _C o st _S S_ G = E_Cost_SS_G ( hour ) + s um _ E_ Co st _ SS _G ; % Total sum of scheduled cost P AR _s ch e du le d_ G = max ( s ch e du le _l o ad _G ) /(( s u m _ s c h e d u l e d _ l o a d _ G ) /24) ; % PAR value after scheduling

486 487 488 489 490 491 492 493

%% Appliances Scheduled hours Lights_G (: , hour ) = app_Sch_G ( hour ,1) ; % Scheduled hours for lights using HSA

81

.2. APPENDIX B Fans_G (: , hour ) = app_Sch_G ( hour ,2) ; % Scheduled hours for fans using HSA Clot hes_Iron _G (: , hour ) = app_Sch_G ( hour ,3) ; % Scheduled hours for iron using

494 495 496

HSA Oven_G (: , hour ) = app_Sch_G ( hour ,4) ; % Scheduled hours for oven using HSA Toaster_G (: , hour ) = app_Sch_G ( hour ,5) ; % Scheduled hours for toaster using

497 498 499

HSA

500

Coff ee_Maker _G (: , hour ) = app_Sch_G ( hour ,6) ; % Scheduled hours for coffee maker using HSA W a s h i n g _ M a c h i n e _ G (: , hour ) = app_Sch_G ( hour ,7) ; % Scheduled hours for washing machine using HSA Cloth_Dryer_G (: , hour ) = app_Sch_G ( hour ,8) ; % Scheduled hours for cloth dryer using HSA Dish_washer_G (: , hour ) = app_Sch_G ( hour ,9) ; % Scheduled hours for dish washer using HSA AC_G (: , hour ) = app_Sch_G ( hour ,10) ; % Scheduled hours for AC using HSA Refri gerator _G (: , hour ) = app_Sch_G ( hour ,11) ; % Scheduled hours for refrigerator using HSA Water _Heater _G (: , hour ) = app_Sch_G ( hour ,12) ; % Scheduled hours for water heater using HSA Space _Heater _G (: , hour ) = app_Sch_G ( hour ,13) ; % Scheduled hours for space heater using HSA

501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523

%% ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Next Generation ! !! !! ! !! !! ! !! !! %% % - - - - - - - Genereate new population using Harmony - - - - - - - - - - - - - - - - - - - - -% for j =1: MaxItr PA =( PAmax - PAmin ) /( MaxItr ) * j + PAmin ; % pitch adjustment rate % coef = log ( bwmin / bwmax ) / MaxItr ; % bwmin = minimium bandwidth , bwmax = maximum bandwidth for pp =1: NVAR BW ( pp ) = bwmax * exp ( coef * j ) ;

524 525

End

526 527 528 529 530 531 532 533 534

% - - - - - - - - - - - - - - - - - - - - - - - Improvise a new harmony vector - - - - - - - - - -& for i =1: NVAR ran = rand (1) ; if ( ran < HMCR ) % memory consideration index = randint (1 , HMS ) ; NCHV ( i ) = HM ( index , i ) ; %% gbest % NCHV ( i )

535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551

pvbRan = rand (1) ; if ( pvbRan < PA ) % pitch adjusting pvbRan1 = rand (1) ; result = NCHV ( i ) ; if ( pvbRan1 < 0.5) result = result + rand (1) * BW ( i ) ; % if ( result < PVB (i ,2) ) NCHV ( i ) = result ; % answer = NCHV ( i ) % end else result = result - rand (1) * BW ( i ) ; % if ( result > PVB (i ,1) ) NCHV ( i ) = result ; end end

82

.2. APPENDIX B 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566

else NCHV ( i ) = xl + rand (1) *( xu - xl ) ; % random selection % answer = NCHV ( i ) end new_h = NCHV ; end new_h1 = new_h ; % nchv = NCHV ( i ) for i =1: NVAR if ( new_h1 (1 , i ) > 0.5) new_h1 (1 , i ) =1; else new_h1 (1 , i ) =0; end end

567 568 569 570 571 572 573 574 575 576

F = F1 ; if hour min ( u ns ch ed u le dl oa d ) HM ( worst_index ,:) = new_h ; F ( worst_index ) = new ;

581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609

end end end % toc tL1_HSA = strfind ( Lights_G ,[1]) ;% return the location of string where lights are ON tF1_HSA = strfind ( Fans_G ,[1]) ; % return the location of string where fans are ON tCI1_HSA = strfind ( Clothes_Iron_G ,[1]) ; % return the location of string where iron is ON tO1_HSA = strfind ( Oven_G ,[1]) ; % return the location of string where oven is ON tT1_HSA = strfind ( Toaster_G ,[1]) ; % return the location of string where toaster is ON tCM1_HSA = strfind ( Coffee_Maker_G ,[1]) ; % return the location of string where coffee maker is ON tWM1_HSA = strfind ( Washing_Machine_G ,[1 1 1 1 1]) ;% return the location of string where washing machine is consecutively ON tCD1_HSA = strfind ( Cloth_Dryer_G ,[1 1 1 1]) ; % return the location of string where cloth dryer is consecutively ON tDW1_HSA = strfind ( Dish_washer_G ,[1]) ; % return the location of string where dish washer is ON tAC1_HSA = strfind ( AC_G ,[1]) ; % return the location of string where AC is ON tR1_HSA = strfind ( Refrigerator_G ,[1]) ; % return the location of string where refrigerator is ON tWH1_HSA = strfind ( Water_Heater_G ,[1]) ; % return the location of string where water heater is ON

83

.2. APPENDIX B 610 611

tSH1_HSA = strfind ( Space_Heater_G ,[1]) ; % return the location of string where space heater is ON

612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636

%%%% - - - - - - - - waiting time - - - - - - - - - - -%%%% D1_HSA = ( sum ( abs ( tL1 - tL1_HSA ) ) ) / sum ( Lights_G ) ; % waiting time for lights D2_HSA = ( sum ( abs ( tF1 - tF1_HSA ) ) ) / sum ( Fans_G ) ; % waiting time for fans D3_HSA = ( sum ( abs ( tCI1 - tCI1_HSA ) ) ) / sum ( Clot hes_Iro n_G ) ; % waiting time for iron D4_HSA = ( sum ( abs ( tO1 - tO1_HSA ) ) ) / sum ( Oven_G ) ; % waiting time for oven D5_HSA = ( sum ( abs ( tT1 - tT1_HSA ) ) ) / sum ( Toaster_G ) ; % waiting time for toaster D6_HSA = ( sum ( abs ( tCM1 - tCM1_HSA ) ) ) / sum ( Coff ee_Make r_G ) ; % waiting time for coffee maker D7_HSA = ( sum ( abs ( tWM1 - tWM1_HSA ) ) ) / sum ( W a s h i n g _ M a c h i n e _ G ) ; % waiting time for washing machine D8_HSA = ( sum ( abs ( tCD1 - tCD1_HSA ) ) ) / sum ( Cloth_Dryer_G ) ; % waiting time for cloth dryer D9_HSA = ( sum ( abs ( tDW1 - tDW1_HSA ) ) ) / sum ( Dish_washer_G ) ; % waiting time for dish washer D10_HSA = ( sum ( abs ( tAC1 - tAC1_HSA ) ) ) / sum ( AC_G ) ; % waiting time for AC D11_HSA = ( sum ( abs ( tR1 - tR1_HSA ) ) ) / sum ( Refr igerator _G ) ; % waiting time for refrigerator D12_HSA = ( sum ( abs ( tWH1 - tWH1_HSA ) ) ) / sum ( W ater_Hea ter_G ) ;% waiting time for water heater D13_HSA = ( sum ( abs ( tSH1 - tSH1_HSA ) ) ) / sum ( S pace_Hea ter_G ) ; % waiting time for space heater

637 638 639 640 641 642 643 644

645 646 647 648 649 650 651 652

U s e r _ C o m f o r t _ H S A = [ D1_HSA D2_HSA D3_HSA D4_HSA D5_HSA D6_HSA D7_HSA D8_HSA D9_HSA D10_HSA D11_HSA D12_HSA D13_HSA ]; waiting_HSA = sum ( U s er _ C o m f o r t _ H S A ) ; % Total hours for waiting time Avg_UCom_HSA = waiting_HSA /13; % Average waiting time % toc % % % % % % % % % % % % % % % % % % % % % % % % % % end of HSA % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

%%——————————– TS ———————————%% %%— Parameters Initialization for TABU search—-%% pop_size =30; D =13; schedule MaxItr =100; xl =0.1; xu =0.9;

% population size % Dimension of a search space number of appliances to %%% Maximum generation %%% Lower and upper bound

653 654 655 656 657 658 659 660 661 662 663 664 665 666

%%%%%% custom %%%% app_SchTS = zeros (24 ,13) ; % Scheduled appliances via TS time_slots_TS =[ t im e_ s lo t_ Fi x ed t i m e _ s l o t _ S h i f t a b l e time _slot_Ba se ]; % Array of timeslot for all appliances app =13; % number of appliances pop =30; % Pop size Tabu_list = zeros (30 ,13) ; % Tabu list which track records forbidden moves % ASP_C =0; G_X = zeros ( pop ,13) ; XX = zeros (30 ,13) ; % best solution after comparing all solutions k =2; % iteration counter x = zeros ( pop , app ) ; % x = zeros ( pop , app ) ;

84

.2. APPENDIX B 667 668 669 670 671 672 673 674 675 676 677

for i =1: pop for j =1: app if rand >=0.5 x (i , j ) =1; else x (i , j ) =0; end end end size ( x )

%% Initial population %%

678 679 680 681 682 683 684 685 686 687 688

for hour =1:24 % 24 hour time horizon E l e c t r i c i t y _ c o s t 1 =[ EP ( hour ) * p ];% electricity in time interval t % Generate 6 neighborhood solutions %%% trail vectors %%% s1 = zeros ( pop , app ) ; s2 = zeros ( pop , app ) ; s3 = zeros ( pop , app ) ; s4 = zeros ( pop , app ) ; s5 = zeros ( pop , app ) ; s6 = zeros ( pop , app ) ;

689 690 691 692

for j =1: k % no of iterations for i =1: pop for j =1: app

693 694 695 696 697 698 699 700 701

% find the fitness of first neighborhood solution if rand >=0.5 s1 (i , j ) =1; else s1 (i , j ) =0; F1 =( E l e c t r i c i t y _ c o s t 1 * s1 ’) ; f11 = mean ( F1 ) ; end

702 703 704 705 706 707 708 709 710

% find the fitness of second neighborhood solution if rand >=0.5 s2 (i , j ) =1; else s2 (i , j ) =0; F2 =( E l e c t r i c i t y _ c o s t 1 * s2 ’) ; f21 = mean ( F2 ) ; end

711 712 713 714 715 716 717 718 719

% find the fitness of third neighborhood solution if rand >=0.5 s3 (i , j ) =1; else s3 (i , j ) =0; F3 =( E l e c t r i c i t y _ c o s t 1 * s3 ’) ; f31 = mean ( F3 ) ; end

720 721 722 723 724

% find the fitness of fourth neighborhood solution if rand >=0.5 s4 (i , j ) =1; else

85

.2. APPENDIX B 725

s4 (i , j ) =0;

726 727 728 729

F4 =( E l e c t r i c i t y _ c o s t 1 * s4 ’) ; f41 = mean ( F4 ) ; end

730 731 732 733 734 735 736 737 738

% find the fitness of fifth neighborhood solution if rand >=0.5 s5 (i , j ) =1; else s5 (i , j ) =0; F5 =( E l e c t r i c i t y _ c o s t 1 * s5 ’) ; f51 = mean ( F5 ) ; end

739 740 741 742 743 744 745 746 747 748 749 750

% find the fitness of sixth neighborhood solution if rand >=0.5 s6 (i , j ) =1; else s6 (i , j ) =0; F6 =( E l e c t r i c i t y _ c o s t 1 * s6 ’) ; f61 = mean ( F6 ) ; end end ab =[ f11 , f21 , f31 , f41 , f51 , f61 ]; end

751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771

abb = sort ( ab ) ; % sort the fitness of each neighbor solution F = zeros (30 ,13) ; %% - - Compare trail matrix and find the best neighborhood solution - - %% if min ( ab ) == f11 ; F = s1 ; elseif min ( ab ) == f21 F = s2 ; elseif min ( ab ) == f31 F = s3 ; elseif min ( ab ) == f41 F = s4 ; elseif min ( ab ) == f51 F = s5 ; elseif min ( ab ) == f61 F = s6 ; end min_T =( E l e c t r i c i t y _ c o s t 1 *F ’) ; min_Trail = mean ( min_T ) ; g_best = F ; % best neighborhood solution L_best = x ; % initial solution

772 773 774 775 776 777 778 779 780 781 782

% - - - - compare a best neighborhood solution with the initial solution - - - - -% for i =1: pop mean_GB_Cost = mean ( E l e c t r i c i t y _ c o s t 1 * g_best (i ,:) ’) ; mean_GB_Load = mean ( g_best (i ,:) *p ’) ; mean_LB_Cost = mean ( E l e c t r i c i t y _ c o s t 1 * L_best (i ,:) ’) ; mean_LB_Load = mean ( L_best (i ,:) *p ’) ; if mean_GB_Cost < mean_LB_Cost && mean_GB_Load < mean_LB_Load Tabu_list (i ,:) = L_best (i ,:) ; XX (i ,:) = g_best (i ,:) ;

86

.2. APPENDIX B 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835

else Tabu_list (i ,:) = g_best (i ,:) ; XX (i ,:) = L_best (i ,:) ; end end end X2 = Tabu_list ; % best solution is selected for i =1: pop_size % converting all values into binary for switching appliances for k =1: app if X2 (i , k ) >0.5 X2 (i , k ) =1; else X2 (i , k ) =0; end end end %% end of TS lhour =25 - hour ; %%%%%%%%%% if lhour 1 for a =1: pop if app_SchTS ( hour -1 ,7) ==1 X2 (a ,7) =1; end if time_slots_TS (1 ,7) >0 % check washing machine operation is completed or not X2 (a ,8) =0; % if it is not completed cloth dryer is not switched ON end if time_slots_TS (1 ,7) 0 % check washing machine operation is completed or not X2 (a ,8) =0; end end

836 837 838 839 840

%% - - - - - - - - - - - - - - - - - - - - - - - - Scheduling of lights - - - - - - - - - - - - - - - - - - - - - - -%% for a =1: pop if time_slots_TS (1 ,1) >1 && hour >=1 && hour 0 && hour >=18 X2 (a ,1) =1; else X2 (a ,1) =0; end end

852 853 854 855 856 857 858 859 860 861 862

%% - - - - - - - - - - - - - - - - - - - - - - - - Scheduling of fans - - - - - - - - - - - - - - - - - - - - - - -%% for a =1: pop if time_slots_TS (1 ,2) >1 && hour 0 && hour >=12 X2 (a ,2) =1; else X2 (a ,2) =0; end end

863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881

%% - - - - - - - - - - - - - - - - - - - - - - - - Scheduling of clothes iron - - - - - - - - - - - - - - - - - - - - - - -%% for a =1: pop if time_slots_TS (1 ,3) >0 && hour >=14 && hour 0 && hour >=6 elseif time_slots_TS (1 ,4) >0 && hour >15 && hour 0 && hour >=6 && hour 0 && hour >9 && hour 0 && hour >=9 && hour 0 && hour >=19 && hour 0 && hour >=7 && hour =9 && hour 0 X2 (a ,9) =1; else X2 (a ,9) =0; end end %% - - - - - - - - - - - - - - - - - - - - - - - - Scheduling of AC - - - - - - - - - - - - - - - - - - - - - - -%% for a =1: pop if time_slots_TS (1 ,10) >0 && hour >=6 if lhour 0 X2 (a ,10) =1; end elseif time_slots_TS (1 ,10) 0 && hour >=6 if lhour 0 X2 (a ,11) =1; end elseif time_slots_TS (1 ,11) 0 && hour >6 if lhour 0 X2 (a ,12) =1; end elseif time_slots_TS (1 ,12) 0 && hour >=6 if lhour 0 X2 (a ,13) =1; end elseif time_slots_TS (1 ,13) ( std ( un s ch ed ul e dl oa d ) +2*( min ( u ns ch ed u le dl oa d ) ) ) ) &&( Load (1 , i ) < mean ( u n sc he du l ed lo ad ) - min ( u ns ch ed u le dl oa d ) ) %&& Load (1 , i ) < mean ( u ns c he du le d lo ad ) % clc && Load (1 , i ) ( mean ( un s ch ed ul e dl oa d ) - min ( u ns c he du l ed lo ad ) ) % && Load (1 , i ) = min ( EP ) ) % Compare fitness value with D11 . D11 = F_ts (1 , i ) ; L1best = X2 (i ,:) ; % gbest position achieved here F1best = D11 ; ds = E_Cost_ts (1 , i ) ;

90

.2. APPENDIX B 1015 1016 1017 1018 1019

ij = i ; end end end if EP ( hour ) min ( u ns ch e du le dl o ad ) ) D11 = F_ts (1 , i ) ; % mean ( un sc h ed ul ed l oa d ) L1best = X2 (i ,:) ; % gbest position achieved here F1best = D11 ; ds = E_Cost_ts (1 , i ) ; ij = i ; end if ( F_ts (1 , i ) > D11 && Load (1 , i ) > min ( u ns ch e du le d lo ad ) ) D11 = F_ts (1 , i ) ; % mean ( un sc h ed ul ed l oa d ) L1best = X2 (i ,:) ; % gbest position achieved here F1best = D11 ; ds = E_Cost_ts (1 , i ) ; ij = i ; end end end if D11 == inf for i = 1: pop_size if ( F_ts (1 , i ) < D11 && Load (1 , i ) > min ( u ns ch e du le d lo ad ) ) D11 = F_ts (1 , i ) ; L1best = X2 (i ,:) ; % gbest position achieved here F1best = D11 ; ds = E_Cost_ts (1 , i ) ; ij = i ; end end end if D11 == inf for i = 1: pop_size if ( F_ts (1 , i ) < D11 ) % && Load (1 , i ) > min ( un sc h ed ul ed l oa d ) ) D11 = F_ts (1 , i ) ; L1best = X2 (i ,:) ; % gbest position achieved here F1best = D11 ; ds = E_Cost_ts (1 , i ) ; ij = i ; end end end g1best = L1best (1 ,:) ; X2 ( ij ,:) =0; for b =1:13 if ( g1best (1 , b ) ==1) time_slots_TS (1 , b ) = time_slots_TS (1 , b ) -1; elseif ( g1best (1 , b ) ==0) time_slots_TS (1 , b ) = time_slots_TS (1 , b ) ; end end time_slots_TS ; hour ;

1071 1072

app_SchTS ( hour ,:) = g1best (: ,:) ; % appliances scheduled hours using TS

91

.2. APPENDIX B 1073 1074 1075 1076 1077 1078 1079

s c h e d u l e _ l o a d_ T S ( hour ) = p * g1best ’; % Appliances scheduled load per hour using TS s u m _ s c h e d u l e _ l o d T S = sum ( s c h e d u l e _ l o a d _ T S ) ; % Sum of scheduled load using TS P A R _ s c h e d u l e d_ T S = max ( s c h e d u l e _ l o a d _ T S ) /( s u m _ s c h e d u l e _ l o d T S /24) ; % Peak to average ratio using TS E_Cost_SS_TS ( hour ) = E le c t r i c i t y _ c o s t 1 * g1best ’; % Cost per hour using TS sum_TS_Cost1 = sum ( E_Cost_SS_TS ) ; % Sum of cost using TS

1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105

%% Appliances Scheduled hours Lights_TS (: , hour ) = app_SchTS ( hour ,1) ; % Scheduled hours for lights using TS Fans_TS (: , hour ) = app_SchTS ( hour ,2) ; % Scheduled hours for fans using TS C lo th e s_ Ir on _ TS (: , hour ) = app_SchTS ( hour ,3) ; % Scheduled hours for iron using TS Oven_TS (: , hour ) = app_SchTS ( hour ,4) ; % Scheduled hours for oven using TS Toaster_TS (: , hour ) = app_SchTS ( hour ,5) ; % Scheduled hours for toaster using TS C of fe e_ M ak er _T S (: , hour ) = app_SchTS ( hour ,6) ; % Scheduled hours for coffee maker using TS W a s h i n g _ M a c h i n e _ T S (: , hour ) = app_SchTS ( hour ,7) ; % Scheduled hours for washing machine using TS Clot h_Dryer_ TS (: , hour ) = app_SchTS ( hour ,8) ; % Scheduled hours for clothes dryer using TS Dish _washer_ TS (: , hour ) = app_SchTS ( hour ,9) ; % Scheduled hours for dish washer using TS AC_TS (: , hour ) = app_SchTS ( hour ,10) ; % Scheduled hours for AC using TS R ef ri ge r at or _T S (: , hour ) = app_SchTS ( hour ,11) ; % Scheduled hours for refrigerator using TS W at er _H e at er _T S (: , hour ) = app_SchTS ( hour ,12) ; % Scheduled hours for water heater using TS S pa ce _H e at er _T S (: , hour ) = app_SchTS ( hour ,13) ; % Scheduled hours for space heater using TS end % toc

1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130

tL1_TS = strfind ( Lights_TS ,[1]) ; % return the location of string where lights are ON tF1_TS = strfind ( Fans_TS ,[1]) ; % return the location of string where fans are ON tCI1_TS = strfind ( Clothes_Iron_TS ,[1]) ; % return the location of string where iron is ON tO1_TS = strfind ( Oven_TS ,[1]) ; % return the location of string where oven is ON tT1_TS = strfind ( Toaster_TS ,[1]) ; % return the location of string where toaster is ON tCM1_TS = strfind ( Coffee_Maker_TS ,[1]) ; % return the location of string where coffee maker is ON tWM1_TS = strfind ( Washing_Machine_TS ,[1 1 1 1 1]) ;% return the location of string where washing machine is consecutively ON tCD1_TS = strfind ( Cloth_Dryer_TS ,[1 1 1 1]) ;% return the location of string where cloth dryer is consecutively ON tDW1_TS = strfind ( Dish_washer_TS ,[1]) ; % return the location of string where dish washer is ON tAC1_TS = strfind ( AC_TS ,[1]) ; % return the location of string where AC is ON tR1_TS = strfind ( Refrigerator_TS ,[1]) ; % return the location of string where refrigerator is ON tWH1_TS = strfind ( Water_Heater_TS ,[1]) ; % return the location of string where water heater is ON

92

.2. APPENDIX B 1131 1132

tSH1_TS = strfind ( Space_Heater_TS ,[1]) ; where space heater is ON

% return the location of string

1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157

% % % % % % % % % % % % % % % % % % % % waiting time % % % % % % % % % % % % % % % % % % % % % % % D1_TS = ( sum ( abs ( tL1 - tL1_TS ) ) ) / sum ( Lights_TS ) ; % waiting time for lights D2_TS = ( sum ( abs ( tF1 - tF1_TS ) ) ) / sum ( Fans_TS ) ; % waiting time for fans D3_TS = ( sum ( abs ( tCI1 - tCI1_TS ) ) ) / sum ( Cl ot h es _I ro n _T S ) ; % waiting time for iron D4_TS = ( sum ( abs ( tO1 - tO1_TS ) ) ) / sum ( Oven_TS ) ; % waiting time for oven D5_TS = ( sum ( abs ( tT1 - tT1_TS ) ) ) / sum ( Toaster_TS ) ; % waiting time for toaster D6_TS = ( sum ( abs ( tCM1 - tCM1_TS ) ) ) / sum ( Co ff e e_ Ma ke r _T S ) ; % waiting time for coffee maker D7_TS = ( sum ( abs ( tWM1 - tWM1_TS ) ) ) / sum ( W a s h i n g _ M a c h i n e _ T S ) ; % waiting time for washing machine D8_TS = ( sum ( abs ( tCD1 - tCD1_TS ) ) ) / sum ( Clo th_Drye r_TS ) ; % waiting time for cloth dryer D9_TS = ( sum ( abs ( tDW1 - tDW1_TS ) ) ) / sum ( Dis h_washe r_TS ) ; % waiting time for dish washer D10_TS = ( sum ( abs ( tAC1 - tAC1_TS ) ) ) / sum ( AC_TS ) ; % waiting time for AC D11_TS = ( sum ( abs ( tR1 - tR1_TS ) ) ) / sum ( Re f ri ge r at or _T S ) ; % waiting time for refrigerator D12_TS = ( sum ( abs ( tWH1 - tWH1_TS ) ) ) / sum ( W at e r_ He a te r_ TS ) ; % waiting time for water heater D13_TS = ( sum ( abs ( tSH1 - tSH1_TS ) ) ) / sum ( S pa c e_ He a te r_ TS ) ; % waiting time for space heater

1158 1159 1160 1161 1162 1163 1164

U se r_ Co m fo rt _ TS = [ D1_TS D2_TS D3_TS D4_TS D5_TS D6_TS D7_TS D8_TS D9_TS D10_TS D11_TS D12_TS D13_TS ]; waiting_TS = sum ( U s er _C om f or t_ TS ) ; % Total hours for waiting time via TS Avg_UCom_TS = waiting_TS /13; % Average waiting time via TS

1165 1166

% % % % % % % % % % % % % % % % % % % % % % % % % % % TS_END % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

1167 1168

%%%%%%%!!!!!!!!!!!!! - - - - - - - - - - - FIGURES - - - - - - - - - - -!!!!!!!!!!!!! %%%%%%%

1169 1170

1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187

%%++++++++++++Cost per hour++++++++++++++++%% figure stairs (1:24 , unschedulecost , ’ Rs - ’ , ’ LineWidth ’ ,1.5) ; hold on stairs (1:24 , E_Cost_SS_TS , ’ Bx - ’ , ’ LineWidth ’ ,2.5) ; hold on stairs (1:24 , E_Cost_SS_G , ’ M + - ’ , ’ LineWidth ’ ,1.5) ; xlabel ( ’ Time ( hours ) ’, ’ fontsize ’ ,19) ; ylabel ( ’ Cost ( cent ) ’, ’ fontsize ’ , 19) ; set ( gca , ’ XTick ’ ,1:24 , ’ XTickLabel ’ ,{ ’1 ’ ’2 ’ ’3 ’ ’4 ’ ’5 ’ ’6 ’ ’7 ’ ’8 ’ ’9 ’ ’10 ’ ’11 ’ ’12 ’ ’13 ’ ’14 ’ ’15 ’ ’16 ’ ’17 ’ ’18 ’ ’19 ’ ’20 ’ ’21 ’ ’22 ’ ’23 ’ ’24 ’} , ’ fontsize ’ ,19) legend ({ ’ Unscheduled ’ , ’ TS ’ , ’ HSA ’} , ’ fontsize ’ ,19) ;% , ’ BFA Scheduled ’ , ’ HBG Scheduled ’ ) ; hleg2 = legend ( ’ Location ’ , ’ NorthEast ’) ; set ( hleg2 , ’ position ’ ,[0.05 0.65 0.35 0.3])

93

.2. APPENDIX B 1188 1189

grid on hold off

1190 1191 1192

1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216

1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233

%%++++++++++++Load per hour++++++++++++++++%% figure stairs (1:24 , unscheduledload , ’ Rs - ’ , ’ LineWidth ’ ,1.5) ; hold on stairs (1:24 , s ch e d u l e _ l o a d _ T S ,’Bx - ’ , ’ LineWidth ’ ,2.5) ; hold on stairs (1:24 , s ch ed u le _l oa d _G ,’M + - ’ , ’ LineWidth ’ ,1.5) ; % hold on % stairs (1:24 , sc hedule_ load1 ,’G * - ’ , ’ LineWidth ’ ,1.5) ; % hold on % stairs (1:24 , schedule_load_B , ’ M + - ’ , ’ LineWidth ’ ,1.5) xlabel ( ’ Time ( hours ) ’, ’ fontsize ’ ,19) ; ylabel ( ’ Load ( kWh ) ’, ’ fontsize ’ ,19) ; set ( gca , ’ XTick ’ ,1:24 , ’ XTickLabel ’ ,{ ’1 ’ ’2 ’ ’3 ’ ’4 ’ ’5 ’ ’6 ’ ’7 ’ ’8 ’ ’9 ’ ’10 ’ ’11 ’ ’12 ’ ’13 ’ ’14 ’ ’15 ’ ’16 ’ ’17 ’ ’18 ’ ’19 ’ ’20 ’ ’21 ’ ’22 ’ ’23 ’ ’24 ’} , ’ fontsize ’ ,16) legend ({ ’ Unscheduled ’ , ’ TS ’ , ’ HSA ’} , ’ fontsize ’ ,19) ;% , ’ BFA Scheduled ’ , ’ HBG Scheduled ’) ; hleg1 = legend ( ’ Location ’ , ’ NorthEast ’) ; set ( hleg1 , ’ position ’ ,[0.05 0.65 0.35 0.3]) % title ( ’ Load per Hour ’) ; grid on

%%++++++++++++PAR++++++++++++++++%% figure bar (1 , PAR_unscheduled ,0.3 , ’ red ’) hold on bar (2 , PAR_scheduled_TS ,0.3 , ’ blue ’) hold on bar (3 , PAR_scheduled_G ,0.3 , ’ magenta ’) % hold on % bar (4 , PAR1 ,0.3 , ’ green ’) % hold on % bar (4 , PA R_ sc h ed ul ed _ B ,0.3 , ’ magenta ’) ylabel ( ’ Peak to Average Ratio ’ , ’ fontsize ’ ,16) ; set ( gca , ’ XTick ’ ,1:1:4 , ’ XTickLabel ’ ,{ ’ Unscheduled ’ , ’ TS ’ , ’ HSA ’} , ’ fontsize ’ ,16) ;% , ’ BFA Scheduled ’ , ’ HBG Scheduled ’}) grid on hold off

1234 1235 1236 1237 1238 1239 1240 1241 1242 1243

%% % % % % % % % % % % % % % = = = = = = = = = = = = = Cost = = = = = = = = = = = = = % % % % % % % % % % % % % % % % % % figure bar (1 , sum_unscheduled_cost ,0.3 , ’ red ’) hold on bar (2 , sum_TS_Cost1 ,0.3 , ’ blue ’) hold on bar (3 , sum_E_Cost_SS_G ,0.3 , ’ magenta ’) % hold on % bar (4 , sum_E_Cost1 ,0.3 , ’ green ’)

94

.2. APPENDIX B 1244 1245 1246 1247 1248

set ( gca , ’ XTick ’ ,1:1:4 , ’ XTickLabel ’ ,{ ’ Unscheduled ’ , ’ TS ’ , ’ HSA ’} , ’ fontsize ’ ,16) ;% , ’ HBG Scheduled ’}) ylabel ( ’ Total Cost ( Cent ) ’, ’ fontsize ’ ,16) ; % title ( ’ Over All Cost ’) ; grid on

1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264

%% % % % % % % % % % % % % % = = = = = = = = = = = = = total load = = = = = = = = = = = = = % % % % % % % % % % % % % % % % % % figure bar (1 , sum_unscheduledload ,0.3 , ’ red ’) hold on bar (2 , sum_schedule_lodTS ,0.3 , ’ blue ’) hold on bar (3 , sum_scheduled_load_G ,0.3 , ’ magenta ’) % hold on % bar (4 , sum_schedule_lod1 ,0.3 , ’ green ’) set ( gca , ’ XTick ’ ,1:1:4 , ’ XTickLabel ’ ,{ ’ Unscheduled ’ , ’ TS ’ , ’ HSA ’} , ’ fontsize ’ ,16) ;% , ’ HBG Scheduled ’}) ylabel ( ’ Load ( kWh ) ’, ’ fontsize ’ ,16) ; % title ( ’ Over All Cost ’) ; grid on %%

1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278

1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291

figure stairs (1:24 , EP , ’ LineWidth ’ ,1.5) ; xlabel ( ’ Time ( hours ) ’) ; ylabel ( ’ Cost ( cent ) ’, ’ fontsize ’ ,19) ; xlim ([1 24]) ; set ( gca , ’ XTick ’ ,1:24 , ’ XTickLabel ’ ,{ ’1 ’ ’2 ’ ’3 ’ ’4 ’ ’5 ’ ’6 ’ ’7 ’ ’8 ’ ’9 ’ ’10 ’ ’11 ’ ’12 ’ ’13 ’ ’14 ’ ’15 ’ ’16 ’ ’17 ’ ’18 ’ ’19 ’ ’20 ’ ’21 ’ ’22 ’ ’23 ’ ’24 ’} , ’ fontsize ’ ,16) legend ( ’ RTP prices ’) ;% , ’ BFA Scheduled ’ , ’ HBG Scheduled ’) ; legend ( ’ Location ’ , ’ NorthEast ’) ; % title ( ’ Load per Hour ’) ; grid on

%%++++++++++++USER COMFORT++++++++++++++++%% figure bar (1 , Avg_UCom_TS ,0.3 , ’ blue ’) hold on bar (2 , Avg_UCom_HSA ,0.3 , ’ magenta ’) % hold on ylabel ( ’ Waiting Time ( Hours ) ’, ’ fontsize ’ ,16) ; set ( gca , ’ XTick ’ ,1:1:4 , ’ XTickLabel ’ ,{ ’ TS ’ , ’ HSA ’ } , ’ fontsize ’ ,16) ;% , ’ BFA Scheduled ’ , ’ HBG Scheduled ’}) grid on hold off

95

.3. APPENDIX C

.3

Appendix C

%% ****Appendix C contains the MATLAB code for Backtracking Search Optimization Algorithm and Hybrid Backtracking Tabu Search Algorithm ****%% %% ****The research paper is published under the title “An Approach towards Efficient Scheduling of Home Energy Management System using Backtracking Search Optimization and Tabu Search”****%%

%% ****Ieeexplore link: https://ieeexplore.ieee.org/document/8418076/****%%

%% ****Researchgate link: https://www.researchgate.net/publication/326562149_ An_Approach_Towards_Efficient_Scheduling_of_Home_Energy_Management_System_ Using_Backtracking_Search_Optimization_and_Tabu_Search ****%%

%% ****MATLAB source code file “Sundas C2.m”is available on the link given below ****%% %% ****Source code link: ****%% %%** Step by step guidelines to run this code are provided in Readme.txt file **%% %% **** Link: ****%%

%% *************************************************************** %% %%—- This code is developed by Sundas Shafiq under the supervision of Dr. Nadeem Javaid for the fulfillment of MS thesis—- %% % —- Fall 2017 to Spring 2018—- %% % — ComSens (Communication over Sensors) Lab, Department of Computer Science— %% %—- COMSATS University Islamabad (CUI), Islamabad 44000, Pakistan—-%

% ****************************** Sundas Shafiq ****************************** %% %Website Link: https://sites.google.com/student.comsats.edu.pk/sundas\ -shafiq/home % Email Address: [email protected] % Mobile Number: 96

.3. APPENDIX C % ***************************** Dr. Nadeem Javaid *************************** %% % Website Link: www.njavaid.com % Email Address: [email protected] % Mobile Number: +92-300-5792728 %% *************************************************************** %% %%%%— An Approach towards Efficient Scheduling of Home Energy Management System using Backtracking Search Optimization and Tabu Search —%%%% %% Before going for the code, must read the original algorithms of Backtracking Search Optimization and Tabu Search %% %% Tabu Search Algorithm used in this research paper is given in Appendix B %%

1292 1293 1294 1295 1296 1297 1298 1299 1300 1301

%% *******************Source Code*************************** %% close all ; % Close all the figures clear ; % removes all variables from the current workspace , releasing them from system memory clc ; % Clears all input and output from the Command Window display , giving you a clean screen %%%%%%%%%%%%% Day ahead price RTP Signal %%%%%%%%%%%%%%%%%%% 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];

1302 1303

%%%%%%%%%% State of appliances %%%%%%%%%%%

1304 1305

1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321

1322 1323 1324 1325 1326 1327 1328

———————————– Appliances ———————————-%% %%———— Fixed appliances ———–%% Lights = [0 1 1 1 1 1 Lights status in 24 hours Fans = [1 1 1 1 1 0 status in 24 hours Clothes_Iron = [0 0 0 0 0 0 Clothes_Iron status in 24 hours Oven = [0 0 0 0 0 0 status in 24 hours Toaster = [0 0 0 0 0 0 Toaster status in 24 hours Coffee_Maker = [0 0 0 0 0 0 Coffee_Maker status in 24 hours

1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0]; % 0 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 0 0]; % Fans 0 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0]; % 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0]; % Oven 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; %

%%———— Shiftable appliances ———–%% % Cloth dryer will be on immediately after washing machine stop working W as hi ng _ Ma ch i ne =[0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % W as hi ng _ Ma ch in e status in 24 hours Cloth_Dryer = [0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0]; % Cloth_Dryer status in 24 hours

97

.3. APPENDIX C 1329 1330

Dish_washer = [0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % Dish_washer status in 24 hours

1331 1332 1333 1334 1335 1336 1337

F i x e d _ a p p l i a nc e s =[ Lights ’ , Fans ’ , Clothes_Iron ’ , Oven ’ , Toaster ’ , Coffee_Maker ’]; % Set of all the F i x e d _ a p p l i a n c e s S h i f t a b l e _ a p p l i a n c e s =[ Washing_Machine ’ , Cloth_Dryer ’ , Dish_washer ’];% Set of all the S h i f t a b l e _ a p p l i a n c e s Appliances =[ F i x e d _ a p p l i a n c e s S h i f t a b l e _ a p p l i a n c e s ]; % Set of all the appliances

1338 1339 1340 1341 1342 1343 1344

%% Smart Grid Parameters intialization t im e_ s lo t_ Fi x ed = [12 16 6 7 2 2]; % Operating hours for fixed appliances time_slot_Shiftable = [5 4 3]; % Operating hours for the Shiftable_appliances time_slots = [ t im e _s lo t_ F ix ed t i m e _ s l o t _ S h i f t a b l e ];

1345 1346 1347 1348

SH_Fixed = [2 1 14 6 6 6]; % starting hour for fixed appliances SH_Shiftable = [8 6 7]; % starting hour for shiftable appliances SH = [ SH_Fixed SH_Shiftable ];

1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359

EH_Fixed = [24 24 23 22 10 22]; % ending hour for fixed appliances EH_Shiftable = [16 18 12]; % ending hour for shiftable appliances EH = [ EH_Fixed EH_Shiftable ]; % power ratings of App ’ s in that are to be schedule pFixed = [0.6 0.75 1.5 1.18 0.5 0.8]; % Power rating of fixed appliances pShiftable = [0.78 4.40 3.60]; % Power rating of Shiftable appliances p =[ pFixed pShiftable ]; maxAvg =3;

1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372

%% Find the location of Appliances who have minimum waiting time % return the location of string where the value is equal to 1 , means the appliance is on tL1 = strfind ( Lights ,(1) ) ; tF1 = strfind ( Fans ,(1) ) ; tCI1 = strfind ( Clothes_Iron ,(1) ) ; tO1 = strfind ( Oven ,(1) ) ; tT1 = strfind ( Toaster ,(1) ) ; tCM1 = strfind ( Coffee_Maker ,(1) ) ; tWM1 = strfind ( Washing_Machine ,[1 1 1 1 1]) ; tCD1 = strfind ( Cloth_Dryer ,[1 1 1 1 ]) ; tDW1 = strfind ( Dish_washer ,(1) ) ;

1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386

%% %%%%%%% - - - - - - - - - - - Contraints - - - - - - - - - - - - -%%%%%%%%%%%%%%%%%%%%%%% for hour =1:24 E l e c t r i c i t y _ c os t =[ 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 u ns ch ed u le dl oa d ( hour ) = Appliances ( hour ,:) *p ’; % Unscheduled load per hour unsc heduleco st ( hour ) = Appliances ( hour ,:) * Electricity_cost ’; % Unscheduled cost per hour end s u m _ u n s c h e d u l e d l o a d = sum ( un s ch ed ul e dl oa d ) ; % Sum of unscheduled load for 24 hours s u m _ u n s c h e d u l e d _ c o s t = sum ( un schedul ecost ) ; % Cost of unscheduled load for 24 hours

98

.3. APPENDIX C 1387 1388

P AR _u ns c he du l ed = max ( u ns c he du l ed lo ad ) /( s u m _ u n s c h e d u l e d l o a d /24) ; % Calculating PAR of unscheduled case

1389 1390 1391

%% On - peak and Off - peak D_EP = round ( mean ( EP ) ) ; % Mean electric price signal

1392 1393 1394 1395 1396 1397 1398

1399 1400 1401 1402 1403

%% Normalized load for fitness function load_ (1: length ( u ns c he du le d lo ad ) ) =( u n sc he du l ed lo ad (1: length ( u ns ch ed u le dl oa d ) ) - min ( un sc h ed ul ed l oa d ) ) /( max ( un sc h ed ul ed l oa d ) - min ( u ns ch ed u le dl oa d ) ) ; t_load = sum ( load_ ) ;

%%———————— BSOA ————————–%% Scheduling for the Appliances just to minimize the cost and PAR via BSOA %% %%%%%%%%%% - - - - - - - - - - - - - - Scheduling - - - - - - - - - - - - - - - - - -%%%%%%%%%%%% %% - - - - - - - - - - - - - - - Parameters Ini tializat ion using BSOA - - - - - - - - - - - - - - - %%

1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414

low =0.1; % lower boundary value up =0.9; % upper boundary value dim =9; % Dimension , i . e . , number of appliances N =30; % Number of population D =9; % Dimension mixrate =0.8; %% crossover probability MaxItr =100; % Maximum number of iteration b =9; % Number of appliances %% Parameters Initi alizati on p =[ pFixed pShiftable ];

1415 1416 1417 1418 1419

%% %% Average Calculation Variable in itializ ation %%%% best = inf ; Pbest = inf ; Fbest = inf ;

1420 1421 1422 1423 1424 1425 1426 1427 1428

1429

%% Parametre initilization for calculation app_Sch = zeros (24 ,9) ; % Scheduled appliances using BSOA s c h e d u l e _ l o a d _ B S O A = zeros (1 ,24) ; % Scheduled load per hour using BSOA s u m _ s c h e d u l e d _ l o a d _ B S O A =0; % Sum of scheduled load time_slots =[ ti me _ sl ot _F i xe d t i m e _ s l o t _ S h i f t a b l e ]; s c h e d u l e _ c o s t _ B S O A = zeros (1 ,24) ; % Scheduled cost using BSOA s u m _ s c h e d u l e _ c o s t _ B S O A =0; % Sum of scheduled cost

%%================= Initialize Population==============%%

1430 1431 1432

%%%%% - - - - - - - - - - - - - - - - - - - I nitializ ation of P - - - - - - - - - - - - - - - - - -%%%%%%

1433 1434 1435 1436 1437 1438 1439 1440 1441

if numel ( low ) ==1 %% numel ( A ) returns the number of elements , n , in array A , equivalent to prod ( size ( A ) ) . low = low * ones (1 , dim ) ; up = up * ones (1 , dim ) ; for i =1: N for j =1: D P (i , j ) = rand *( up ( j ) - low ( j ) ) + low ( j ) ; % Generate random population for P end

99

.3. APPENDIX C end

1442 1443 1444

%%%%% - - - - - - - - - - - - - - - - - I nitiali zation of oldP - - - - - - - - - - - - - - - - - -%%%%%%

1445 1446 1447

for i =1: N for j =1: D oldP (i , j ) = rand *( up ( j ) - low ( j ) ) + low ( j ) ; % Generate random population for

1448 1449 1450 1451 1452 1453 1454

oldP end end end

1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466

%%%%% - - - - - - - - - - - - - - - - - Convert into binary - - - - - - - - - - - - - - - - - -%%%%%% P1 = P ; for i =1: N for j =1: D if P1 (i , j ) >0.5 % std ( un sc h ed ul ed l oa d ) % rand (1) means 1*1 matrix P1 (i , j ) =1; else P1 (i , j ) =0; end end end

1467 1468 1469 1470 1471

%%%%% - - - - - - - - - - - - - Calculate the cost of fitness value - - - - - - - - - - - - - - -%%%%%% x =( rand (N , D ) ) ; J = zeros (N ,1) ;

1472 1473 1474 1475 1476 1477 1478 1479 1480

for i =1: N for j =1: D -1 J ( i ) = sum (100*( x (i , j +1) -x (i , j ) ^2) ^2+( x (i , j ) -1) ^2) ; % initial fitness calculation end end fitnessP = J ; %%%!!!!!%%%

1481 1482 1483

1484 1485 1486 1487 1488 1489 1490 1491

%%================= Selection 1=================%% for iteration =1: MaxItr if rand < rand oldP = P ; end oldP = oldP ( randperm ( N ) ,:) ; end

1492 1493 1494

1495 1496 1497 1498

%%=================Mutant=================%% F =3* randn ; A = oldP - P ;

100

.3. APPENDIX C 1499

Mutant = P +( F * A ) ;

1500 1501 1502

1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515

%%=================Crossover=================%% map (1: N ,1: D ) =1; if rand < rand for i =1: N u = randperm ( dim ) ; map (i , u (1: ceil ( mixrate * rand * dim ) ) ) =0; end else for i =1: N map (i , randi ( dim ) ) =0; end end

1516 1517 1518 1519 1520 1521 1522 1523 1524

%%%%% - - - - - - - - - - - Generation of trial population T - - - - - - - - -%%%%%% T = Mutant ; for i =1: N for j =1: D if map (1 , j ) ==1 T (i , j ) = P (i , j ) ; end end

1525

1543 1544

%%%%% - - - - - - - - - - - Boundary control mechanism - - - - - - - - -%%%%%% for i =1: N for j =1: D if ( T (i , j ) < low ( j ) ) ||( T (i , j ) > up ( j ) ) T (i , j ) = rand *( up ( j ) - low ( j ) ) + low ( j ) ; end end end end x =( rand (N , D ) ) ; J = zeros (N ,1) ; for i =1: N for j =1: D -1 J ( i ) = sum (100*( x (i , j +1) -x (i , j ) ^2) ^2+( x (i , j ) -1) ^2) ; % initial fitness calculation end end fitnessT = J ;

1545

%%=================Selection II=================%%

1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542

1546 1547 1548 1549 1550 1551 1552

for i =1: N if fitnessT ( i ) < fitnessP ( i ) fitnessP ( i ) = fitnessT ( i ) ; P(i)=T(i); end end

1553 1554 1555

globalminimum = min ( Pbest ) ; g lo ba l mi ni mi z er = inf ;

101

.3. APPENDIX C 1556 1557 1558 1559 1560

fitnessPbest = min ( fitnessP ) ; if fitnessPbest < globalminimum globalminimum = fitnessPbest ; g lo ba lm i ni mi z er = Pbest ; end

1561 1562 1563 1564 1565

for hour =1:24 % gen =24 e l e c t r i c i t y _ co s t =[ 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

1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597

%% - - - - - - - - - - - - - Washing machine and cloth dryer scheduling - - - - - - - - - - - - -%% lhour =25 - hour ; if lhour 1 for a =1: N if app_Sch ( hour -1 ,7) ==1 P1 (a ,7) =1; end if time_slots (1 ,7) >0 P1 (a ,8) =0; end if time_slots (1 ,7) 0 P1 (a ,8) =0; end end

1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612

%% - - - - - - - - - - - - - - - - - - - - - - - - Lights Scheduling - - - - - - - - - - - - - - - - - - - - - - -%% for a =1: N if time_slots (1 ,1) >1 && hour >=1 && hour 0.5 P1 (1 ,1) =1; elseif j 0 && hour >=18 P1 (a ,1) =1; else P1 (a ,1) =0; end

1613

102

.3. APPENDIX C %% - - - - - - - - - - - - - - - - - - - - - - - - Fans Scheduling - - - - - - - - - - - - - - - - - - - - - - -%% if time_slots (1 ,2) >1 && hour 0 && hour >=14 P1 (a ,2) =1; else P1 (a ,2) =0; end

1614 1615 1616 1617 1618 1619 1620 1621 1622

%% - - - - - - - - - - - - - - - - - - - - - - - - clothes iron scheduling - - - - - - - - - - - - - - - - - - - -%% if time_slots (1 ,3) >0 && hour >=15 && hour 0 && hour >=6 elseif time_slots (1 ,4) >0 && hour >15 && hour 0 && hour >6 && hour =1 P1 (a ,6) =0; elseif time_slots (1 ,6) >0 && hour >=6 || hour 0 && hour >=7 P1 (a ,9) = P1 (a ,9) ; elseif time_slots (1 ,9) >0 hour >9 && hour D11 && Load (1 , i ) > min ( un sc he d ul ed lo a d ) ) D11 = F (1 , i ) ; % mean ( uns ch e du le dl o ad ) Lbest = P1 (i ,:) ; % gbest position achieved here Fbest = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end

1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755

if D11 == inf for i = 1: N if ( F (1 , i ) < D11 && Load (1 , i ) > min ( un sc he d ul ed lo a d ) ) D11 = F (1 , i ) ; Lbest = P1 (i ,:) ; % gbest position achieved here Fbest = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end

1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767

if D11 == inf for i = 1: N if ( F (1 , i ) < D11 ) % && Load (1 , i ) > min ( u ns ch ed u le dl oa d ) ) D11 = F (1 , i ) ; Lbest = P1 (i ,:) ; % gbest position achieved here Fbest = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end

1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783

Pbest = Lbest (1 ,:) ; P1 ( ij ,:) =0; for b =1: D if ( Pbest (1 , b ) ==1) time_slots (1 , b ) = time_slots (1 , b ) -1; elseif ( Pbest (1 , b ) ==0) time_slots (1 , b ) = time_slots (1 , b ) ; end end time_slots ; hour ; %%%%%%% check gbest ; app_Sch ( hour ,:) = Pbest (: ,:) ; % Scheduled appliances s c h e d u l e _ l o a d _ B S O A ( hour ) = p * Pbest ’; % Load per hour via scheduled BSOA s c h e d u l e _ c o s t _ B S O A ( hour ) = ds ;% Scheduled cost per hour

1784 1785 1786 1787

s u m _ s c h e d u l e d _ l o a d _ B S O A = s c h e d u l e _ l o a d _ B S O A ( hour ) + s u m _ s c h e d u l e d _ l o a d _ B S O A ; % Sum of scheduled load s u m _ s c h e d u l e _ c o s t _ B S O A = sum ( s c h e d u l e _ c o s t _ B S O A ) ; % Sum of scheduled cost

105

.3. APPENDIX C 1788 1789

;

P A R _ s c h e d u l e d _ B S O A = max ( s c h e d u l e _ l o a d _ B S O A ) /(( s u m _ s c h e d u l e d _ l o a d _ B S O A ) /24) % PAR incase of BSOA

1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801

%% Appliances Scheduled hours Lights_BSOA (: , hour ) = app_Sch ( hour ,1) ; Fans_BSOA (: , hour ) = app_Sch ( hour ,2) ; C l o t h e s _ I r o n _ B S O A (: , hour ) = app_Sch ( hour ,3) ; Oven_BSOA (: , hour ) = app_Sch ( hour ,4) ; Toaster_BSOA (: , hour ) = app_Sch ( hour ,5) ; C o f f e e _ M a k e r _ B S O A (: , hour ) = app_Sch ( hour ,6) ; W a s h i n g _ M a c h i n e _ B S O A (: , hour ) = app_Sch ( hour ,7) ; C l o t h _ D r y e r _ B SO A (: , hour ) = app_Sch ( hour ,8) ; D i s h _ w a s h e r _ B SO A (: , hour ) = app_Sch ( hour ,9) ; End

1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812

%% - - Return the location of string where the appliances are ON - - -%%%% tL1_BSOA = strfind ( Lights_BSOA ,[1]) ; tF1_BSOA = strfind ( Fans_BSOA ,[1]) ; tCI1_BSOA = strfind ( Clothes_Iron_BSOA ,[1]) ; tO1_BSOA = strfind ( Oven_BSOA ,[1]) ; tT1_BSOA = strfind ( Toaster_BSOA ,[1]) ; tCM1_BSOA = strfind ( Coffee_Maker_BSOA ,[1]) ; tWM1_BSOA = strfind ( Washing_Machine_BSOA ,[1 1 1 1 1]) ; tCD1_BSOA = strfind ( Cloth_Dryer_BSOA ,[1 1 1 1]) ; tDW1_BSOA = strfind ( Dish_washer_BSOA ,[1]) ;

1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823

%%%% - - - - - - - - Waiting time for the scheduled appliances - - - - - - - - - - -%%%% D1_BSOA = ( sum ( abs ( tL1 - tL1_BSOA ) ) ) / sum ( Lights_BSOA ) ; D2_BSOA = ( sum ( abs ( tF1 - tF1_BSOA ) ) ) / sum ( Fans_BSOA ) ; D3_BSOA = ( sum ( abs ( tCI1 - tCI1_BSOA ) ) ) / sum ( C l o t h e s _ I r o n _ B S O A ) ; D4_BSOA = ( sum ( abs ( tO1 - tO1_BSOA ) ) ) / sum ( Oven_BSOA ) ; D5_BSOA = ( sum ( abs ( tT1 - tT1_BSOA ) ) ) / sum ( Toaster_BSOA ) ; D6_BSOA = ( sum ( abs ( tCM1 - tCM1_BSOA ) ) ) / sum ( C o f f e e _ M a k e r _ B S O A ) ; D7_BSOA = ( sum ( abs ( tWM1 - tWM1_BSOA ) ) ) / sum ( W a s h i n g _ M a c h i n e _ B S O A ) ; D8_BSOA = ( sum ( abs ( tCD1 - tCD1_BSOA ) ) ) / sum ( C l o t h _ D r y e r _ B S O A ) ; D9_BSOA = ( sum ( abs ( tDW1 - tDW1_BSOA ) ) ) / sum ( D i s h _ w a s h e r _ B S O A ) ;

1824 1825 1826 1827 1828 1829 1830 1831 1832 1833

1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844

U s e r _ C o m f o r t _ B S O A = [ D1_BSOA D2_BSOA D3_BSOA D4_BSOA D5_BSOA D6_BSOA D7_BSOA D8_BSOA D9_BSOA ]; waiting_BSOA = sum ( U s e r _ C o m f o r t _ B S O A ) ; % Total hours for waiting time via BSOA Avg_UCom_BSOA = waiting_BSOA /9; % Average waiting time via BSOA % toc % % % % % % % % % % % % % % % % % % % % % % % % % % end of BSA % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

%%————————— HYBRID TBSO —————–%% low =0.1; up =0.9; dim =9; N =30; D =9; mixrate =0.8; %% crossover probability MaxItr =100; b =9; p =[ pFixed pShiftable ];

106

.3. APPENDIX C 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857

%% %% Average Calculation % G_time_slots =[ ti me _ sl ot _F i xe d t i m e _ s l o t _ S h i f t a b l e ]; best = inf ; Pbest11 = inf ; Fbest11 = inf ; %% parametres for claculation app_Sch_TBSA = zeros (24 ,9) ; s c h e d u l e _ l o a d _ T B S A = zeros (1 ,24) ; s u m _ s c h e d u l e d _ l o a d _ T B S A =0; time_slots_HI =[ t im e_ s lo t_ Fi x ed t i m e _ s l o t _ S h i f t a b l e ]; s c h e d u l e _ c o s t _ T B S A = zeros (1 ,24) ; s u m _ s c h e d u l e _ c o s t _ T B S A =0;

1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869

%% - - - - - - - - - - - - - - - - - - - - - - - - Initialize Population - - - - - - - - - - - - - - - - - - - - - - - -%% if numel ( low ) ==1 %% numel ( A ) returns the number of elements , n , in array A , equivalent to prod ( size ( A ) ) . low = low * ones (1 , dim ) ; up = up * ones (1 , dim ) ; for i =1: N for j =1: D Q (i , j ) = rand *( up ( j ) - low ( j ) ) + low ( j ) ; end end

1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887

%%%%% - - - - - - - - - - - - - - - - - Initiali zation of oldP - - - - - - - - - - - - - - - - - -%%%%%% for i =1: N for j =1: D oldQ (i , j ) = rand *( up ( j ) - low ( j ) ) + low ( j ) ; end end end oldP1 = oldQ ; for i =1: N for j =1: D if oldP1 (i , j ) >0.5 % std ( u ns c he du l ed lo ad ) % rand (1) means 1*1 matrix oldP1 (i , j ) =1; else oldP1 (i , j ) =0; end end end

1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899

%%%%% - - - - - - - - - - - - - - - - - Convert into binary - - - - - - - - - - - - - - - - - -%%%%%% P11 = Q ; for i =1: N for j =1: D if P11 (i , j ) >0.5 % std ( un s ch ed ul e dl oa d ) % rand (1) means 1*1 matrix P11 (i , j ) =1; else P11 (i , j ) =0; end end end

1900 1901 1902

%%%%% - - - - - - - - - - - - - - - - - Calculate the cost of fitness value - - - - - - - - - - - - - -%%%%%%

107

.3. APPENDIX C 1903 1904 1905 1906 1907 1908 1909 1910 1911

x11 =( rand (N , D ) ) ; J11 = zeros (N ,1) ; for i =1: N for j =1: D -1 J11 ( i ) = sum (100*( x11 (i , j +1) - x11 (i , j ) ^2) ^2+( x11 (i , j ) -1) ^2) ; % initial fitness calculation end end fitnessQ = J11 ;

1912 1913 1914 1915 1916 1917 1918 1919 1920

%%%%% - - - - - - - - - - - Selection 1 - - - - - - - - -%%%%%% for iteration =1: MaxItr if rand < rand oldQ = P11 ; else oldQ = oldQ ( randperm ( N ) ,:) ; end end

1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934

%%%%% - - - - - - - - - - - Mutant - - - - - - - - -%%%%%% F11 =3* randn ; A11 = oldQ - P11 ; Mutant = Q +( F11 * A11 ) ; Mutant1 = Mutant ; E l e c t r i c i t y _ c o s t 1 1 =[ EP ( hour ) * p ]; %%% trails from TS %%% s11 = zeros (N , D ) ; s21 = zeros (N , D ) ; s31 = zeros (N , D ) ; s41 = zeros (N , D ) ; s51 = zeros (N , D ) ; s61 = zeros (N , D ) ;

1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960

for j =1:2 for i =1: N for j =1: D if rand >=0.5 s11 (i , j ) =1; else s11 (i , j ) =0; F11 =( E l e c t r i c i t y _ c o s t 1 1 * s11 ’) ; ff11 = mean ( F11 ) ; end if rand >=0.5 s21 (i , j ) =1; else s21 (i , j ) =0; F22 =( E l e c t r i c i t y _ c o s t 1 1 * s21 ’) ; ff21 = mean ( F22 ) ; end if rand >=0.5 s31 (i , j ) =1; else s31 (i , j ) =0; F33 =( E l e c t r i c i t y _ c o s t 1 1 * s31 ’) ; ff31 = mean ( F33 ) ; end if rand >=0.5

108

.3. APPENDIX C 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999

s41 (i , j ) =1; else s41 (i , j ) =0; F44 =( E l e c t r i c i t y _ c o s t 1 1 * s41 ’) ; ff41 = mean ( F44 ) ; end if rand >=0.5 s51 (i , j ) =1; else s51 (i , j ) =0; F55 =( E l e c t r i c i t y _ c o s t 1 1 * s51 ’) ; ff51 = mean ( F55 ) ; end if rand >=0.5 s61 (i , j ) =1; else s61 (i , j ) =0; F66 =( E l e c t r i c i t y _ c o s t 1 1 * s61 ’) ; ff61 = mean ( F66 ) ; end end ab1 =[ ff11 , ff21 , ff31 , ff41 , ff51 , ff61 ]; end abb1 = sort ( ab1 ) ; F11 = zeros (30 ,9) ; %% compare trail matrix %% if min ( ab1 ) == ff11 ; F11 = s11 ; elseif min ( ab1 ) == ff21 F11 = s21 ; elseif min ( ab1 ) == ff31 F11 = s31 ; elseif min ( ab1 ) == ff41 F11 = s41 ; elseif min ( ab1 ) == ff51 F11 = s51 ; elseif min ( ab1 ) == ff61 F11 = s61 ; end

2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016

min_H =( E l e c t r i c i t y _ c o s t 1 1 * F11 ’) ; min_Trail1 = mean ( min_H ) ; g11_best = F11 ; L11_best = x11 ; end %%%%% - - - - - - - - - - - Crossover - - - - - - - - -%%%%%% if rand < rand for i =1: N u = randperm ( dim ) ; g11_best (i , u (1: ceil ( mixrate * rand * dim ) ) ) =0; end else for i =1: N g11_best (i , randi ( dim ) ) =0; end end

2017 2018

%%%%% - - - - - - - - - - - Generation of trial population T - - - - - - - - -%%%%%%

109

.3. APPENDIX C 2019 2020 2021 2022 2023 2024 2025

T11 = Mutant ; for i =1: N for j =1: D if g11_best (1 , j ) ==1 T11 (i , j ) = g11_best (i , j ) ; end end

2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044

%%%%% - - - - - - - - - - - Boundary control mechanism - - - - - - - - -%%%%%% for i =1: N for j =1: D if ( T11 (i , j ) < low ( j ) ) ||( T11 (i , j ) > up ( j ) ) T11 (i , j ) = rand *( up ( j ) - low ( j ) ) + low ( j ) ; end end end end x11 =( rand (N , D ) ) ; J11 = zeros (N ,1) ; for i =1: N for j =1: D -1 J11 ( i ) = sum (100*( x11 (i , j +1) - x11 (i , j ) ^2) ^2+( x11 (i , j ) -1) ^2) ; % initial fitness calculation end end fitnessT11 = J11 ;

2045 2046 2047 2048 2049 2050 2051 2052

%%%%% - - - - - - - - - - - Selection 2 - - - - - - - - -%%%%%% for i =1: N if fitnessT11 ( i ) < fitnessQ ( i ) fitnessQ ( i ) = fitnessT11 ( i ) ; Q ( i ) = T11 ( i ) ; end end

2053 2054 2055 2056 2057 2058 2059 2060

g lo ba lm i ni mu m1 1 = min ( Pbest11 ) ; g l o b a l m i n i m i z e r 1 1 = inf ; fitn essPbest 11 = min ( fitnessQ ) ; if fitnessPbest11 < g lo ba lm i ni mu m1 1 g lo ba lm i ni mu m1 1 = fitne ssPbest 11 ; g l o b a l m i n i m i z e r 1 1 = Pbest11 ; end

2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075

for i =1: N for j =1: D if Q (i , j ) >0.5 % std ( u n sc he du l ed lo a d ) % rand (1) means 1*1 matrix Q (i , j ) =1; else Q (i , j ) =0; end end end R=Q; for hour =1:24 % gen =24 e l e c t r i c i t y _ c o s t 1 1 =[ 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

2076

110

.3. APPENDIX C 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108

%% - - - - - - - - - - - - - - - - - Washing machine and cloth dryer scheduling - - - - - - - - - - - - - -%% lhour =25 - hour ; if lhour 1 for a =1: N if app_Sch_TBSA ( hour -1 ,7) ==1 R (a ,7) =1; end if time_slots_HI (1 ,7) >0 R (a ,8) =0; end if time_slots_HI (1 ,7) 0 R (a ,8) =0; end end

2109 2110 2111 2112 2113 2114 2115

%% - - - - - - - - - - - - - - - - - - - - - - - - Lights - - - - - - - - - - - - - - - - - - - - - - -%% for a =1: N if time_slots_HI (1 ,1) >1 && hour >=1 && hour 0 R (a ,1) = R (a ,1) ; end

2116 2117 2118 2119 2120 2121

elseif time_slots_HI (1 ,1) >0 && hour >=16 R (a ,1) =1; else R (a ,1) =0; end

2122 2123 2124 2125 2126 2127 2128 2129 2130

%% - - - - - - - - - - - - - - - - - - - - - - - - Fans - - - - - - - - - - - - - - - - - - - - - - -%% if time_slots_HI (1 ,2) >1 && hour 0 && hour >=15 R (a ,2) =1; else R (a ,2) =0; end

2131 2132 2133 2134

%% - - - - - - - - - - - - - - - - - - - - - - - - clothes iron - - - - - - - - - - - - - - - - - - - -%% if time_slots_HI (1 ,3) >0 && hour >=15 || hour 0 && hour >=6 if time_slots_HI (1 ,4) >0 R (a ,4) = R (a ,4) ; end elseif time_slots_HI (1 ,4) >0 && hour >15 R (a ,4) =1; else R (a ,4) =0; End

2149 2150 2151 2152 2153 2154 2155

%% - - - - - - - - - - - - - - - - - - - - - - - - Toaster - - - - - - - - - - - - - - - - - - - - - - -%% if time_slots_HI (1 ,5) >0 && hour >6 || hour 0 && hour >=6 if R (a ,5) >=1 R (a ,6) =0; end elseif time_slots_HI (1 ,6) >0 && hour >=6 R (a ,6) =1; else R (a ,6) =0; End

2167 2168 2169 2170 2171 2172 2173 2174 2175 2176

% - - - - - - - - - - - - - - - - - - - - - - - - Dish Washer - - - - - - - - - - - - - - - - - - - - - - -%% if time_slots_HI (1 ,9) >0 && hour >=7 R (a ,9) = R (a ,9) ; elseif time_slots_HI (1 ,9) >0 hour >9 || hour D11 && Load11 (1 , i ) > min ( u n sc he du l ed lo ad ) ) D11 = F11 (1 , i ) ; % mean ( un sc he d ul ed lo a d )

113

.3. APPENDIX C Lbest11 = R (i ,:) ; % gbest position achieved here . Fbest11 = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end

2251 2252 2253 2254 2255 2256 2257

?

2258

if D11 == inf for i = 1: N if ( F11 (1 , i ) < D11 && Load11 (1 , i ) > min ( u n sc he du l ed lo ad ) ) D11 = F11 (1 , i ) ; Lbest11 = R (i ,:) ; % gbest position achieved here . ? Fbest11 = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end

2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270

if D11 == inf for i = 1: N if ( F11 (1 , i ) < D11 ) % && Load (1 , i ) > min ( u n sc he du l ed lo ad ) ) D11 = F11 (1 , i ) ; Lbest11 = R (i ,:) ; % gbest position achieved here . ? Fbest11 = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end

2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282

Pbest11 = Lbest11 (1 ,:) ; P11 ( ij ,:) =0; for b =1: D if ( Pbest11 (1 , b ) ==1) time_slots_HI (1 , b ) = time_slots_HI (1 , b ) -1; elseif ( Pbest11 (1 , b ) ==0) time_slots_HI (1 , b ) = time_slots_HI (1 , b ) ; end end time_slots_HI ; hour ; %%%%%%% check gbest ;

2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295

%% app_Sch_TBSA ( hour ,:) = Pbest11 (: ,:) ; s c h e d u l e _ l o a d _ T B S A ( hour ) = p * Pbest11 ’; s c h e d u l e _ c o s t _ T B S A ( hour ) = ds ; s u m _ s c h e d u l e d _ l o a d _ T B S A = s c h e d u l e _ l o a d _ T B S A ( hour ) + s u m _ s c h e d u l e d _ l o a d _ T B S A ; s u m _ s c h e d u l e _ c o s t _ T B S A = sum ( s c h e d u l e _ c o s t _ T B S A ) ; P A R _ s c h e d u l e d _ T B S A = max ( s c h e d u l e _ l o a d _ T B S A ) /(( s u m _ s c h e d u l e d _ l o a d _ T B S A ) /24)

2296 2297 2298 2299 2300 2301 2302 2303

;

2304 2305 2306 2307 2308

%% Appliances Scheduled hours Lights_TBSA (: , hour ) = app_Sch_TBSA ( hour ,1) ; Fans_TBSA (: , hour ) = app_Sch_TBSA ( hour ,2) ; C l o t h e s _ I r o n _ T B S A (: , hour ) = app_Sch_TBSA ( hour ,3) ;

114

.3. APPENDIX C 2309 2310 2311 2312 2313 2314 2315

Oven_TBSA (: , hour ) = app_Sch_TBSA ( hour ,4) ; Toaster_TBSA (: , hour ) = app_Sch_TBSA ( hour ,5) ; C o f f e e _ M a k e r _ T B S A (: , hour ) = app_Sch_TBSA ( hour ,6) ; W a s h i n g _ M a c h i n e _ T B S A (: , hour ) = app_Sch_TBSA ( hour ,7) ; C l o t h _ D r y e r _ TB S A (: , hour ) = app_Sch_TBSA ( hour ,8) ; D i s h _ w a s h e r _ TB S A (: , hour ) = app_Sch_TBSA ( hour ,9) ; End

2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326

% return the location of string %%%% tL1_TBSA = strfind ( Lights_TBSA ,[1]) ; tF1_TBSA = strfind ( Fans_TBSA ,[1]) ; tCI1_TBSA = strfind ( Clothes_Iron_TBSA ,[1]) ; tO1_TBSA = strfind ( Oven_TBSA ,[1]) ; tT1_TBSA = strfind ( Toaster_TBSA ,[1]) ; tCM1_TBSA = strfind ( Coffee_Maker_TBSA ,[1]) ; tWM1_TBSA = strfind ( Washing_Machine_TBSA ,[1 1 1 1 1]) ; tCD1_TBSA = strfind ( Cloth_Dryer_TBSA ,[1 1 1 1]) ; tDW1_TBSA = strfind ( Dish_washer_TBSA ,[1]) ;

2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337

%%%% - - - - - - - - waiting time - - - - - - - - - - -%%%% D1_TBSA = ( sum ( abs ( tL1 - tL1_TBSA ) ) ) / sum ( Lights_TBSA ) ; D2_TBSA = ( sum ( abs ( tF1 - tF1_TBSA ) ) ) / sum ( Fans_TBSA ) ; D3_TBSA = ( sum ( abs ( tCI1 - tCI1_TBSA ) ) ) / sum ( C l o t h e s _ I r o n _ T B S A ) ; D4_TBSA = ( sum ( abs ( tO1 - tO1_TBSA ) ) ) / sum ( Oven_TBSA ) ; D5_BTBSA = ( sum ( abs ( tT1 - tT1_TBSA ) ) ) / sum ( Toaster_TBSA ) ; D6_TBSA = ( sum ( abs ( tCM1 - tCM1_TBSA ) ) ) / sum ( C o f f e e _ M a k e r _ T B S A ) ; D7_TBSA = ( sum ( abs ( tWM1 - tWM1_TBSA ) ) ) / sum ( W a s h i n g _ M a c h i n e _ T B S A ) ; D8_TBSA = ( sum ( abs ( tCD1 - tCD1_TBSA ) ) ) / sum ( C l o t h _ D r y e r _ T B S A ) ; D9_TBSA = ( sum ( abs ( tDW1 - tDW1_TBSA ) ) ) / sum ( D i s h _ w a s h e r _ T B S A ) ;

2338 2339 2340 2341 2342

User_Comfort_TBSA = [ D1_TBSA D2_TBSA D3_TBSA D4_TBSA D5_BTBSA D6_TBSA D7_TBSA D8_TBSA D9_TBSA ]; waiting_TBSA = sum ( U s e r _ C o m f o r t _ T B S A ) ; Avg_UCom_TBSA = waiting_TBSA /9;

2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361

%% ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Cost ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! %% figure stairs (1:24 , unschedulecost , ’ C + - ’ , ’ LineWidth ’ ,1.5) ; hold on stairs (1:24 , schedule_cost_BSOA , ’ M * - ’ , ’ LineWidth ’ ,1.5) ; hold on stairs (1:24 , E_Cost_SS_TS , ’ Bx - ’ , ’ LineWidth ’ ,2.5) ; hold on stairs (1:24 , schedule_cost_TBSA , ’ G * - ’ , ’ LineWidth ’ ,1.5) ; xlabel ( ’ Time ( hours ) ’) ; ylabel ( ’ Electricity Cost ( cent ) ’, ’ fontsize ’ , 16) ; set ( gca , ’ XTick ’ ,1:2:24 , ’ XTickLabel ’ ,{ ’2 ’ ’4 ’ ’6 ’ ’8 ’ ’10 ’ ’12 ’ ’14 ’ ’16 ’ ’18 ’ ’20 ’ ’22 ’ ’24 ’} , ’ fontsize ’ ,16) legend ( ’ Unscheduled ’ , ’ BSOA ’ , ’ TS ’ , ’ TBSA ’) ; legend ( ’ Location ’ , ’ NorthEast ’) ; % title ( ’ Cost per hour ’) ; grid on hold off

2362 2363 2364 2365 2366

%% ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Load ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! %% figure stairs (1:24 , unscheduledload , ’ C + - ’ , ’ LineWidth ’ ,1.5) ; hold on

115

.3. APPENDIX C 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380

2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396

stairs (1:24 , s c h e d u l e _ l o a d _ B S O A ,’M * - ’ , ’ LineWidth ’ ,1.5) ; hold on stairs (1:24 , s ch e d u l e _ l o a d _ T S ,’Bx - ’ , ’ LineWidth ’ ,2.5) hold on stairs (1:24 , s c h e d u l e _ l o a d _ T B S A ,’G * - ’ , ’ LineWidth ’ ,1.5) ; xlabel ( ’ Time ( hours ) ’, ’ fontsize ’ ,16) ; ylabel ( ’ Load ( kWh ) ’, ’ fontsize ’ ,16) ; set ( gca , ’ XTick ’ ,1:2:24 , ’ XTickLabel ’ ,{ ’2 ’ ’4 ’ ’6 ’ ’8 ’ ’10 ’ ’12 ’ ’14 ’ ’16 ’ ’18 ’ ’20 ’ ’22 ’ ’24 ’} , ’ fontsize ’ ,16) legend ( ’ Unscheduled ’ , ’ BSOA ’ , ’ TS ’ , ’ TBSA ’) ; legend ( ’ Location ’ , ’ NorthEast ’) ; % title ( ’ Load per Hour ’) ; grid on

%%++++++++++++PAR++++++++++++++++%% figure bar (1 , PAR_unscheduled ,0.3 , ’ cyan ’) hold on bar (2 , PAR_scheduled_BSOA ,0.3 , ’ magenta ’) hold on bar (3 , PAR_scheduled_TS ,0.3 , ’ blue ’) hold on bar (4 , PAR_scheduled_TBSA ,0.3 , ’ green ’) ylabel ( ’ PAR ’ , ’ fontsize ’ ,16) ; set ( gca , ’ XTick ’ ,1:1:4 , ’ XTickLabel ’ ,{ ’ Unscheduled ’ , ’ BSOA ’ , ’ TS ’ , ’ TBSA ’} , ’ fontsize ’ ,16) ;% , ’ BFA Scheduled ’ , ’ HBG Scheduled ’}) % title ( ’ Peak Average Ratio ’) ; grid on hold off

2397 2398 2399

2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413

%%++++++++++++Total cost++++++++++++++++%% figure bar (1 , sum_unscheduled_cost ,0.3 , ’ cyan ’) hold on bar (2 , sum_schedule_cost_BSOA ,0.3 , ’ magenta ’) hold on bar (3 , sum_TS_Cost1 ,0.3 , ’ blue ’) hold on bar (4 , sum_schedule_cost_TBSA ,0.3 , ’ green ’) set ( gca , ’ XTick ’ ,1:1:4 , ’ XTickLabel ’ ,{ ’ Unscheduled ’ , ’ BSOA ’ , ’ TS ’ , ’ TBSA ’}) ; ylabel ( ’ Total Cost ’) ; % title ( ’ Over All Cost ’) ; grid on

2414 2415 2416

2417 2418 2419 2420 2421 2422

%%++++++++++++Total load++++++++++++++++%% figure bar (1 , sum_unscheduledload ,0.3 , ’ cyan ’) hold on bar (2 , sum_scheduled_load_BSOA ,0.3 , ’ magenta ’)

116

.3. APPENDIX C 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432

hold on bar (3 , sum_schedule_lodTS ,0.3 , ’ blue ’) hold on bar (4 , sum_scheduled_load_TBSA ,0.3 , ’ green ’) % bar (4 , sum_scheduled_load_B ,0.3 , ’ magenta ’) set ( gca , ’ XTick ’ ,1:1:4 , ’ XTickLabel ’ ,{ ’ Unscheduled ’ , ’ BSOA ’ , ’ TS ’ , ’ TBSA ’}) ;% , ’ HBG Scheduled ’}) ylabel ( ’ load ’) ; % title ( ’ Over All Load ’) ; grid on

2433 2434 2435

2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449

%%++++++++++++User comfort++++++++++++++++%% figure bar (1 , Avg_UCom_BSOA ,0.3 , ’ magenta ’) hold on bar (2 , Avg_UCom_TS ,0.3 , ’ blue ’) hold on bar (3 , Avg_UCom_TBSA ,0.3 , ’ green ’) ylabel ( ’ waiting time ’) ; set ( gca , ’ XTick ’ ,1:1:4 , ’ XTickLabel ’ ,{ ’ BSOA ’ , ’ TS ’ , ’ TBSA ’}) ;% , ’ BFA Scheduled ’ , ’ HBG Scheduled ’}) % title ( ’ waiting time ’) ; grid on hold off

2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463

%% % % % % % % % % % % + + + + + + + + + + + + RTP + + + + + + + + + + + + + + + + % % % % % % % % % % % % % % % % % % figure stairs (1:24 , EP , ’ LineWidth ’ ,1.5) ; xlabel ( ’ Time ( hours ) ’) ; ylabel ( ’ Price ’) ; xlim ([1 24]) ; set ( gca , ’ XTick ’ ,1:24 , ’ XTickLabel ’ ,{ ’1 ’ ’2 ’ ’3 ’ ’4 ’ ’5 ’ ’6 ’ ’7 ’ ’8 ’ ’9 ’ ’10 ’ ’11 ’ ’12 ’ ’13 ’ ’14 ’ ’15 ’ ’16 ’ ’17 ’ ’18 ’ ’19 ’ ’20 ’ ’21 ’ ’22 ’ ’23 ’ ’24 ’}) legend ( ’ price ’) ; legend ( ’ Location ’ , ’ NorthEast ’) ; % title ( ’ RTP Signal ’) ; grid on

117

.4. APPENDIX D

.4

Appendix D

%% ****The appendix D contains the details for the implementation of MATLAB code for the Enhanced Differential Evolution Algorithm****%%

%% ****The research paper is published under the title “A Comparative Study of Meta-Heuristic Approaches Towards Utilization of Home Energy Management”****%%

%%****Semantic Scholar link: https://www.semanticscholar.org/paper/Comparative\ -study-of-meta-heuristic-approaches-of-Fatima-Javaid/f4bb738af91382204\ ff53df2343b9f08219b6d57****%%

%% ****Researchgate link: https://www.researchgate.net/publication/322681744_ Comparative_study_of_meta-heuristic_approaches_towards_utilization_of_ home_energy_management ****%%

%% ****MATLAB source code file “Sundas C3.m”is available on the link given below ****%% %% ****Source code link: ****%% %%** Step by step guidelines to run this code are provided in Readme.txt file **%% %% **** Link: ****%%

%% *************************************************************** %% %%—- This code is developed by Sundas Shafiq under the supervision of Dr. Nadeem Javaid for the fulfillment of MS thesis—- %% % —- Fall 2017 to Spring 2018—- %% % — ComSens (Communication over Sensors) Lab, Department of Computer Science— %% %—- COMSATS University Islamabad (CUI), Islamabad 44000, Pakistan—-%

% ****************************** Sundas Shafiq ****************************** %% %Website Link: https://sites.google.com/student.comsats.edu.pk/sundas\ -shafiq/home 118

.4. APPENDIX D % Email Address: [email protected] % Mobile Number: % ***************************** Dr. Nadeem Javaid *************************** %% % Website Link: www.njavaid.com % Email Address: [email protected] % Mobile Number: +92-300-5792728 %% *************************************************************** %% %%%%— A Comparative Study of Meta-Heuristic Approaches Towards Utilization of Home Energy Management —%%%% %% Before going for the code, must read the original algorithms of Harmony Search, Enhanced Differential Evolution and Tabu Search Algorithm %% %% Harmony Search Algorithm and Tabu Search Algorithm used in this research paper are given in Appendix B and Appendix C %%

%% *******************Source Code*************************** %% 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479

close all ; clear ;

% Close all the figures % removes all variables from the current workspace , releasing them from system memory clc ; % Clears all input and output from the Command Window display , giving you a clean screen %%%%%%%%%%%%% Day ahead price RTP Signal %%%%%%%%%%%%%%%%%%% % 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]; %%%%%%%%%%%%% TOU %%%%%%%%%%%%%%%%%%% % 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]; %%%%%%%%%%%%% CPP %%%%%%%%%%%%%%%%%%% 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];

2480 2481 2482

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

2483

%%————shiftable appliances ———–%%

2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495

Dish_washer = AC = Heater = Water_Heater = Pool_pump = E l e c t i r c _ V e h i c le = Lighting = TV = PC = Ironing_Appliance = Hair_Dryer =

[0 [0 [0 [0 [0 [0 [0 [0 [0 [0 [0

0 0 1 0 0 0 0 0 0 0 0

0 0 1 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0

0 0 0 1 0 0 0 0 0 0 0

119

0 0 0 1 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0

0 0 0 1 0 0 0 0 1 1 1

0 1 0 0 0 0 0 1 1 1 0

0 1 0 1 1 0 0 0 1 1 0

0 1 1 0 1 0 0 1 1 0 0

1 1 1 1 0 0 0 0 1 1 0

1 1 0 1 1 0 1 1 1 1 1

0 1 0 0 1 1 1 0 0 0 0

0 1 0 1 0 1 1 0 0 0 0

1 0 0 0 0 1 0 1 0 0 0

1 0 1 0 0 1 0 0 0 0 0

0 0 1 0 0 0 0 0 0 0 0

0 0 0 0 0 0 1 0 0 0 0

1 0 0 0 0 0 1 0 0 0 0

0];%5 0];%7 1];%7 0];%7 0];%5 0];%4 1];%6 0];%4 0];%6 0];%5 0];%3

.4. APPENDIX D 2496 2497

Other =

2498

%%———— Non-intrubable ———–%%

2499 2500 2501 2502 2503

Elec tric_Sto ve = Cloth_Dryer = Vacu um_clean er = Refrigerator =

[0 0 0 0 0 1 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0 0 0 0];%7

[0 [0 [0 [0

0 0 0 0

0 0 0 0

0 0 0 0

0 0 0 0

0 0 0 0

0 0 0 1

0 0 0 1

0 0 0 0

0 0 0 0

1 0 0 0

1 0 1 0

0 0 1 0

1 1 1 0

1 1 1 0

0 1 0 0

0 1 0 0

0 0 0 0

0 0 0 0

0 0 0 0

0 0 0 0

0 0 0 0

0 0 0 0

0];%4 0];%4 0];%4 0];%4

2504 2505 2506 2507 2508 2509

%% Elastic base Appliances I n t r u p t _ a p p l i a n c e s =[ Dish_washer ’ , AC ’ , Heater ’ , Water_Heater ’ , Pool_pump ’ , Electirc_Vehicle ’ , Lighting ’ , TV ’ , PC ’ , Ironing_Appliance ’ , Hair_Dryer ’ , Other ’]; N on _i nt r up ta bl e = [ Electric_Stove ’ , Cloth_Dryer ’ , Vacuum_cleaner ’ , Refrigerator ’];

2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523

Appliances = [ I n t r u p t _ a p p l i a n c e s N on _i n tr up ta b le ]; %% Smart Grid Parameters intialization t i m e _ s l o t s _ I n t r u p t =[5 7 7 7 4 4 6 4 6 5 2 7]; % hours for appliances brustload intruptable t i m e _ s l o t s _ n o n I n t r =[4 4 4 2]; I_time_slots =[ t i m e _ s l o t s _ I n t r u p t t i m e _ s l o t s _ n o n I n t r ]; % I_time_slots =[ t i m e _ s l o t s _ i n t r u p t t i m e _ s l o t s _ n o n l n t r time_ slotFix ed ];%% SUFYAN ANWAR %% pIntr = [1 1 1.5 1.5 2 2.5 0.5 0.25 0.25 1 1 1.5]; % power ratings of App ’ s in that are to be schedule pNonTntr = [1.5 0.5 1 0.125]; p =[ pIntr pNonTntr ]; maxAvg =3;

2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541

%% Find the location of Appliances who have minimum waiting time tDW1 = strfind ( Dish_washer ,(1) ) ; % return the location of string tAC1 = strfind ( AC ,(1) ) ; tHE1 = strfind ( Heater ,(1) ) ; tWH1 = strfind ( Water_Heater ,(1) ) ; tPP1 = strfind ( Pool_pump ,(1) ) ; tEV1 = strfind ( Electirc_Vehicle ,(1) ) ; tLT1 = strfind ( Lighting ,(1) ) ; tTV1 = strfind ( TV ,(1) ) ; tPC1 = strfind ( PC ,(1) ) ; tIA1 = strfind ( Ironing_Appliance ,(1) ) ; tHD1 = strfind ( Hair_Dryer ,(1) ) ; tOT1 = strfind ( Other ,(1) ) ; tES1 = strfind ( Electric_Stove ,[1111]) ; tCD1 = strfind ( Cloth_Dryer ,[1111]) ; tVC1 = strfind ( Vacuum_cleaner ,[1111]) ; tRF1 = strfind ( Refrigerator ,[11]) ;

2542 2543 2544 2545 2546 2547 2548 2549

% H_Prority =[8 ,9]; % NoN_IntruPt =[1 2 3 4 5 6 7 8 9 10 11 12]; % cannot be intrupted during the runing mod % InTruPt =[13 14 15 16]; % Appliances that can be off during the emergencey % Min _time_s lots =[4 7 6 7];% not used %% % % % % % % % % % % % % % % % % % % % % % % % % % Contraints % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % for hour =1:24

120

.4. APPENDIX D 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559

E l e c t r i c i t y _ c o st =[ EP ( hour ) * p ];% 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) EP ( hour ) * p (10) EP ( hour ) * p (11) EP ( hour ) * p (12) EP ( hour ) * p (13) EP ( hour ) * p (14) EP ( hour ) * p (15) EP ( hour ) * p (16) ];% coefficients of objective function u ns ch ed u le dl oa d ( hour ) = Appliances ( hour ,:) *p ’; unsc heduleco st ( hour ) = Appliances ( hour ,:) * Electricity_cost ’; end s u m _ u n s c h e d u l e d l o a d = sum ( un sc h ed ul ed l oa d ) ; s u m _ u n s c h e d u l e d _ c o s t = sum ( un schedule cost ) ; P AR _u ns c he du le d = max ( u ns c he du le d lo ad ) ^2/( s u m _ u n s c h e d u l e d l o a d /24) ^2;

2560 2561

%% On - peak and Off - peak

2562

2567 2568

D_EP = round ( mean ( EP ) ) ; %% Normalized load for fitness function load_ (1: length ( u ns c he du le d lo ad ) ) =( u ns c he du l ed lo ad (1: length ( un sc h ed ul ed l oa d ) ) - min ( u ns ch ed u le dl o ad ) ) /( max ( u ns ch ed u le dl oa d ) - min ( u n sc he d ul ed lo a d ) ) ; t_load = sum ( load_ ) ;

2569

%%————————— EDE —————–%%

2563 2564 2565 2566

2570 2571 2572 2573 2574 2575 2576 2577

pop_size =30; % population size D =16; % number of appliances MaxItr =100; %%% Maximum generation xl =0.1; xu =0.9; %%%%%% custom %%%%% app_Sch3a = zeros (24 ,16) ; time_slots = I_time_slots ;

2578 2579 2580 2581 2582 2583 2584

%% Intialize Population for i =1: pop_size for j =1: D X (i , j ) = xl + rand (1) *( xu - xl ) ; end end

2585 2586 2587 2588 2589 2590

for hour = 1:24 E l e c t r i c i t y _ c o s t =[ 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) EP ( hour ) * p (10) EP ( hour ) * p (11) EP ( hour ) * p (12) EP ( hour ) * p (13) EP ( hour ) * p (14) EP ( hour ) * p (15) EP ( hour ) * p (16) ];

2591

2600 2601

%% - - - - - - - - - - - - - Start of EDE - - - - - - - - - - - - - - - - -%% b1 = randperm ( pop_size ) ;% randomly selecting three values for finding mutation b11 = b1 (1 ,1) ; r11 = X ( b11 ,:) ; b21 = b1 (1 ,2) ; r21 = X ( b21 ,:) ; b31 = b1 (1 ,3) ; r31 = X ( b31 ,:) ; Mutant1 = r11 +0.5*( r21 - r31 ) ;

2602

%%——————————– Trial vector ———————————%%

2592 2593 2594 2595 2596 2597 2598 2599

2603 2604 2605 2606

for j =1: MaxItr for i =1: D % total appliacnes

121

.4. APPENDIX D 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630

if rand (1) >=0.3 % rand (1) means 1*1 matrix Y11 (1 , i ) = r11 (1 , D ) ; else Y11 (1 , i ) = Mutant1 (1 , D ) ; % trial vector using first equation end end for i =1: D % total appliacnes if rand (1) >=0.6 % rand (1) means 1*1 matrix Y21 (1 , i ) = r11 (1 , i ) ; else Y21 (1 , i ) = Mutant1 (1 , i ) ;% trial vector using second eqxbtion end end for i =1: D % total appliacnes if rand (1) >=0.9 % rand (1) means 1*1 matrix Y31 (1 , i ) = r11 (1 , i ) ; else Y31 (1 , i ) = Mutant1 (1 , i ) ;% trial vector using third eqxbtion end end for i =1: D % total appliacnes Y41 (1 , i ) = rand (1) * r11 (1 , i ) ; % Y41 (1 , i ) = rand (1) * r11 (1 , i ) ; % rand (1) means 1*1 matrix % Y41 (1 , i ) = r11 (1 , i ) ;

2631 2632 2633 2634

end for i =1: D % total appliacnes Y51 (1 , i ) = rand (1) * Mutant1 (1 , i ) +(1 - rand (1) ) * r11 (1 , i ) ;

2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664

end for k_k =1: D if Y11 (1 , k_k ) >0.5 Y1_1 (1 , k_k ) =1; else Y1_1 (1 , k_k ) =0; end end for k_k =1: D if Y21 (1 , k_k ) >0.5 Y2_1 (1 , k_k ) =1; else Y2_1 (1 , k_k ) =0; end end for k_k =1: D if Y31 (1 , k_k ) >0.5 Y3_1 (1 , k_k ) =1; else Y3_1 (1 , k_k ) =0; end end for k_k =1: D if Y41 (1 , k_k ) >0.5 Y4_1 (1 , k_k ) =1; else Y4_1 (1 , k_k ) =0; end end

122

.4. APPENDIX D 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679

for k_k =1: D if Y51 (1 , k_k ) >0.5 Y5_1 (1 , k_k ) =1; else Y5_1 (1 , k_k ) =0; end end for k_k =1: D if r11 (1 , k_k ) >0.5 r11_1 (1 , k_k ) =1; else r11_1 (1 , k_k ) =0; end end Electricity_cost ;

2680 2681 2682 2683 2684 2685 2686

F11 = E l e c t r i c i t y _ c o s t * Y1_1 ’; % calculating fitness of all trial vectors and use the trial vector having minimum fitness value F21 = E l e c t r i c i t y _ c o s t * Y2_1 ’; F31 = E l e c t r i c i t y _ c o s t * Y3_1 ’; F41 = E l e c t r i c i t y _ c o s t * Y4_1 ’; F51 = E l e c t r i c i t y _ c o s t * Y5_1 ’;

2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708

F =[ F11 F21 F31 F41 F51 ]; if min ( F ) == F11 T = Y1_1 ; elseif min ( F ) == F21 T = Y2_1 ; elseif min ( F ) == F31 T = Y3_1 ; elseif min ( F ) == F41 T = Y4_1 ; else min ( F ) == F51 T = Y5_1 ; end T11 = E l e c t r i c i t y _ c o s t *T ’; T12 = E l e c t r i c i t y _ c o s t * r11_1 ’; if T12 < T11 X ( b11 ,:) = r11_1 ; else X ( b11 ,:) = T ; end end %% - - - - - - - - - - - - - - - - - - - end of EDE - - - - - - - - - - - - -%%

2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719

X1 = X ; for i =1: pop_size % converting all values into binary for switching appliances for k =1: D if X1 (i , k ) >0.5 X1 (i , k ) =1; else X1 (i , k ) =0; end end end

2720 2721

lhour =25 - hour ;

2722

123

.4. APPENDIX D 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734

%%% - - - - - - - - - - - Dish washer - - - - - - - - - - - - - %%% for a =1: pop if time_slots (1 ,1) >0 && hour >=15 && hour =12 && hour 15 if lhour 0 X1 (a ,3) =1; elseif time_slots (1 ,3) 0 && hour >=15 && hour =12 && hour =16 && hour =16 && hour =16 && hour =8 && hour =6 && hour =6 && hour =6 && hour =6 && hour 0 && hour >=14 && hour 0 && hour >=6 && hour 0 && hour >=6 && hour ( std ( u ns c he du le d lo ad ) +2*( min ( u n sc he du l ed lo ad ) ) ) ) &&( Load (1 , i ) < mean ( u n sc he du l ed lo ad ) - min ( un s ch ed ul e dl oa d ) ) %&& Load (1 , i ) < mean ( u ns ch ed u le dl o ad ) % clc && Load (1 , i ) ( mean ( u ns ch e du le dl o ad ) - min ( un sc h ed ul ed l oa d ) ) % && Load (1 , i ) = min ( EP ) ) % Compare fitness value with D11 . D11 = F (1 , i ) ; Lbest = X1 (i ,:) ; % gbest position achieved here

127

.4. APPENDIX D 2955 2956 2957 2958 2959 2960 2961

Fbest = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end if EP ( hour ) min ( u n sc he d ul ed lo a d ) ) D11 = F (1 , i ) ; % mean ( u ns ch e du le dl o ad ) Lbest = X1 (i ,:) ; % gbest position achieved here Fbest = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end if ( F (1 , i ) > D11 && Load (1 , i ) > min ( un sc he d ul ed lo a d ) ) D11 = F (1 , i ) ; % mean ( u ns ch e du le dl o ad ) Lbest = X1 (i ,:) ; % gbest position achieved here Fbest = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end if D11 == inf for i = 1: pop_size if ( F (1 , i ) < D11 && Load (1 , i ) > min ( un sc he d ul ed lo a d ) ) D11 = F (1 , i ) ; Lbest = X1 (i ,:) ; % gbest position achieved here Fbest = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end if D11 == inf for i = 1: pop_size if ( F (1 , i ) < D11 ) % && Load (1 , i ) > min ( u ns ch ed u le dl oa d ) ) D11 = F (1 , i ) ; Lbest = X1 (i ,:) ; % gbest position achieved here Fbest = D11 ; ds = E_Cost (1 , i ) ; ij = i ; end end end g1best = Lbest (1 ,:) ; X1 ( ij ,:) =0; for b =1:16 if ( g1best (1 , b ) ==1) time_slots (1 , b ) = time_slots (1 , b ) -1; elseif ( g1best (1 , b ) ==0) time_slots (1 , b ) = time_slots (1 , b ) ; end end time_slots ; hour ;

128

.4. APPENDIX D 3013 3014 3015 3016 3017 3018 3019

app_Sch3a ( hour ,:) = g1best (: ,:) ; sche dule_loa d1 ( hour ) = p * g1best ’; s u m _ s c h e d u l e _ l o d 1 = sum ( schedule _load1 ) ; PAR1 = max ( sche dule_loa d1 ) /( s u m _ s c h e d u l e _ l o d 1 /24) ; E_costt ( hour ) = E l e c t r i c i t y _ c o s t * g1best ’; sum_E_Cost1 = sum ( E_costt ) ;

3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039

%% - - - - - - - - - - - - - Appliances Scheduled hours - - - - - - - - - - - - - - %% D is h_ wa s he r_ ED E (: , hour ) = app_Sch3a ( hour ,1) ; AC_EDE (: , hour ) = app_Sch3a ( hour ,2) ; Heater_EDE (: , hour ) = app_Sch3a ( hour ,3) ; W a t e r _ H e a t e r _ E D E (: , hour ) = app_Sch3a ( hour ,4) ; Pool_pump_EDE (: , hour ) = app_Sch3a ( hour ,5) ; E l e c t i r c _ V e h i c l e _ E D E (: , hour ) = app_Sch3a ( hour ,6) ; Lighting_EDE (: , hour ) = app_Sch3a ( hour ,7) ; TV_EDE (: , hour ) = app_Sch3a ( hour ,8) ; PC_EDE (: , hour ) = app_Sch3a ( hour ,9) ; I r o n i n g _ A p p l i a n c e _ E D E (: , hour ) = app_Sch3a ( hour ,10) ; Hair_ Dryer_E DE (: , hour ) = app_Sch3a ( hour ,11) ; Other_EDE (: , hour ) = app_Sch3a ( hour ,12) ; E l e c t r i c _ S t o v e _ E D E (: , hour ) = app_Sch3a ( hour ,13) ; C lo th _D r ye r_ ED E (: , hour ) = app_Sch3a ( hour ,14) ; V a c u u m _ c l e a n e r _ E D E (: , hour ) = app_Sch3a ( hour ,15) ; R e f r i g e r a t o r _ E D E (: , hour ) = app_Sch3a ( hour ,16) ; end % toc

3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058

% Return the location of string %%% tDW1_EDE = strfind ( Dish_washer_EDE ,(1) ) ; tAC1_EDE = strfind ( AC_EDE ,(1) ) ; tHE1_EDE = strfind ( Heater_EDE ,(1) ) ; tWH1_EDE = strfind ( Water_Heater_EDE ,(1) ) ; tPP1_EDE = strfind ( Pool_pump_EDE ,(1) ) ; tEV1_EDE = strfind ( Electirc_Vehicle_EDE ,(1) ) ; tLT1_EDE = strfind ( Lighting_EDE ,(1) ) ; tTV1_EDE = strfind ( TV_EDE ,(1) ) ; tPC1_EDE = strfind ( PC_EDE ,(1) ) ; tIA1_EDE = strfind ( Ironing_Appliance_EDE ,(1) ) ; tHD1_EDE = strfind ( Hair_Dryer_EDE ,(1) ) ; tOT1_EDE = strfind ( Other_EDE ,(1) ) ; tES1_EDE = strfind ( Electric_Stove_EDE ,[1111]) ; tCD1_EDE = strfind ( Cloth_Dryer_EDE ,[1111]) ; tVC1_EDE = strfind ( Vacuum_cleaner_EDE ,[1111]) ; tRF1_EDE = strfind ( Refrigerator_EDE ,[1111]) ;

3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070

% % % % % % % % % % % % % % % % % % % % waiting time % % % % % % % % % % % % % % % % % % % % % % % D1_EDE = ( sum ( abs ( tDW1 - tDW1_EDE ) ) ) / sum ( Di sh _w a sh er _E D E ) ; D2_EDE = ( sum ( abs ( tAC1 - tAC1_EDE ) ) ) / sum ( AC_EDE ) ; D3_EDE = ( sum ( abs ( tHE1 - tHE1_EDE ) ) ) / sum ( Heater_EDE ) ; D4_EDE = ( sum ( abs ( tWH1 - tWH1_EDE ) ) ) / sum ( W a t e r _ H e a t e r _E D E ) ; D5_EDE = ( sum ( abs ( tPP1 - tPP1_EDE ) ) ) / sum ( Pool_pump_EDE ) ; D6_EDE = ( sum ( abs ( tEV1 - tEV1_EDE ) ) ) / sum ( E l e c t i r c _ V e h i c l e _ E D E ) ; D7_EDE = ( sum ( abs ( tLT1 - tLT1_EDE ) ) ) / sum ( Lighting_EDE ) ; D8_EDE = ( sum ( abs ( tTV1 - tTV1_EDE ) ) ) / sum ( TV_EDE ) ; D9_EDE = ( sum ( abs ( tPC1 - tPC1_EDE ) ) ) / sum ( PC_EDE ) ;

129

.4. APPENDIX D 3071 3072 3073 3074 3075 3076 3077

D10_EDE D11_EDE D12_EDE D13_EDE D14_EDE D15_EDE D16_EDE

= = = = = = =

( sum ( abs ( tIA1 - tIA1_EDE ) ) ) ( sum ( abs ( tHD1 - tHD1_EDE ) ) ) ( sum ( abs ( tOT1 - tOT1_EDE ) ) ) ( sum ( abs ( tES1 - tES1_EDE ) ) ) ( sum ( abs ( tCD1 - tCD1_EDE ) ) ) ( sum ( abs ( tVC1 - tVC1_EDE ) ) ) ( sum ( abs ( tRF1 - tRF1_EDE ) ) )

/ / / / / / /

sum ( I r o n i n g _ A p p l i a n c e _ E D E ) ; sum ( H air_Drye r_EDE ) ; sum ( Other_EDE ) ; sum ( E l e c t r i c _ S t o v e _ E D E ) ; sum ( Cl o th _D ry e r_ ED E ) ; sum ( V a c u u m _ c l e a n e r _ E D E ) ; sum ( R e f r i g e r a t o r _ E D E ) ;

3078 3079 3080 3081 3082

U s e r _ C o m f o r t _ E DE = [ D1_EDE D2_EDE D3_EDE D4_EDE D5_EDE D6_EDE D7_EDE D8_EDE D9_EDE D10_EDE D11_EDE D12_EDE D13_EDE D14_EDE D15_EDE D16_EDE ]; waiting_EDE = sum ( U s e r_ C o m f o r t _ E D E ) ; Avg_UCom_EDE = waiting_EDE /16;

3083 3084

% % % % % % % % % % % % % % % % % % % % % % % % % % % EDE_END % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %

3085 3086

% ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Figures ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 1 %

3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106

figure stairs (1:24 , unschedulecost , ’ Rs - ’ , ’ LineWidth ’ ,1.5) ; hold on stairs (1:24 , E_Cost_SS_TS , ’ Bx - ’ , ’ LineWidth ’ ,2.5) ; hold on stairs (1:24 , E_Cost_SS_G , ’ M + - ’ , ’ LineWidth ’ ,1.5) ; hold on stairs (1:24 , E_costt , ’ G * - ’ , ’ LineWidth ’ ,1.5) ; % hold on % stairs (1:24 , E_Cost_SS_B , ’ M + - ’ , ’ LineWidth ’ ,1.5) ; xlabel ( ’ Time ( hours ) ’) ; ylabel ( ’ Electricity Cost ( cent ) ’, ’ fontsize ’ , 16) ; set ( gca , ’ XTick ’ ,1:24 , ’ XTickLabel ’ ,{ ’1 ’ ’2 ’ ’3 ’ ’4 ’ ’5 ’ ’6 ’ ’7 ’ ’8 ’ ’9 ’ ’10 ’ ’11 ’ ’12 ’ ’13 ’ ’14 ’ ’15 ’ ’16 ’ ’17 ’ ’18 ’ ’19 ’ ’20 ’ ’21 ’ ’22 ’ ’23 ’ ’24 ’} , ’ fontsize ’ ,16) legend ( ’ Unscheduled ’ , ’ TS ’ , ’ EDE ’) ;% , ’ BFA Scheduled ’ , ’ HBG Scheduled ’ ) ; legend ( ’ Location ’ , ’ NorthEast ’) ; grid on hold off

3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127

%% ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Load ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! %% figure stairs (1:24 , unscheduledload , ’ Rs - ’ , ’ LineWidth ’ ,1.5) ; hold on stairs (1:24 , sc h e d u l e _ l o a d _ T S ,’Bx - ’ , ’ LineWidth ’ ,2.5) ; hold on stairs (1:24 , s ch ed u le _l oa d _G ,’M + - ’ , ’ LineWidth ’ ,1.5) ; hold on stairs (1:24 , schedul e_load1 ,’G * - ’ , ’ LineWidth ’ ,1.5) ; % hold on % stairs (1:24 , schedule_load_B , ’ M + - ’ , ’ LineWidth ’ ,1.5) xlabel ( ’ Time ( hours ) ’, ’ fontsize ’ ,16) ; ylabel ( ’ Load ( kWh ) ’, ’ fontsize ’ ,16) ; set ( gca , ’ XTick ’ ,1:24 , ’ XTickLabel ’ ,{ ’1 ’ ’2 ’ ’3 ’ ’4 ’ ’5 ’ ’6 ’ ’7 ’ ’8 ’ ’9 ’ ’10 ’ ’11 ’ ’12 ’ ’13 ’ ’14 ’ ’15 ’ ’16 ’ ’17 ’ ’18 ’ ’19 ’ ’20 ’ ’21 ’ ’22 ’ ’23 ’ ’24 ’} , ’ fontsize ’ ,16) legend ( ’ Unscheduled ’ , ’ TS ’ , ’ HSA ’ , ’ EDE ’) ;% , ’ BFA Scheduled ’ , ’ HBG Scheduled ’) ; legend ( ’ Location ’ , ’ NorthEast ’) ; % title ( ’ Load per Hour ’) ; grid on

3128

130

.4. APPENDIX D 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145

%% % % % % % % % % % % + + + + + + + + + + + + PAR + + + + + + + + + + + + + + + + % % % % % % % % % % % % % % % % % % figure bar (1 , PAR_unscheduled ,0.3 , ’ red ’) hold on bar (2 , PAR_scheduled_TS ,0.3 , ’ blue ’) hold on bar (3 , PAR_scheduled_G ,0.3 , ’ magenta ’) hold on bar (4 , PAR1 ,0.3 , ’ green ’) % hold on % bar (4 , P A R_ sc he d ul ed _B ,0.3 , ’ magenta ’) ylabel ( ’ PAR ’ , ’ fontsize ’ ,16) ; set ( gca , ’ XTick ’ ,1:1:4 , ’ XTickLabel ’ ,{ ’ Unscheduled ’ , ’ TS ’ , ’ HSA ’ , ’ EDE ’} , ’ fontsize ’ ,16) ;% , ’ BFA Scheduled ’ , ’ HBG Scheduled ’}) title ( ’ Peak Average Ratio ’) ; grid on hold off

3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160

%% % % % % % % % % % % % % % = = = = = = = = = = = = = Cost = = = = = = = = = = = = = % % % % % % % % % % % % % % % % % % figure bar (1 , sum_unscheduled_cost ,0.3 , ’ red ’) hold on bar (2 , sum_TS_Cost1 ,0.3 , ’ blue ’) hold on bar (3 , sum_E_Cost_SS_G ,0.3 , ’ magenta ’) hold on bar (4 , sum_E_Cost1 ,0.3 , ’ green ’) set ( gca , ’ XTick ’ ,1:1:4 , ’ XTickLabel ’ ,{ ’ Unscheduled ’ , ’ TS ’ , ’ HSA ’ , ’ EDE ’}) ;% , ’ HBG Scheduled ’}) ylabel ( ’ Total Cost ’) ; % title ( ’ Over All Cost ’) ; grid on

3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176

%% % % % % % % % % % % % % % = = = = = = = = = = = = = total load = = = = = = = = = = = = = % % % % % % % % % % % % % % % % % % figure bar (1 , sum_unscheduledload ,0.3 , ’ red ’) hold on bar (2 , sum_schedule_lodTS ,0.3 , ’ blue ’) hold on bar (3 , sum_scheduled_load_G ,0.3 , ’ magenta ’) hold on bar (4 , sum_schedule_lod1 ,0.3 , ’ green ’) set ( gca , ’ XTick ’ ,1:1:4 , ’ XTickLabel ’ ,{ ’ Unscheduled ’ , ’ TS ’ , ’ HSA ’ , ’ EDE ’}) ;% , ’ HBG Scheduled ’}) ylabel ( ’ load ’) ; % title ( ’ Over All Cost ’) ; grid on %%

3177 3178 3179 3180 3181 3182 3183 3184 3185 3186

figure stairs (1:24 , EP , ’ LineWidth ’ ,1.5) ; xlabel ( ’ Time ( hours ) ’) ; ylabel ( ’ Price ’) ; xlim ([1 24]) ; set ( gca , ’ XTick ’ ,1:24 , ’ XTickLabel ’ ,{ ’1 ’ ’2 ’ ’3 ’ ’4 ’ ’5 ’ ’6 ’ ’7 ’ ’8 ’ ’9 ’ ’10 ’ ’11 ’ ’12 ’ ’13 ’ ’14 ’ ’15 ’ ’16 ’ ’17 ’ ’18 ’ ’19 ’ ’20 ’ ’21 ’ ’22 ’ ’23 ’ ’24 ’}) legend ( ’ price ’) ;% , ’ BFA Scheduled ’ , ’ HBG Scheduled ’) ; legend ( ’ Location ’ , ’ NorthEast ’) ;

131

.4. APPENDIX D 3187 3188

% title ( ’ Load per Hour ’) ; grid on

3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207

%% % % % % % % % % % % + + + + + + + + + + + + USER COMFORT + + + + + + + + + + + + + + + + % % % % % % % % % % % % % % % % % % figure bar (1 , Avg_UCom_TS ,0.3 , ’ blue ’) hold on bar (2 , Avg_UCom_HSA ,0.3 , ’ magenta ’) hold on bar (3 , Avg_UCom_EDE ,0.3 , ’ green ’) % hold on % bar (3 , Avg_UCom_BFA ,0.3 , ’ magenta ’) % hold on % bar (4 , BG_PAR_Avg ,0.3 , ’ green ’) ylabel ( ’ waiting time ’) ; set ( gca , ’ XTick ’ ,1:1:4 , ’ XTickLabel ’ ,{ ’ TS ’ , ’ HSA ’ , ’ EDE ’ }) ;% , ’ BFA Scheduled ’ , ’ HBG Scheduled ’}) title ( ’ waiting time ’) ; grid on hold off

132

.5. APPENDIX E

.5

Appendix E

%% ****Appendix E contains the MATLAB code for Optimal Power Flow Approach using Genetic Algorithm ****%%

%% ****The research paper is published under the title “An Optimal Power Flow Approach for Stochastic Wind and Solar Energy Integrated Power Systems”****%%

%% ****Springer link: https://link.springer.com/chapter/10.1007/978-3-\ 319-93659-8_26****%%

%% ****Researchgate link: https://www.researchgate.net/publication/325855975_ An_Optimal_Power_Flow_Approach_for_Stochastic_Wind_and_Solar_Energy_ Integrated_Power_Systems ****%%

%% ****MATLAB source code file “Sundas C4.m”is available on the link given below ****%% %%****Source code link: ****%% %%** Step by step guidelines to run this code are provided in Readme.txt file **%% %% **** Link: ****%%

%% *************************************************************** %% %%—- This code is developed by Sundas Shafiq under the supervision of Dr. Nadeem Javaid for the fulfillment of MS thesis—- %% % —- Fall 2017 to Spring 2018—- %% % — ComSens (Communication over Sensors) Lab, Department of Computer Science— %% %—- COMSATS University Islamabad (CUI), Islamabad 44000, Pakistan—-%

% ****************************** Sundas Shafiq ****************************** %% %Website Link: https://sites.google.com/student.comsats.edu.pk/sundas\ -shafiq/home 133

.5. APPENDIX E % Email Address: [email protected] % Mobile Number: % ***************************** Dr. Nadeem Javaid *************************** %% % Website Link: www.njavaid.com % Email Address: [email protected] % Mobile Number: +92-300-5792728 %% *************************************************************** %% %%%%— An Optimal Power Flow Approach for Stochastic Wind and Solar Energy Integrated Power Systems —%%%% %% Before going for the code, must read the overview of optimal power flow %%

%% *******************Source Code*************************** %% 3208 3209 3210 3211 3212 3213 3214

close all ; % Close all the figures clear ; % removes all variables from the current workspace , releasing them from system memory clc ; % Clears all input and output from the Command Window display , giving you a clean screen

3215 3216

%%%%%% - - - - - - - - - - - !!!! opf3 . m file !!!!! - - - - - - - - - - - -%%%%%%

3217 3218 3219 3220 3221 3222

function [ F1 Pgg vv TL Emi Ctax Qgg ]= opf3 ( x ) % x =[0.5 0.5 0.5 0.5 0.5]; %% uncomment this line while % IEEE 30 - BUS TEST SYSTEM ( American Electric Power ) % Bus Bus Voltage Angle --- Load - - - - ------- Generator - - - - - Injected % No code ( kb ) Mag . Degree MW Mvar MW Mvar Qmin Qmax Mvar

3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244

% ( bus bus Voltage Angle Load load Gener - gener - Gen % num code magni - degree MW MVar ator - ator Qmin Qmax % tude PD QD MW MVAR busdata =[1 1 1.06 0.0 0.0 0.0 0.0 0.0 0 2 2 1.043 0.0 21.70 12.7 40.0 0.0 -40 50 3 0 1.0 0.0 2.4 1.2 0.0 0.0 0 0 4 0 1.06 0.0 7.6 1.6 0.0 0.0 0 0 5 2 1.01 0.0 94.2 19.0 0.0 0.0 -40 40 6 0 1.0 0.0 0.0 0.0 0.0 0.0 0 0 7 0 1.0 0.0 22.8 10.9 0.0 0.0 0 0 8 2 1.01 0.0 30.0 30.0 0.0 0.0 -10 60 9 0 1.0 0.0 0.0 0.0 0.0 0.0 0 0 10 0 1.0 0.0 5.8 2.0 0.0 0.0 -6 24 11 2 1.082 0.0 0.0 0.0 0.0 0.0 0 0 12 0 1.0 0 11.2 7.5 0 0 0 0 13 2 1.071 0 0 0.0 0 0 -6 24 14 0 1 0 6.2 1.6 0 0 0 0 15 0 1 0 8.2 2.5 0 0 0 0 16 0 1 0 3.5 1.8 0 0 0 0 17 0 1 0 9.0 5.8 0 0 0 0 18 0 1 0 3.2 0.9 0 0 0 0

134

Gen % Injected Mvar 0 0 0 0 0 0 0 0 0 19 0 0 0 0 0 0 0 0

0

.5. APPENDIX E 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256

19 20 21 22 23 24 25 26 27 28 29 30

0 0 0 0 0 0 0 0 0 0 0 0

1 1 1 1 1 1 1 1 1 1 1 1

0 0 0 0 0 0 0 0 0 0 0 0

9.5 2.2 17.5 0 3.2 8.7 0 3.5 0 0 2.4 10.6

3.4 0.7 11.2 0.0 1.6 6.7 0.0 2.3 0.0 0.0 0.9 1.9

0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 4.3 0 0 0 0 0 0];

3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301

% % Bus bus R % nl nr p . u . linedata =[1 2 0.0192 1 3 0.0452 0.1852 2 4 0.0570 0.1737 3 4 0.0132 0.0379 2 5 0.0472 0.1983 2 6 0.0581 0.1763 4 6 0.0119 0.0414 5 7 0.0460 0.1160 6 7 0.0267 0.0820 6 8 0.0120 0.0420 6 9 0.0 0.2080 6 10 0 .5560 9 11 0 .2080 9 10 0 .1100 4 12 0 .2560 12 13 0 .1400 12 14 .1231 .2559 12 15 .0662 .1304 12 16 .0945 .1987 14 15 .2210 .1997 16 17 .0824 .1923 15 18 .1073 .2185 18 19 .0639 .1292 19 20 .0340 .0680 10 20 .0936 .2090 10 17 .0324 .0845 10 21 .0348 .0749 10 22 .0727 .1499 21 22 .0116 .0236 15 23 .1000 .2020 22 24 .1150 .1790 23 24 .1320 .2700 24 25 .1885 .3292 25 26 .2544 .3800 25 27 .1093 .2087 28 27 0 .3960 27 29 .2198 .4153 27 30 .3202 .6027 29 30 .2399 .4533 8 28 .0636 .2000 6 28 .0169 .0599

Line code X 1/2 B = 1 for lines p.u. p.u. > 1 or < 1 tr . tap at bus nl 0.0575 0.02640 1 0.02040 1 0.01840 1 0.00420 1 0.02090 1 0.01870 1 0.00450 1 0.01020 1 0.00850 1 0.00450 1 0.0 0.978 0 0.969 0 1 0 1 0 0.932 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0.968 0 1 0 1 0 1 0.0214 1 0.065 1];

3302

135

.5. APPENDIX E

3317 3318

vin =3; % wind cutin speed vout =18; % wind cutout speed vr =17; % rated speed pwr =3; v =[8 8.1 7.5 8 7 7.4 7.4 7.3 6 5 4 4.5 5 6 7 8 8.6 8 7.1 8 7.8 7.4 7 7.5]; for i =1:24 if v (1 , i ) < vin && v (1 , i ) > vout pw (1 , i ) =0; elseif vin < v (1 , i ) && v (1 , i ) < vr pw (1 , i ) = pwr *(( v (1 , i ) - vin ) /( vr - vin ) ) ; elseif vr < v (1 , i ) && v (1 , i ) < vout pw (1 , i ) = pwr ; end end W1pw = pw *25;

3319

%%============Generation cost coefficients=============%%

3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316

3320 3321 3322 3323 3324 3325 3326 3327 3328

% Active power % BUSNUMBER c gencost = [1 2 0.0175 5 0.0625 8 0.0083 11 0.025 13 0.025

b 0.00375 1.75 1 3.25 3 3

a 0 0

% MIN MAX 2 0 50 140; 20 80;%% first 3 are thermal generatore 0 10 35; W1pw (1 ,1) W1pw (1 ,1) ; % wt 0 30 30; % WT 0 20 20]; % PV

3329 3330 3331 3332 3333 3334 3335 3336 3337

%%% Emission coefficients %%% emission = [1 4.091 -5.554 6.49 0.0002 omega mu 2 2.543 -6.047 5.638 0.0005 3.333; 5 5.326 -3.55 3.38 0.002 2; 8 0.00 0 0 0 0; 11 0.00 0 0 0 0; 13 0.00 0 0 0 0];

6.667; % busnum Alpha beta gamma

3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353

%% %% %%%% formation of Y bus j = sqrt ( -1) ; % nl = num of lines %% nr = num of recieving lines % R = resistance of line nl = linedata (: ,1) ; % from bus nr = linedata (: ,2) ; % to bus R = linedata (: ,3) ; X = linedata (: ,4) ; Bc = j * linedata (: ,5) ; Tap = linedata (: , 6) ; % a = max line transfer nbr = length ( linedata (: ,1) ) ; % nbr = length of line data nbus = max ( max ( nl ) , max ( nr ) ) ; Z = R + j * X ; % impedence of branch y = ones ( nbr ,1) ./ Z ; % branch admittance

3354 3355 3356 3357 3358 3359

for n = 1: nbr if Tap ( n ) 1 x ( ii ) =1; else end y1 ( ii ) = gencost ( ii +1 ,5) + x ( ii ) *( gencost ( ii +1 ,6) - gencost ( ii +1 ,5) ) ; % as 5 th and 6 th column has min max values end

3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402

for i =1: nn1 -1; xx = gencost ( i +1 ,1) ; % bus number of last generator busdata ( xx ,7) = y1 ( i ) ; % rows from xx row , 7 th column end basemva = 100; % to calculate power , base is taken as 100. ( perunit = present value / base value ) accuracy = 0.002; maxiter =5; ns =0; ng =0; Vm =0; delta =0; yload =0; deltad =0;

3403 3404

nbus = length ( busdata (: ,1) ) ;

3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417

for k =1: nbus n = busdata (k ,1) ; kb ( n ) = busdata (k ,2) ; % kb = busnumber Vm ( n ) = busdata (k ,3) ; % vm = voltage magnitude , delta ( n ) = busdata (k , 4) ; % delta = angle of voltage Pd ( n ) = busdata (k ,5) ; % Pd = total load demand Qd ( n ) = busdata (k ,6) ; % Qd is reactive power Pg ( n ) = busdata (k ,7) ; % Pg is scheduled generation Qg ( n ) = busdata (k ,8) ; % Qg is reactive power generation Qmin ( n ) = busdata (k , 9) ; Qmax ( n ) = busdata (k , 10) ; Qsh ( n ) = busdata (k , 11) ; % shunt capacitance

137

.5. APPENDIX E 3418 3419 3420

if Vm ( n ) = accuracy && iter Qmax ( n ) , % bring the generator Mvar within Vm ( n ) = Vm ( n ) - 0.01; % the specified limits . end else end

139

.5. APPENDIX E 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549

else end else end end if kb ( n ) ~= 1 A ( nn , nn ) = J11 ; % diagonal elements of J1 DC ( nn ) = P ( n ) - Pk ; end if kb ( n ) == 0 A ( nn , lm ) = 2* Vm ( n ) * Ym (n , n ) * cos ( t (n , n ) ) + J22 ; % diagonal elements of J2 A ( lm , nn ) = J33 ; % diagonal elements of J3 A ( lm , lm ) = -2* Vm ( n ) * Ym (n , n ) * sin ( t (n , n ) ) - J44 ; % diagonal of elements of J4 DC ( lm ) = Q ( n ) - Qk ; end end

3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591

DX = A \ DC ’; % produced reactive power \ means denominator divided by numerator . opposite of /. for n =1: nbus nn =n - nss ( n ) ; lm = nbus +n - ngs ( n ) - nss ( n ) - ns ; if kb ( n ) ~= 1 delta ( n ) = delta ( n ) + DX ( nn ) ; end if kb ( n ) == 0 Vm ( n ) = Vm ( n ) + DX ( lm ) ; end end maxerror = max ( abs ( DC ) ) ; end V = Vm .* cos ( delta ) + j * Vm .* sin ( delta ) ; deltad =180/ pi * delta ; i = sqrt ( -1) ; k =0; for n = 1: nbus if kb ( n ) == 1 k = k +1; S(n)= P(n)+j*Q(n); Pg ( n ) = P ( n ) * basemva + Pd ( n ) ; Qg ( n ) = Q ( n ) * basemva + Qd ( n ) - Qsh ( n ) ; Pgg ( k ) = Pg ( n ) ; Qgg ( k ) = Qg ( n ) ; % june 97 elseif kb ( n ) ==2 k = k +1; S(n)=P(n)+j*Q(n); Qg ( n ) = Q ( n ) * basemva + Qd ( n ) - Qsh ( n ) ; Pgg ( k ) = Pg ( n ) ; Qgg ( k ) = Qg ( n ) ; % June 1997 end yload ( n ) = ( Pd ( n ) - j * Qd ( n ) + j * Qsh ( n ) ) /( basemva * Vm ( n ) ^2) ; end busdata (: ,3) = Vm ’; %(: ,3) All rows from 3 rd column busdata (: ,4) = deltad ’; Pgt = sum ( Pg ) ; Qgt = sum ( Qg ) ; Pdt = sum ( Pd ) ;

140

.5. APPENDIX E 3592 3593 3594 3595 3596 3597 3598

Qdt = sum ( Qd ) ; Qsht = sum ( Qsh ) ; if Pgg (1) > gencost (1 ,6) ; % if the system production goes high than maximum then make it equal to maximum Pgg (1) = gencost (1 ,6) ; else end

3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612

%% %% % Pdt =283.4; TL = basemva * sum ( P ) ; % total loss Pgg = abs ( Pgg ) ; lam =100* abs ( sum ( Pgg ) -TL - Pdt ) ; e =[0.037 0.038 0.045]; % valve point effect coefficients for thermal generators . d =[18 16 12]; P1 = Pgg ; c1 = gencost (1:3 ,2) ; %( 1 to 3 rd row in 2 nd column of gencost ) b1 = gencost (1:3 ,3) ; %( 1 to 3 rd row in 3 rd column of gencost ) a1 = gencost (1:3 ,4) ;%( 1 to 3 rd row in 4 th column of gencost ) m1 = gencost (1:3 ,5) ; %( 1 to 3 rd row in 5 th column of gencost )

3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623

Co1 = d .* sin ( e .*( m1 ’ - Pgg (1 ,1:3) ) ) ; % cost Co2 = abs ( Co1 ) ; % d1 =( Pgg .* Pgg ) * a1 + Pgg * b1 + sum ( c1 ) + lam ; d1 =( Pgg (1 ,1:3) .* Pgg (1 ,1:3) ) * c1 + Pgg (1 ,1:3) * b1 + sum ( a1 ) + lam ; vv = abs ( V ) ; % d1 = sum ( a1 ) + Pgg (1 ,1:3) * b1 +(( Pgg (1 ,1:3) .* Pgg (1 ,1:3) ) * c1 ) + lam ; g1 =1.60; % wind g2 =1.75; % wind s1 =1.20; % solar WS =[ g1 g2 s1 ];

3624 3625 3626 3627

d2 = WS .* Pgg (1 ,4:6) ;%1 st row , 4 5 and 6 th column d = d1 + sum ( d2 ) + sum ( Co2 ) ; % all cost for all generators F1 = d ; % Without emission

3628 3629 3630 3631 3632 3633 3634 3635 3636

%% %% alpha = emission (: ,2) ’; beta = emission (: ,3) ’; gamma = emission (: ,4) ’; omega = emission (: ,5) ’; mue = emission (: ,6) ’; PGT = Pgg ;

3637 3638 3639 3640 3641

PTT = PGT .* PGT ; format short g PTT ;

3642 3643 3644 3645 3646

Emi =( alpha + beta .* PGT + gamma .* PTT ) *0.01+ omega .*( mue .* PGT ) ; Cemi = sum ( Emi ) /1000; % per tonn convresion of emmission Ctax = Cemi *20; Cost = F1 + Ctax ; % With emission

3647 3648 3649

%%%%%% - - - - - - - - - - - !!!! gaopf1 . m file !!!!! - - - - - - - - - - - -%%%%%%

141

.5. APPENDIX E 3650 3651 3652

clear all ; close all ; clc ;

3653 3654 3655 3656 3657

% % Injected %

IEEE 30 - BUS TEST SYSTEM ( American Electric Power ) Bus Bus Voltage Angle --- Load - - - - ------- Generator - - - - No

code Mag .

Degree

MW

Mvar

MW

Mvar Qmin Qmax

Mvar

3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688

busdata =[1 1 2 2 1.043 3 0 1.0 4 0 1.06 5 2 1.01 6 0 1.0 7 0 1.0 8 2 1.01 9 0 1.0 10 0 1.0 11 2 1.082 12 0 1.0 13 2 1.071 14 0 1 15 0 1 16 0 1 17 0 1 18 0 1 19 0 1 20 0 1 21 0 1 22 0 1 23 0 1 24 0 1 25 0 1 26 0 1 27 0 1 28 0 1 29 0 1 30 0 1

1.06 0.0 0.0 0.0 0.0 0.0 21.70 12.7 40.0 0.0 -40 0.0 2.4 1.2 0.0 0.0 0 0.0 7.6 1.6 0.0 0.0 0 0.0 94.2 19.0 0.0 0.0 -40 0.0 0.0 0.0 0.0 0.0 0 0.0 22.8 10.9 0.0 0.0 0 0.0 30.0 30.0 0.0 0.0 -10 0.0 0.0 0.0 0.0 0.0 0 0.0 5.8 2.0 0.0 0.0 -6 0.0 0.0 0.0 0.0 0.0 0 0 11.2 7.5 0 0 0 0 0 0.0 0 0 -6 0 6.2 1.6 0 0 0 0 8.2 2.5 0 0 0 0 3.5 1.8 0 0 0 0 9.0 5.8 0 0 0 0 3.2 0.9 0 0 0 0 9.5 3.4 0 0 0 0 2.2 0.7 0 0 0 0 17.5 11.2 0 0 0 0 0 0.0 0 0 0 0 3.2 1.6 0 0 0 0 8.7 6.7 0 0 0 0 0 0.0 0 0 0 0 3.5 2.3 0 0 0 0 0 0.0 0 0 0 0 0 0.0 0 0 0 0 2.4 0.9 0 0 0 0 10.6 1.9 0 0 0

0.0 50 0 0 40 0 0 60 0 24 0 0 24 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0

0 0 0 0 0 0 0 0 0 19 0 0 0 0 0 0 0 0 0 0 0 0 0 4.3 0 0 0 0 0 0];

3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707

% Line code % Bus bus R X 1/2 B = 1 for lines % nl nr p . u . p.u. p.u. > 1 or < 1 tr . tap at bus nl linedata =[1 2 0.0192 0.0575 0.02640 1 1 3 0.0452 0.1852 0.02040 1 2 4 0.0570 0.1737 0.01840 1 3 4 0.0132 0.0379 0.00420 1 2 5 0.0472 0.1983 0.02090 1 2 6 0.0581 0.1763 0.01870 1 4 6 0.0119 0.0414 0.00450 1 5 7 0.0460 0.1160 0.01020 1 6 7 0.0267 0.0820 0.00850 1 6 8 0.0120 0.0420 0.00450 1 6 9 0.0 0.2080 0.0 0.978 6 10 0 .5560 0 0.969 9 11 0 .2080 0 1 9 10 0 .1100 0 1 4 12 0 .2560 0 0.932

142

0

.5. APPENDIX E 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733

12 13 12 14 12 15 12 16 14 15 16 17 15 18 18 19 19 20 10 20 10 17 10 21 10 22 21 22 15 23 22 24 23 24 24 25 25 26 25 27 28 27 27 29 27 30 29 30 8 28 6 28

0 .1231 .0662 .0945 .2210 .0824 .1073 .0639 .0340 .0936 .0324 .0348 .0727 .0116 .1000 .1150 .1320 .1885 .2544 .1093 0 .2198 .3202 .2399 .0636 .0169

.1400 .2559 .1304 .1987 .1997 .1923 .2185 .1292 .0680 .2090 .0845 .0749 .1499 .0236 .2020 .1790 .2700 .3292 .3800 .2087 .3960 .4153 .6027 .4533 .2000 .0599

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0214 0.065

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.968 1 1 1 1 1];

3734 3735 3736 3737 3738 3739 3740 3741

%% %%%%%%% Wind Speed and Solar Irradiance %%%%%%% vin =3; vout =18; vr =17; pwr =3; v =[8 8.1 7.5 8 7 7.4 7.4 7.3 6 5 4 4.5 5 6 7 8 8.6 8 7.1 8 7.8 7.4 7 7.5];

3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752

for i =1:24 if v (1 , i ) < vin && v (1 , i ) > vout pw (1 , i ) =0; elseif vin < v (1 , i ) && v (1 , i ) < vr pw (1 , i ) = pwr *(( v (1 , i ) - vin ) /( vr - vin ) ) ; elseif vr < v (1 , i ) && v (1 , i ) < vout pw (1 , i ) = pwr ; end end W1pw = pw *25;

3753 3754 3755 3756 3757 3758 3759 3760

%%% Generation cost co - efficients %%% gencost = [1 0.00375 2 0 50 140; 2 0.0175 1.75 0 20 80; 5 0.0625 1 0 10 35; 8 0.0083 3.25 0 W1pw (1 ,1) W1pw (1 ,1) ; 11 0.025 3 0 0 65; 13 0.025 3 0 0 50];

3761 3762 3763 3764 3765

%%% Emission co - efficients %%% emission = [1 4.091 -5.554 6.49 0.0002 2 2.543 -6.047 5.638 0.0005 3.333; 5 5.326 -3.55 3.38 0.002 2 ;

143

6.667;

.5. APPENDIX E 3766 3767 3768 3769

3770

8 11 13

0.00 0.00 0.00

0

0 0 0

0 0 0

0 0 0

; 0 0];

;

%%=====================GA=======================%%

3771 3772 3773 3774 3775 3776 3777 3778 3779 3780

global busdata linedata gencost options = gaoptimset ; options = gaoptimset ( ’ PopulationSize ’ , 50 , ’ Display ’ , ’ iter ’ , ’ Generations ’ , 200 , ’ StallGenLimit ’ ,100 , ’ TimeLimit ’ , 300 , ’ StallTimeLimit ’ , 300 , ’ SelectionFcn ’ , @selectionroulette , ’ CrossoverFcn ’ , @crossoverheuristic , ’ MutationFcn ’ , @mutationgaussian , ’ PlotFcns ’ , { @gaplotbestf , @ g a p l o t b e s t i n d i v }) ; [ x ff ]= ga ( @opf3 ,5 , options ) ; [ F Pgg vv TL Emi Ctax Qgg ]= opf3 ( x ) %%% Output values from " opf3 . m "

3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813

% alpha = emission (: ,2) ’; % beta = emission (: ,3) ’; % gamma = emission (: ,4) ’; % omega = emission (: ,5) ’; % mue = emission (: ,6) ’; % PGT = Pgg ; % % % PTT = PGT .* PGT ; % format short g % PTT ; % % emi1 =( alpha + beta .* PGT + gamma .* PTT ) *0.01+ omega .*( mue .* PGT ) ; GenM (i ,:) = Pgg ; %%%% %%%%%%%% %% Active power generation %%%%%%%%% figure bar (1 , Pgg (1 ,1) ,0.3 , ’ red ’) hold on bar (2 , Pgg (1 ,2) ,0.3 , ’ blue ’) hold on bar (3 , Pgg (1 ,3) ,0.3 , ’ magenta ’) hold on bar (4 , Pgg (1 ,4) ,0.3 , ’ green ’) hold on bar (5 , Pgg (1 ,5) ,0.3 , ’ yellow ’) hold on bar (6 , Pgg (1 ,4) ,0.3 , ’ cyan ’) set ( gca , ’ XTick ’ ,1:1:6 , ’ XTickLabel ’ ,{ ’ TG1 ’ , ’TG2 ’ , ’ TG3 ’ , ’ WG1 ’ , ’ WG2 ’ , ’S PV ’} , ’ fontsize ’ ,18) ylabel ( ’ Generators output power ’ , ’ fontsize ’ ,18) ; legend ({ ’ TG1 ’ , ’TG2 ’ , ’TG3 ’ , ’WG1 ’ , ’WG2 ’ , ’S - PV ’} , ’ fontsize ’ ,18) ; legend ( ’ Location ’ , ’ NorthEast ’)

3814 3815 3816 3817 3818 3819 3820 3821

%%%% %%%%%%%% %% Bus voltage %%%%%%%%% figure plot ( vv ) ; set ( gca , ’ XTick ’ ,1:1:30 , ’ XTickLabel ’ ,{ ’1 ’ , ’2 ’ , ’3 ’ , ’4 ’ , ’5 ’ , ’6 ’ , ’7 ’ , ’8 ’ , ’9 ’ , ’10 ’ , ’11 ’ , ’12 ’ , ’13 ’ , ’14 ’ , ’15 ’ , ’16 ’ , ’17 ’ , ’18 ’ , ’19 ’ , ’20 ’ , ’21 ’ , ’22 ’ , ’23 ’ , ’24 ’ , ’25 ’ , ’26 ’ , ’27 ’ , ’28 ’ , ’29 ’ , ’30 ’} , ’ fontsize ’ ,18) xlabel ( ’ Bus voltage ’ , ’ fontsize ’ ,18) ;

3822

144

.5. APPENDIX E %%%% %%%%%%%% %% Forecasted wind speed %%%%%%%%% figure plot ( v ) set ( gca , ’ XTick ’ ,1:1:30 , ’ XTickLabel ’ ,{ ’1 ’ , ’2 ’ , ’3 ’ , ’4 ’ , ’5 ’ , ’6 ’ , ’7 ’ , ’8 ’ , ’9 ’ , ’10 ’ , ’11 ’ , ’12 ’ , ’13 ’ , ’14 ’ , ’15 ’ , ’16 ’ , ’17 ’ , ’18 ’ , ’19 ’ , ’20 ’ , ’21 ’ , ’22 ’ , ’23 ’ , ’24 ’} , ’ fontsize ’ ,18) xlabel ( ’ Forecasted wind speed W1 ’ , ’ fontsize ’ ,18) ;

3823 3824 3825 3826 3827 3828 3829 3830

%%%% %%%%%%%% %% Emission %%%%%%%%% figure bar (1 , Emi (1 ,1) ,0.3 , ’ red ’) hold on bar (2 , Emi (1 ,2) ,0.3 , ’ blue ’) hold on bar (3 , Emi (1 ,3) ,0.3 , ’ magenta ’) set ( gca , ’ XTick ’ ,1:1:30 , ’ XTickLabel ’ ,{ ’ TG1 ’ , ’ TG2 ’ , ’ TG3 ’} , ’ fontsize ’ ,18)

3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841

; xlabel ( ’ Emission ’ , ’ fontsize ’ ,18) ;

145

Suggest Documents