You are on page 1of 75

UNIVERSITY OF NAIROBI HTED with RE-2016

UNIVERSITY OF NAIROBI
SCHOOL OF ENGINEERING
DEPARTMENT OF ELECTRICAL AND INFORMATION
ENGINEERING

NAME: MBOGO LAWRENCE MUNENE


REG NO: F17/1459/2011
COURSE TITLE: FINAL YEAR PROJECT
COURSE CODE: FEE 560
PROJECT INDEX: PRJ 135
SUPERVISOR: MR. PETER MUSAU
EXAMINER: PROF. MANG’OLI

TITLE OF WORK

HYDRO THERMAL ECONOMIC DISPATCH WITH


RENEWABLE ENERGY
PROJECT REPORT SUBMITTED IN PARTIAL FULFILLMENT OF THE
REQUIREMENT FOR THE AWARD OF THE DEGREE OF BACHELOR OF
SCIENCE IN ELECTRICAL AND INFORMATION ENGINEERING OF THE
UNIVERSITY OF NAIROBI 2016
DATE SUBMITTED: …………/…………/………….

F17/1459/2011: MBOGO LAWRENCE MUNENE 1


UNIVERSITY OF NAIROBI HTED with RE-2016

Declaration of Originality

NAME OF STUDENT: MBOGO LAWRENCE MUNENE

REGISTRATION NUMBER: F17/1459/2011

COLLEGE: ARCHITECTURE AND ENGINEERING

FACULTY: ENGINEERING

DEPARTMENT: ELECTRICAL AND INFORMATION


ENGINEERING

TITLE OF WORK: HYDROTHERMAL ECONOMIC


DISPATCH WITH RENEWABLE
ENERGY

a) I understand what plagiarism is and I am aware of the university policy on this regard.

b) I declare that this final year project is my original work and has not been submitted elsewhere
for examination, award of a degree or for publication. Where other people’s work or my own work
has been used, this has been properly acknowledged and referenced in accordance with the
University of Nairobi’s requirements.

c) I have not sought or used the service(s) of any professional agencies to produce this work.

d) I have not allowed, and shall not allow anyone to copy my work with the intention of passing
it off as his/her own work.

e) I understand that any false claim in respect of this work shall result in disciplinary action, in
accordance with University anti-plagiarism policy.

Signature: Date:
……………………………………… ………………………………………

F17/1459/2011: MBOGO LAWRENCE MUNENE 2


UNIVERSITY OF NAIROBI HTED with RE-2016

Certification
I ……………………………………………… certify on this …….. day of ………………….........

of the year 2016 that this project work entitled “Hydrothermal Economic Dispatch With
Renewable Energy” has been submitted to the University of Nairobi, Department of Electrical
and Information Engineering. This work is a partial fulfillment for the award of an undergraduate
degree in Bachelor of Science (Electrical & Information Engineering) degree and the work was
done under my utmost and clear guidance and supervision.

I also certify that the work has been submitted by MBOGO LAWRENCE MUNENE with the
student Registration Number F17/1459/2011 and it has not been submitted earlier by any other
student.

Signature

………………………………..

F17/1459/2011: MBOGO LAWRENCE MUNENE 3


UNIVERSITY OF NAIROBI HTED with RE-2016

Dedication
To my ever present and supportive parents and family for your outstanding encouragement and
being there for me for the time that I have been studying is unfathomable.

To all electrical engineering students with the hope that the content of this project report will
become a pillar in your pursuit of this critical career line.

To my good and very supportive friend Christine Gatugi njagi. Your support in completion of this
work was unparalled.

To the source of all wisdom, knowledge and understanding, My Lord and Redeemer Jehovah God.

F17/1459/2011: MBOGO LAWRENCE MUNENE 4


UNIVERSITY OF NAIROBI HTED with RE-2016

Acknowledgements
Attainment of education to the undergraduate degree level is not an easy task. It takes courage,
diligence and cooperation with the many kinds of people that one comes along in the journey of
getting there. Preparation and completion of this work was not without these virtues. I am therefore
deeply grateful for the sum total contributions of each individual that has been a part of my life in
school.

My utmost gratitude go to Mr. Peter Musau of the University of Nairobi, Department of Electrical
and Information who has been there for me, as my supervisor, from the initial stages of the
development of this project work. Your motivation, advise, supervision and support are
unparalleled.

Christine Gatugi, Wilfred Waweru, Lydia Wanja and Carol Kiama, diligent and compassionate
friends who allowed me to spend their precious time and resources without which this work would
have been hampered and probably not completed. Your encouragement and prayers counted much.
You are a gift to me and may your generosity abound.

My sincere regards also to the entire University of Nairobi fraternity-teaching staff, non teaching
staff, students, and Main Campus Christian Union community for providing an environment where
I have been nurtured to the level of preparation and completion of such work. The values I have
attained through my interactions with you shall remain.

My Parents, Family and Sponsors, Your support has been vital. You all believed in me and chose
to invest resources in me. God bless you so much.

I finally acknowledge the Author of human life and all wisdom, Jehovah God. His love and
enablement and grace allowed all the above and that which is contained in this work to be. His
Name be honoured.

F17/1459/2011: MBOGO LAWRENCE MUNENE 5


UNIVERSITY OF NAIROBI HTED with RE-2016

List of Figures and Tables


Figure 1.6.4: Flow Diagram for the ACS Algorithm………………………………………….…36

Figure 2.2.1: Thermal electrical energy cost function of a thermal unit with and without valve-
points ……………………………………………………………………………………….……22

Figure 3.6: Flow chart for the PSO method …………………………………………………….43

Figure 4.1: One line diagram of a 30 bus system………………………………………………..45

Figure 4.1: (a) PSO Convergence characteristic at 600MW…………………………………….47

Figure 4.1: (b) PSO Convergence characteristic at 900MW…………………………………….47

Figure 4.1: (c) PSO Convergence characteristic at 1000MW…………………………………...48

Figure 4.1: (d). PSO Convergence characteristic at 1300MW…………………………………..48

Figure 4.2: Variation of cost with respect to active power losses (sample of 1300MW)……….49

Figure 4.3: Variation of Total Cost with respect to the hourly demand (sample of 1300MW)…49

Figure 4.4: The typical wind power curve………………………………………………….........50

Figure 4.5: The typical cost curve for a thermal generator………………………………………50

Table 3.5: PSO Parameters set up………………………………………………………………..41

Table 4.1: Generator coefficients and power limits………………………………………...........44

Table 4.3: Simulations Result.. ………………………………………………………………….46

Matrix 4.0: The B coefficients for the 30 bus network ………………………………………….44

F17/1459/2011: MBOGO LAWRENCE MUNENE 6


UNIVERSITY OF NAIROBI HTED with RE-2016

List of Abbreviations
ED-Economic Dispatch

DEDP-Dynamic Economic Dispatch Problem

RE-Renewable Energy

HTED-Hydro Thermal Economic Dispatch

IEEE-Institute of Electrical and Electronics Engineers

NN-Neural network

EAs-Evolutionary Algorithms

TS-Tabu Search

PSO-Particle swarm Optimization

ACSM- Ant Colony Search Method

BCA-Bee Colony Algorithm

GA-Genetic Algorithm

ANN- Artificial Neural Networks

PSO-Particle Swarm Optimization

F17/1459/2011: MBOGO LAWRENCE MUNENE 7


UNIVERSITY OF NAIROBI HTED with RE-2016

Abstract
The main objective of any economic dispatch (ED) problem is cost minimization while still
meeting the required power demand and losses. With the current situation, renewable energy has
continued to be explored and its use found to greatly affect the optimal allocation of output power
to the scheduled units. The contribution of this project centers on solving the Dynamic Economic
Dispatch Problem (DEDP) of a hydro thermal system with a penetration of the renewable energy
sources of solar and wind. It suggests an effective way of utilization of Renewable Energy (RE) to
effectively cater for the active transmission line losses and also reduce the cost of generation for
the hydrothermal system. Since the renewable resources are not dispatchable to meet load demand
on their own (independently), a practical approach based on their availability and intermittent
nature is applied to maximize their positive impact in the Hydrothermal Economic Dispatch
(HTED) problem. Since maximizing on the Renewable Energy (RE) and minimizing fuel cost are
conflicting objectives, a practical approach based on multi-objective optimization is applied to
obtain solutions in a single simulation run for each demand value using the Particle Swarm
Optimization (PSO) algorithm. The efficacy of the proposed approach is illustrated with the help
of sample test cases on the IEEE 30 bus system. This project report would be useful for society,
electric utilities, consultants, regulatory bodies, policy makers and planners.

F17/1459/2011: MBOGO LAWRENCE MUNENE 8


UNIVERSITY OF NAIROBI HTED with RE-2016

Contents
Declaration of originality.................................................................................................................2
Certification ... ................................................................................................................................3
Dedication .......................................................................................................................................4
Acknowledgements .....................................................................................................................…5
List of figures and tables .................................................................................................................6
List of abbreviations .......................................................................................................................7
Abstract ......................................................................................................................…….............8

CHAPTER ONE

Introduction: Definitions and General Overviews.

1.0 Economic dispatch…………………………...………………………………………………13

1.1 Hydrothermal Economic Dispatch ……………...……………………………………………13

1.2 Renewable energy ……………...……………………………………..……………………..14

1.2.1 Solar energy ……………...……………………………………………………..…14

1.2.2 Wind energy ……………...………………………………………………………..14

1.2.3 Biomass energy ……………...……………………………………………………..15

1.2.4 Geothermal gas ……………...……………………………………………………..15

1.3 Economic Dispatch Problem……………...………………………………………………….15

1.4 Optimization ……………...………………………………………………………………….16

1.5 Solution to the Economic Dispatch problem ……………...…………………………………16

1.5.1 Unit commitment ……………...…………………………………………………...16

1.6 Problem statement…..……………… ……………...………………………………………..18

1.7 Objectives of the project………………………..…………………………………………….18

1.8 Research Questions……………………………………………………………………..……19

F17/1459/2011: MBOGO LAWRENCE MUNENE 9


UNIVERSITY OF NAIROBI HTED with RE-2016

1.9 Organization of the project……………………..……………………………………………19

CHAPTER TWO

Literature Review On The Hydrothermal Economic Dispatch Problem With Renewable


Energy

2.1 Thermal System Economic dispatch ……………...…………………………………………21

2.1.1 The general input-output characteristics of a thermal generator ……………….....21

2.1.2 Economic Dispatch for a Purely Thermal System ……………...…………………23


2.1.2.1 Constraints on Thermal economic dispatch……………...………………………24

2.1.2.1.1 Generator power ratings. ……………...…………………….…………24

2.1.2.1.2 Generator Ramp limits ……………...…………………………………24

2.1.2.1.3 Transmission line losses ……………...……………………………….25

2.2 Hydrothermal Economic Dispatch (HTED) ……………...…………………………………25

2.2.1 Water discharge constraint. ……………...…………………………………...……25

2.3 Economic dispatch of Renewable Energy (Wind and Solar energy) ………………………..26

2.4 Hydrothermal Economic Dispatch with Renewable Energy (HTED with RE) …………..…26

2.4.1 System constraints ……………...…………………………………………………26

2.4.1.1 Equality Constraints ……………...……………………………………...26

2.4.1.2 Inequality Constraints ……………...……………………………………27

2.4.1.2.1 Generator constraints …...……………………………………..27

2.4.1.2.2 Generator ramp limits …...…………………………………….27

2.4.1.2.3 Water discharge constraints …...………………………………27

2.4.1.2.4 Transmission line losses…...…………………………………..28

2.4.1.2.5 Renewable Energy constraint …...…………………………….28

F17/1459/2011: MBOGO LAWRENCE MUNENE 10


UNIVERSITY OF NAIROBI HTED with RE-2016

2.4.1.2.6 Prohibited Operating Zone and Generation Limits…………….28

2.5 Objective functions ………………………………………………………………………….29

2.5.1 Operation cost function for thermal power generation ……………………29

2.5.2 Operation cost function for hydro power generation………………………29

2.5.3 Operation cost function for wind power generation………………………...30

2.5.4 Operation cost function for solar power generation. ……………………...30

2.5.5 Overall cost function for total generation………………………………….30

2.6 Problem Formulation ………………………………………………………………………..31

CHAPTER 3

Solution to The Hydrothermal Economic Dispatch With Renewable Energy (HTED with
RE) Problem

3.1 Simulated Annealing (SA) ……………...……………………………………………………32

3.1.2 Tabu Search (TS) ……………...…………………………………………………32

3.1.3 Genetic Algorithm (GA) ……………...……………………………………………33

3.1.4 Ant-Colony Search (ACS) ……………...………………………………………….35

3.1.5 Artificial Neural Networks (ANN) ……………...………………………………....36

3.1.6 Particle Swarm Optimization (PSO) ……………...……………………………….37

3.1.7 Hybrid Methods ……………...……………………………………………………37

3.2 Review on the Particle Swarm Optimization (PSO) Method …...…………………………..37

3.2.1 PSO Terminologies …...…………………………………………………………...38

3.2.2 PSO Key Features and Advantages …...…………………………………………..39

3.3 Formulation of the PSO ……………………………………………………………………..40

3.4 Application of PSO to HTED with RE ……………………………………………………...41

F17/1459/2011: MBOGO LAWRENCE MUNENE 11


UNIVERSITY OF NAIROBI HTED with RE-2016

3.5 Flow chart for the PSO method ……………………………………………………………..42

CHAPTER FOUR

Results and Analysis

4.1 The Test system ……………………………………………………………………………..44

4.2 IEEE 30 bus network ………………………………………………………………………..45

