Upload
hoangtram
View
218
Download
3
Embed Size (px)
Citation preview
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
1
M9L2
MODULE - 9 LECTURE NOTES – 2
GENETIC ALGORITHMS
INTRODUCTION
Most real world optimization problems involve complexities like discrete, continuous or
mixed variables, multiple conflicting objectives, non-linearity, discontinuity and non-convex
region. The search space (design space) may be so large that global optimum cannot be found
in a reasonable time. The existing linear or nonlinear methods may not be efficient or
computationally inexpensive for solving such problems. Various stochastic search methods
like simulated annealing, evolutionary algorithms (EA) or hill climbing can be used in such
situations. EAs have the advantage of being applicable to any combination of complexities
(multi-objective, non-linearity etc) and also can be combined with any existing local search
or other methods. Various techniques which make use of EA approach are Genetic
Algorithms (GA), evolutionary programming, evolution strategy, learning classifier system
etc. All these EA techniques operate mainly on a population search basis. In this lecture
Genetic Algorithms, the most popular EA technique, is explained.
CONCEPT
EAs start from a population of possible solutions (called individuals) and move towards the
optimal one by applying the principle of Darwinian evolution theory i.e., survival of the
fittest. Objects forming possible solution sets to the original problem is called phenotype and
the encoding (representation) of the individuals in the EA is called genotype. The mapping of
phenotype to genotype differs in each EA technique. In GA which is the most popular EA,
the variables are represented as strings of numbers (normally binary). If each design variable
is given a string of length ‘l’, and there are n such variables, then the design vector will have
a total string length of ‘nl’. For example, let there are 3 design variables and the string length
be 4 for each variable. The variables are 17,4 321 xandxx . Then the chromosome
length is 12 as shown in the figure.
0 1 0 0 0 1 1 1 0 0 0 1
1x 2x 3x
An individual consists a genotype and a fitness function. Fitness represents the quality of the
solution (normally called fitness function). It forms the basis for selecting the individuals and
thereby facilitates improvements.
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
2
M9L2
The pseudo code for a simple EA is given below
i = 0
Initialize population P0
Evaluate initial population
while ( ! termination condition)
{
i = i+1
Perform competitive selection
Create population Pi from Pi-1 by recombination and mutation
Evaluate population Pi
}
A flow chart indicating the steps of a simple genetic algorithm is shown in figure 1.
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
3
M9L2
Fig. 1
The initial population is usually generated randomly in all EAs. The termination condition
may be a desired fitness function, maximum number of generations etc. In selection,
individuals with better fitness functions from generation ‘i' are taken to generate individuals
of ‘i+1’th
generation. New population (offspring) is created by applying recombination and
mutation to the selected individuals (parents). Recombination creates one or two new
individuals by swaping (crossing over) the genome of a parent with another. Recombined
individual is then mutated by changing a single element (genome) to create a new individual.
Generate Initial Population
Start
Encode Generated Population
Evaluate Fitness Functions
Meets
Optimization
Criteria?
Best
Individuals
Yes
Stop
Selection (select parents)
Mutation (mutate offsprings)
Crossover (selected parents)
No
R
E
G
E
N
E
R
A
T
I
O
N
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
4
M9L2
Finally, the new population is evaluated and the process is repeated. Each step is described in
more detail below.
PARENT SELECTION
After fitness function evaluation, individuals are distinguished based on their quality.
According to Darwin's evolution theory the best ones should survive and create new offspring
for the next generation. There are many methods to select the best chromosomes, for example
roulette wheel selection, Boltzmann selection, tournament selection, rank selection, steady
state selection and others. Two of these are briefly described, namely, roulette wheel
selection and rank selection:
Roulette Wheel Selection:
Parents are selected according to their fitness i.e., each individual is selected with a
probability proportional to its fitness value. In other words, depending on the percentage
contribution to the total population fitness, string is selected for mating to form the next
generation. This way, weak solutions are eliminated and strong solutions survive to form the
next generation. For example, consider a population containing four strings shown in the
Table 1. Each string is formed by concatenating four substrings which represents variables
a,b,c and d. Length of each string is taken as four bits. The first column represents the
possible solution in binary form. The second column gives the fitness values of the decoded
strings. The third column gives the percentage contribution of each string to the total fitness
of the population. Then by "Roulette Wheel" method, the probability of candidate 1 being
selected as a parent of the next generation is 28.09%. Similarly, the probability that the
candidates 2, 3, 4 will be chosen for the next generation are 19.59, 12.89 and 39.43
respectively. These probabilities are represented on a pie chart, and then four numbers are
randomly generated between 1 and 100. Then, the likeliness that the numbers generated
would fall in the region of candidate 2 might be once, whereas for candidate 4 it might be
twice and candidate 1 more than once and for candidate 3 it may not fall at all. Thus, the
strings are chosen to form the parents of the next generation.
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
5
M9L2
Table 1
Candidate Fitness value Percentage of total fitness
1011 0110 1101 1001 109 28.09
0101 0011 1110 1101 76 19.59
0001 0001 1111 1011 50 12.89
1011 1111 1011 1100 153 39.43
Total 388 100
Rank Selection:
The previous type of selection may have problems when the fitnesses differ very much. For
example, if the best chromosome fitness is 90% of the entire roulette wheel then the other
chromosomes will have very few chances to be selected. Rank selection first ranks the
population and then every chromosome receives fitness from this ranking. The worst will
have fitness 1, second worst 2 etc. and the best will have fitness N (number of chromosomes
in population). By this, all the chromosomes will have a chance to be selected. But this
method can lead to slower convergence, because the best chromosomes may not differ much
from the others.
CROSSOVER
Selection alone cannot introduce any new individuals into the population, i.e., it cannot find
new points in the search space. These are generated by genetically-inspired operators, of
which the most well known are crossover and mutation.
Crossover can be of either one-point or two-point scheme. In one point crossover, selected
pair of strings is cut at some random position and their segments are swapped to form new
pair of strings. In two-point scheme, there will be two break points in the strings that are
randomly chosen. At the break-point, the segments of the two strings are swapped so that
new set of strings are formed. For example, let us consider two 8-bit strings given by
'10011101' and '10101011'.
Then according to one-point crossover, if a random crossover point is chosen after 3 bits from
left and segments are cut as shown below:
100 | 11101
101 | 01011
and the segments are swapped to form
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
6
M9L2
10001011
10111101
According to two-point crossover, if two crossover points are selected as
100 | 11 | 101
101 | 01 | 011
Then after swapping both the extreme segments, the resulting strings formed are
10001101
10111011
Crossover is not usually applied to all pairs of individuals selected for mating. A random
choice is made, where the probability of crossover being applied is typically between 0.6 and
0.9.
MUTATION
Mutation is applied to each child individually after crossover. It randomly alters each gene
with a small probability (generally not greater than 0.01). It injects a new genetic character
into the chromosome by changing at random a bit in a string depending on the probability of
mutation.
Example: 10111011
is mutated as 10111111
It is seen in the above example that the sixth bit '0' is changed to '1'. Thus, in mutation
process, bits are changed from '1' to '0' or '0' to '1' at the randomly chosen position of
randomly selected strings.
REAL-CODED GAs
As explained earlier, GAs work with a coding of variables i.e., with a discrete search space.
GAs have also been developed to work directly with continuous variables. In these cases,
binary strings are not used. Instead, the variables are directly used. After the creation of
population of random variables, a reproduction operator can be used to select good strings in
the population.
AREAS OF APPLICATION IN WATER RESOURCES
Water distribution systems
Hydrological modeling
Watershed Management
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
7
M9L2
Groundwater modeling
Reservoir Operation
ADVANTAGES AND DISADVANTAGES OF EA:
EA can be efficiently used for highly complex problems with multi-objectivity, non-linearity
etc. It provides not only a single best solution, but the 2nd
best, 3rd
best and so on as required.
It gives quick approximate solutions. EA methods can very well incorporate with other local
search algorithms.
There are some drawbacks also in using EA techniques. An optimal solution cannot be
ensured on using EA methods, which are usually known as heuristic search methods.
Convergence of EA techniques are problem oriented. Sensitivity analysis should be carried
out to find out the range in which the model is efficient. Also, the implementation of these
techniques requires good programming skill.
MULTI-OBJECTIVE EVOLUTIONARY ALGORITHMS
Genetic algorithms are efficient in solving multiobjective problems. Considerations in Multi-
Objective Evolutionary Algorithms (MOEAs) implementation are
1. Preserve non-dominated points – elitism
2. Progress towards points on Pareto front
3. Maintain diversity of points on Pareto Front (phenotype) and/or Pareto Optimal
solutions (genotype)
4. Provide decision maker a limited number of Pareto Front (PF) points.
Non-dominated solutions are always better than 1st-level dominated solutions, which are
always better than 2nd-level dominated solutions, etc. Within the same level of dominance,
solutions which are isolated are better than solutions that are clumped together.
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
8
M9L2
Flow chart of Multi-objective Genetic Algorithm with Elitism
Fig. 2
Multi Objective Genetic Algorithms for Optimal Reservoir Operation – Case Study
Bhadra Reservoir – A multi-purpose reservoir located in the district of Chickmangalur,
Karnataka state, India; 75o38
’20
’’ E longitude and 13
o42
’ N
latitude.
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
9
M9L2
Fig. 3 Schematic diagram of Bhadra reservoir Project
Multi Objective Reservoir Operation Model
Objective functions:
1. Minimize irrigation deficit (f1)
212
1
212
1 t
trtr
t
tltl IRDIRDSQDV ,,,,
2. Maximize hydropower production (f2)
12
1
321
t
tbtbtrtrtltl HRkHRkHRkE ,,,,,,
Subject to constraints in
(i) Reservoir storage continuity constraint
tttttttt OERRRISS ,,, 3211
(ii) Storage bounds
maxmin SSS t
(iii)Turbine capacity limits
max,,,
max,,,
max,,,
333
222
111
EHpR
EHpR
EHpR
tt
tt
tt
(iv) Canal capacity limits
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
10
M9L2
max,,
max,,
22
11
CR
CR
t
t
(v) Irrigation demands
ttt
ttt
DRD
DRD
,,,
,,,
maxmin
maxmin
222
111
(vi) Water quality requirements
tt MDTR ,3
Pareto optimal solution for reservoir operation
0 2 4 6 8 10 12
x 104
150
160
170
180
190
200
210
220
230
gen=50
gen=200
gen=500
Fig. 4 Improvement in Pareto optimal front over the iterations. f1 is annual squared irrigation
deficit; f2 is hydropower generated MkWh
Model Application
MOGA model is solved for three different inflow scenarios into the reservoir
Scenario 1: Mean monthly inflows – 0.5 * SD
Scenario 2: Mean monthly inflows
Scenario 3: Mean monthly inflows + 0.5 * SD
where SD is the standard deviation of monthly flows
f1
f2
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
11
M9L2
Fig. 5 Pareto optimal front, showing the trade-off between irrigation ( f1) and hydropower (
f2) for different inflow scenarios. f1 = sum of squared irrigation deficits, (Mm3)2; f2 =
hydropower generated, (MkWh)
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
12
M9L2
Fig. 6 Reservoir operating policies for different inflow scenarios, showing the initial storages
for different situations, viz., equal priority case, irrigation only priority case and hydropower
only priority case.
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
13
M9L2
Fig. 7 Optimal release policy obtained for equal priority case, showing releases in Mm3 for
Left bank canal (R1), Right bank canal (R2) and River bed (R3) for different inflow
scenarios.
Advantages of MOEAs:
MOEAs are easy to adopt and can provide efficient solutions for multi-objective problems.
They are capable of handling nonlinear objectives/ constraints, disconnected Pareto-fronts,
Water Resources Systems Planning and Management: Advanced Topics – Genetic Algorithms
D Nagesh Kumar, IISc, Bangalore
14
M9L2
non-convex decision space. They can find solutions to extremely complex and high
dimensional real-world applications in reasonable computation time. They have high
potential for multi-objective optimization of hydrological and water resources problems.