university of nairobi substation design saidi...
TRANSCRIPT
UNIVERSITY OF NAIROBI
SUBSTATION DESIGN
PRJ 100
BY:
SAIDI FELIX JUMA
REG. NO. F17/9366/2002
SUPERVISOR: DR. CYRUS WEKESA
EXAMINER: DR. MAURICE .K. MANGOLI
MAY, 2009
DEPARTMENT OF ELECTRICAL AND INFORMATION ENGINEERING
PROJECT REPORT SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENT FOR THE AWARD OF BACHELOR OF SCIENCE
DEGREE IN ELECTRICAL AND ELECTRONIC ENGINEERING, UNIVERSITY OF NAIROBI.
i
I dedicate this project to all those who stood by me in my times of need especially my parents.
I thank God for always being there.
ii
ACKNOWLEDGEMENTS
The completion of this work would not have been possible without the assistance of many people who devoted their time, energy and knowledge. Very special thanks to Dr Cyrus Wekesa lecturer, School of Engineering, University of Nairobi and supervisor of my project.
I would also like to acknowledge all my lecturers who have been a fountain of knowledge for me to quench my thirst for knowledge. The knowledge I have gained as a student from them is truly immense.
I thank my friends who constantly edged me onwards.
iii
Table of Contents DEDICATION...................................................................................................................i
ACKNOWLEDGEMENT.................................................................................................ii
ABSTRACT......................................................................................................................vi
CHAPTER ONE: INTRODUCTION ............................................................................................. 1
1.1 General background..................................................................................................... 1
1.2 Objective of the project ............................................................................................... 2
1.3 Usual design procedure ............................................................................................... 2
1.3.1 Bisector perpendicular Rule .................................................................................. 2
Chapter 2 LITERATURE REVIEW ............................................................................................. 4
2.1 Electrical substation ..................................................................................................... 4
2.1.1 Elements of a substation ....................................................................................... 4
2.1.2 Types of substations ................................................................................................. 5
2.1.3 Layout ................................................................................................................... 6
2.1.4 Switching function................................................................................................. 7
2.2 Genetic algorithm ........................................................................................................ 8
2.2.1 Initialization ........................................................................................................ 10
2.2.2 Selection ............................................................................................................. 10
2.2.3 Reproduction ...................................................................................................... 11
2.2.4 Termination ........................................................................................................ 15
2.2.5 Observations ....................................................................................................... 16
2.2.6 Variants .............................................................................................................. 18
Chapter 3 : METHODOLOGY ................................................................................................ 20
3.1 Optimal location of distribution substations ............................................................... 20
3.1.1 Simple generational genetic algorithm pseudocode ............................................ 21
3.2 The Genetic Algorithm - a brief overview ................................................................... 21
3.2.1 What's the Crossover Rate? ................................................................................ 22
3.2.2 What's the Mutation Rate? ................................................................................. 22
iv
3.3 From Theory to Practice ............................................................................................. 23
3.3.1 Stage 1: Encoding ................................................................................................ 23
3.3.2 A Quick Word about Decoding ............................................................................ 24
3.3.3 Stage 2: Deciding on a Fitness Function ............................................................... 25
3.3.4 Stage 3: Getting down to business....................................................................... 26
3.3.4.6 Mutation:.....................................................................................................30
3.3.5 HOW THE DEVELOPED ALGORITHM WORKS......................................................... 31
Chapter 4 RESULTS AND ANALYSIS....................................................................................... 32
4.1 Upper level working ................................................................................................... 32
4.1.2 Data worksheets needed ..................................................................................... 33
4.2 DATA IN ..................................................................................................................... 34
4.2.1 Loads .................................................................................................................. 34
4.2.2 Current_Substation ............................................................................................. 35
4.2.3 Candidates .......................................................................................................... 36
4.3 Running the program ................................................................................................. 36
4.4 Distribution substation placement plot ...................................................................... 37
4.5 RESULTS FILE DATA .................................................................................................... 39
4.5.1 Transformer Capacities (KVA) .............................................................................. 39
4.5.2 Transformer Powers (KW) ................................................................................... 39
4.5.3 Substation coordinates worksheet ...................................................................... 40
4.5.4 LOAD (X-Y) and SS (X-Y) LINKS ............................................................................. 41
4.6 Analysis of tables and figures ..................................................................................... 41
Chapter 5 CONCLUSIONS ..................................................................................................... 43
5.1 Conclusion ................................................................................................................. 43
5.2 Challenges faced ........................................................................................................ 43
5.3 Recommendations for future work ............................................................................ 44
REFERENCES ........................................................................................................................ 45
APPENDIX A ......................................................................................................................... 46
6.1 Genetic algorithm codes written in MATLAB .............................................................. 46
6.1.1 SP_main .............................................................................................................. 46
6.1.2 SP_Create ........................................................................................................... 55
6.1.3 SP_Initialize ......................................................................................................... 55
v
6.1.4 SP_fitness ........................................................................................................... 55
6.1.5 SP_Crossover ...................................................................................................... 57
6.1.6 SP_Mutation ....................................................................................................... 57
6.1.7 SP_stepup ........................................................................................................... 57
6.1.8 SP_2kva .............................................................................................................. 58
6.1.9 SP_instcost .......................................................................................................... 58
6.1.10 DSP ................................................................................................................... 58
6.1.11 SP_tlosscost1 .................................................................................................... 61
6.1.12 SP_losscost2 ..................................................................................................... 61
vi
Abstract
A genetic algorithm methodology is presented, conceived to assist the electric system planning engineers in the selection of the distribution substation locations, taking into account the current substation locations and the candidate points of new ones. The objective of the project was to develop an algorithm for distribution substation location.
At first the bisector perpendicular rule which was investigated and it was seen from literature that it is not an effective method for determining substation location. However it usually provided a good starting/initial solution which should be subject to further refinement.
The choice of using genetic algorithm was made based on the fact that GAs by definition is a search technique used in computing to find exact or approximate solutions to optimization and search problems.The substation location is an optimization problem of continuous variables (the substation geographical co-ordinates).
The report describes how the genetic algorithm was developed and shows that the project was accomplished.
1
CHAPTER ONE: INTRODUCTION
1.1 General background The distribution system is the most extensive part of an electrical system and it is the
main loss of electric energy .Therefore the application of optimisation techniques in
the design and expansion of such subsystem can lead to significant economic gains,
finding networks that minimize immediate costs (facility installation costs) and
further costs (related to energy losses and system maintenance).
Electrical energy distribution systems are, intrinsically, systems in steady evolution.
They are frequently exposed to several changes, such as the appearance of new
consumer centres, a change of load pattern in existing centres, a change in geographic
distribution of loads in existing centres, and so forth. That situation does not favour
the application of efficient design methodologies, since the system would be
frequently redesigned in some small part. Traditional approaches only consider this
fragment of the system for planning the expansion, disregarding a lot of possible
solutions to this combinatorial problem, often resulting in more expensive and lossy
networks than would be obtained with global design techniques.
In some cases the existing substation facilities are not sufficient to supply a service
region with energy. Regions where the cities are growing are a good example of such
cases. This phenomenon occurs more often in developing countries, but the economic
fluctuations that are intrinsic to globalisation provoke demographic changes even in
developed nations. Existing electrical distribution systems which are operating in
places where such changes are in progress must follow the eventual increase in the
load, keeping some slack capacity to allow future load increments, in a trade-off
between the minimisation of the present installation costs and the minimisation of the
future needs of facility redesign. In these cases new substations (substation) must be
installed and the distribution system must be resized, or completely replaced in some
critical cases, to supply the new demand.
2
System expansion in these cases involves two sub problems:
• The substation location
• The network topology design.
These problems should not be treated separately since they exhibit a strong
interaction: when the solution of one of them is changed, the solution of the other also
changes.
However due to the fact that network topology design is not within the scope of this
project it will not be delved into in this project. This will be taken up as further work
after the objective of optimal substation location has been achieved.
1.2 Objective of the project The aim of the project was to design an algorithm that could be used for the planning
of the location of distribution substations in a network.
The substation location is an optimisation problem of continuous variables (the
substation geographical co-ordinates). As the substation location varies, the lengths of
the conductors which immediately connect the substation to the network nodes vary
continuously too. This influences the problem of optimal network topology design.
1.3 Usual design procedure
1.3.1 Bisector perpendicular Rule In current engineering practice there is no globally accepted criterion to define the
substation position. Generally the proposed solutions are based on designer
experience. A criterion usually adopted is based on a graphical method, called the
bisector perpendicular rule. The method is briefly described here. This traditional
procedure is based on the idea of assisting the consumer with the nearest substation,
which is supposed to guarantee the minimum distribution line distance, reducing the
losses, failure rates and the installation costs. The bisector perpendicular rule can be
divided into some basic steps as follows:
a) Estimate a feasible initial position for the substation.
b) Draw a line between the estimated substation position and each neighbour
substation.
c) Bisect each line perpendicularly with another line.
d) The set of bisections defines the service area of the substation.
3
e) If this area is not the desired one the substation must be moved to a correcting
direction and the steps (b)-(e) must be re-executed.
f) The load assisted by the substation is the sum of all loads in its service area.
This procedure can be time-consuming for the designer and is not an efficient tool in
the search of optimal solutions. However, the solution that is found often represents a
good initial solution which may be subject to further refinement.
This report uses a, genetic algorithm (GA) to solve the optimal substation location
problem. It’s seen that the approach taken her considers only one of the two sub
problems mentioned (i.e. substation location).
4
LITERATURE REVIEW
2.1 Electrical substation
An electrical substation is a subsidiary station of an electricity generation,
transmission and distribution system where voltage is transformed from high to low or
the reverse using transformers. Electric power may flow through several substations
between generating plant and consumer, and may be changed in voltage in several
steps.
A substation that has a step-up transformer increases the voltage while decreasing the
current, while a step-down transformer decreases the voltage while increasing the
current for domestic and commercial distribution. The word substation comes from
the days before the distribution system became a grid. The first substations were
connected to only one power station where the generator was housed, and were
subsidiaries of that power station.
2.1.1 Elements of a substation
Substations generally contain one or more transformers, and have switching,
protection and control equipment. In a large substation, circuit breakers are used to
interrupt any short-circuits or overload currents that may occur on the network.
Smaller distribution stations may use recloser circuit breakers or fuses for protection
of branch circuits. Substations do not (usually) have generators, although a power
plant may have a substation nearby. A typical substation will contain line termination
structures, high-voltage switchgear, one or more power transformers, low voltage
switchgear, surge protection, controls, grounding (earthing) system, and metering.
Other devices such as power factor correction capacitors and voltage regulators may
also be located at a substation.
Substations may be on the surface in fenced enclosures, underground, or located in
special-purpose buildings. High-rise buildings may have indoor substations. Indoor
substations are usually found in urban areas to reduce the noise from the transformers,
5
for reasons of appearance, or to protect switchgear from extreme climate or pollution
conditions.
Where a substation has a metallic fence, it must be properly grounded to protect
people from high voltages that may occur during a fault in the transmission system.
Earth faults at a substation can cause ground potential rise at the fault location.
Currents flowing in the earth's surface during a fault can cause metal objects to have a
significantly different voltage than the ground under a person's feet; this touch
potential presents a hazard of electrocution.
2.1.2 Types of substations
2.1.2.1 Transmission substation
A transmission substation connects two or more transmission lines. The simplest case
is where all transmission lines have the same voltage. In such cases, the substation
contains high-voltage switches that allow lines to be connected or isolated for
maintenance. A transmission station may have transformers to convert between two
transmission voltages, or equipment such as phase angle regulators to control power
flow between two adjacent power systems.
Transmission substations can range from simple to complex. A small "switching
station" may be little more than a bus plus some circuit breakers. The largest
transmission substations can cover a large area (several acres/hectares) with multiple
voltage levels, and a large amount of protection and control equipment (capacitors,
relays, switches, breakers, voltage and current transformers).
2.1.2.2 Distribution substation
A distribution substation transfers power from the transmission system to the
distribution system of an area. It is uneconomical to directly connect electricity
consumers to the high-voltage main transmission network, unless they use large
amounts of energy; so the distribution station reduces voltage to a value suitable for
local distribution.
The input for a distribution substation is typically at least two transmission or
subtransmission lines. Input voltage may be, for example, 220kv or 132kv, or
6
whatever is common in the area. The output is a number of feeders. Distribution
voltages are typically medium voltage, between 33kv, 3.3kv or 66kv depending on the
size of the area served and the practices of the local utility.
The feeders will then run overhead, along streets (or under streets, in a city) and
eventually power the distribution transformers at or near the customer premises.
Besides changing the voltage, the job of the distribution substation is to isolate faults
in either the transmission or distribution systems. Distribution substations may also be
the points of voltage regulation, although on long distribution circuits (several
km/miles), voltage regulation equipment may also be installed along the line.
Complicated distribution substations can be found in the downtown areas of large
cities, with high-voltage switching, and switching and backup systems on the low-
voltage side. More typical distribution substations have a switch, one transformer, and
minimal facilities on the low-voltage side.
2.1.3 Layout
The first step in planning a substation layout is the preparation of a one-line diagram
which shows in simplified form the switching and protection arrangement required, as
well as the incoming supply lines and outgoing feeders or transmission lines. It is a
usual practice by many electrical utilities to prepare one-line diagrams with principal
elements (lines, switches, circuit breakers, and transformers) arranged on the page
similarly to the way the apparatus would be laid out in the actual station.
Incoming lines will almost always have a disconnect switch and a circuit breaker. In
some cases, the lines will not have both; with either a switch or a circuit breaker being
all that is considered necessary. A disconnect switch is used to provide isolation, since
it cannot interrupt load current. A circuit breaker is used as a protection device to
interrupt fault currents automatically, and may be used to switch loads on and off.
Where a large fault current flows through the circuit breaker this may be detected
through the use of current transformers. The magnitude of the current transformer
outputs may be used to 'trip' the circuit breaker resulting in a disconnection of the load
supplied by the circuit break from the feeding point. This seeks to isolate the fault
point from the rest of the system, and allow the rest of the system to continue
7
operating with minimal impact. Both switches and circuit breakers may be operated
locally (within the substation) or remotely from a supervisory control centre.
Once past the switching components, the lines of a given voltage connect to one or
more buses. These are sets of bus bars, usually in multiples of three, since three-phase
electrical power distribution is largely universal around the world.
The arrangement of switches, circuit breakers and buses used affects the cost and
reliability of the substation. For important substations a ring bus, double bus or so-
called "breaker and a half" setup can be used, so that the failure of any one circuit
breaker does not interrupt power to branch circuits for more than a brief time, and so
that parts of the substation may be de-energized for maintenance and repairs.
Substations feeding only a single industrial load may have minimal switching
provisions, especially for small installations.
Once having established buses for the various voltage levels, transformers may be
connected between the voltage levels. These will again have a circuit breaker, much
like transmission lines, in case a transformer has a fault (commonly called a 'short
circuit').
Along with this, a substation always has control circuitry needed to command the
various breakers to open in case of the failure of some component.
2.1.4 Switching function
An important function performed by a substation is switching, which is the
connecting and disconnecting of transmission lines or other components to and from
the system. Switching events may be "planned" or "unplanned".
A transmission line or other component may need to be de-energized for maintenance
or for new construction; for example, adding or removing a transmission line or a
transformer.
To maintain reliability of supply, no company ever brings down its whole system for
maintenance. All work to be performed, from routine testing to adding entirely new
substations, must be done while keeping the whole system running.
8
Perhaps more importantly, a fault may develop in a transmission line or any other
component. Some examples of this: a line is hit by lightning and develops an arc, or a
tower is blown down by a high wind. The function of the substation is to isolate the
faulted portion of the system in the shortest possible time.
There are two main reasons: a fault tends to cause equipment damage; and it tends to
destabilize the whole system. For example, a transmission line left in a faulted
condition will eventually burn down, and similarly, a transformer left in a faulted
condition will eventually blow up. While these are happening, the power drain makes
the system more unstable. Disconnecting the faulted component, quickly, tends to
minimize both of these problems.
2.2 Genetic algorithm
A genetic algorithm (GA) is a search technique used in computing to find exact or
approximate solutions to optimization and search problems. Genetic algorithms are a
particular class of evolutionary algorithms that use techniques inspired by
evolutionary biology such as inheritance, mutation, selection, and crossover (also
called recombination).
Computer programs that "evolve" in ways that resemble natural selection can solve
complex problems even their creators do not fully understand
by John H. Holland
Genetic algorithms are implemented as a computer simulation in which a population
of abstract representations (called chromosomes) of candidate solutions (called
individuals) to an optimization problem evolves toward better solutions. Usually,
solutions are represented in binary as strings of 0s and 1s, but other encodings are also
possible. In this report that traditional representation of using bit strings is adopted.
The evolution usually starts from a population of randomly generated individuals and
happens in generations. In each generation, the fitness of every individual in the
population is evaluated, multiple individuals are selected from the current population
(based on their fitness), and modified (recombined and possibly randomly mutated) to
9
form a new population. The new population is then used in the next iteration of the
algorithm. Each successive generation should have a much better average fitness than
the previous one.
An analogy can be used here of children inheriting most of the desirable traits of their
parents and very few of the undesirable ones. It should be noted that a little of the less
fit attributes are introduced to the next generation to avoid running into a plateau
situation where all individuals are fit and successive generations yield no difference.
Commonly, the algorithm terminates when either a maximum number of generations
has been produced, or a satisfactory fitness level has been reached for the population.
If the algorithm has terminated due to a maximum number of generations, a
satisfactory solution may or may not have been reached.
Genetic algorithms find application in quite a number of places; computational
science, engineering, economics, chemistry, manufacturing, mathematics, physics and
other fields.
Typical genetic algorithm requirements:
1. A genetic representation of the solution domain,
2. A fitness function to evaluate the solution domain.
A standard representation of the solution is as an array of bits. Arrays of other types
and structures can be used in essentially the same way. The main property that makes
these genetic representations convenient is that their parts are easily aligned due to
their fixed size, which facilitates simple crossover operation. Variable length
representations may also be used, but crossover implementation is more complex in
this case.
The fitness function is defined over the genetic representation and measures the
quality of the represented solution. The fitness function is always problem dependent.
In some problems, it is hard or even impossible to define the fitness expression; in
these cases, interactive genetic algorithms are used.
10
Once we have the genetic representation and the fitness function defined, GA
proceeds to initialize a population of solutions randomly, and then improve it through
repetitive application of mutation, crossover, inversion and selection operators
2.2.1 Initialization Initially many individual solutions are randomly generated to form an initial
population. The population size depends on the nature of the problem, but typically
contains several hundreds or thousands of possible solutions. Traditionally, the
population is generated randomly, covering the entire range of possible solutions (the
search space). Occasionally, the solutions may be "seeded" in areas where optimal
solutions are likely to be found.
2.2.2 Selection During each successive generation, a proportion of the existing population is selected
to breed a new generation. Individual solutions are selected through a fitness-based
process, where fitter solutions (as measured by a fitness function) are typically more
likely to be selected. Certain selection methods rate the fitness of each solution and
preferentially select the best solutions. Other methods rate only a random sample of
the population, as this process may be very time-consuming.
Most functions are designed so that a small proportion of less fit solutions are
selected. This helps keep the diversity of the population large, preventing premature
convergence on poor solutions. Popular and well-studied selection methods include
roulette wheel selection and tournament selection.
2.2.2.1 Roulette Wheel selection This is a way of choosing members from the population of chromosomes in a way
that is proportional to their fitness. It does not guarantee that the fittest member goes
through to the next generation merely that it has a very good chance of doing so. The
Roulette Wheel Selection operation is as shown below:
Imagine that the population’s total fitness score is represented by a pie chart (or
roulette wheel). Now you assign a slice of the wheel to each member of the
population. The size of the slice is proportional to that chromosomes fitness score. I.e.
the fitter a member is the bigger the slice of pie it gets. Now, to choose a chromosome
all you have to do is spin the ball and grab the chromosome at the point it stops.
11
In roulette wheel selection, individuals are given a probability of being selected that is
directly proportionate to their fitness. Two individuals are then chosen randomly
based on these probabilities and produce offspring. Pseudo-code for a roulette wheel
selection algorithm is shown below.
for all members of population sum += fitness of this individual end for for all members of population probability = sum of probabilities + (fitness / sum) sum of probabilities += probability end for loop until new population is full do this twice number = Random between 0 and 1 for all members of population if number > probability but less than next probability then you have been selected end for end create offspring end loop
While this code is very general and will obviously not compile, it illustrates the basic
structure of a selection algorithm.
2.2.3 Reproduction
The next step is to generate a second generation population of solutions from those
selected through genetic operators:
• Crossover (also called recombination)
• And/or mutation.
12
2.2.3.1 CROSSOVER
Crossover is a genetic operator that combines (mates) two chromosomes (parents) to
produce a new chromosome (offspring). The idea behind crossover is that the new
chromosome may be better than both of the parents if it takes the best characteristics
from each of the parents. Crossover occurs during evolution according to a user-
definable crossover probability. Sometimes, based on a set probability, no crossover
occurs and the parents are copied directly to the new population. The probability of
crossover occurring is usually 60% to 70%.
2.2.3.1.1OnePoint
A crossover operator that randomly selects a crossover point within a chromosome
then interchanges the two parent chromosomes at this point to produce two new
offspring.
Consider the following 2 parents which have been selected for crossover. The “|”
symbol indicates the randomly chosen crossover point.
Parent 1: 11001|010
Parent 2: 00100|111
After interchanging the parent chromosomes at the crossover point, the following
offspring are produced:
Offspring1: 11001|111
Offspring2: 00100|010
2.2.3.1.2 Two Point
A crossover operator that randomly selects two crossover points within a chromosome
then interchanges the two parent chromosomes between these points to produce two
new offspring.
13
Consider the following 2 parents which have been selected for crossover. The “|”
symbols indicate the randomly chosen crossover points.
Parent 1: 110|010|10
Parent 2: 001|001|11
After interchanging the parent chromosomes between the crossover points, the
following offspring are produced:
Offspring1: 110|001|10
Offspring2: 001|010|11
2.2.3.1.3 Uniform A crossover operator that decides (with some probability – known as the mixing ratio)
which parent will contribute each of the gene values in the offspring chromosomes.
This allows the parent chromosomes to be mixed at the gene level rather than the
segment level (as with one and two point crossover). For some problems, this
additional flexibility outweighs the disadvantage of destroying building blocks.
Consider the following 2 parents which have been selected for crossover:
Parent 1: 11001010
Parent 2: 00100111
If the mixing ratio is 0.5, approximately half of the genes in the offspring will come
from parent 1 and the other half will come from parent 2. Below is a possible set of
offspring after uniform crossover:
2.2.3.1.4 Arithmetic
A crossover operator that linearly combines two parent chromosome vectors to
produce two new offspring according to the following equations:
Offspring1 = a * Parent1 + (1- a) * Parent2
Offspring2 = (1 – a) * Parent1 + a * Parent2
14
where a is a random weighting factor (chosen before each crossover operation).
Consider the following 2 parents (each consisting of 4 float genes) which have been
selected for crossover:
Parent 1: (0.3)(1.4)(0.2)(7.4)
Parent 2: (0.5)(4.5)(0.1)(5.6)
If a = 0.7, the following two offspring would be produced:
Offspring1: (0.36)(2.33)(0.17)(6.86)
Remember offspring1=a*parent1 + (1-a)*parent2
Offspring1=0.7[(0.3) (1.4) (0.2) (7.4)] + (1-0.7) [(0.5) (4.5) (0.1) (5.6)]
Offspring 1= (0.21) (0.98) (0.14) (5.18) + (0.15) (1.35) (0.03) (1.68)
Offspring 1= (0.36) (2.33) (0.17) (6.86)
Offspring2: (0.402) (2.981) (0.149) (6.842)
The value of offspring 2 is calculated in the same way as I have shown in offspring1.
2.2.3.1.5 Heuristic A crossover operator that uses the fitness values of the two parent chromosomes to
determine the direction of the search. The offspring are created according to the
following equations:
Offspring1 = BestParent + r * (BestParent – WorstParent)
Offspring2 = BestParent
where: r is a random number between 0 and 1.
It is possible that Offspring1 will not be feasible. This can happen if r is chosen such
that one or more of its genes fall outside of the allowable upper or lower bounds. For
15
this reason, heuristic crossover has a user settable parameter (n) for the number of
times to try and find an r that results’ in a feasible chromosome. If a feasible
chromosome is not produced after n tries, the WorstParent is returned as Offspring1.
NB: the WorstParent is returned so as to maintain variety because BestParent has
already been returned as Offspring2.
For each new solution to be produced, a pair of "parent" solutions is selected for
breeding from the pool selected previously. By producing a "child" solution using the
above methods of crossover and mutation, a new solution is created which typically
shares many of the characteristics of its "parents". New parents are selected for each
child, and the process continues until a new population of solutions of appropriate size
is generated.
These processes ultimately result in the next generation population of chromosomes
that is different from the initial generation. Generally the average fitness will have
increased by this procedure for the population, since only the best organisms from the
first generation are selected for breeding, along with a small proportion of less fit
solutions, for reasons already mentioned above.
2.2.3.2 MUTATION After selection and crossover, we now have a new population full of individuals.
Some are directly copied, and others are produced by crossover. In order to ensure
that the individuals are not all exactly the same, we allow for a small chance of
mutation. You loop through all the genes of all the individuals, and if that gene is
selected for mutation, you can either change it by a small amount or replace it with a
new value. The probability of mutation is usually between 1 and 2 tenths of a percent.
A visual for mutation is shown below.
BEFORE: 1101 0011 0001 1110
AFTER: 1101 0011 1001 1110
The bit in bold has been changed from 0 to 1. We just change the selected bit based
on what we feel is necessary. Mutation is, however, vital to ensuring genetic diversity
within the population.
16
2.2.4 Termination a) This generational process is repeated until a termination condition has been
reached. Common terminating conditions are:
b) A solution is found that satisfies minimum criteria. In MATLAB this is done by
altering the fitness limit. If the best fitness value is less than or equal to the value of
fitness limit then the algorithm stops.
c) Fixed number of generations reached. In MATLAB the generations specifies the
maximum number of iterations the genetic algorithm performs.
d) The highest ranking solution's fitness is reaching or has reached a plateau such that
successive iterations no longer produce better results. In MATLAB this is set by
specifying the number of stall generations. If there is no improvement in the best
fitness value for the number of generations specified by stall generations the
algorithm will stop.
e) A time limit can also be set whereby we specify the time in seconds that the
genetic algorithm runs before stopping.
f) We can also set the stall time limit. If there is no improvement in the best fitness
value for an interval of time in seconds specified by the stall time limit then the
GA terminates.
g) Combinations of the above
2.2.5 Observations There are several general observations about the generation of solutions via a genetic
algorithm:
• Repeated fitness function evaluation for complex problems is often the most
prohibitive and limiting segment of artificial evolutionary algorithms. Finding
optimal solution to complex high dimensional, multimodal problems often
requires very expensive fitness function evaluations. In real world problems
such as structural optimization problems, one single function evaluation may
require several hours to several days of complete simulation. Typical
optimization method cannot deal with such a type of problem. In this case, it
may be necessary to forgo an exact evaluation and use an approximated
fitness that is computationally efficient. .
• In many problems, GAs may have a tendency to converge towards local
optima or even arbitrary points rather than the global optimum of the problem.
17
This means that it does not "know how" to sacrifice short-term fitness to gain
longer-term fitness. The likelihood of this occurring depends on the shape of
the fitness landscape: certain problems may provide an easy ascent towards a
global optimum; others may make it easier for the function to find the local
optima. This problem may be alleviated by using a different fitness function,
increasing the rate of mutation, or by using selection techniques that maintain
a diverse population of solutions, although the No Free Lunch theorem proves
that there is no general solution to this problem. A common technique to
maintain diversity is to impose a "niche penalty", wherein, any group of
individuals of sufficient similarity (niche radius) have a penalty added, which
will reduce the representation of that group in subsequent generations,
permitting other (less similar) individuals to be maintained in the population.
Diversity is important in genetic algorithms because crossing over a
homogeneous population does not yield new solutions.
• Operating on dynamic data sets is difficult, as genomes begin to converge
early on towards solutions which may no longer be valid for later data. Several
methods have been proposed to remedy this by increasing genetic diversity
somehow and preventing early convergence, either by increasing the
probability of mutation when the solution quality drops (called triggered
hypermutation), or by occasionally introducing entirely new, randomly
generated elements into the gene pool (called random immigrants). Again,
evolution strategies and evolutionary programming can be implemented with a
so-called "comma strategy" in which parents are not maintained and new
parents are selected only from offspring. This can be more effective on
dynamic problems.
• GAs cannot effectively solve problems in which the only fitness measure is a
single right/wrong measure, as there is no way to converge on the solution (no
hill to climb). However, if the situation allows the success/failure trial to be
repeated giving (possibly) different results, then the ratio of successes to
failures provides a suitable fitness measure.
• Selection is clearly an important genetic operator, but opinion is divided over
the importance of crossover versus mutation. Some argue that crossover is the
most important, while mutation is only necessary to ensure that potential
solutions are not lost. Others argue that crossover in a largely uniform
18
population only serves to propagate innovations originally found by mutation,
and in a non-uniform population crossover is nearly always equivalent to a
very large mutation (which is likely to be catastrophic. However across all
problems the No Free Lunch theorem holds, so these opinions are without
merit unless the discussion is restricted to a particular problem.
• Often, GAs can rapidly locate good solutions, even for difficult search spaces.
• For specific optimization problems and problem instances, other optimization
algorithms may find better solutions than genetic algorithms (given the same
amount of computation time).. The question of which, if any, problems are
suited to genetic algorithms (in the sense that such algorithms are better than
others) is open and controversial.
• As with all current machine learning problems it is worth tuning the
parameters such as mutation probability, recombination (crossover)
probability and population size to find reasonable settings for the problem
class being worked on. A very small mutation rate may lead to genetic drift
(which is non-ergodic in nature). A recombination rate that is too high may
lead to premature convergence of the genetic algorithm. A mutation rate that is
too high may lead to loss of good solutions unless there is elitist selection.
There are theoretical but not yet practical upper and lower bounds for these
parameters that can help guide selection.
• The implementation and evaluation of the fitness function is an important
factor in the speed and efficiency of the algorithm.
2.2.6 Variants The simplest algorithm represents each chromosome as a bit string. Typically,
numeric parameters can be represented by integers, though it is possible to use
floating point representations. The floating point representation is natural to evolution
strategies and evolutionary programming. The notion of real-valued genetic
algorithms has been offered but is really a misnomer because it does not really
represent the building block theory that was proposed by Holland in the 1970s. This
theory is not without support though, based on theoretical and experimental results
The basic algorithm performs crossover and mutation at the bit level. Other variants
treat the chromosome as a list of numbers which are indexes into an instruction table,
nodes in a linked list, hashes, objects, or any other imaginable data structure.
19
Crossover and mutation are performed so as to respect data element boundaries. For
most data types, specific variation operators can be designed. Different chromosomal
data types seem to work better or worse for different specific problem domains.
When bit strings representations of integers are used, Gray coding is often employed.
In this way, small changes in the integer can be readily effected through mutations or
crossovers. This has been found to help prevent premature convergence at so called
Hamming walls, in which too many simultaneous mutations (or crossover events)
must occur in order to change the chromosome to a better solution.
A very successful (slight) variant of the general process of constructing a new
population is to allow some of the better organisms from the current generation to
carry over to the next, unaltered. This strategy is known as elitist selection.
It can be quite effective to combine GA with other optimization methods. GA tends to
be quite good at finding generally good global solutions, but quite inefficient at
finding the last few mutations to find the absolute optimum. Other techniques (such as
simple hill climbing) are quite efficient at finding absolute optimum in a limited
region. Alternating GA and hill climbing can improve the efficiency of GA while
overcoming the lack of robustness of hill climbing.
20
: METHODOLOGY
3.1 Optimal location of distribution substations The main target of power system planning and developing in each part of generation,
transmission and distribution is response to consumption growth through confident
method with maximum reliability and economical efficiency. In distribution part
various evolutionary plans are presented whose aims are optimizing the distribution
grid.
Due to complex structure of distribution system, it is impossible to optimize the
structure of the grid in a global manner. Thus, the system planning is divided into two
subsets.
a) The first subset involves determination of location and sizing of substations
b) The second subset considers optimal routing of distribution feeders.
We can try to solve these subsets simultaneously but due to complexity of the
problem it was not done here.
All the optimization methods of planning and expansion of distribution systems are
classified in two groups below:
• Mathematical programming methods
• Innovative methods including intelligent systems and evolutionary algorithms
Initially all the research had been based on the mathematical programming whereas
most of recent works are concentrated on innovative and intelligent methods and
evolutionary algorithms which are of interest to me now as Genetic Algorithms fall
here.
Also some researchers have come up with some methods using complex procedures,
in which the run-time of the continuous algorithms is decreased. In my algorithm the
run time is greatly influenced by the fitness function, the number of generations
(iterations) and the stall generation limit which I choose to use in the main code
“SP_main”.
21
The problem of optimal location of distribution substations is to be dealt with, in
which cost of coupling the candidate distribution substations to upward grid is not
considered as of utmost importance.
In this report, a method for substation location is presented is where the genetic
algorithm is used as an optimization program. It determines the location and capacity
of new substation and also the expansion capacity of existing substations.
3.1.1 Simple generational genetic algorithm pseudocode 1. Choose initial population
2. Evaluate the fitness of each individual in the population
3. Repeat until termination: (time limit or sufficient fitness achieved)
i.Select best-ranking individuals to reproduce
ii.Breed new generation through crossover and/or mutation (genetic
operations) and give birth to offspring
iii.Evaluate the individual fitnesses of the offspring
iv.Replace worst ranked part of population with offspring
3.2 The Genetic Algorithm - a brief overview Before using a genetic algorithm to solve the problem, a way had to be found of
encoding any potential solution to the problem. This could be as a string of real
numbers or, as is more typically the case, a binary bit string. In GA a binary bit string
represents a chromosome. A typical chromosome may look like this:
1001 01011 1010 1001 0100 1110 1101 1101 1111 1101
At the beginning of a run of a genetic algorithm a large population of random
chromosomes is created and when decoded each one represents a different solution to
the problem at hand.
As an example, let there be N chromosomes in the initial population. It is to be noted
that the following steps are repeated until a solution is found:
22
1) Each chromosome is tested to see how good it is at solving the problem at hand and
a fitness score assigned accordingly. The fitness score is a measure of how good that
chromosome is at solving the problem to hand.
2) Two members will be selected from the current population. The chance of being
selected is proportional to the chromosomes fitness. Roulette wheel selection is a
commonly used method.
3) Dependent on the crossover rate, the bits from each chosen chromosome undergo
crossover at a randomly chosen point.
4) The algorithm will then step through the chosen chromosomes bits and flip
dependent on the mutation rate.
5) The above steps 2, 3, 4 will be repeated until a new population of N members has
been created.
3.2.1 What's the Crossover Rate? This term mentioned above is simply the chance that two chromosomes will swap
their bits. A good value for this is around 0.7. Crossover is performed by selecting a
random gene along the length of the chromosomes and swapping all the genes after
that point.
E.g. Given two chromosomes I have indicated below
100010011 10010010
010100010 01000011
I can choose a random bit along the length, say at position 9, and swap all the bits
after that point so the above become:
10001001101000011
01010001010010010
3.2.2 What's the Mutation Rate? This is the chance that a bit within a chromosome will be flipped (0 becomes 1 and 1
becomes 0). This is usually a very low value for binary encoded genes, say 0.001.
23
So whenever chromosomes are chosen from the population the algorithm first checks
to see if crossover should be applied and then the algorithm iterates down the length
of each chromosome mutating the bits if applicable.
3.3 From Theory to Practice
Given the digits 0 through 9 and the operators +, -, * and /, find a sequence that will
represent a given target number. The operators will be applied sequentially from left
to right as you read.
So, given the target number 23, the sequence 6+5*4/2+1 would be one possible
solution.
If 75.5 is the chosen number then 5/2+9*7-5 would be a possible solution.
3.3.1 Stage 1: Encoding
First we need to encode a possible solution as a string of bits (which can also be
referred to as a chromosome as pointed out earlier). To do this I will first need to
represent all the different characters available to the solution... that is 0 through to 9
and +, -, * and /. Each of this characters when represented will represent a gene. Each
chromosome will be made up of several genes.
Four bits are required to represent the range of characters used. This is due to fact
that there are only fourteen (14) characters and the use of four bits allows for 2^4 = 16
different characters. The integers are converted to their binary equivalent while the
special mathematical operators are given their own representations after 9.
0: 0000
1: 0001
2: 0010
3: 0011
4: 0100
5: 0101
6: 0110
7: 0111
8: 1000
24
9: 1001
+: 1010
-: 1011
*: 1100
/: 1101
The above show all the different genes required to encode the problem as described.
The possible genes 1110 & 1111 will remain unused and will be ignored by the
algorithm if encountered.
As it now can be seen the solution mentioned above for 23, ' 6+5*4/2+1' would be
represented by nine genes like so:
0110 1010 0101 1100 0100 1101 0010 1010 0001
6 + 5 * 4 / 2 + 1
These genes are all strung together to form the chromosome:
011010100101110001001101001010100001
3.3.2 A Quick Word about Decoding
Because the algorithm deals with random arrangements of bits it is often going to
come across a string of bits like this:
0010001010101110101101110010
Decoded, these bits represent:
0010 0010 1010 1110 1011 0111 0010
2 2 + N/A - 7 2
25
This is meaningless in the context of this problem! Therefore, when decoding, the
algorithm will just ignore any genes which don’t conform to the expected pattern of:
number -> operator -> number -> operator …and so on. With this in mind the above
‘nonsense’ chromosome is read (and tested) as:
2 + 7
Note that the format of ‘number -> operator -> number ‘has been conformed with.
3.3.3 Stage 2: Deciding on a Fitness Function This can be the most difficult part of the algorithm to figure out. This is due to the
fact that it really depends on the problem one is trying to solve. However the general
idea is to give a higher fitness score the closer a chromosome comes to solving the
problem. A fitness score can be assigned that's inversely proportional to the difference
between the solution and the value a decoded chromosome represents.
Now if the target number is taken to be 42, the chromosome I have mentioned above
i.e. 011010100101110001001101001010100001 will have a fitness score of 1/ (42-
23) or 1/19.
As it stands, if a solution is found, a divide by zero error would occur as the fitness
would be 1/ (42-42). This is not a problem however as we have found what we were
looking for... a solution. Therefore a test can be made for this occurrence and the
algorithm halted accordingly. Remember as pointed this out earlier in the stopping
criteria options for a genetic algorithm this condition can be included under the fitness
limit in the GA tool.
26
3.3.4 Stage 3: Getting down to business
For optimal planning of distribution grid, it is necessary to determine the location and
capacity of distribution substations in such a way that all load points be energized
with minimum possible cost. Choice of location and capacity of distribution
substations is dependent to some important indexes such as load density of load
points, geographical constraints and so on. In large scale systems since having too
many several choices, obtaining a system with minimum cost which efforts load
demand, is a difficult task.
The main target of this project is determination of optimal location of a distribution
substation. However the capacity of distribution substations has also been included.
The area is divided into smaller regions (load centre) for load prediction. Each region
accompanied with its corresponding consuming load in its gravity centre is defined as
a load point. Then, it is supposed that the prediction and determination of load points
for each region is performed with proper methods.
After prediction of the loads of regions, it is necessary to determine the candidate
locations to construct substations in the area under study. Some of these candidate
locations will be selected to substation construction after program running. In the
selection of candidate locations there are some factors which are considered such as:
location of existing substations, distance from load centres.
Optimization is performed in each time period to find optimal location, capacity and
service area of the distribution substations through candidate construction candidates
(considering the whole constraints).
The following variables are determined:
• Optimal location to construct the new substation from candidate locations
• Transformer capacity which must be considered in each new substation and
also construction timing of new substation
• Number and capacity of transformers which must be added to existing
substations.
27
• Optimal service area of each substation
3.3.4.1 Constraints of problem: The problem of location and determination of optimal service area of distribution
substations is minimized subject to below constraints. The fitness function ensures
that these are adhered to.
• Demand of all load points must be supplied (there must be no distinct load
point)
• Each load point is permitted to be supplied with just one substation.
• Loading of substations must be in the minimum and maximum permitted
limits of substations capacity. Every substation has these values of minimum
and the maximum permitted loading.
3.3.4.2 Problem solution conditions: Generally, obtaining global optimal solution is proved in numerical optimization
techniques such as linear programming, but due to complexity of our problem, using
mathematical programming methods is very complex and precise modelling of all
practical facts of this problem is impossible which is the main reason genetic
algorithm is used for the optimization in this project.
“Computer programs that "evolve" in ways that resemble natural selection can solve
complex problems even their creators do not fully understand “
by John H. Holland
3.3.4.3 Chromosome structure: For optimization of the problem, the considered chromosomes have matrix structure.
In these chromosomes the number of rows equals to the number of substations
(involving the existing and candidate ones) where En is the number of existing
substations and Nn is the number of candidate substations, also the number of
columns equals to the number of load points where l indicated the number of load
points. Figure 1 below shows the structure of these chromosomes.
28
L1 L2 L3 L4 - - - - - - Ln E1
E2
.
.
.
En
N1
N2
.
.
.
Nn
Figure 1: structure of the chromosome
It is worth noting that a row can contain several 1 entries. This scenario simply
implies that the substation is connected to more than one load. This is due to the fact
that a substation can connect (power) multiple load centres based on its capacity.
The elements of this matrix can be zero or one. Each element represents a gene in the
chromosome. If element ij in a matrix equals one, it means that substation i supplies
load point j.
Each load point can be supplied by just one substation, thus in each column of the
matrix there is just one 1 element.
Using the chromosome, it is possible to obtain the load amount connected to each
existing or candidate substation. The procedure of calculating load amount connected
to each substation is that in row related to supposed substation elements 1 are
searched and the connected loads to the substation are recognized, then summing the
amounts of these loads, amount of connected loads to the substation is calculated.
3.3.4.4 Initial population: To have faster optimization, the most possible constraints of the problem must be
initially applied. Thus in the generation of the initial population, selection of illegal
1 0 0
0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
29
cases is avoided. Such constraints involve maximum permitted length for minimum
voltage feeders which is analyzed at the start of the optimization.
To perform this, the connection matrix is defined which shows the possibility of
connection of a load to substation. Having an element of this matrix equal to 1 shows
that the load related to column of this element and the substation related to row of this
element have connection possibility and having an element equal to 0 means that
there is no connection possibility. Based on this matter and noting the structure of
considered area, the geographical constraint for problem is evaluated. Now, triangular
distance between load points and substations is evaluated and if this distance exceeds
the permitted value, the element which its row and column is respectively substation
and load, is zeroed in the connection matrix.
Considering this matrix, the initial population is generated and in procedures of
crossover and mutation this matrix is considered too.
In the procedure to generate the initial population, constraint of connection of all load
points to substations and constraint of connection of each point to just one substation
is satisfied. Also crossover and mutation operators act in such a way that these two
constraints are satisfied and generation of illegal chromosomes is avoided. It’s
important to remember that the rows represent the substations both existing and
candidate substation points. The columns represent the loads and a 1 or a 0 in a
column shows whether a load is connected to a particular substation or not. In each
column there can only be one 1 since a load can only be connected to one substation.
When performing crossover and mutation this condition SHOULD NOT be violated.
3.3.4.5 Crossover: Noting that in each column of chromosome, there is just one gene with value one
(other genes of the column are zero). A crossover function was needed that did not
cause the contravention of the constraint of supplement of each load point from just
one substation.
In this project, multi-point crossovers are performed on the selected chromosomes to
generate new offspring. The choice of multi-point crossovers was made because given
such constraints they would be the best at avoiding more than one 1 in a particular
column.
30
3.3.4.6 Mutation:
In this project, two kinds of mutation as explained below are employed:
• Random selection of one column of a chromosome and zeroing the only gene
with value 1 of that column. And making another random gene of the column
equal to one.
• Of course, performing the mutation, there is possibility to perform the
mutation on several columns. This is possible if we consider the structure of
the chromosome which is in a matrix structure.
Performing this mutation, load point is disconnected from one substation and
connected to another.
Random selection of one or more candidate substation in a chromosome (selection of
rows related to candidate substations) and zeroing all genes of that substation and
connecting the loads previously supplied by that substation, to another substations
Performing the algorithm using first mutation, the probability of omitting a candidate
substation from candidates (zeroing all genes related to load point connection to it) is
very low and almost zero. Thus, performing the algorithm, second mutation is used
with rather low probability. This action has a positive effect on the speed of algorithm
and reduction of the number of selected substations.
A mutation function SP_mutation was developed in MATLAB to handle this two
way mutation. The development of this function was made necessary by the fact that
in the genetic algorithm tool I decided to use a custom population type. This alteration
gave rise to the need for me to write my own creation, mutation and crossover
functions which are SP_create, SP_mutation and SP_crossover respectively which
would work with my population type. The population type does specify the type of
input to the fitness function.
31
3.3.4.7 Fitness index of chromosomes: Chromosomes which more minimize the solution will be given a larger fitness index..
For chromosomes which contravene one of problem constraints (infeasible solutions),
a low fitness index is attached to the chromosome making them less likely to be
selected for breeding. Thus, the chromosomes which contravene at least one of
problem constraints lower indexes. The roulette wheel selection criterion is applied
here.
To prevent the presence of defective chromosomes in next generations, a subroutine is
performed and the chromosomes with very low fitness index are omitted from the
selection list.
NB: The fitness of the population (substation) in the algorithm designed in this project
is checked using the “SP_fitness” function which has been generated using
MATLAB.
3.3.5 HOW THE DEVELOPED ALGORITHM WORKS Optimal Distribution Substations Placement finds the optimal location and capacity of
distribution substations
This program uses an Excel data file "DATA.xls" as an input to the program. The
input file consists of these worksheets:
1. input load data (active power of each load block and their X-Y coordinates
2. Present transformers and their capacities in kVA
3. Candidate points for new transformers
4. Transformers Loading Factor and design Power Factor
5. Types of transformers usable in the network.
This program searches for the best alignment and configuration for distribution
substations
Output of the program is an Excel file "RESULT.xls" that includes all selected and
designed transformers capacities, X-Y coordinates and each Load-Transformer
connection.
The algorithm that was developed using MATLAB ran after numerous attempts and debugging.
32
RESULTS AND ANALYSIS
4.1 Upper level working
This program uses an Excel data file "DATA.xls" as an input to the program. The
input file consists of the following worksheets:
1. input load data (active power of each load block and their X-Y coordinates)
2. Present transformers and their capacities in kVA
3. Candidate points for new transformers/substations locations.
4. Transformers Loading Factor (or utilization factor (%)) and design Power Factor
5. Types of transformers usable in the network.
This program searches for the best alignment and configuration for distribution
substations and each new generation of the population is much better than the
previous one.
Upon running the program two outputs were observed.
1. Excel file "RESULT.xls" that includes all selected and designed transformers
capacities, X-Y coordinates and each Load-Transformer connection.
2. MATLAB also does give a plot showing the substation optimal location in the
form of X-Y coordinates, the substation capacity, and the loads which will be
connected to a particular substation.
The worksheets were filled with the relevant information which is indicated by the
name of the particular worksheet and the code run in MATLAB.
Its’ worth noting that when filling in the information in the cells the worksheet of
Design_Constant (i.e. power factor 0.9 and Utilization factor 80(%) is left as it is
most of the time) is left is i have provided most of the time. This is due to the fact
that these are the specifications that the transformers are to meet.
Also the transformer_Types worksheet which provides the information of
Transformer Types (KVA), Install costs, Open-Circuit Losses (KW) and the
Short-Circuit Losses (KW) of the various transformers is also left unchanged. This
is so most of the time unless of course the installation costs have varied, which
usually happens after certain duration. The dynamic worksheets were taken to be
loads, Current_Substations and Candidates.
33
Below the DATA file is shown with the various worksheets as they should be
arranged shown. (Loads, Current_Substations, Candidates, Design_Constants and
Transformers_Types.
Figure 2: image of the opened sample DATA file with worksheets visible
4.1.2 Data worksheets needed The individual worksheets are as shown below.
4.1.2.1 Loads
X Y Load (kW)
Table 1: where coordinates of load and load values are entered
34
4.1.2.2 Current_Substations
X Y S (kVA)2000 2000 16003500 5700 250
Table 2: input worksheet of current substations
4.1.2.3 Candidates
X Y
Table 3: worksheet for inputting candidate location points of substation
4.2 DATA IN The following data was fed into the program through the DATA.xls file:
4.2.1 Loads
X Y Load (kW)6304.09 3438.09 13.7905675.93 3441.37 7.0056075.79 3441.58 15.5886193.91 3445.71 74.2865927.00 3450.29 41.2845416.96 3450.74 2.8596136.77 3458.07 3.2685373.69 3458.15 6.3545985.62 3464.92 53.4753464.92 5551.45 7.9323482.70 5745.66 35.8723494.09 6015.71 54.4493496.34 5394.00 5.3153508.57 6046.69 42.8943509.73 5488.21 5.5033517.56 6335.03 2.7733518.37 6422.55 8.0723518.85 5988.17 11.3403539.51 5451.73 12.4333543.98 5824.24 6.580
Table 4: sample loads with coordinates
35
4.2.2 Current_Substation
X Y S (kVA)2000 2000 16003500 5700 2502400 2000 2502600 2000 2502800 2000 2503000 2000 2503200 2000 2503400 2000 2503600 2000 2503800 2000 2504000 2000 2504200 2000 2504400 2000 2504600 2000 2504800 2000 2505000 2000 2503600 6200 3153400 5200 1005600 3800 506000 3750 200
Table 5: current substation points
4.2.3 Candidates
X Y6175.79 3441.585540.76 3482.706090.60 3309.735810.15 3543.986260.26 3118.866230.00 3662.055551.45 3886.075494.00 3694.985488.21 3609.446435.03 3720.607496.34 5394.003598.37 6422.55
Table 6: Candidate points for the location of the substation
4.3 Running the program The code was then run after the required data had been entered into the xls file
“DATA” the program was run. It should be noted that the code can be run in several
36
ways provided the M files have been placed in the appropriate directory. We can use
the command window to run DSP.fig, DSP.m or SP_main. The first two will activate
the GUI (Graphics User Interface) which just contains two buttons (Run DSP and
Help) as shown below
Figure 3: GIU tool that was developed to act as an interface.
Using SP_main simply runs the algorithm without invoking the GUI tool.
In the command window the message below will be displayed showing that the
algorithm has been started.
Shown below is the waitbar which I decided to include in the main code SP_main to
give a graphic display of the progress of the optimisation process.
Figure 4: waitbar showing progress of optimization Once the process has reached 100% the elapsed time since tic was invoked is shown
and the figure showing the distribution substations locations and their equivalent
capacities is also displayed. The xls file RESULTS is created in the current directory
37
where the functions SP_main, SP_Create, SP_fitness, SP_initialize, SP_stepup,
SP_crossover, SP_mutation and DATA.xls are located.
An images of this are shown below with an enlarged one concentrating on the location
between coordinates (3100, 5600) and (4100, 6450) shown directly below it
4.4 Distribution substation placement plot
Figure 5: Displayed figure of substation connection for the given load points.
38
Figure 6: Enhanced diagram of connection to substation with links more visible.
39
4.5 RESULTS FILE DATA The output file RESULTS.xls contains the following in the appropriately named
worksheet.
4.5.1 Transformer Capacities (KVA)
1 4002 1003 504 505 506 507 508 509 50
10 5011 5012 5013 5014 5015 5016 5017 20018 5019 5020 5021 315
Table 7: Transformer capacities in KVA
4.5.2 Transformer Powers (KW)
1 02 68.323 04 05 06 07 08 09 0
10 011 012 013 014 015 016 017 119.527718 5.31461519 16.2184620 021 201.6915
40
Table 8: Representation of the transformer powers which is just a sum of the loads connected to it. Zero indicates no connection to any load.
4.5.3 Substation coordinates worksheet
X coordinates Y coordinates1 2000 20002 3500 57003 2400 20004 2600 20005 2800 20006 3000 20007 3200 20008 3400 20009 3600 2000
10 3800 200011 4000 200012 4200 200013 4400 200014 4600 200015 4800 200016 5000 200017 3600 620018 3400 520019 5600 380020 6000 375021 6175.79 3441.58
Table 9: Showing the coordinates of the substations, both used and unused.
41
4.5.4 LOAD (X-Y) and SS (X-Y) LINKS
LOAD X LOAD Y SS X SS Y1 6304.09 3438.09 6175.79 3441.582 5675.93 3441.37 5600 38003 6075.79 3441.58 6175.79 3441.584 6193.91 3445.71 6175.79 3441.585 5927 3450.29 6175.79 3441.586 5416.96 3450.74 5600 38007 6136.77 3458.07 6175.79 3441.588 5373.69 3458.15 5600 38009 5985.62 3464.92 6175.79 3441.58
10 3464.92 5551.45 3500 570011 3482.7 5745.66 3500 570012 3494.09 6015.71 3600 620013 3496.34 5394 3400 520014 3508.57 6046.69 3600 620015 3509.73 5488.21 3500 570016 3517.56 6335.03 3600 620017 3518.37 6422.55 3600 620018 3518.85 5988.17 3600 620019 3539.51 5451.73 3500 570020 3543.98 5824.24 3500 5700
Table 10: Showing which substation each of the loads is connected.
4.6 Analysis of tables and figures From the tables and figures given it can be seen that the loads are linked to one of the
transformers. The exact one is determined by the optimization algorithm with starts its
evolution from the initially given positions of the current substations and the
candidate points. It can be seen that the loads are connected one of the provided
substations which can either a current substation or the candidate substation location.
Examples are: (3600, 6200) which is a current substation position, (6175.79,
3441.58) which is a candidate position, (5600, 3800) current position, (3400, 5200)
candidate point, (3500, 5700) current position,
The algorithm thus ensures that the best substation among the numerous ones
provided as candidate points would be ideal.
The figure that was plotted (figure 5 & figure 6) gives a better view of how the
information contained in the file RESULTS.xls.
42
The capacities in KVA are indicated in red for each substation. The load centres are
also shown with the green lines showing the substation they should be connected to.
43
CONCLUSIONS
5.1 Conclusion In this project a comprehensive genetic algorithm for optimal location of distribution
substations and determination of their capacity and service area was generated. At
first, information was sought on the methods currently being employed for substation
location. It was found that in the current engineering practice no globally accepted
criterion to define the substation position existed. Generally the proposed solutions
are based on designer experience. A criterion usually adopted is based on a graphical
method, called the bisector perpendicular rule which did not always give the proper
location as it was based on trial and error and was also quiet time consuming.
Because Genetic Algorithms are used for optimisation a study of them was
undertaken to learn more about their operation
Therefore the search method based on genetic algorithm to optimize the problem has
been proposed. To have faster convergence of genetic algorithm, generation of many
illegal cases has been prevented in initial population generation. This was achieved by
making sure that each load was connected to only one substation (i.e. only one
element in each column could be 1 representing a connection while the rest were 0
indicating no connection). The creation function (SP_Create) was written in a way to
ensure this.
The objective which was to was to design an algorithm that could be used for the
planning of the location of distribution substations in a network was met as both a
MATLAB plot and xls file RESULTS were the programs output clearly showing
substation location and which loads were connected to which.
5.2 Challenges faced Although the set objective of the project was achieved it was discovered that literatures on substation location were quite hard to come by. A search in the city bookshops and on campus bookshop yielded no results of any book on substations. The university library only contained a few books on power stations as opposed to the target one on substations.
However despite these local problems the guidance my supervisor enabled me to discover some useful journals via the internet which proved quite handy.
44
45
5.3 Recommendations for future work
• The algorithm that was developed was attaining local optima. It can be quite
effective to combine genetic algorithms with other optimization methods. This
is due to the fact that GA tends to be quite good at finding good global
solutions, but quite inefficient at finding the last few mutations to find the
absolute optimum. Other techniques (such as simple hill climbing) are quite
efficient at finding absolute optimum in a limited region. Alternating GA and
hill climbing can improve the efficiency of GA while overcoming the lack of
robustness of hill climbing.
• Reproduction methods used in this project was more biology inspired and
involved the use of two parents. Recent researches suggest that more than two
“parents” are better to be used to produce a good quality chromosome. This
idea should be explored.
46
REFERENCES
[1] “Optimal substation location and energy distribution network design using a
hybrid GA-BFGS algorithm,” IEEE Proc-Gener Trans Dist. 152 (6): 919-926
[2] T. H. Fawzi, K. F. Ali, and S. M. El Sobki, “A new planning model for
distribution systems,” IEEE Trans. Power App. Syst., vol. 102, Sept. 1983.
[3] Zhu, J.Z.: ‘Optimal reconfiguration of electrical distribution network
using the refined genetic algorithm’, Electr. Power Syst. Res., 2002, 62,
(1), pp. 37–42
[4] Duan, G., and Yu, Y.: ‘Problem-specific genetic algorithm for power
transmission system planning’, Electr. Power Syst. Res., 2002, 61
[5] “Optimal location and sizing of HV/MV substation in uncertainty load
environment using genetic algorithm”. Elect Power System Res. 63 : 37-50
[6] D. Crawford and S. Holt, “A mathematical optimization technique for locating
and sizing distribution substations, and deriving their optimal service areas,”
IEEE Trans. Power App. Syst., vol. 94,Mar./Apr. 1975.
[9] A novel method for optimal location and expansion of sub-transmission
substations considering existing medium voltage distribution feeders.
http://findarticles.com/p/articles/mi_7109/is_3_6/ai_n31336957/
[10] http://en.wikipedia.org/wiki/Genetic_algorithm
[11] www.ai-junkie.com/ga/intro/gat1.html
47
APPENDIX A 6.1 Genetic algorithm codes written in MATLAB
6.1.1 SP_main This is the main program and all the other functions provided in this appendix are linked to it. All the function should be placed be placed in the same directory to facilitate their calling and execution without the provision of errors.
% this program is designed for optimal distribution substation placement %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function SP_main() clear; %Removes items from workspace,freeing up system memory. clc; % clc=Clear Command Window pack; %Consolidate workspace memory tic; % starts a stopwatch timer not necessary but why not display('PROJECT NO. 100: SUBSTATION DESIGN'); display('OPTIMAL SUBSTATION PLACEMENT ALGORITHM BY SAIDI FELIX JUMA STARTED'); display('REG NO.: F17/9366/2002'); % global=Define a global variable global T L FinalTransPow FinalLoad FinalTransCap TransTypes AuxTransCap AuxTransPow K2 K3 MaxT global SelCaseRow FinalTrans_x FinalTrans_y FinalLoad_x FinalLoad_x FinalLoad_y BrTransIndex global AuxFinalTrans_x AuxFinalTrans_y AuxFinalLoad_x AuxFinalLoad_x AuxFinalLoad_y AuxFinalLoad global FinalTLDistances VarCheckPrg global finaltranspow finaltranscap global PowerFactor UtilizationFactor TransformersTypes KWTransformersTypes global InstallCosts OpenCircuitLosses ShortCircuitLosses global CurrentTr_x CurrentTr_y K2 = 0.0035e-3; K3 = 0.64; % determination of load centers & the vector of load values % //in the next five lines of my code the required data is read from the excel file DATA which acts as my input DATA = xlsread('DATA.xls','Loads'); CANDIDATES = xlsread('DATA.xls','Candidates'); CURRENT_SUBSTATIONS = xlsread('DATA.xls','Current_Substation'); DESIGN_CONSTANTS = xlsread('DATA.xls','Design_Constants'); TRANSFORMERS_TYPES = xlsread('DATA.xls','Transformers_Types'); ExcelLoad_x = DATA(:,1); ExcelLoad_y = DATA(:,2); ExcelLoads = DATA(:,3); ExcelCandidates_x = CANDIDATES(:,1);
48
ExcelCandidates_y = CANDIDATES(:,2); PowerFactor = DESIGN_CONSTANTS(1,1); UtilizationFactor = DESIGN_CONSTANTS(1,2)/100; TransformersTypes(1,:) = sort(TRANSFORMERS_TYPES(:,1)); KWTransformersTypes = ceil(UtilizationFactor*PowerFactor*TransformersTypes); InstallCosts(1,:) = sort(TRANSFORMERS_TYPES(:,2)); OpenCircuitLosses(1,:) = sort(TRANSFORMERS_TYPES(:,3)); ShortCircuitLosses(1,:) = sort(TRANSFORMERS_TYPES(:,4)); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Loads(1,:) = ExcelLoads(:,1); Load_x(1,:) = ExcelLoad_x(:,1); Load_y(1,:) = ExcelLoad_y(:,1); Candidates_x(1,:) = ExcelCandidates_x(:,1); Candidates_y(1,:) = ExcelCandidates_y(:,1); if length(CURRENT_SUBSTATIONS) ~= 0 CurrentTr_x = CURRENT_SUBSTATIONS(:,1)'; CurrentTr_y = CURRENT_SUBSTATIONS(:,2)'; CurrentTrCap = CURRENT_SUBSTATIONS(:,3)'; CurrentTrPow = ceil(UtilizationFactor*PowerFactor*CurrentTrCap); else CurrentTr_x = []; CurrentTr_y = []; CurrentTrCap = []; CurrentTrPow = []; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % initialize transformer locations and powers % one transformer in every load center. initially we assume the first % transformer for all candidate points. TransTypes = length(TransformersTypes); LoadCenters = length(ExcelLoads); CurrentTrNo = length(CurrentTr_x); CandidateNo = length(ExcelCandidates_x); for count1=1:CurrentTrNo, if CurrentTrPow(1,count1) >= ceil((400*UtilizationFactor*PowerFactor)) LimitedCurrentTrPow(1,count1) = KWTransformersTypes(1,6); else LimitedCurrentTrPow(1,count1) = KWTransformersTypes(1,1); end; end; Trans_x = [CurrentTr_x Candidates_x]; Trans_y = [CurrentTr_y Candidates_y]; TransCap = [LimitedCurrentTrPow (KWTransformersTypes(1,1) + zeros(1,length(ExcelCandidates_x)))]; CandidateCenters = length(TransCap); % current + candidate transformers TransPow = zeros(1,CandidateCenters); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % calculation of the distances between transformers % this is a matrice with dimensions: (LoadCenters)*(CandidateCenters) Distances = zeros(LoadCenters,CandidateCenters); for count1=1:LoadCenters,
49
for count2=1:CandidateCenters, Distances(count1,count2) = sqrt((Load_x(1,count1)-Trans_x(1,count2))^2 + (Load_y(1,count1)-Trans_y(1,count2))^2); end; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CanDistances = zeros(CandidateCenters); for count1=1:CandidateCenters, for count2=1:count1, CanDistances(count1,count2) = sqrt((Trans_x(1,count1)-Trans_x(1,count2))^2 + (Trans_y(1,count1)-Trans_y(1,count2))^2); CanDistances(count2,count1) = CanDistances(count1,count2); end; end; % the distances are pairly compared with 100, if they are smaller than 100 % the transformer with smaller value of load is detached. for count1=1:CandidateCenters, for count2=1:CandidateCenters, if (CanDistances(count1,count2) <= 100) & (count1 ~= count2) & (count1 > CurrentTrNo) TransCap(1,count1) = 0; TransPow(1,count1) = 0; end; end; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % this function step-up the transformers size until it can feed the total % loads connected to it. % for count1=1:TransTypes, % for count2=1:LoadCenters, % if (TransCap(1,count2) < Loads(1,count2)) && (TransCap(1,count2) ~= 0) % TransCap(1,count2) = SP_stepup(TransCap(1,count2)); % end; % end; % end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % in this subsection, the coordinations of the final possible transformers % are saved in FinalTrans_x & FinalTrans_y and their values in % FinalTransCap. similarly, the coordinations of the loadcenters to be % attached to transformers are saved in FinalLoad_x & FinalLoad_y and their % values in FinalLoad. T = 1; L = LoadCenters; for count1 = 1:CandidateCenters, if (TransCap(1,count1) ~= 0) FinalTransCap(1,T) = TransCap(1,count1); FinalTransPow(1,T) = 0; FinalTrans_x(1,T) = Trans_x(1,count1); FinalTrans_y(1,T) = Trans_y(1,count1); T = T+1; end; end; MaxT = T-1;
50
% MinL = L-1; % if ((MaxT > 23) & (VarCheckPrg == 1)) % warndlg('MATLAB unable to solve! Try smaller number of loads',' DSP Warning'); % display('MATLAB unable to solve! Try smaller number of loads'); % return; % end; AuxTransCap = FinalTransCap; AuxTransPow = FinalTransPow; AuxFinalTrans_x = FinalTrans_x; AuxFinalTrans_y = FinalTrans_y; AuxFinalLoad_x = Load_x; AuxFinalLoad_y = Load_y; AuxFinalLoad = Loads; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % calculation of Distances beetween transformers and loads in a (MinL*MaxT) matrice. for count1=1:LoadCenters, for count2=1:MaxT, TLDistances(count1,count2) = sqrt((AuxFinalLoad_x(1,count1)-AuxFinalTrans_x(1,count2))^2 + (AuxFinalLoad_y(1,count1)-AuxFinalTrans_y(1,count2))^2); end; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % HERE, THE OPERATION OF GENETIC ALGORITHM IS STARTED. TotalLevels = 0; LowLim = CurrentTrNo; MaxLim = LowLim + (MaxT-CurrentTrNo); for count5=LowLim:MaxLim, TotalLevels = TotalLevels + ceil(nchoosek(MaxT,count5)); end; ScalingFactor = ceil(TotalLevels/20); TotalLevels = ceil(TotalLevels/ScalingFactor); Index = 0; TMat = [(CurrentTrNo+1):MaxT]; % if ((TotalLevels < 20) & (VarCheckPrg == 1)) % warndlg('Try smaller Scaling Factor!',' DSP Warning'); % display('Try smaller Scaling Factor!'); % return; % end; % if ((TotalLevels > 300) & (VarCheckPrg == 1)) % warndlg('Try bigger Scaling Factor!',' DSP Warning'); % display('Try bigger Scaling Factor!'); % return; % end; % if ((VarCheckPrg == 1) & ((TotalLevels <= 300) & (TotalLevels >= 20))) % warndlg('No problem in running program. Push "Run DSP"',' DSP Warning'); % LEVELS = TotalLevels; % LEVELS % display('No problem in running program. Push "Run DSP"'); % return; % end; close all; pack; cfinaltranscap = cell(TotalLevels,1); cfinaltranspow = cell(TotalLevels,1);
51
cfinaltrans_x = cell(TotalLevels,1); cfinaltrans_y = cell(TotalLevels,1); cfinalload = cell(TotalLevels,1); cfinalload_x = cell(TotalLevels,1); cfinalload_y = cell(TotalLevels,1); pack; h = waitbar(0,'PRJ 100.SUBSTATION LOCATION OPTIMIZATION IN PROGRESS.Please wait...BY SAIDI FELIX JUMA.'); for count1=0:(MaxLim-LowLim), % MAIN for. NOTE: "count1" stands for the number of new trans. T = LowLim + count1; % "LowLim" stands for the number of current transformers. numberOfVariables = LoadCenters; L = numberOfVariables; SelCaseMat = nchoosek(TMat,count1); SIZE = size(SelCaseMat); RowNumber = SIZE(1,1); for count2=1:ScalingFactor:RowNumber, Index = Index + 1; Level = Index; SelCaseRow = [[1:CurrentTrNo] SelCaseMat(count2,:)]; % SelCaseRow should be sent to SP_create.m. It is a selection of transformers %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % modifying FinalTrans_x,y & FinalLoad_x,y & FinalLoad & % FinalTransPow & FinalTransCap finaltranscap = zeros(1,MaxT) -1; finaltranspow = zeros(1,MaxT) -1; finaltrans_x = zeros(1,MaxT) -1; finaltrans_y = zeros(1,MaxT) -1; for count3=1:T, finaltranscap(1,SelCaseRow(1,count3)) = AuxTransCap(1,SelCaseRow(1,count3)); finaltranspow(1,SelCaseRow(1,count3)) = AuxTransPow(1,SelCaseRow(1,count3)); finaltrans_x(1,SelCaseRow(1,count3)) = AuxFinalTrans_x(1,SelCaseRow(1,count3)); finaltrans_y(1,SelCaseRow(1,count3)) = AuxFinalTrans_y(1,SelCaseRow(1,count3)); end; FinalTransCap = finaltranscap; FinalTransPow = finaltranspow; FinalTrans_x = finaltrans_x; FinalTrans_y = finaltrans_y; cfinaltranscap{Index} = finaltranscap; cfinaltranspow{Index} = finaltranspow; cfinaltrans_x{Index} = finaltrans_x; cfinaltrans_y{Index} = finaltrans_y; finalload = Loads; finalload_x = Load_x; finalload_y = Load_y; % Li = 0; % for count3=1:LoadCenters, % if (size(find(FinalTrans_x==Load_x(1,count3)))==[1 0] | size(find(FinalTrans_y==Load_y(1,count3)))==[1 0]) % Li = Li + 1; % finalload(1,Li) = Loads(1,count3); % finalload_x(1,Li) = Load_x(1,count3); % finalload_y(1,Li) = Load_y(1,count3); % end; % end; FinalLoad = finalload; FinalLoad_x = finalload_x; FinalLoad_y = finalload_y; cfinalload{Index} = finalload; cfinalload_x{Index} = finalload_x; cfinalload_y{Index} = finalload_y;
52
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % calculation of Distances beetween transformers and loads in a (L*T) matrice. Li = 0; FinalTLDistances = 0; BrFinalTransPow = zeros(1,T); BrFinalTransCap = zeros(1,T); BrFinalTrans_x = zeros(1,T); BrFinalTrans_y = zeros(1,T); BrTransIndex = zeros(1,T); for count3=1:MaxT, if (FinalTrans_x(1,count3)~=-1) Li = Li + 1; BrFinalTransPow(1,Li) = FinalTransPow(1,count3); BrFinalTransCap(1,Li) = FinalTransCap(1,count3); BrFinalTrans_x(1,Li) = FinalTrans_x(1,count3); BrFinalTrans_y(1,Li) = FinalTrans_y(1,count3); BrTransIndex(1,Li) = count3; end; end; for r=1:L, for s=1:T, FinalTLDistances(r,s) = sqrt((FinalLoad_x(1,r)-BrFinalTrans_x(1,s))^2 + (FinalLoad_y(1,r)-BrFinalTrans_y(1,s))^2); end; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % IN THIS SECTION OF MY ALGORITHM IT CAN BE SEEN THAT GA ALGORITHM TOOL IS INVOKED. PLEASE NOTE % THAT I HAVE CREATED MY OWN CROSSOVER,MUTATION AND CREATION FUNCTIONS. WHEN USING THE GA TOOL THIS MUST % BE REMEMBERED.THIS IS WHERE THE OPTIMIZATION ACTUALLY TAKES PLACE FitnessFcn = @(x) SP_fitness(x,FinalTLDistances); options = gaoptimset('PopulationType', 'custom','PopInitRange', ... [1;L]); options = gaoptimset(options,'CreationFcn',@SP_create, ... 'CrossoverFcn',@SP_crossover, ... 'MutationFcn',@SP_mutation, ... 'Generations',300,'PopulationSize',50, ... 'StallGenLimit',20,'StallTimeLimit',inf,'Vectorized','on'); [x(1,Index),fval(1,Index)] = ga(FitnessFcn,numberOfVariables,options); pack; end; Str1 = num2str(floor((Level*100)/((MaxLim-LowLim)+1))); Str2 = '% '; Str3 = ' of 100% Completed'; Message = strcat(Str1,Str2,Str3); disp(Message); disp('INCREASE ACTIVATED....'); waitbar(Level/((MaxLim-LowLim)+1)); end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53
% here, we increase transformers capacities till they could feed % their related loads. close(h); % closes waiting bar [BestVal,BestValIndex] = min(fval); Fitness_Function_Best_Value = BestVal; X = x{BestValIndex}; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % At the end, transformers are stated in terms of their capacities (kVA). % these are saved in "Transformers" variable. note that the positions of % final transformers are saved in FinalTrans_x & FinalTrans_y. % similarly, final loads and their locations are saved in FinalLoad & % FinalLoad_x & FinalLoad_y respectively. Then, every load is connected to % it's correspounding transformer. L = length(X); % T = LoadCenters - L; FinalTransCap = cfinaltranscap{BestValIndex}; FinalTransPow = cfinaltranspow{BestValIndex}; FinalTrans_x = cfinaltrans_x{BestValIndex}; FinalTrans_y = cfinaltrans_y{BestValIndex}; FinalLoad = cfinalload{BestValIndex}; FinalLoad_x = cfinalload_x{BestValIndex}; FinalLoad_y = cfinalload_y{BestValIndex}; for count1=1:MaxT, if (FinalTrans_x(1,count1)~=-1) FinalTransPow(1,count1) = AuxTransPow(1,count1); FinalTransCap(1,count1) = AuxTransCap(1,count1); end; end; Li = 0; BrFinalTransPow = zeros(1,T); BrFinalTransCap = zeros(1,T); BrFinalTrans_x = zeros(1,T); BrFinalTrans_y = zeros(1,T); for count1=1:L, FinalTransPow(1,X(count1,2)) = FinalTransPow(1,X(count1,2)) + FinalLoad(1,X(count1,1)); end; for count3=1:MaxT, if (FinalTrans_x(1,count3) ~= -1) Li = Li + 1; BrFinalTrans_x(1,Li) = FinalTrans_x(1,count3); BrFinalTrans_y(1,Li) = FinalTrans_y(1,count3); BrFinalTransPow(1,Li) = FinalTransPow(1,count3); % last added BrFinalTransCap(1,Li) = FinalTransCap(1,count3); % last added end; end; % newly added for constant transformers positions T = Li; %%%%%%%%%%%%%%%%DELETING ZERO TRANSFORMERS%%%%%%%%%%%%%%%%%%%%%%%% Lj = 1; %an auxalary variable for count3=1:MaxT if (count3 <= CurrentTrNo) DEL_POW(1,Lj) = BrFinalTransPow(1,count3); DEL_CAP(1,Lj) = BrFinalTransCap(1,count3); DEL_X(1,Lj) = BrFinalTrans_x(1,count3); DEL_Y(1,Lj) = BrFinalTrans_y(1,count3); Lj = Lj + 1;
54
elseif (BrFinalTransPow(1,count3) ~= 0) DEL_POW(1,Lj) = BrFinalTransPow(1,count3); DEL_CAP(1,Lj) = BrFinalTransCap(1,count3); DEL_X(1,Lj) = BrFinalTrans_x(1,count3); DEL_Y(1,Lj) = BrFinalTrans_y(1,count3); Lj = Lj + 1; end end BrFinalTransPow = DEL_POW; BrFinalTransCap = DEL_CAP; BrFinalTrans_x = DEL_X; BrFinalTrans_y = DEL_Y; Lj = Lj -1; T = Lj; %%%%%%%%%%%%%%%%ENND OF DELETING ZERO TRANSFORMERS%%%%%%%%%%%%%%%% % newly added for constant transformers positions for count1=1:TransTypes, for count2=1:T, if (BrFinalTransCap(1,count2) < BrFinalTransPow(1,count2)) BrFinalTransCap(1,count2) = SP_stepup(BrFinalTransCap(1,count2),BrFinalTrans_x(1,count2),BrFinalTrans_y(1,count2)); end; end; end; for count1=1:T, Transformers(1,count1) = SP_2kva(BrFinalTransCap(1,count1)); end; % PLOTs plot(Load_x,Load_y,'bo'); % This plots our load centres.. removal leaves only the links hanging hold on; for count1=1:T, if (count1 <= CurrentTrNo) % new transformers are RED plot(BrFinalTrans_x(1,count1),BrFinalTrans_y(1,count1),'b*'); hold on; else plot(BrFinalTrans_x(1,count1),BrFinalTrans_y(1,count1),'r*'); hold on; end; end; for count1=1:L, % The plot function below displays the links/connectors to the loads in the figure TOEXCELCONNECTIONS(count1,1) = count1; TOEXCELCONNECTIONS(count1,2) = FinalLoad_x(1,X(count1,1)); TOEXCELCONNECTIONS(count1,3) = FinalLoad_y(1,X(count1,1)); TOEXCELCONNECTIONS(count1,4) = FinalTrans_x(1,X(count1,2)); TOEXCELCONNECTIONS(count1,5) = FinalTrans_y(1,X(count1,2)); plot([FinalLoad_x(1,X(count1,1)) FinalTrans_x(1,X(count1,2))],[FinalLoad_y(1,X(count1,1)) FinalTrans_y(1,X(count1,2))],'g'); hold on; end; for count1=1:T, TextTransformers(1,count1) = {num2str(Transformers(1,count1))}; end; for count1=1:T, text(BrFinalTrans_x(1,count1)-30,BrFinalTrans_y(1,count1)+40,TextTransformers(1,count1),'FontSize',20,'Color','red'); hold on; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% new
55
for count1=1:T, plot(BrFinalTrans_x(1,count1),BrFinalTrans_y(1,count1),'r*'); hold on; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% new for count1=1:LoadCenters, TextAllLoads(1,count1) = {num2str(Loads(1,count1))}; end; for count1=1:LoadCenters, text(Load_x(1,count1)-5,Load_y(1,count1)-20,TextAllLoads(1,count1),'FontSize',8); hold on; end; TransOverLoad = 0; TransOverLoadCandIndex = find(BrFinalTransCap == KWTransformersTypes(1,TransTypes)); % check for overloaded trans.. compared with a 1600kVA Size = length(TransOverLoadCandIndex); for count1=1:Size, if BrFinalTransPow(1,TransOverLoadCandIndex(1,count1)) > BrFinalTransCap(1,TransOverLoadCandIndex(1,count1)) TransOverLoad = 1; break; end; end; if TransOverLoad == 1 warndlg('OverLoaded transformer(s) found!',' DSP Warning'); end; grid on; % Here i have set the grids to be displayed for increased ease in checking the position % OUTPUTS in command window of MATLAB delete ('RESULT.xls'); %Delete files or graphics objects BrFinalTrans_x BrFinalTrans_y Transformers xlswrite('RESULT.xls',Transformers','Transformer Capacities (kVA)'); xlswrite('RESULT.xls',BrFinalTransPow','Transformer Powers (kW)'); xlswrite('RESULT.xls',BrFinalTrans_x','SUBSTATION X coordinates'); xlswrite('RESULT.xls',BrFinalTrans_y','SUBSTATION Y coordinates'); xlswrite('RESULT.xls',TOEXCELCONNECTIONS,'Load(X,Y)-SS(X,Y) Links'); toc; %toc prints the elapsed time since tic was used. display('RESULTS OBTAINED.LOCAL OPTIMA ATTAINED'); display('FIGURE DISPLAYED AND EXCEL FILE "RESULTS" CREATED'); display('(PROJECT NO. 100)');
56
6.1.2 SP_Create
% this function creates the first population used by Genetic Algorithm function pop = SP_create(NVARS,FitnessFcn,options) global T L FinalTransPow FinalLoad FinalTransCap TransTypes AuxTransCap AuxTransPow K2 K3 global SelCaseRow FinalTrans_x FinalTrans_y FinalLoad_x FinalLoad_x FinalLoad_y global AuxFinalTrans_x AuxFinalTrans_y AuxFinalLoad_x AuxFinalLoad_x AuxFinalLoad_y AuxFinalLoad global FinalTLDistances totalPopulationSize = sum(options.PopulationSize); pop = cell(totalPopulationSize,1); for counter=1:NVARS, SelDistance = FinalTLDistances(counter,:); [SelTr,SelectedTrIndex] = min(SelDistance); firstpop(counter,1) = counter; firstpop(counter,2) = SelCaseRow(1,SelectedTrIndex); end; pop{1} = firstpop; for j=2:totalPopulationSize, for count1=1:NVARS, % NVARS=L the number of final loads and also the number of variables. TIndex = randperm(length(SelCaseRow)); popindividual(count1,1) = count1; popindividual(count1,2) = SelCaseRow(1,TIndex(1,1)); end; pop{j} = popindividual; end;
6.1.3 SP_Initialize global VarCheckPrg ScalingFactor SP_main();
6.1.4 SP_fitness
% here, the fitness function is created. the sum of distances from loads to % present transformers are calculated and the set which minimizes this sum % is achieved by MATLAB ga function. % x is an individual % f1= substation installation cost % f2= LV network cost (for conductors loss) % f3= transformers loss cost function scores = SP_fitness(x,FinalTLDistances) global T L FinalTransPow FinalLoad FinalTransCap TransTypes AuxTransCap AuxTransPow K2 K3 MaxT global SelCaseRow FinalTrans_x FinalTrans_y FinalLoad_x FinalLoad_x FinalLoad_y BrTransIndex global AuxFinalTrans_x AuxFinalTrans_y AuxFinalLoad_x AuxFinalLoad_x AuxFinalLoad_y AuxFinalLoad
57
global finaltranspow finaltranscap scores = zeros(size(x,1),1); for u = 1:size(x,1) p = x{u}; VoltageDropWarn = 0; FinalTransPow = finaltranspow; % reset FinalTransPow for every individual FinalTransCap = finaltranscap; % reset FinalTransCap for every individual %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for count1=1:L, FinalTransPow(1,p(count1,2)) = FinalTransPow(1,p(count1,2)) + FinalLoad(1,p(count1,1)); end; for count1=1:TransTypes, for count2=1:MaxT, if (FinalTransPow(1,count2) ~= -1) if (FinalTransCap(1,count2) < FinalTransPow(1,count2)) FinalTransCap(1,count2) = SP_stepup(FinalTransCap(1,count2),FinalTrans_x(1,count2),FinalTrans_y(1,count2)); end; end; end; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% f1 = 0; for count1=1:MaxT, if (FinalTransCap(1,count1) ~= -1) f1 = f1 + SP_instcost(FinalTransCap(1,count1)); end; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% f2 = 0; for count1=1:L, % L=NVARS size of final loads c1 = p(count1,1); c2 = p(count1,2); Temp = find(BrTransIndex == c2); f2 = f2 + (1400*K2*(FinalTLDistances(c1,Temp)*(FinalLoad(1,c1)^2))); % check for undervoltage occurence if ((FinalLoad(1,c1)*FinalTLDistances(c1,Temp)) > 7500) VoltageDropWarn = 1; end; end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% f3 = 0; % for count1=1:L, % c1 = p(count1,2); % f3 = f3 + (1400*(K3*SP_tlosscost2(FinalTransCap(1,c1)) + SP_tlosscost1(FinalTransCap(1,c1)))); % end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (VoltageDropWarn == 0) scores(u) = f1 + f2 + f3; else scores(u) = f1 + f2 + f3 + (1e9); end; end;
58
6.1.5 SP_Crossover % this function is dedicated for crossover operation used by MATLAB GA % function. function xoverKids = SP_crossover(parents,options,NVARS, ... FitnessFcn,thisScore,thisPopulation) nKids = length(parents)/2; xoverKids = cell(nKids,1); % Normally zeros(nKids,NVARS); index = 1; for i=1:nKids parent = thisPopulation{parents(index)}; index = index + 2; % Flip a section of parent1. p1 = ceil((length(parent) -1) * rand); p2 = p1 + ceil((length(parent) - p1- 1) * rand); child = parent; child(p1:p2) = fliplr(child(p1:p2)); xoverKids{i} = child; % Normally, xoverKids(i,:); end
6.1.6 SP_Mutation % this function is dedicated for crossover operation used by MATLAB ga % function. function mutationChildren = SP_mutation(parents ,options,NVARS, ... FitnessFcn, state, thisScore,thisPopulation,mutationRate) mutationChildren = cell(length(parents),1);% Normally zeros(length(parents),NVARS); for i=1:length(parents) parent = thisPopulation{parents(i)}; % Normally thisPopulation(parents(i),:) p = ceil(length(parent) * rand(1,2)); child = parent; child(p(1)) = parent(p(2)); child(p(2)) = parent(p(1)); mutationChildren{i} = child; % Normally mutationChildren(i,:) end
6.1.7 SP_stepup % this function step-up the transformers size until it can feed the total % loads connected to it. function NextVal = SP_stepup(CurVal,X_Cord,Y_Cord) global KWTransformersTypes TransTypes CurrentTr_x CurrentTr_y global FinalTrans_x FinalTrans_y UtilizationFactor PowerFactor Tag = find(KWTransformersTypes == CurVal); if (Tag ~= TransTypes) if (isempty(find(CurrentTr_x==X_Cord)) & isempty(find(CurrentTr_y==Y_Cord))) %check if a new candidate!? NextVal = KWTransformersTypes(1,Tag+1); elseif (CurVal == KWTransformersTypes(1,5)) % if a 315kVA transformer NextVal = CurVal; else
59
NextVal = KWTransformersTypes(1,Tag+1); end; else NextVal = CurVal; end;
6.1.8 SP_2kva % this function convert the input to a correspounding kVA. function OutVal = SP_2kva(InVal) global KWTransformersTypes TransformersTypes Tag = find(KWTransformersTypes == InVal); %Tag =Specify a label to associate with a serial port object OutVal = TransformersTypes(1,Tag);
6.1.9 SP_instcost % this function dedicates the primary installation cost % for any distribution substation function subscost = SP_instcost(substation) global KWTransformersTypes InstallCosts Tag = find(KWTransformersTypes == substation); subscost = InstallCosts(1,Tag); d=0;
6.1.10 DSP Running this program invokes the Graphics User Interface (GUI) which was developed in MATLAB. Two buttons will be made available ( run DSP and Help).
function varargout = DSP(varargin) % Pass or return variable numbers of arguments % eg function varargout = foo(n) returns a variable number % of arguments from function foo.m % DSP M-file for DSP.fig % DSP, by itself, creates a new DSP or raises the existing % singleton*. % % H = DSP returns the handle to a new DSP or the handle to % the existing singleton*. % % DSP('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in DSP.M with the given input arguments. % % DSP('Property','Value',...) creates a new DSP or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before DSP_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to DSP_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES
60
% Edit the above text to modify the response to help DSP % Last Modified by GUIDE v2.5 15-MAY-2009 02:23:10 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @DSP_OpeningFcn, ... 'gui_OutputFcn', @DSP_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before DSP is made visible. function DSP_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to DSP (see VARARGIN) % Choose default command line output for DSP handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes DSP wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = DSP_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; function generations_Callback(hObject, eventdata, handles) % hObject handle to generations (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
61
% Hints: get(hObject,'String') returns contents of generations as text % str2double(get(hObject,'String')) returns contents of generations as a double % --- Executes during object creation, after setting all properties. function generations_CreateFcn(hObject, eventdata, handles) % hObject handle to generations (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function populations_Callback(hObject, eventdata, handles) % hObject handle to populations (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of populations as text % str2double(get(hObject,'String')) returns contents of populations as a double % --- Executes during object creation, after setting all properties. function populations_CreateFcn(hObject, eventdata, handles) % hObject handle to populations (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in Run_DSP. function Run_DSP_Callback(hObject, eventdata, handles) % hObject handle to Run_DSP (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) function scalingfactor_Callback(hObject, eventdata, handles)
62
% hObject handle to scalingfactor (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of scalingfactor as text % str2double(get(hObject,'String')) returns contents of scalingfactor as a double % --- Executes during object creation, after setting all properties. function scalingfactor_CreateFcn(hObject, eventdata, handles) % hObject handle to scalingfactor (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
6.1.11 SP_tlosscost1 % this function return the transformer's (input argument) loss function FValue=SP_tlosscost1(InValue) global KWTransformersTypes OpenCircuitLosses Tag = find(KWTransformersTypes == InValue); FValue = OpenCircuitLosses(1,Tag);
6.1.12 SP_losscost2 % this function return the transformer's (input argument) loss function FValue=SP_tlosscost1(InValue) global KWTransformersTypes ShortCircuitLosses Tag = find(KWTransformersTypes == InValue); FValue = ShortCircuitLosses(1,Tag);