4.3 Simulation Results…………………………………………………………………………...45

4.4 Simulation Results: Analysis ………………………………………………………………..51

4.5 Conclusion from results and analysis ……………………………………………………….51

CHAPTER FIVE

Conclusion and Further Work

5.1 Conclusion of this Report …………………………………………………………………...52

5.2 Further work …………………………………………………………………………………52

References ……………………………………………………………………………………….53

Appendices ………………………………………………………………………………………54

F17/1459/2011: MBOGO LAWRENCE MUNENE 12


UNIVERSITY OF NAIROBI HTED with RE-2016

CHAPTER ONE

Introduction: Definitions and General Overviews.

1.0 Economic dispatch

There are different methods that are used in generating electrical energy. These include, hydro-
generation, nuclear, use of fossil fuels and also there is generation through renewable resources
such as solar and wind. This energy is usually generated at a place that is located far away from
the load center (consumers) and the distance in between is bridged through transmission. For
maximum benefits, the power system, which includes aspects such as generation, transmission and
distribution, has to operate under optimum economic conditions. This ensures profit for the
investment made in establishing a power plant. The system security, emissions and optimal
releases are some of the aspects that are necessary to consider to ensure optimum operation
costwise.

The generating units have different output capacities and production costs with the most efficient
ones being preferred to the least efficient. Economic dispatch therefore refers to the operation
of these generating units together so as to meet the power demand combined with the possible
losses during transmission at minimum generation costs. This raises a problem called economic
dispatch problem. The main aim in the economic dispatch problem is minimization of the total
generation cost at various selected stations or plants to meet a given load demand and the
transmission losses considering the various constraints for the selected system or area. The capital
investment is usually exempted when getting a solution to the economic dispatch problem.

1.1 Hydrothermal Economic Dispatch

As the name suggests above, this is economic dispatch that has only two types of generation
namely hydro-generation and use of fossil fuels (thermal). In this form of dispatch, the optimal
operation of the thermal plants is dependent on the hydro plants. The operation is constrained by
the availability of water since the generation costs for hydro power are negligible. This makes the
Hydrothermal Economic Dispatch problem a dynamic optimization problem. The other possible
constraint is the power balance constraint. Ramp limits and the generator power output limits are
also constraints in such a dynamic economic dispatch problem.

F17/1459/2011: MBOGO LAWRENCE MUNENE 13


UNIVERSITY OF NAIROBI HTED with RE-2016

1.2 Renewable energy

Renewable energy resources have a high potential of meeting power demand when harnessed
appropriately. These resources are increasingly being used because they are environmentally
friendly. The conventional methods of generation which include use of fossil fuels and coal are
being developed at a lower rate as compared to harnessing renewable energy. This is because of
their adverse environmental effects as a result of emissions. The declining capital costs and costs
of electricity generated from renewable energy has given a clear front that the future growth in the
energy sector will be primarily in the new regime of renewable energy and to some extent natural
gas based systems and not in the conventional oil and coal sources. [05] These sources include
solar, wind, tidal energy, geothermal gas and biomass. A brief summary of each is given below.
These energy sources are receiving significant importance in recent researches and studies due to
lower electricity generation price and positive effect on environment [07].

1.2.1 Solar energy

This is the primary source of all other form of energy. Solar energy is energy produced by the solar
radiation, directly or in a diffuse way through the atmosphere [07]. Solar energy it can be used in
its raw form to generate electricity. This happens in two broad ways where first, it can be converted
to heat and the heat is used to boil water to steam for steam generation. The other way of use is
where the solar insolation is converted to electricity using photovoltaic cells fondly known as solar
panels [18]. This second way is the most commonly used and is the one used in this project. An
array of solar panels are set to produce a certain amount of the overall power demand. Solar power
is cyclic as it depends on the hours that solar radiation is available and this is a cycle naturally.

1.2.2 Wind energy

This is energy harnessed from the movement of air masses as a result of differences in atmospheric
pressure in various places above the earth surface. This is as a result of solar insolation [18]. This
form of energy is equally useful like the solar energy and it does not cause emission. The wind
energy is harvested using wind turbine generators and many of them constitute generation that is
dispatchable. The wind speed is the major factor to consider in setting up a wind power station.
Due to wind uncertainty, wind power generation makes its incorporation into the grid quite tasking
[13]. Its generation cost is higher than that of solar energy. Unlike solar energy which is cyclic and

F17/1459/2011: MBOGO LAWRENCE MUNENE 14


UNIVERSITY OF NAIROBI HTED with RE-2016

diurnal, wind is available throughout the day and the night. The only disadvantage is that it is
intermittent.[18]

1.2.3 Biomass energy

Biomass is the term used for all organic material originating from plants (including Algae), trees
and crops and is essentially the collection and storage of the sun’s energy through photosynthesis
[05]. This was the first type of energy to be harnessed by humans. This type of energy is usually
not considered a modern source. It is readily available for use and contribute to a very small
percentage in to the power demands in developing countries.

1.2.4 Geothermal gas

This is energy that is in gases/steam that is generated underground as a result of heating of the
earth’s high temperatures. The heating results to steam at high pressure which can be harnessed
appropriately and electrical energy is harvested from them. This is the resource used at Ol-karia
and other potentially active places on the earth surface. The steam is processed first to remove any
harmful components to the system before it is used to run the steam turbines which in turn are
coupled with generators that produce electrical power.

1.3 Economic Dispatch Problem

Operating thermal generators, hydro generators, wind generators and incorporation of solar energy
raises a problem. Each of these units has constraints that in one or another affect the running of
the other units. This kind of a problem is known as economic dispatch problem. It is usually aimed
at minimizing the cost and at the same time meeting all the demand and losses involved. This
problem can be single objective or multi-objective problem depending on the aim of a project. In
a single objective problem there is only one aim which maybe to reduce costs or to minimize
emissions while in a multi-objective problem, both cost and emissions require to be minimized.

The economic dispatch problem can also be described as static or dynamic. The dynamic economic
dispatch aims to determine the optimal power outputs of on-line generating units in order to meet the load
demand subject to satisfying various operational constraints over finite dispatch periods [19]. The static
economic dispatch is limited to thermal plants only and does not consider constraints such as ramp
limits.

F17/1459/2011: MBOGO LAWRENCE MUNENE 15


UNIVERSITY OF NAIROBI HTED with RE-2016

1.4 Optimization

Optimization can be defined as the process of maximization or minimization of a given function


with some defined constraints [09]. With the constraints being applied, the optimization is said to
be constrained while the one without constraints is an unconstrained optimization process. The
main objective of optimization is to obtain the best results subject to restrictions or constraints that
are imposed. In general, the target of optimization in this project is to minimize the costs for
construction and operation of the system putting into consideration all possible constraints.

1.5 Solution to the Economic Dispatch problem

The economic dispatch problem can be solved at different levels depending on the type of electrical
power generation under consideration. However, there are other basic considerations in solving
the economic dispatch problem and these include the unit commitment problem and load flow.
This project leans more on the unit commitment problem since the worst case scenario demands
that the bulk power be generated thermally.

1.5.1 Unit commitment

This refers to the computational procedure for getting a sequence in which operating units should
be started up and when to connect them to the network so as to meet the load demand and losses
thereof []. It is the problem of determining the schedule of generating units within a power system
subject to equipment and operating constraints [10]. It also incorporates the shut down time and
how long a unit should remain shut down. The main aim of unit commitment is to ensure that the
power generated is able to meet the forecast load demand at minimum cost. There must be at least
one unit on-line to meet the base load as obtained from the load profile for any power system. Any
other load apart from the base load can be supplied through various combinations of the other
available units appropriately.

For a system with K units, we can get 2K-1 possible combinations in order to meet a certain load.
Considering the generator constraints and power output specifications, some of the combinations
are infeasible while the feasible ones have to be chosen wisely so as to get the optimal operation
point for the system.

F17/1459/2011: MBOGO LAWRENCE MUNENE 16


UNIVERSITY OF NAIROBI HTED with RE-2016

The process of finding the possible combinations for optimum operation can be very time
consuming and various methods have been employed to solve this problem. These methods known
as dynamic programming approaches are used to compare the economics of combinations. These
techniques assume the following are known a priori:

(i) Number of units available.


(ii) The individual unit cost characteristics.
(iii) The load cycle/profile for the system.
(iv) The load on each unit in the feasible combinations changes in small but uniform
values e.g. 1MW.
In the search procedure for solving the unit commitment problem, the following assumptions are
basic. That:

a) The daily load schedule has N discrete time intervals or stages and durations of which are
not necessarily equal.
b) A decision must be made for e ach stage k regarding which p a reticular combination of
units to operate during that stage.
c) To solve for the N decisions, N sub-problems are solved sequentially in such a way that
the combined best decisions for the N sub-problems yield the best overall solution for the
original problem.
The unit commitment can as well be mathematically formulated by the equation below

Fi* (k) = minxj(k+1) {P i* (k) + + F (k+1)}

Where the variables are as defined below.

xj = feasible combination at stage k.

k = stage under consideration raging from 1 to N.

P i* (k) = Production cost at stage k.

T i*j (k) = Transition cost at stage k.

F17/1459/2011: MBOGO LAWRENCE MUNENE 17


UNIVERSITY OF NAIROBI HTED with RE-2016

1.6 Problem statement

Different authors have solved the economic dispatch problem in different ways, proposing the use
of MATLAB optimization toolbox, Lagrange`s techniques, direct search, evolutionary
programming, particle swarm optimization, genetic algorithms, simulated annealing among others.
The history of the economic dispatch (ED) is old and the literature is abundant. So far, there are
numerous optimization methods that solve this ED problem reaching a power generation
configuration that satisfies the demand at minimum cost. [17]

The problem of hydrothermal economic dispatch with renewable resources is non linear and
dynamic and aims at optimization on cost. The load demand must be met at other particular time
putting into consideration various constraints of the power system such as generator constraints,
transmission line losses, uncertainty of wind speed, the randomness of solar radiation and many
others. Thermal generation has the highest generation cost implication on the system and needs to
be optimized since hydro generation has almost negligible generation costs. Wind and solar energy
are freely available and are thus preferred as the renewable resources in order to cut on costs.
However, the uncertainty in them calls for an appropriate measure to take care of that shortcoming
in their use. The optimization in this problem is done by extracting renewable power as much as
possible from both wind and solar. The remaining power demand is distributed is distributed
among the hydro and thermal units. This is done considering all the possible constraints on the
objective function.

The problem will involve formulation of a solution to the hydrothermal economic dispatch with
renewable sources problem using MATLAB programming software. The particle swarm
optimization technique will be used to obtain the solution that guarantees power generation in the
most economical way. The PSO optimization method is well elaborated in the next chapter in an
attempt to solve the problem.

1.7 Objectives of the project

In light of the statement above, this project therefore seeks to solve this nonlinear, dynamic and
heuristic economic dispatch problem by aiming at the following:

1. Getting a solution of this that has the minimum cost of generation.

F17/1459/2011: MBOGO LAWRENCE MUNENE 18


UNIVERSITY OF NAIROBI HTED with RE-2016

2. To show the effect of incorporation of wind and solar generated power on costs of
generation by thermal units.
3. To appreciate the PSO technique of solving this heuristic problem and use it to find the
optimal solution for this particular economic dispatch problem.
1.8 Research Questions

This project involves formulation of a solution to a dynamic economic dispatch problem


accounting for the effects of renewable energy. In the process of solving this problem, there are
several questions whose answers constitute the information necessary for this project to be termed
successful. These include and not limited to:

1. What is the most appropriate method of solving the HTED with RE economic Dispatch
problem?
2. What are the possible sources of renewable energy in an economic dispatch problem?
3. What is the effect of including renewable energy in an economic dispatch problem?
4. How are the renewable resources accounted for in formulating the economic dispatch
problem?
5. What constraints are there in a power system that has renewable energy and how are they
factored in the solution for the economic dispatch problem?
The above five questions provide a research platform on which this project work is based and in
answering them, the objectives of the report shall have been achieved.

1.9 Organization of the project

The contents of this work is organized in form of chapters and the brief details of each chapter is
as explained as shown below

Chapter One forms the introduction of the title. This introduction gives the definitions of various
key words in this work and also an overview of the various critical aspects of an ED problem and
formulation of its solution.

Chapter Two gives the literature review on the HTED with RE. it is in this chapter where there is
the mathematical formulations of ED of varius forms and the constraints involved there in.

F17/1459/2011: MBOGO LAWRENCE MUNENE 19


UNIVERSITY OF NAIROBI HTED with RE-2016

Chapter Three forms the backbone of this project since it states the HTED with RE problem and
a solution of this problem is also given here.

Chapter Four has the results obtained from the simulations, the analysis and conclusions from
the analysis of these results. The test system used in this work is also explained in this chapter.

Chapter Five contains a summary of the work in this project in the form of conclusions of the
overall report. Recommendations and Further work are propsed here. It also gives the references
and appendices.

F17/1459/2011: MBOGO LAWRENCE MUNENE 20


UNIVERSITY OF NAIROBI HTED with RE-2016

CHAPTER TWO

Literature Review on the Hydrothermal Economic Dispatch


With Renewable Energy
In a power system, different costs are incurred and these include capital costs, generation and fuel
costs, maintenance costs and also labour costs. All these costs come in handy in solving any
economic dispatch problem with the fuels costs being highly considered since other costs are
incurred not as frequently as the fuel costs. These costs are modeled by the cost curves for each
mode of generation. The various possible power systems are explained below as well as their
economic dispatch. These include a purely thermal system, a hydrothermal system and a
hydrothermal system that incorporates renewable energy resources which in this project are wind
and solar energy only.

2.1 Thermal System Economic dispatch

This is a system that constitutes of all units that use fossil fuels to generate electric power. This
system is very expensive and should be least used if the other methods of generation as listed
earlier are readily available. To help us understand the dynamics of such a system we are going to
study a thermal generator: its cost characteristics, the constraints and finally the economic dispatch
of a purely thermal system.

2.1.1 The general input-output characteristics of a thermal generator.

In a thermal system, fuel engines are used to turn as the prime movers of the generators. These
combustion engines use fossil fuel which is turned to heat and the rotary motion is hence produced.
The heat rate of the fuel determines the energy output of the generator. This gives a quadratic
relation between the output of the generator and its output. The most conventional thermal system
consists of a boiler, steam turbine and the generator. The unit of the generator fuel consumption
function is Btu per hour of heat input to the unit (or MBtu/h) where the conversion is 1Btu =
0.29307107Watt. This input output relation is also known as the generator cost function and is
given by the equation below.

𝐹 (𝑃g) = 𝑎 𝑃g + 𝑏 𝑃g + 𝑐

F17/1459/2011: MBOGO LAWRENCE MUNENE 21


UNIVERSITY OF NAIROBI HTED with RE-2016

Where 𝐹 (𝑃g) is the fuel cost, 𝑃g is the generator power output. While a, b, and c are the constant
coefficients of the unit. The constant c is equivalent to the fuel consumption of the generating unit
operation without output. These constant coefficients can be obtained as outlined in [09]. A plot of the
fuel cost against for a unit is as shown in figure 1 below. The dotted line represents a system without
the valve point effects. The one with the valve point represents the system that is real and modern. To
model the valve-point effect, an additional sinusoidal term is added to the quadratic electrical
energy cost function, the fuel cost function of ith thermal generating unit is expressed as:

𝐹 (𝑃g) = 𝑎 (𝑃g)2 + 𝑏 (𝑃g) + 𝑐 + | ei sin (F (Pgmin – Pg)) |

The non-smooth electrical energy cost function considering multiple valve-point effects [20] is
shown in Fig. 2.1.1 below.

Figure 2.2.1: Thermal electrical energy cost function of a thermal unit with and without valve-
points

The above curve can be obtained experimentally. The maximum power output and minimum
power output are determined by the design of the unit.

F17/1459/2011: MBOGO LAWRENCE MUNENE 22


UNIVERSITY OF NAIROBI HTED with RE-2016

2.1.2 Economic Dispatch for a Purely Thermal System

In a power system, the operations of various units vary widely depending on the fuel costs, labour
and maintenance costs and capital cost. The formulation of the ED is considered for thermal units
only without any constraints. Consider N thermal units generating at optimum costs. Thus: CT

CT = ∑ 𝐹i (Pgi)
𝑖=1

CT = F1 (Pg1) + F2 (Pg2) + F3 (Pg3) + F4 (Pg4) + … + FN (PgN)

Where CT is fuel cost plus any other cost of unit i and Pgi is the total power production of unit i.
The above equation leads us to the total load, PT demand equation which is given by

PT = Pg1 + Pg2 + Pg3 + Pg4 + … PgN

The total load can be assumed constant for a short period and thus for economic dispatch the
equality constraint of power demand must be satisfied to get the unit output that minimize the total
cost, CT.

To minimize total cost, CT all the units should operate at equal incremental costs also known as
marginal costs. Marginal costs can be defined as the costs incurred to generate one extra megawatt
of electrical power. Therefore:

dC1 dC2 dC3 dCN


= = =
dP1 dP2 dP3 dPN

From the above, we get that the minimum value of the total cost occurs when its differential is
equal to zero. That is;

𝜕𝐶𝑇 𝜕𝐶𝑇 𝜕𝐶𝑇


𝑑𝐶𝑇 = 𝑑𝑃1 + 𝑑𝑃2 + ⋯ + 𝑑𝑃𝑁 = 0
𝜕𝑃1 𝜕𝑃2 𝜕𝑃𝑁

𝜕𝐶1 𝜕𝐶2 𝜕𝐶𝑁


𝜕𝐶𝑇 = 𝑑𝑃1 + 𝑑𝑃2 + ⋯ + 𝑑𝑃𝑁 = 0
𝜕𝑃1 𝜕𝑃2 𝜕𝑃𝑁

Taking PT constant, we see

F17/1459/2011: MBOGO LAWRENCE MUNENE 23


UNIVERSITY OF NAIROBI HTED with RE-2016

d P1 + d P3 + d P3 + … + d PN = 0

It can be shown that

dC1 dC2 dC3 dCN


= = …= =𝜆
dP1 dP2 dP3 dPN

Where 𝜆 denotes the marginal cost or the incremental cost.

2.1.2.1 Constraints on Thermal economic dispatch

The above type of system was uncostrained and in real life situation, it is almost impossible to
have such a problem. This calls for a mention of some of the possible constraints. These include,
the generator ratings of power output, overloading of transmission lines and other involved
equipment and also adverse weather conditions. These constraints are as briefly explained below.

2.1.2.1.1 Generator power ratings.

Given that the design of machines varies widely, a generator output cannot be infinite and
therefore, there is a limit to the maximum amount of power it can generate. Similarly, the
generators have a lower limit in terms of output below which the production would be
uneconomical [18]. This is given as an inequality constraint for a power system. It is usually given
as below.

Pmin ≤ P ≤ Pmax

Where Pmin is the minimum power that the given unit can generate and Pmax is the maximum power
from the same generator.

2.1.2.1.2 Generator Ramp limits

The change in power output for any generator within a finite time is also a key consideration in
any economic dispatch problem. One of the impractical assumption has taken in conventional
economic dispatch problem is that the adjustment of power output are instantaneous [51].The ramp
rates for thermal generating units is given as follows:

(a) as generation increases


Pi – Pio ≤ URi

F17/1459/2011: MBOGO LAWRENCE MUNENE 24


UNIVERSITY OF NAIROBI HTED with RE-2016

(b) as generation decreases


Pi – Pio ≤ DRi

Such that

Pi = current power output

Pio = previous power output

URi = up-ramp limit

DRi = down-ramp limit

2.1.2.1.3 Transmission line losses

These losses are as a result of the load center being far away from the generating units. They can
be modeled using the B coefficients and more details of these are given in the hydrothermal system
that incorporates the renewable resources.

2.2 Hydrothermal Economic Dispatch (HTED)

Hydrothermal economic dispatch is where we have both hydro and thermal units being used in the
generation of power [11]. A hydrothermal system is a more complex one as compared to an all
thermal system since it is dynamic as the water levels keep changing, whereas the thermal problem
is a static one. In this kind of a system the thermal units come in where water in not readily
available because hydro generation is almost at zero cost since water is freely available. The
constraint above for the all thermal system apply as well in the hydrothermal system with an
additional constraint known as the water discharge constraint. A hydrothermal ED problem can be
viewed as the problem of minimizing operation cost of thermal plants under the constraint of water
availability for hydro generation over a given period of time.

2.2.1 Water discharge constraint.

This constraint is well dealt with in the formulation of the objective function of the hydro
generation. It specifies the limits of water discharge so as to attain a certain amount of hydro power
bearing in mind that minimum power is to be generated by conventional method of using fossil
fuels.

F17/1459/2011: MBOGO LAWRENCE MUNENE 25


UNIVERSITY OF NAIROBI HTED with RE-2016

2.3 Economic dispatch of Renewable Energy (Wind and Solar energy)

In this project, the two resources named above are the ones considered in the Hydrothermal
Economic dispatch. The potential in them is increasingly being exploited. Their impact in this type
of ED problem is dependent on their availability as well as their predictability. These renewable
energy resources depend on the data of the climate such as the wind speed for wind energy, solar
radiation and the temperature for solar thermal energy [07]. These resources may not be dispatched
to find their optimal operation costs but their penetration into a hydrothermal power system has a
great impact on the cost of generation using thermal units only. Although renewable sources, e.g.,
wind, tidal, and photovoltaic, are environmentally-friendly practices, the intermittent nature of the
renewable sources choices degrades their applicability as dispatchable options [19]

2.4 Hydrothermal Economic Dispatch with Renewable Energy (HTED with RE)

Penetration of renewable energy makes the HTED problem more complicated and thus careful
study of the effects of these renewable sources. In light of the facts above concerning the RE it is
important to consider the possible other constraints in this kind of a system.

2.4.1 System constraints

These constraints can be widely classified into two categories namely

(i) equality constraints


(ii) inequality constraints

2.4.1.1 Equality Constraints

There is only one equality constraint in this system and it is known as the active power balance
equation. This equation has it that the total power generated must be able to meet the total demand
and the active losses involved in the system. This equation is given as

PD + PL = ∑𝑵 𝑵 𝑵 𝑵
𝒊=𝟏 𝑷TH + ∑𝒊=𝟏 𝑷H + ∑𝒊=𝟏 𝑷W + ∑𝒊=𝟏 𝑷S

Where PD is the total load demand and PL is the total active losses. The first term refers to total
thermal power, second term refers to hydro power, third term refers to wind power and fourth
term refers to solar power respectively.

F17/1459/2011: MBOGO LAWRENCE MUNENE 26


UNIVERSITY OF NAIROBI HTED with RE-2016

2.4.1.2 Inequality Constraints

These are quite a number and their effect on the economic dispatch cannot be assumed. They
include, the generator constraints, the ramp limits, the water discharge constraints, transmission
line losses, power loss constraint, Renewable power constraint, spinning reserve constraint,
generator prohibited zones [19]. Each of these constraints is explained below while much more
details for others are as explained in other sections of this report.

2.4.1.2.1 Generator constraints

This type of constraint has been explained as shown the classical economic dispatch problem
above.

2.4.1.2.2 Generator ramp limits

As known from the practical aspect of operating machines, it is impossible to achieve


instantaneous change in certain parameters. The formulation of this constraint is as illustrated in
subsection 2.1.2.1.2 above.

2.4.1.2.3 Water discharge constraints

The problem of minimizing the operating cost of a hydrothermal system can be viewed as one of
minimizing the fuel cost of thermal plants under the constraint of water availability (storage and
inflow) for hydro generation over a given period of operation [12]. Depending on the type of the
hydro power station, the optimization can be determined accordingly. In this kind of dynamic
problem, it is assumed that the amount of water at the beginning of the dispatch period is equal to
the amount at the end of the dispatch period. This leaves us to deal with water discharge as the
only issue to determine the amount of hydro energy available. This can be modeled as follows.

xmin< x < xmax

where xmin is the minimum discharge possible, x is discharge for generation and xmax is the
maximum possible discharge for the hydrothermal unit. A further understanding of this is given in
the formulation of the cost function for a hydro unit.

F17/1459/2011: MBOGO LAWRENCE MUNENE 27


UNIVERSITY OF NAIROBI HTED with RE-2016

2.4.1.2.4 Transmission line losses

Given that the load centre is located far from the power plants, the power losses encountered during
transmission need to be accounted for. Additionally, Large interconnected networks where power
is transmitted for a long distances, transmission losses are a major factor and affect the optimum
dispatch of generation [21]. The following equation is a representation of the losses as derived
using the B coefficients and expressed as a function of the thermal generating units.

2.4.1.2.5 Renewable Energy constraint

Due to the intermittent nature of the renewable resources, it is important to allocate them for
dispatch as appropriate. The renewable power used for dispatch should not exceed the 30% of total
power demand as seen from many studies reveal. Therefore this can be formulated as

Pw Ps 0.3 PD

Where Pw is the wind power available, Ps is the solar power available and PD is the power demand
for a specific period of time.

2.4.1.2.6 Prohibited Operating Zone and Generation Limits

Each generator has its generation capacity, which cannot be exceeded at any time. Therefore, in
practical operation, adjusting the power output of a unit must avoid all capacity limits and unit
operations in prohibited zones. The feasible operating zones of a unit can be described as follows:

F17/1459/2011: MBOGO LAWRENCE MUNENE 28


UNIVERSITY OF NAIROBI HTED with RE-2016

2.5 Objective functions

2.5.1 Operation cost function for thermal power generation

As mentioned earlier, this fuel cost is represented as quadratic function with the input as the power
output. It is assumed that the labour cost, the maintenance cost and the capital cost are not
considered in this objective function. This function is given as:

𝐹 (𝑃g) = 𝑎 (𝑃g)2 + 𝑏 (𝑃g) + 𝑐

2.5.2 Operation cost function for hydro power generation

The optimal operation of a power system of hydrothermal with representations of individual


hydroelectric power plants and deterministic inputs can be formulated as follows:

J = ∑𝑇𝑡=1 𝑓 [𝑐 (𝑡)],

where t is the Time period (week or month or hour), T is the number of time periods, f is operational
cost function and c (t) is the Non hydro generation such that the non hydro generation refers
thermal generation using coal, oil nuclear power or gas. The total hydro generation is obtained
from the equation:

H (t) = ∑𝑇𝑡=1⌽ [𝑋𝑖 (𝑡), 𝑈𝑖 (𝑡)]

where ⌽I (t) is the hydrogenation function xi is the water storage in reservoir i and ui is the water
release from reservoir i. The hydro-generation is a function of water head and the water release as
given by the equation

⌽ (x, u) = k [h1 (x) – h2 (u)] * min [u, qmax]

such that k is a constant that takes into account gravitational force, density of water, turbine and
generator efficiency and all the conversion factors, h1(x) is the upstream level as a function of
storage, h2(u) is the downstream level as a function of release and qmax is the maximum water
discharge.

The dynamic water balance equations for each reservoir are given by

xi (t + 1) = xi(t) + yi (t) + ∑ uk (t) – ui (t)

F17/1459/2011: MBOGO LAWRENCE MUNENE 29


UNIVERSITY OF NAIROBI HTED with RE-2016

where yi is the incremental water flow into reservoir 1. The storage and releases are bounded due
to operational limits, flood control, navigation as well as other purposes by the constraint:

ximin(t) ≤ xi ≤ ximax(t)

uimin(t) ≤ ui ≤ uimax(t)

2.5.3 Operation cost function for wind power generation

The wind power is dispatched depending on its availability. As a result, the scheduled wind power
may be greater than or less than the generated wind power. To cater for the deviation in wind
power, penalty factors for over-generation (wind power available exceeds the scheduled wind
power) and under-generation (wind power available is less than the scheduled wind power). A cost
coefficient for the wind power generated is also factored in as a representation of the other costs
involved. The above factors put together as a function of wind power constitute the cost function
given as:

Fw (wi) = cw (wi) + co (ws -wi) + cu (wi - ws)

where wi is the total output of the wind generation, cw, co, and cu are the coefficients of generation,
over-generation and under-generation respectively all of which range from 1 to 3 [20] respectively
and ws is the scheduled wind power.

2.5.4 Operation cost function for solar power generation.

This is given by the function:

Fs (si) = cs (si) + cos (sss -si) + cus (si - sss)

where si is the total output of the wind generation, cs, cos, and cus are the coefficients of generation,
over-generation and under-generation respectively all of which range from 1 to 3 [20] respectively
and sss is the scheduled wind power.

2.5.5 Overall cost function for total generation

The total cost function is attained as a summation of the individual cost function and this is as
summarized below.

Tcost = 𝐹 (𝑃g) + J + Fw (wi) + Fs (si)

F17/1459/2011: MBOGO LAWRENCE MUNENE 30


UNIVERSITY OF NAIROBI HTED with RE-2016

such that J is assumed to be zero since the hydro generation costs is assumed to be zero. This
reduces the function which is to be minimized to

Tcost = 𝐹 (𝑃g) + Fw (wi) + Fs (si)

in light of the constraints given in this report.

2.6 Problem Formulation

The objective of the economic dispatch problem in this project is to minimize costs and ensuring
maximum utilization of the available renewable energy. The problem is formulated as a multi-
objective optimization problem. It consists in distributing the power demand and the active
transmission line losses to the renewable energy productions and between the hydro and thermal
power stations in the most economical way, to reduce the generation costs especially using the
thermal units. The generation costs for the hydro power have been considered negligible and thus
it is assumed in this project that we are not incurring any costs to get hydro power. All the available
hydro power under the water discharge constraint is first dispatched and the remaining amount out
of the total demand is generated by the thermal units. The approach used does not consider the
renewable energy while dispatching power. Once the scheduled and available thermal units are
decided and operated, the availability of wind energy and solar energy are considered as an extra
benefit. If solar energy is available, it is used to meet the transmission losses and if the losses are
fully met and there is more solar energy available, the thermal generator producing the maximum
power is de-loaded to the order of the solar energy available after meeting the losses. The wind
energy available is treated in a similar manner, that is, the first thermal generator is de-loaded an
amount equal to the available wind energy. Any other thermal unit can be de-loaded since they are
already dispatched and that means they have equal marginal costs. The generation dispatch is the
fundamental issue during operational process. For this approach to be as practical as possible there
are many wind generators in one farm and the minimum available units are 50 in number.
Similarly, the solar energy is assumed to be from a solar farm with many solar cell arrays. The
wind energy is set to be determined by the available units while solar energy is determined by solar
irradiance. The losses are obtained using the B coefficients formula. Therefore, this project deals
with hydrothermal generation dispatch, under the effect of renewable energy from wind and solar
on the fuel costs. The feasibility of this problem is displayed by testing on IEEE-30 bus test system.

F17/1459/2011: MBOGO LAWRENCE MUNENE 31


UNIVERSITY OF NAIROBI HTED with RE-2016

CHAPTER 3

Methodology
3.1 Optimization Techniques

A large number of optimization techniques have been applied to power systems [10]. These include
dynamic programming techniques, linear programming techniques, newton methods and more
recently the intelligent search methods. Some of the intelligence search methods include the
following: Neural network (NN), Evolutionary Algorithms (EAS), Tabu Search (TS), Particle
swarm Optimization (PSO), Ant Colony Search Method (ACSM), Bee Colony Algorithm (BCA)
[11] and Genetic Algorithm (GA). This section gives an overview of some of the most commonly
used techniques with most inclined on the intelligent search methods and the ones applicable to
such an economic dispatch problem as the handled in this project.

3.1.1 Simulated Annealing (SA)

Simulated annealing techniques were originally inspired by the formation of crystals in solids
during cooling [10]. Annealing is the process of heating up a metal and then cooling it down
slowly. It is the opposite of hardening or quenching. As the metal cools down, the thermal energy
of the molecules reduces and this makes the internal energy low and thus a nice crystal is formed.

In this method, the internal energy corresponds to the objective function while the state represents
the solution to the objective function. Temperature is used as the control parameter and a freezing
point is set to give the heuristic solution. Each iteration consists of the random selection of a
configuration from the neighbourhood of the current configuration and the calculation of the
corresponding change in cost function. The process can be simply described as follows.

Step 1: The initial solution and initial temperature are selected.

Step 2: A trial solution is selected in the neighbourhood.

Step 3: An evaluation condition is set (the difference between B and A must be greater than 0)

Step 4: An equilibrium point (a point where there is no further change is observed) is then reached.

F17/1459/2011: MBOGO LAWRENCE MUNENE 32


UNIVERSITY OF NAIROBI HTED with RE-2016

Step 5: The temperature is decreased until the freezing point is attained.

Step 6: Stop the process.

In this way of operation, two things must be determined and these are the cooling schedule and the
neighborhood selection.

The advantages of Simulated Annealing are its general applicability to deal with arbitrary systems
and cost functions; its ability to statistically guarantee finding an optimal solution and its simplicity
of implementation, even for complex problems. However, it has a major drawback in that it is slow
which translates to huge computational time and it can be easily trapped in a local minimum. In
addition, it does not tell whether it has found an optimal solution.

3.1.2 Tabu Search (TS)

With its roots going back to the late 1960's and early 1970's, the tabu search was proposed in its
present form a few years ago by Glover. It is a heuristic search strategy for efficiently solving
combinatorial optimization problems. [10] This method works by the means of an evaluation
function; that chooses the highest evaluation situation at each iteration. It then selects the more
that produces the most improvement or the least deterioration in the objective function [11]. The
most basic components of the TS are the moves, tabu list and aspiration level (criterion). Moves
are procedures in which the TS method is implemented. They are of two types namely single
moves and exchange moves. A tabu list is a means of storing some of the moves made in order to
prevent going back to a local optimum already achieved. The aspiration criterion is a way of
determining when a tabu move is to be overridden. The main purpose of the criterion is to enable
tabu moves that could possibly lead to an optimal solution.

3.1.3 Genetic Algorithm (GA)

This is a population based search algorithm that has found extensive use in optimization problems.
Instead of iterative changes to a single solution, GAs work with a population of solutions, which
are 'evolved' in a manner analogous to natural selection [10]. This method is inspired of the
biological concept of genetics and reproduction. The population is represented as chromosomes
and the individuals in a population correspond to genes. The evolution usually starts from a
population of randomly generated individuals and happens in generations. In each generation, the

F17/1459/2011: MBOGO LAWRENCE MUNENE 33


UNIVERSITY OF NAIROBI HTED with RE-2016

fitness of every individual in the population is evaluated, multiple individuals are stochastically
selected from the current population (based on their fitness), and modified (recombined and
possibly randomly mutated) to form a new population. The new population is then used in the next
iteration of the algorithm [12].

To illustrate the working process of genetic algorithm, the steps to realize a basic GA are:

Step 1: Represent the problem variable domain as a chromosome of fixed length; choose the size
of the chromosome population N, the crossover probability Pc and the mutation probability Pm.

Step 2: Define a fitness function to measure the performance of an individual chromosome in the
problem domain. The fitness function establishes the basis for selecting chromosomes that will be
mated during reproduction.

Step 3: Randomly generate an initial population of size N: X1, X2, X3… XN ; N = 1, 2, 3,…

Step 4: Calculate the fitness of each individual chromosome: F (X1), F (X2), F (X3)… F (XN).

Step 5: Select a pair of chromosomes for mating from the current population. Parent chromosomes
are selected with a probability related to their fitness. High fit chromosomes have a higher
probability of being selected for mating than less fit chromosomes.

Step 6: Create a pair of offspring chromosomes by applying the genetic operators.

Step 7: Place the created offspring chromosomes in the new population.

Step 8: Repeat Step 5 until the size of the new population equals that of initial population, N.

Step 9: Replace the initial (parent) chromosome population with the new (offspring) population.

Step 10: Go to Step 4, and repeat the process until the termination criterion is satisfied. [13]

The main advantage of GAs is that it can employ implicit parallelism in its operation. Its high
intuitiveness and ease of implementation strengthens its ability to effectively solve highly
nonlinear mixed integer optimization problems. This method however has its shortcomings as
well. These include highly correlated parameters, premature convergence and expensive
computational costs.

F17/1459/2011: MBOGO LAWRENCE MUNENE 34


UNIVERSITY OF NAIROBI HTED with RE-2016

The genetic algorithm differs from other search methods in that it searches among a population of
points, and works with a coding of parameter set, rather than the parameter values themselves. It
also uses objective function information without any gradient in-formation. The transition scheme
of the genetic algorithm is probabilistic, where as traditional methods use gradient information.
Because of these features of genetic algorithm, they are used as general purpose optimization
algorithm. They also provide means to search irregular space and hence are applied to a variety of
function optimization, parameter estimation and machine learning applications [17].

3.1.4 Ant-Colony Search (ACS)

This is an algorithm that is inspired by the behavior of a colony of ants in search for food. It was
proposed by Marco Dorigo in1992 in his PhD thesis [51]. The algorithm mimics the behavior of
real ants. The key considerations are the ability of these almost blind insects with their small
individual capacities are capable of finding the shortest path between their nest and the food source.
The ants colony is able to do this by employing what is known as pheromone trails as they locate
the paths as they wonder randomly. Once the shortest path is located, they are likely not to keep
travelling at random, but to instead follow this trail, returning and reinforcing it if they eventually
find food. This is repeated upon finding an obstacle on the path and also in attempt to adapt to the
changing environmental conditions. The algorithm mimics this behavior and can be simply
modeled in the steps below as outlined in the book Modern Optimization Techniques in Power
Systems.

Step 1: Initialize A (t).

Step 2: Evaluate A (t) based on the objective function.

Step 3: Add trail: Trail quantity is added to the particular directions the ants have selected in
proportion to the ants' fitness.

Step 4: Send ants A (t): According to the objective function, their performance will be weighed as
fitness value which directs influence to the level of trail quantity adding to the particular directions
the ants have selected.

Step 5: Evaporate: Finally, the pheromone trail secreted by an ant eventually evaporates and the
starting point (nest) is updated with the best tour found.

F17/1459/2011: MBOGO LAWRENCE MUNENE 35


UNIVERSITY OF NAIROBI HTED with RE-2016

There are several attractive characteristics of this algorithm and these are: its use of constructive
greedy heuristic approach which helps to find acceptable solutions in the early stages of the
process; the positive feedback by ants gives a rapid discovery of a good solution and to sum it all,
its distributed computation helps to avoid premature convergence [10]. The flow diagram of this
algorithm is as shown below.

Figure 1.6.4: Flow Diagram for the ACS Algorithm

3.1.5 Artificial Neural Networks (ANN)

The Hopfield neural network was first developed in 1982 and has since found applications in many
optimization problems [10]. The original Hopfield network consists of a single layer of simple
processing elements known as neurons and models its working from the functioning of the human
brain perspective. Hopfield networks are single layer, recurrent neural networks. The action of a
Hopfield network is to minimize an energy function. This method is iterative and this process
continues until the outputs do not change on successive iterations at which stage convergence is
said to have occurred. This method has a limitation in that any cost function which contains both
discrete and continuous terms may not be accurately mapped to the energy function of a Hopfield
network. To speed up convergence of the economic dispatch problem solved by Hopfield’s Neural
Networks, two adjustment methods can be used namely the Slope Adjustment Method and Bias
Adjustment Method [16].

F17/1459/2011: MBOGO LAWRENCE MUNENE 36


UNIVERSITY OF NAIROBI HTED with RE-2016

3.1.6 Particle Swarm Optimization (PSO)

This is a modern optimization technique that has found its application in solving economic
dispatch problems that are non linear and dynamic. It belongs to the category of the heuristic and
stochastic methods due to its versatility and applicability to both discrete and continuous data. This
method was first established by Kennedy and Eberhart in 1995 as an alternative to Genetic
Algorithms [16]. PSO is inspired by particles moving around in the search space. The individuals
in a PSO thus have their own positions and velocities. These individuals are denoted as particles.
Traditionally, PSO has no crossover between individuals and has no mutation, and particles are
never substituted by other individuals during the run. More of this method is given in the
subsequent section.

3.1.7 Hybrid Methods

In the simplest of its meaning, the word hybrid refers to combination of two or more elements to
make a stronger and more robust single element. In our case here, hybrid methods or techniques
refers to a combination of two or more optimization methods with the aim of taking advantage of
the pros of each method used in the mix while reducing on computation time hence speeding up
convergence and/or better the quality of the solution [09]. Due to the complexity of real-world
problems and the pro and cons of various search techniques, it is apparent that hybridization is a
way forward to develop more powerful algorithms [10]. This is a totally new area of research that
is being explored and some of these techniques include: integrating GA and PSO to maximize on
the search criteria and reduce on time of calculation and integration of simulated annealing and
genetic algorithm. Hybridisation allows searches that display particular properties to be produced.

3.2 Review on the Particle Swarm Optimization (PSO) Method

PSO algorithm is a heuristic optimization technique introduced by Kennedy and EbberHart in


1995. It is population based search algorithm based on biological behavior of groups of organisms
such as swarms of birds and schools of fish. The behavior of the particles is modeled to solve any
optimization engineering problem of which many problems are such. This method of optimization
is preferred because of its efficiency (short computation time) and better/stable convergence
characteristics. This algorithm being population based search algorithm gives it an advantage of
implicit parallelism which is not available in other algorithms such as Genetic Algorithm. This

F17/1459/2011: MBOGO LAWRENCE MUNENE 37


UNIVERSITY OF NAIROBI HTED with RE-2016

algorithm uses the objective function and the evaluation function (known as fitness function in
GA) to evaluate the candidate solution [13].

In this method, individuals normally referred to as particles, keep shifting in positions (states) with
time in a multi dimensional search space to attain the optimum values. As the particles fly around
the search space, they keep updating their positions and velocities according to two factors as
follows:

a) Individual particle experience and,


b) Characteristics of the neighboring particles (entire population).
Many particles with small variations in their experiences fly together and these constitute a swarm.
The swarm direction is dependent on the individual particles in it and their history experience. As
the particles update their positions, there is the tendency of the swarm to move toward the region
with higher objective function value. Eventually, all the particles gather around the point with the
highest value. The highest value serves as the solution to the objective function.

3.2.1 PSO Terminologies

Algorithm: This is a method of solving a particular problem.

Swarm: A swarm refers to a group of apparently disorganized population of particles clustered


together towards a common optimum while each particle seems to be moving in a random
direction.

Particle: This refers to a candidate solution to the problem at hand and is represented by an m-
dimensional vector where m is the number of optimizing parameters.

State: This is the actual location of the particle in the multi dimensional search space. It is defined
by the position and velocity of the individual particle.

Population: This is a set of n particles at a time t and can be represented as follows:

[X1 (t), X2 (t), X3 (t), X4 (t) ………………… Xn (t)]T

Particle Velocity: This is the speed of the moving particles represented by an m-dimensional real
valued vector.

F17/1459/2011: MBOGO LAWRENCE MUNENE 38


UNIVERSITY OF NAIROBI HTED with RE-2016

Inertial Weight: This can be defined as a control parameter that is used to determine the impact
of the previous velocities on the current velocity. Hence, it influences the tradeoff between the
local and global exploration abilities of the particles. It is usually set at large values in the initial
stages for faster global exploration and to small values for final stages for faster local exploration.

Individual best: This is the best position that is associated with the best fitness value encountered
as the particle flies through the search space size since its initialization.

Global Best: This is the best position among all the individual best positions achieved for any
iteration.

Iteration: It is the act of repeating the process of generating the optimum value by application of
the process of PSO.

Stopping criteria: These are a set of previously determined conditions under which the search for
an optimum value will terminate.

3.2.2 PSO Key Features and Advantages

Particle Swarm Optimization technique has the following key features compared with the
conventional optimization algorithms.

It only requires a fitness function to measure the “quality” of a solution instead of complex
mathematical operations like gradient, Hessian, or matrix inversion. This reduces the
computational complexity and relieves some of the restrictions that are usually imposed on the
objective function like differentiability, continuity, or convexity.

1) It is less sensitive to a good initial solution since it is a population – based method.


2) It can be easily incorporated with other optimization tools to form hybrid ones.
3) It has the ability to escape local minima since it follows probabilistic transition rules.
More interesting PSO advantages can be emphasized when compared to other members of
evolutionary algorithms like the following.

i) It can be easily programmed and modified with basic mathematical and logic operations.
ii) It is inexpensive in terms of computation time and memory.
iii) It requires less parameter tuning.

F17/1459/2011: MBOGO LAWRENCE MUNENE 39


UNIVERSITY OF NAIROBI HTED with RE-2016

iv) It works with direct real - valued numbers, which eliminates the need to do binary
conversion of a classical canonical genetic algorithm.
3.3 Formulation of the PSO

This is an iterative search process and is carried out as follows. Let Pg and V denote a particle
position and its corresponding velocity in a search space, respectively. Hence, the i th particle is
represented as:

Pg = Pgi1, Pgi2, Pgi3, Pgi4 … Pgid, in the ‘d’ dimensional space.

The state of each particle is defined by its position and velocity in the multi dimensional search
space with the initial states given randomly as

Xi0 = Pgimin + rand (Pgimax − Pgimin )

Vi0 = (Pgimin + rand (Pgimax −Pgimin ))/∆t = position/time

In each iteration, the best previous known positions of the ith particle recorded are presented as
Pbest1, Pbest2 , Pbest3, and the best particle among all the particles is represented by Gbestd. After the
first iteration the velocity and position of the each particle is updated and hence, the modified
velocity and the position of each particle can be calculated by using the current velocity and the
distance from Pbestd to Gbestd as shown in the formulas below:

Vi(t + 1) = w*Vid (t) + c1*rand (Pgi - Xik)/ ∆t + c2*rand (Pbestd - Xik)/ ∆t………….3.4 (a)

Xi (t+1) = Xi0 + Vi (t + 1)* ∆t………………3.4 (b)

where w is the inertia weighting factor and its value ranges from 0.4 to 0.9, c1 and c2 are self
confidence factors for the particle velocity and swarm velocity respectively. c1 ranges between 1.5
to 2.0 and c2 ranges between 2.0 and 2.5. The velocity update formula includes some random

F17/1459/2011: MBOGO LAWRENCE MUNENE 40


UNIVERSITY OF NAIROBI HTED with RE-2016

parameters, represented by the uniformly distributed variables, rand , to ensure good coverage of
the design space and avoid entrapment in local optima[21]. The three steps of velocity update,
position update, and fitness calculations are repeated until a desired convergence criterion is met.
In the PSO algorithm implemented in this study, the stopping criteria is that the maximum change
in best fitness should be smaller than specified tolerance, ε, for a specified number of iterations, S.
In this work, S is specified as five thousand iterations and ε is specified as 10-10 for all test
problems.

3.4 Application of PSO to HTED with RE

Step 1: Specify the fuel cost coefficients of each unit and the maximum and minimum limits of
power generation of each generating unit, the B coefficients for computation of power loss and the
PSO parameters as listed below starting with the maximum number of iteration to be performed.

Iterations between updating display 1 000


Maximum number of iterations 100 000
Population size 100
Acceleration constant 1 (local best influence) 2.0
Acceleration constant 2 (global best influence) 2.0
Initial inertia weight 0.9
Final inertia weight 0.4

Table 3.5: PSO Parameters set up

Step 2: initialize the population and the velocity of each particle in the population and also set the
maximum possible velocity of the particles.

Step 3: Perform the first iteration which begins by obtaining the pbest value and gbest value for this
iteration. Set the iteration counter at this point.

Step 4: update the particle velocity as given by the equation given by 3.4 (a) above.

Step 5: update the particle position as given by the equation given by 3.4 (b) above.

F17/1459/2011: MBOGO LAWRENCE MUNENE 41


UNIVERSITY OF NAIROBI HTED with RE-2016

Step 6: check whether the stopping criteria is fulfilled by the final gbest value.

Step 7: if the stopping condition has been fulfilled, return this final gbest value as the optimal
solution to the particular demand. If the condition is not met, get back to step 3 for the next
iteration.

Step 8: Using the B coefficients, calculate and display the active transmission line losses.

3.5 Flow chart for the PSO method

The flow chart that is used for the formulation of the Particle Swarm Optimisation Method is as
shown in the figure 3.6 below.

F17/1459/2011: MBOGO LAWRENCE MUNENE 42


UNIVERSITY OF NAIROBI HTED with RE-2016

F17/1459/2011: MBOGO LAWRENCE MUNENE 43


UNIVERSITY OF NAIROBI HTED with RE-2016

CHAPTER FOUR

Results and Analysis


4.1 The Test system

To verify the feasibility of this project, the results are based on the IEEE 30 bus network and the
dispatch takes into account the transmission line losses. The test includes six thermal units, one
wind farm and one solar farm. The demand is scheduled for a period of one hour. The hydro power
is dispatched first and is determined by water discharge. The remaining power is supplied
thermally using fossil fuels and the effects of the renewable sources are accounted for thereafter
as explained earlier. The generator cost coefficients, maximum and minimum limits are as shown
on table 4.1, the B coefficients are as shown in matrix 4.0

UNIT a (MW/$) b (MW/$) c ($) Pmin (MW) Pmax (MW)


P1 0.0070 7 240 100 500
P2 0.0095 10 200 50 200
P3 0.0090 8.5 220 80 300
P4 0.0090 11 200 50 150
P5 0.0080 10.5 220 50 200
P6 0.0075 12 120 50 120
Table 4.1: Generator coefficients and power limits

B= [0.000140 0.000017 0.000015 0.000019 0.000026 0.000022

0.000017 0.000060 0.000013 0.000016 0.000015 0.000020

0.000015 0.000013 0.000065 0.000017 0.000024 0.000019

0.000019 0.000016 0.000017 0.000071 0.000030 0.000025

0.000026 0.000015 0.000024 0.000030 0.000069 0.000032

0.000022 0.000020 0.000019 0.000025 0.000032 0.000085]

Matrix 4.0: the B coefficients for the 30 bus network

F17/1459/2011: MBOGO LAWRENCE MUNENE 44


UNIVERSITY OF NAIROBI HTED with RE-2016

4.2 IEEE 30 bus network

The one line diagram of an IEEE-30 bus system is shown in Fig. 4.1. as seen from this figure, the
units are connected to the buses 1, 2, 5, 8, 11 and 13 respectively. There are several transmission
lines interconnected to the transformers as shown.

Figure 4.1: One line diagram of a 30 bus system

4.3 Simulation Results

Simulations were carried out on a Intel Core i5, 2.40 GHz, 4 GB RAM processor. The coding is
written in MATLAB 2011 version. The PSO algorithm is used for solving the HTED problem for
the demand of one hour finite periods. The results obtained are as shown on the figures and tables
on the next few pages.

F17/1459/2011: MBOGO LAWRENCE MUNENE 45


UNIVERSITY OF NAIROBI HTED with RE-2016
Power
Demand 600 650 700 730 800 900 1000 1200 1300
Per hour
Hydro 110.569 115.36 100.94 100.94 120.17 120.17 144.207 127.383 124.979
Power (230) (240) (210) (210) (250) (250) (300) (265) (260)

P1 (Unit 1) 183.883 210.261 273.687 264.475 284.169 320.038 343.789 407.424 428.888

P2 (Unit 2) 50.000 50.000 50.000 56.387 71.400 95.384 109.969 151.133 167.588

P3 (Unit 3) 80.000 99.220 127.15 137.18 152.89 176.80 192.694 234.954 251.493

P4 (Unit 4) 50.000 50.000 50.000 50.000 50.000 50.000 59.443 99.566 116.129

P5 (Unit 5) 50.000 50.000 50.000 50.000 50.000 72.453 89.878 133.120 150.001

P6 (Unit 6) 50.00 50.000 50.000 50.000 50.000 50.000 50.000 51.179 69.311

Power 5.369 6.335 7.895 8.680 10.111 13.572 16.6102 27.056 33.039
Loss
Wind 25.447 24.538 24.084 23.175 22.721 26.356 24.993 25.265 27.265
Power (56) (54) (53) (51) (50) (58) (55) (60) (60)

Solar 24.295 24.823 0.000 23.767 26.407 24.295 23.239 23.351 31.689
Power (2300) (2350) (2000) (2250) (2500) (2300) (2200) (2400) (3000)

Total 5810.47 6258.35 7183.79 7283.94 7830.66 9058.61 10007.77 12871.94 14242.32

Cost
Hydro
Thermal 6024.27 6493.31 7192.90 7530.64 8115.61 9311.19 10252.83 13080.69 14485.83

Cost

Table 4.3 Simulation Results

F17/1459/2011: MBOGO LAWRENCE MUNENE 46


UNIVERSITY OF NAIROBI HTED with RE-2016

Figure 4.1: (a) PSO Convergence characteristic at 600MW

Figure 4.1: (b) PSO Convergence characteristic at 900MW

F17/1459/2011: MBOGO LAWRENCE MUNENE 47


UNIVERSITY OF NAIROBI HTED with RE-2016

Figure 4.1: (c) PSO Convergence characteristic at 1000MW

Figure 4.1: (d) PSO Convergence characteristic at 1300MW

F17/1459/2011: MBOGO LAWRENCE MUNENE 48


UNIVERSITY OF NAIROBI HTED with RE-2016

Figure 4.2: Variation of cost with respect to active power losses (sample of 1300MW)

Figure 4.3: Variation of Total Cost with respect to the hourly demand (sample of 1300MW)

F17/1459/2011: MBOGO LAWRENCE MUNENE 49


UNIVERSITY OF NAIROBI HTED with RE-2016

Figure 4.4: The typical wind power curve

Figure 4.5: The typical cost curve for a thermal generator

F17/1459/2011: MBOGO LAWRENCE MUNENE 50


UNIVERSITY OF NAIROBI HTED with RE-2016

4.4 Simulation Results: Analysis

The power values in table 4.2 are given in Megawatts and the cost values are in dollars per hour.
It can be clearly noted that the power demand is proportional to the total cost incurred for
generation with the hydrothermal cost only being higher than that of the hydrothermal with
renewable resources. The effect of the inclusion of the renewable resources is reduction on cost
primarily as seen by comparing between the pure hydrothermal cost against the Total cost for the
various power demand values.

The values in brackets in the row for the hydro power, wind power and solar power represent the
variable parameters of water discharge, number of wind generators available and the amount of
solar radiation available for solar power generation respectively. It can be noted clearly that all are
proportional to the power generation in each method with the minimum values set at 200m/s, 50
generators each rated at 0.85 MW and 2200 respectively. From the results obtained, the first unit
carries the biggest load for each power demand while the last three units each generates its
minimum of fifty megawatts for the power demand of less than 800MW. The power loss also
increases with increase in demand. The special case where the solar energy is 0 MW and the overall
effect on the cost is well illustrated by the cost values.

The convergence characteristics displayed by the method is that the different power demand values
have the gbest values at different iteration numbers with the samples of the 900MW, 1000MW,
1300MW and 600MW as shown in figures 4.1 (a), (b), (c) and (d). The variation of total generation
cost with loses is linear as shown and its variation with the power demand is also linear as shown.
The typical wind power curve is as shown in figure 4.2. This figure just shows the region on which
wind power is available the section when the power is zero and maximum have been omitted.
Alongside figure 4.2 is the typical cost curve for a thermal generator and as shown, it is linear.

4.5 Conclusion from results and analysis

From the results obtained, we can conclude that PSO is a viable method for finding the solution to
an economic dispatch problem that involves the renewable energy. In addition, renewable energy
has a significant effect on the cost of power generation and overall performance of the power
system. The Particle Swarm Optimisation Method is both practical and reliable as a power
optimization method.

F17/1459/2011: MBOGO LAWRENCE MUNENE 51


UNIVERSITY OF NAIROBI HTED with RE-2016

CHAPTER FIVE

Conclusion and Further Work


5.1 Conclusion of this Report

In this project, the PSO optimization method has been successfully used to solve the formulated
hydrothermal economic dispatch problem incorporating the renewable resources. The effect of the
penetration of the wind and solar power energy as the renewable resources considered has been
well reflected by the values of cost as shown in the results. Various constraints to the dynamic
economic dispatch have been explored and as many as practical have been applied in finding a
solution to the economic dispatch problem of the nature in this report. Renewable energy is
becoming more preferred in the minimization of costs and they also therefore greatly impact the
emissions from plants that use fossil fuels. To understand the impact of the renewable energy
sources, the results obtained for the hydrothermal costs are compared with the cost results for the
hydrothermal with the renewable sources.

5.2 Further work

The problem solved in this project is multi objective in the sense that it seeks to minimize the cost
while at the same time maximizing on the renewable energy. This has made its solution to be
constrained to renewable sources of wind and solar energy only. Since the renewable energy
exploration is ongoing and gaining preference with time, I therefore recommend a solution to
economic dispatch problem that includes other types of renewable energy such as geothermal gas
and tidal energy.

In addition, hybrid methods can be used so as to ensure that an optimal solution to the dispatch
problem is found, such that most of the constraints to the problem are taken care of and this makes
the solution as practical as possible. Hybrid methodology is the useful tool for efficient solution
by exploiting the strengths of PSO with the powers of other techniques [51] alongside the strengths
of other methods incorporated.

I also recommend that a solution that takes care of emission minimization be sought so as to ensure
environmental effects in economic dispatch problem are taken care of. This will ensure that clean
energy is obtained and that other methods of optimization are used in solving this type of a problem

F17/1459/2011: MBOGO LAWRENCE MUNENE 52


UNIVERSITY OF NAIROBI HTED with RE-2016

which is taking root as time spans. This will cause a reduction in the gaseous emissions from diesel
and other fossil fuel power plants which in turn leads to environmental conservation as the cost is
being minimized.

To make the method used in this project both flexible and versatile, an improvement of it to allow
data input such as wind speeds and the bus datas is recommended. This will make it apply for
different places where establishment of wind and solar farms is feasible. A provision for solar cell
arrays and other factors influencing solar power can also be factored in. in improving this method,
wind power and solar power can be treated in a different manner other than the used in this project.

F17/1459/2011: MBOGO LAWRENCE MUNENE 53


UNIVERSITY OF NAIROBI HTED with RE-2016

References
01. F. R. Pazheri, M. F. Othman, N. H. Malik, E. A. Al-Ammar and Rohikaa M. R, Optimization of
Fuel Cost and Transmission Loss in power dispatch with Renewable Energy and Energy
Storage, IEEE Transmission Power Journal, pp 293-296, 2012

02. D.P Kothari and I.J Nagrath, Modern Power Systems Analysis, New Delhi, Mc Graw Hill
Education Ltd, 3rd Edition pp 242-276.

03. S. Chanda, D. Bose, S. Chakraborty & D. Abhinandan, A Self Healing Methodology for
Economic Integration of Wind Farms to Modern Power Networks, International Journal
of Electrical and Electronics Engineering,Volume 1, Issue 3, 2012

04. Syafawati A.N., I.Daut, S.S. Shema, M. Irwanto, Z. Farhana, N. Razliana and Shatri C.,
Potential of Wind and Solar Energy using Weibull and hagreaves Method Analysis, The
5th International Power Engineering and Optimization Conference, 2011

05. A.V. Hertzog, T.E. Lipman and D.M Kammen, Renewable Energy Resources,
Encyclopedia of life Support Systems, 2011

06. T. Senjyu, S. Chakraborty, A. Y. Saber, H. Toyama, A. Yona and T. Funabashi, Thermal


Unit Commitment Strategy with Solar And Wind Energy Systems Using Genetic
Algorithm Operated Particle Swarm Optimization, 2nd IEEE International Conference on
Power and Energy, December 1-3, 2008

07. B. Saoussen, A. Hsan Hadj, and O. Abderrazak, Economic Dispatch for Power System
included Wind and Solar Thermal Energy, Leonardo Journal of Sciences, Issue 14,
January-June 2009, p. 204-220

F17/1459/2011: MBOGO LAWRENCE MUNENE 54


UNIVERSITY OF NAIROBI HTED with RE-2016

08. Fahad S. Abu-Mouti and Mohamed E. El-Hawary, Optimal Dynamic Economic Dispatch
Including Renewable Energy Source using Artificial Bee Colony Alorithm, IEEE
Transactions on Power, 2012

09. O.N. Ronald, Hydrothermal Economic Dispatch using Generic Algorithm, University of
Nairobi, 2015

10. Professor S. G. Tzafestas, Modern Optimisation Techniques in Power Systems,


International Series on Microprocessor-Based And Intelligent Systems Engineering, edited
by Y.H. Song,Volume 20

11. W. K. Kennedy. Hydrothermal Economic Dispatch Using P.S.O, University of Nairobi,


2015

12. K. Sapna K, A Comparative Study of Genetic Algorithm and the Particle Swarm
Optimization, AKGEC International Journal of Technology, Vol. 2, No. 2, pp 21-24

13. K O. Jones, Comparison Of Genetic Algorithm And Particle Swarm Optimisation,


International Conference on Computer Systems and Technologies - CompSysTech’ 2005

14. R. Sakshi, Performance Analysis of GA and PSO over Economic Load Dispatch,
International Journal of Engineering Research & Technology (IJERT) Vol. 2, Issue 5, May
2013.

15. M. K. Danson, Optimal Solution To Economic Load Dispatch Using Modified Particle
Swarm Optimization Method, University of Nairobi, 2015

16. Z. Jizhong, Optimization Of Power System Operation, IEEE Press Series On Engineering,
Piscataway, John Wiley & Sons, 2009

F17/1459/2011: MBOGO LAWRENCE MUNENE 55


UNIVERSITY OF NAIROBI HTED with RE-2016

17. A. Eduardo, E. Lopez, L. Miguel and J. Vannier, A Stochastic Economic Dispatch Model
with Renewable Energies Considering Demand and Generation Uncertainties, IEEE
Transmission Power Journal, 2011

18. Zwe-Lee Gaing, Particle Swarm Optimization to Solving the Economic Dispatch
Considering the Generator Constraints, IEEE Transactions On Power Systems, Vol. 18,
No. 3, August 2003

19. K. Cheng-Chien and T. Teng-Fa, Generation Dispatch under Large Penetration of Wind
Power Considering Emission and Economy, International Conference on Energy and
Environment Technology, 2009

20. A. A. ElDesouky, Security and Stochastic Economic Dispatch of Power System Including
Wind and Solar Resources with Environmental Consideration, International Journal of
Renewable Energy Research Vol.3, No.4, 2013

21. H. Rania, B. Cohanim, O. Weck, and G. Venter, A Comparison Of Particle Swarm


Optimization And The Genetic Algorithm, American Institute of Aeronautics and
Astronautics, 2004

F17/1459/2011: MBOGO LAWRENCE MUNENE 56


UNIVERSITY OF NAIROBI HTED with RE-2016

Appendices

HTED with RE MATLAB code used together with P.S.O.

%%%%%%%%%%%%%%%%%%%%%%%% HTED WITH end


RE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
power=pOUT/(10^6);
% MBOGO LAWRENCE MUNENE
fprintf('==========================
% F17/1459/2011 ===================================
=');
% FEE 560: PROJECT MATLAB CODE
fprintf ('\n The Average Hydro
% FINAL COPY. Power Generated is = %8.3f
clear MW/hour\n',power);

clc fprintf('==========================
===================================
global data Pd B =\n');
propmt='Enter the power demand Pd = PD - power;
value (in MW)= ';
tic
PD = input(propmt);
data=[0.007 7 240 100 500
%% HYDRO POWER GENERATION
0.0095 10 200 50 200
%P=W*Q*H*n*g Watts where w=water
density, q=discharge in m^3/s, 0.009 8.5 220 80 300
n=efficiency, 0.009 11 200 50 150
%g=gravitational acceleration 0.008 10.5 220 50 200
propmt='\n Enter the water dicharge 0.0075 12 120 50 120];
value=';
B=1e-4*[0.14 0.17 0.15
Q=input(propmt); 0.19 0.26 0.22
w=1000; % Water density 0.17 0.6 0.13 0.16 0.15
H=70; % The water head of the Plant 0.2

g=9.81;% gravitational acceleration 0.15 0.13 0.65 0.17


0.24 0.19
n=0.7; % the operating efficiency
of the plant 0.19 0.16 0.17 0.71 0.3
0.25
if Q<200
0.26 0.15 0.24 0.3 0.69
pOUT=0; 0.32
elseif Q>1000 0.22 0.2 0.19 0.25 0.32
0.85];
pOUT=0;
n=length(data(:,1));
else
a=data(:,1)';
pOUT=w.*Q'*H*n*g;
b=data(:,2)';

F17/1459/2011: MBOGO LAWRENCE MUNENE 57


UNIVERSITY OF NAIROBI HTED with RE-2016
c=data(:,3)'; prated=1*10^6;

l=data(:,4)'; vin=2;

u=data(:,5)'; vr=14;

ran=[l' u']; vout=25;

tic

% P1=[1000 10000 100 2 2 .9 .4 1500 % wind velocity constraint.


1e-25 200 1e50 0 0];
pwvbins=prated*(vbins.^2-
Pdef = [1000 100000 100 2 2 0.9 0.4 vin.^2)/(vr.^2-vin.^2);
1500 1e-10 3000 NaN 0 0];
if data<=vin
[OUT]=pso_Trelea_vectorized('f7',n,
1,ran,0,Pdef); pwbins=0

OPTIMout= abs(OUT); elseif vbins>vout

P = [OPTIMout(1:6)]' pwvbins=0;

[F Pl] = f7(P) elseif data>=vr

fprintf('\n======================== pwvbins=prated;
===================================
elseif data<=vr
===');
pwvbins=prated;
fprintf('\n The total active losses
for this demand = %8.6g MW \n', else pwbins=0;
Pl);
end;
fprintf('==========================
=================================== pdwind=fitdist(v0, 'weibull');
=\n');

toc
% wind power calculation

probdistvbins=pdf(pdwind,vbins);
%% COST OF WIND GENERATION
intterm=probdistvbins.*pwvbins;
format long;
avgpower=trapz(vbins,intterm);
data=[9.891 10.785 6.861 14.482
pwd=(avgpower/(10^6));
12.184 4.602 7.232 8.036 12.333
11.074 10.040]; prompt='\n Enter the available wind
generators = ';
v0= data';
Twind =input(prompt)*pwd;% power
vbins=0:0.5:max(data);
from 50 wind generators
% weibull data distribution.
fprintf('\n\n======================
pdwind = fitdist(v0, 'weibull'); ===================================
====');

% turbine parameters

F17/1459/2011: MBOGO LAWRENCE MUNENE 58


UNIVERSITY OF NAIROBI HTED with RE-2016
fprintf('\n The average wind power %for 50320 panels in series
available is = %8.3f
Megawatts\n',Twind); n=50300;% numner of panels

fprintf('========================== Psolar=n*output/10^6;
=================================== fprintf('\n\n======================
='); ===================================
% COST FUNCTION ====');

actualpw=Twind*1e6; fprintf('\n The average solar power


generated is = %8.3f MW\n',Psolar);
schedw=0.02*PD*1e6;
fprintf('==========================
cwi=1.75;% cost coefficient ===================================
=');
cpw=3;% penalty cost coefficient
for over generation

crw=1.5;% reserve cost coefficient %COST FUNCTION


for under generation
actualps=Psolar*1e6;
cost2=(cwi*actualpw +
cpw*(actualpw-schedw) + scheds=Psolar*1e6;% scheduled solar
crw*(schedw-actualpw))/10^6; power

fprintf('\n The average wind power cwi=1;%cost coefficient


generation cost is = %8.3f
cpw=3;% penalty cost coefficient
Dollars/hr\n',cost2);
for over generation
%% COST OF SOLAR GENERATION
crw=1.5;% reserve cost coefficient
prompt='\n Enter the available for under generation
solar radiation = ';
cost1=(cwi*actualps +
data=input(prompt); cpw*(actualps-scheds) +
crw*(scheds-actualps))/10^6;
tjref=25;
if cost1<0
tj=27;
cost1=0;
p1=0.105;
else cost1=cost1;
%dispersion of the panels
end
x=tj-tjref;
fprintf('\n The average solar power
y=1; generation cost is = %8.3f
Dollars/hr\n',cost1);
z=1+y;
%% deloading the maximum loaded
if data<=2000
generator
p=0;
ASP=Psolar - Pl;
else p=p1.*data*z;
EW =P(1)- schedw/10^6 - ASP;
end
F1 = a(1)*EW^2 + b(1)*EW + c(1);
output=max(max(p));

F17/1459/2011: MBOGO LAWRENCE MUNENE 59


UNIVERSITY OF NAIROBI HTED with RE-2016
F11 = a(1)*P(1)^2 + b(1)*P(1) + % Typical cost curve for generator
c(1); 1

Totalcost=F - F11 + F1 + cost1 + figure(3)


cost2;
plot
fprintf('\n************************ ([0:(P(1)/length([0:F11])):P(1)],[-
*********************************** 1:F11],'-');
****');
title ('Typical cost curve for a
fprintf('\n THE OVERALL COST OF Thermal Unit');
GENERATION = %8.2f Dollars/hr\n',
Totalcost); ylabel ('cost in dollars'); xlabel
('power in megawatts')
fprintf('**************************
*********************************** figure(4)
**\n'); plot (-
y=0:100:F11; 1:PD,[0:Totalcost/length([0:PD]):To
talcost]);
x=0:P(1)/(length(F11)-1):P(1);
title ('TOTAL COST VERSUS POWER
disp(EW); DEMAND'); xlabel('Power Demand in
MW'); ylabel('Cost in Dollars');
%%FIGURES AND PLOTS
figure(5)
% wind turbine power curve.
plot (-
figure(2) 1:Pl,[0:Totalcost/length([0:Pl]):To
plot(vbins, pwvbins, '*'); talcost]);
xlabel('wind speed in m/s'); title ('TOTAL COST VERSUS POWER
ylabel('average wind power'); LOSS'); xlabel('Power Loss in MW');
title('Wind turbine power curve'); ylabel('Cost in Dollars');

The Main PSO Algorithm Code

function if nargin == 2 % only


[OUT,varargout]=pso_Trelea_vectoriz specified functname and D
ed(functname,D,varargin)
VRmin=ones(D,1)*-100;

VRmax=ones(D,1)*100;
rand('state',sum(100*clock));
VR=[VRmin,VRmax];
if nargin < 2
minmax = 0;
error('Not enough arguments.');
P = [];
end
mv = 4;

plotfcn='goplotpso';
% PSO PARAMETERS elseif nargin == 3 % specified
functname, D, and mv

F17/1459/2011: MBOGO LAWRENCE MUNENE 60


UNIVERSITY OF NAIROBI HTED with RE-2016
VRmin=ones(D,1)*-100; if isnan(mv)

VRmax=ones(D,1)*100; mv=4;

VR=[VRmin,VRmax]; end

minmax = 0; VR=varargin{2};

mv=varargin{1}; minmax=varargin{3};

if isnan(mv) P = varargin{4}; % psoparams

mv=4; plotfcn='goplotpso';

end elseif nargin == 7 % Functname, D,


mv, Varrange, minmax, and
P = []; psoparams, plotfcn
plotfcn='goplotpso'; mv=varargin{1};
elseif nargin == 4 % specified if isnan(mv)
functname, D, mv, Varrange
mv=4;
mv=varargin{1};
end
if isnan(mv)
VR=varargin{2};
mv=4;
minmax=varargin{3};
end
P = varargin{4}; % psoparams
VR=varargin{2};
plotfcn = varargin{5};
minmax = 0;
elseif nargin == 8 % Functname, D,
P = []; mv, Varrange, minmax, and
plotfcn='goplotpso'; psoparams, plotfcn, PSOseedValue

elseif nargin == 5 % Functname, D, mv=varargin{1};


mv, Varrange, and minmax if isnan(mv)
mv=varargin{1}; mv=4;
if isnan(mv) end
mv=4; VR=varargin{2};
end minmax=varargin{3};
VR=varargin{2}; P = varargin{4}; % psoparams
minmax=varargin{3}; plotfcn = varargin{5};
P = []; PSOseedValue = varargin{6};
plotfcn='goplotpso'; else
elseif nargin == 6 % Functname, D, error('Wrong # of input
mv, Varrange, minmax, and psoparams arguments.');
mv=varargin{1}; end

F17/1459/2011: MBOGO LAWRENCE MUNENE 61


UNIVERSITY OF NAIROBI HTED with RE-2016

% sets up default pso params % error checking

Pdef = [100 2000 24 2 2 0.9 0.4 if ((minmax==2) & isnan(errgoal))


1500 1e-25 250 NaN 0 0];
error('minmax= 2, errgoal=
Plen = length(P); NaN: choose an error goal or set
minmax to 0 or 1');
P = [P,Pdef(Plen+1:end)];
end

df = P(1);
if ( (PSOseed==1) &
me = P(2); ~exist('PSOseedValue') )
ps = P(3); error('PSOseed flag set but no
ac1 = P(4); PSOseedValue was input');

ac2 = P(5); end

iw1 = P(6);

iw2 = P(7); if exist('PSOseedValue')

iwe = P(8); tmpsz=size(PSOseedValue);

ergrd = P(9); if D < tmpsz(2)

ergrdep = P(10); error('PSOseedValue column


size must be D or less');
errgoal = P(11);
end
trelea = P(12);
if ps < tmpsz(1)
PSOseed = P(13);
error('PSOseedValue row
length must be # of particles or
less');
% used with trainpso, for neural
net training end
if strcmp(functname,'pso_neteval') end
net = evalin('caller','net');

Pd = evalin('caller','Pd'); % set plotting flag


Tl = evalin('caller','Tl'); if (P(1))~=0
Ai = evalin('caller','Ai'); plotflg=1;
Q = evalin('caller','Q'); else
TS = evalin('caller','TS'); plotflg=0;
end end

F17/1459/2011: MBOGO LAWRENCE MUNENE 62


UNIVERSITY OF NAIROBI HTED with RE-2016
% preallocate variables for speed
up
% initialize population of
tr = ones(1,me)*NaN; particles and their velocities at
time zero,

% format of pos= (particle#,


% take care of setting max velocity dimension)
and position params here
% construct random population
if length(mv)==1 positions bounded by VR
velmaskmin = -mv*ones(ps,D); % pos(1:ps,1:D) =
min vel, psXD matrix normmat(rand([ps,D]),VR',1);
velmaskmax = mv*ones(ps,D); %
max vel
if PSOseed == 1 % initial
elseif length(mv)==D
positions user input, see comments
velmaskmin = repmat(forcerow(- above
mv),ps,1); % min vel
tmpsz =
velmaskmax = repmat(forcerow( size(PSOseedValue);
mv),ps,1); % max vel
pos(1:tmpsz(1),1:tmpsz(2)) =
else PSOseedValue;

error('Max vel must be either a end


scalar or same length as prob
dimension D');

end % construct initial random


velocities between -mv,mv
posmaskmin =
repmat(VR(1:D,1)',ps,1); % min vel(1:ps,1:D) =
pos, psXD matrix normmat(rand([ps,D]),...

posmaskmax = [forcecol(-
repmat(VR(1:D,2)',ps,1); % max pos mv),forcecol(mv)]',1);

posmaskmeth = 3; % 3=bounce method


(see comments below inside epoch
loop) % initial pbest positions vals

pbest = pos;

% PLOTTING

message = sprintf('For iteration: % VECTORIZE THIS, or at least


%%g/%g , GBest value = vectorize cost funct call
%%20.20g.\n',me); out = feval(functname,pos); %
returns column of cost values (1
for each particle)
% INITIALIZE INITIALIZE INITIALIZE %---------------------------
INITIALIZE INITIALIZE INITIALIZE

F17/1459/2011: MBOGO LAWRENCE MUNENE 63


UNIVERSITY OF NAIROBI HTED with RE-2016
pbestval=out; % initially, pbest % assign gbest to net at each
is same as pos iteration, these interim
assignments

% are for plotting mostly


% assign initial gbest here also
(gbest and gbestval) if
strcmp(functname,'pso_neteval')
if minmax==1
net=setx(net,gbest);
% this picks gbestval when we
want to maximize the function end

[gbestval,idx1] = %tr(1) = gbestval;


max(pbestval); % save for output

elseif minmax==0 bestpos(1,1:D) = gbest;

% this works for straight


minimization
% this part used for implementing
[gbestval,idx1] = Carlisle and Dozier's APSO idea
min(pbestval);
% slightly modified, this tracks
elseif minmax==2 the global best as the sentry
whereas
% this works when you know
target but not direction you need % their's chooses a different point
to go to act as sentry

% good for a cost function that % see "Tracking Changing Extremea


returns distance to target that can with Adaptive Particle Swarm
be either Optimizer",

% negative or positive % part of the WAC 2002 Proceedings,


(direction info) June 9-13, http://wacong.com

[temp,idx1] = min((pbestval- sentryval = gbestval;


ones(size(pbestval))*errgoal).^2);
sentry = gbest;
gbestval = pbestval(idx1);

end
if (trelea == 3)

% calculate Clerc's constriction


% preallocate a variable to keep coefficient chi to use in his form
track of gbest for all iters
kappa = 1; % standard val = 1,
bestpos = change for more or less
zeros(me,D+1)*NaN; constriction

gbest = pbest(idx1,:); % if ( (ac1+ac2) <=4 )


this is gbest position
chi = kappa;
% used with trainpso, for neural
net training else

psi = ac1 + ac2;

F17/1459/2011: MBOGO LAWRENCE MUNENE 64


UNIVERSITY OF NAIROBI HTED with RE-2016
chi_den = abs(2-psi-sqrt(psi^2
- 4*psi)); %assignin('base','bestpos',bestpos(
i,1:D+1));
chi_num = 2*kappa;
%-------------------------------
chi = chi_num/chi_den; -----------------------------------
end ------

end % this section does the plots


during iterations

if plotflg==1
% INITIALIZE END INITIALIZE END
if (rem(i,df) == 0 ) |
INITIALIZE END INITIALIZE END
(i==me) | (i==1)
rstflg = 0; % for dynamic
environment checking
fprintf(message,i,gbestval);
% start PSO iterative procedures
cnt = cnt+1; % count how
cnt = 0; % counter used for many times we display (useful for
updating display according to df in movies)
the options

cnt2 = 0; % counter used for the


stopping subroutine based on error eval(plotfcn); % defined
convergence at top of script

iwt(1) = iw1;

for i=1:me % start epoch loop end % end update display


(iterations) every df if statement

end % end plotflg if statement

out =
feval(functname,[pos;gbest]);
% check for an error space that
outbestval = out(end,:); changes wrt time/iter

out = out(1:end-1,:); % threshold value that


determines dynamic environment

% sees if the value of gbest


tr(i+1) = gbestval; % changes more than some threshold
keep track of global best val value
te = i; % % for the same location
returns epoch number to calling
program when done chkdyn = 1;

bestpos(i,1:D+1) = rstflg = 0; % for dynamic


[gbest,gbestval]; environment checking

if chkdyn==1

F17/1459/2011: MBOGO LAWRENCE MUNENE 65


UNIVERSITY OF NAIROBI HTED with RE-2016
threshld = 0.05; % percent if minmax == 1
current best is allowed to change,
.05 = 5% etc [gbestval,idx1] =
max(pbestval);
letiter = 5; % # of
iterations before checking elseif minmax==0
environment, leave at least 3 so [gbestval,idx1] =
PSO has time to converge min(pbestval);
outorng = abs( 1- elseif minmax==2 % this
(outbestval/gbestval) ) >= section needs work
threshld;
[temp,idx1] =
samepos = (max( sentry == min((pbestval-
gbest )); ones(size(pbestval))*errgoal).^2);

gbestval =
pbestval(idx1);
if (outorng & samepos) &
rem(i,letiter)==0 end
rstflg=1;

% disp('New Environment: gbest = pbest(idx1,:);


reset pbest, gbest, and vel');

%% reset pbest and pbestval


if warranted % used with trainpso, for
neural net training
% outpbestval = feval(
functname,[pbest] ); % assign gbest to net at
each iteration, these interim
% Poutorng = abs( 1-
assignments
(outpbestval./pbestval) ) >
threshld; % are for plotting mostly
% pbestval = if
pbestval.*~Poutorng + strcmp(functname,'pso_neteval')
outpbestval.*Poutorng;
net=setx(net,gbest);
% pbest =
pbest.*repmat(~Poutorng,1,D) + end
pos.*repmat(Poutorng,1,D);
end % end if outorng

pbest = pos; % reset


sentryval = gbestval;
personal bests to current positions
sentry = gbest;
pbestval = out;

vel = vel*10; %
agitate particles a little (or a end % end if chkdyn
lot)

% recalculate best vals

F17/1459/2011: MBOGO LAWRENCE MUNENE 66


UNIVERSITY OF NAIROBI HTED with RE-2016
% find particles where we have [tempi,dum] =
new pbest, depending on minmax find(pbestval<=out); % new max
choice pbestvals

% then find gbest and gbestval pbestval(tempi,1) =


out(tempi,1); % update pbestvals
%[size(out),size(pbestval)]
pbest(tempi,:) =
if rstflg == 0 pos(tempi,:); % update pbest
if minmax == 0 positions

[tempi] =
find(pbestval>=out); % new min
[iterbestval,idx1] =
pbestvals
max(pbestval);
pbestval(tempi,1) =
if gbestval <= iterbestval
out(tempi); % update pbestvals
gbestval = iterbestval;
pbest(tempi,:) =
pos(tempi,:); % update pbest gbest =
positions pbest(idx1,:);

% used with trainpso,


for neural net training
[iterbestval,idx1] =
min(pbestval); % assign gbest to net
at each iteration, these interim
assignments
if gbestval >= iterbestval % are for plotting
mostly
gbestval = iterbestval;
if
gbest =
strcmp(functname,'pso_neteval')
pbest(idx1,:);

% used with trainpso,


net=setx(net,gbest);
for neural net training
end
% assign gbest to net
at each iteration, these interim end
assignments
elseif minmax == 2 % this
% are for plotting won't work as it is, fix it later
mostly
egones =
if errgoal*ones(ps,1); % vector of
strcmp(functname,'pso_neteval') errgoals

sqrerr2 =
net=setx(net,gbest); ((pbestval-egones).^2);
end sqrerr1 = ((out-
egones).^2);
end

elseif minmax == 1

F17/1459/2011: MBOGO LAWRENCE MUNENE 67


UNIVERSITY OF NAIROBI HTED with RE-2016
[tempi,dum] =
find(sqerr1 <= sqrerr2); % find
particles closest to targ % % build a simple predictor
10th order, for gbest trajectory
pbestval(tempi,1) =
out(tempi,1); % update pbestvals % if i>500

pbest(tempi,:) = % for dimcnt=1:D


pos(tempi,:); % update pbest
% pred_coef = polyfit(i-
positions
250:i,(bestpos(i-
250:i,dimcnt))',20);

sqrerr = % % pred_coef =
((pbestval-egones).^2); % need to polyfit(200:i,(bestpos(200:i,dimcnt
do this to reflect new pbests ))',20);

[temp,idx1] = % gbest_pred(i,dimcnt) =
min(sqrerr); polyval(pred_coef,i+1);

iterbestval = % end
pbestval(idx1); % else

% gbest_pred(i,:) =
zeros(size(gbest));
if (iterbestval-errgoal)^2
<= (gbestval-errgoal)^2 % end
gbestval = iterbestval;

gbest = %gbest_pred(i,:)=gbest;
pbest(idx1,:);

% used with trainpso, %assignin('base','gbest_pred',gbest


for neural net training _pred);
% assign gbest to net
at each iteration, these interim
assignments % % convert to non-inertial
frame
% are for plotting
mostly % gbestoffset = gbest -
gbest_pred(i,:);
if
strcmp(functname,'pso_neteval') % gbest = gbest - gbestoffset;

% pos = pos +
net=setx(net,gbest); repmat(gbestoffset,ps,1);
end % pbest = pbest +
repmat(gbestoffset,ps,1);
end

end

end
%PSOPSOPSOPSOPSOPSOPSOPSOPSOPSOPSOP

F17/1459/2011: MBOGO LAWRENCE MUNENE 68


UNIVERSITY OF NAIROBI HTED with RE-2016
SOPSOPSOPSOPSOPSOPSOPSOPSOPSOPSOPSO
PSOPSO +ac2.*rannum2.*(repmat(gbest,ps,1)-
pos)) ; % social
% get new velocities,
positions (this is the heart of the else
PSO algorithm)
% common PSO algo with
% each epoch get new set of inertia wt
random numbers
% get inertia weight, just
rannum1 = rand([ps,D]); % a linear funct w.r.t. epoch
for Trelea and Clerc types parameter iwe

rannum2 = rand([ps,D]); if i<=iwe

if trelea == 2 iwt(i) = ((iw2-


iw1)/(iwe-1))*(i-1)+iw1;
% from Trelea's paper,
parameter set 2 else

vel = 0.729.*vel... iwt(i) = iw2;


% prev vel
end

+1.494.*rannum1.*(pbest-pos)... % random number including


% independent acceleration constants

ac11 = rannum1.*ac1; %
+1.494.*rannum2.*(repmat(gbest,ps,1 for common PSO w/inertia
)-pos); % social ac22 = rannum2.*ac2;
elseif trelea == 1

% from Trelea's paper,


vel = iwt(i).*vel...
parameter set 1
% prev vel
vel = 0.600.*vel...
+ac11.*(pbest-
% prev vel
pos)... %
independent
+1.700.*rannum1.*(pbest-pos)...
% independent
+ac22.*(repmat(gbest,ps,1)-pos);
% social
+1.700.*rannum2.*(repmat(gbest,ps,1
end
)-pos); % social

elseif trelea ==3

% Clerc's Type 1" PSO % limit velocities here


using masking
vel = chi*(vel...
% prev vel vel = ( (vel <=
velmaskmin).*velmaskmin ) + ( (vel
> velmaskmin).*vel );
+ac1.*rannum1.*(pbest-pos)...
% independent

F17/1459/2011: MBOGO LAWRENCE MUNENE 69


UNIVERSITY OF NAIROBI HTED with RE-2016
vel = ( (vel >= pos = (
velmaskmax).*velmaskmax ) + ( (vel maxposmask_throwaway.*posmaskmin )
< velmaskmax).*vel ); + ( maxposmask_keep.*pos );

elseif posmaskmeth == 3

% update new position (PSO % this is the bounce


algo) method, particles bounce off the
boundaries with -vel
pos = pos + vel;
pos = (
minposmask_throwaway.*posmaskmin )
+ ( minposmask_keep.*pos );
% position masking, limits
positions to desired search space pos = (
maxposmask_throwaway.*posmaskmax )
% method: 0) no position + ( maxposmask_keep.*pos );
limiting, 1) saturation at limit,

% 2) wraparound at
limit , 3) bounce off limit vel =
(vel.*minposmask_keep) + (-
minposmask_throwaway = pos
vel.*minposmask_throwaway);
<= posmaskmin; % these are psXD
matrices vel =
(vel.*maxposmask_keep) + (-
minposmask_keep = pos
vel.*maxposmask_throwaway);
> posmaskmin;
else
maxposmask_throwaway = pos
>= posmaskmax; % no change, this is the
original Eberhart, Kennedy method,
maxposmask_keep = pos
< posmaskmax; % it lets the particles
grow beyond bounds if psoparams (P)

% especially Vmax, aren't


if posmaskmeth == 1 set correctly, see the literature
% this is the saturation end
method

pos = (
minposmask_throwaway.*posmaskmin )
+ ( minposmask_keep.*pos ); %PSOPSOPSOPSOPSOPSOPSOPSOPSOPSOPSOP
SOPSOPSOPSOPSOPSOPSOPSOPSOPSOPSOPSO
pos = (
PSOPSO
maxposmask_throwaway.*posmaskmax )
+ ( maxposmask_keep.*pos ); % check for stopping criterion
based on speed of convergence to
elseif posmaskmeth == 2
desired
% this is the wraparound
% error
method
tmp1 = abs(tr(i) - gbestval);
pos = (
minposmask_throwaway.*posmaskmax ) if tmp1 > ergrd
+ ( minposmask_keep.*pos );

F17/1459/2011: MBOGO LAWRENCE MUNENE 70


UNIVERSITY OF NAIROBI HTED with RE-2016
cnt2 = 0;

elseif tmp1 <= ergrd eval(plotfcn);


cnt2 = cnt2+1; end
if cnt2 >= ergrdep

if plotflg == 1 break

end
fprintf(message,i,gbestval);

disp(' ');

disp(['--> Solution % this is stopping criterion


likely, GBest hasn''t changed by at for constrained from both sides
least ',... if minmax == 2
num2str(ergrd),' for if ((tr(i)<errgoal) &
',... (gbestval>=errgoal)) |
num2str(cnt2),' ((tr(i)>errgoal) ...
epochs.']); & (gbestval <=
eval(plotfcn); errgoal))

end if plotflg == 1

break
fprintf(message,i,gbestval);
end
disp(' ');
end
disp(['--> Error Goal
reached, successful
termination!']);
% this stops if using
constrained optimization and goal
is reached
eval(plotfcn);
if ~isnan(errgoal)
end
if ((gbestval<=errgoal) &
(minmax==0)) | ((gbestval>=errgoal) break
& (minmax==1)) end

end % end if minmax==2


if plotflg == 1 end % end ~isnan if

fprintf(message,i,gbestval);
% % convert back to inertial
disp(' '); frame
disp(['--> Error Goal % pos = pos -
reached, successful repmat(gbestoffset,ps,1);
termination!']);

F17/1459/2011: MBOGO LAWRENCE MUNENE 71


UNIVERSITY OF NAIROBI HTED with RE-2016
% pbest = pbest - end
repmat(gbestoffset,ps,1);
den=abs(large-small);
% gbest = gbest + gbestoffset;
range=newminmax(2)-newminmax(1);
end % end epoch loop
if den==0
%% clear temp outputs
out=x;
% evalin('base','clear temp_pso_out
temp_te temp_tr;'); else

% output & return z21=(x-a)/(den);

OUT=[gbest';gbestval];
out=z21*range+newminmax(1)*ones(siz
varargout{1}=[1:te]; e(z21));

varargout{2}=[tr(find(~isnan(tr)))] end
;

return
%----------------------------------
NORMMAT.M -----------------------------------
-----------------------------------
This function takes a matrix and
elseif flag==1
reformats the data to fit between a new
range a=min(x,[],1);

function b=max(x,[],1);
[out,varargout]=normmat(x,newminmax
,flag) for i=1:length(b)

if flag==0 if abs(a(i))>abs(b(i))

a=min(min((x))); large(i)=a(i);

b=max(max((x))); small(i)=b(i);

if abs(a)>abs(b) else

large=a; large(i)=b(i);

small=b; small(i)=a(i);

else end

large=b; end

small=a; den=abs(large-small);

end temp=size(newminmax);

temp=size(newminmax); if temp(1)*temp(2)==2

if temp(1)~=1
newminmaxA(1,:)=newminmax(1).*ones(
error('Error: for method=0, size(x(1,:)));
range vector must be a 2 element
row vector');

F17/1459/2011: MBOGO LAWRENCE MUNENE 72


UNIVERSITY OF NAIROBI HTED with RE-2016
large(i)=b(i);
newminmaxA(2,:)=newminmax(2).*ones(
size(x(1,:))); small(i)=a(i);

elseif temp(1)>2 end

error('Error: for method=1, end


range matrix must have 2 rows and den=abs(large-small);
same columns as input matrix');
temp=size(newminmax);
else
if temp(1)*temp(2)==2
newminmaxA=newminmax;

end newminmaxA(:,1)=newminmax(1).*ones(
range=newminmaxA(2,:)- size(x(:,1)));
newminmaxA(1,:);

for j=1:length(x(:,1)) newminmaxA(:,2)=newminmax(2).*ones(


size(x(:,1)));
for i=1:length(b)
elseif temp(2)>2
if den(i)==0
error('Error: for method=2,
out(j,i)=x(j,i); range matrix must have 2 columns
and same rows as input matrix');
else
else
z21(j,i)=(x(j,i)-
a(i))./(den(i)); newminmaxA=newminmax;

end
out(j,i)=z21(j,i).*range(1,i)+newmi
nmaxA(1,i);

end range=newminmaxA(:,2)-
newminmaxA(:,1);
end
for j=1:length(x(1,:))
end
for i=1:length(b)
%----------------------------------
----------------------------------- if den(i)==0
-----------------------------------
out(i,j)=x(i,j);
elseif flag==2
else
a=min(x,[],2);
z21(i,j)=(x(i,j)-
b=max(x,[],2); a(i))./([forcecol(den(i))]);

for i=1:length(b)
out(i,j)=z21(i,j).*range(i,1)+newmi
if abs(a(i))>abs(b(i)) nmaxA(i,1);
large(i)=a(i); end
small(i)=b(i); end
else

F17/1459/2011: MBOGO LAWRENCE MUNENE 73


UNIVERSITY OF NAIROBI HTED with RE-2016
end

end

%----------------------------------
-----------------------------------
-----------------------------------

varargout{1}=a;

varargout{2}=b;

return

FORCECOL.M
Function to force a vector to be a single
column
function[out]=forcecol(in)

len=prod(size(in));

out=reshape(in,[len,1]);

FORCEROW.M
function to force a vector to be a single row
function[out]=forcerow(in)

len=prod(size(in));

out=reshape(in,[1,len]);

F7.m

This function calculates the Power losses

function [y Pl]=f7(in)

global data B Pd;

a=data(:,1);

b=data(:,2);

c=data(:,3);

y1=in.*in*diag(a)+in*diag(b);

Pl1=(in*B).*in;

Pl=sum(Pl1');

lam=abs(Pd+Pl-sum(in'))';

y=(sum(y1')+sum(c))'+100*lam;

F17/1459/2011: MBOGO LAWRENCE MUNENE 74


UNIVERSITY OF NAIROBI HTED with RE-2016

THE END
THANK YOU

F17/1459/2011: MBOGO LAWRENCE MUNENE 75

You might also like