Transcript lecture2

Advanced Topics
Genetic Algorithms
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Objectives
 To introduce the concept of genetic algorithms (GA)
 To explain the basic steps in a simple GA
 Parent Selection
 Cross over
 Mutation
 To introduce Multiobjective GA’s (MOGA)
 To apply MOGA in reservoir operation
2
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Introduction
 Real world optimization problems mostly involve complexities like discrete-
continuous or mixed variables, multiple conflicting objectives, non-linearity,
discontinuity and non-convex region
 Global optimum cannot be found in a reasonable time due to the large search space
 For such problems, existing linear or nonlinear methods may not be efficient
 Various stochastic search methods like
 simulated annealing,
 evolutionary algorithms (EA),
 hill climbing can be used in such situations
3
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Introduction

Among these techniques, the special advantage of EA’s are

Can be applied to any combination of complexities (multi-objective, nonlinearity etc) and also


Can be combined with any existing local search or other methods
Various techniques which make use of EA approach

Genetic Algorithms (GA), Evolutionary Programming, Evolution Strategy,
Learning Classifier System etc.

4
EA techniques operate mainly on a population search basis.
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Basic Concept of EA

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

The encoding (representation) or the individuals in the EA is called genotype

The mapping of phenotype to genotype differs in each EA technique
 In GA, variables are represented as strings of numbers (normally binary)
 Let the number of design variables be n
 Let each design variable is given by a string of length ‘l
 Then the design vector will have a total string length ‘nl’
5
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Basic Concept of EA…
 For example, if the string length be 4 for each design variable and there are 3 design
variables,
x1  4, x2  7 and x3  1
 Then the chromosome length is 12 as shown
 An individual consists of a genotype and a fitness function
 Fitness Function:
 Represents the quality of the solution
 Forms the basis for selecting the individuals and thereby facilitates improvements
6
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Basic Concept of EA…
Pseudo code for a simple EA
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
}
7
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Start
Basic Concept of EA…
Generate Initial Population
Encode Generated Population
Evaluate Fitness Functions
Best
Individuals
Flowchart indicating the steps of a
simple genetic algorithm
R
E
G
E
N
E
R
A
T
I
O
N
Meets
Optimization
Criteria?
No
Yes
Stop
Selection (select parents)
Crossover (selected parents)
Mutation (mutate offsprings)
8
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Basic Concept of EA…
Initial population is randomly generated
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)
Finally, the new population is evaluated and the process is repeated
The termination condition may be a desired fitness function, maximum number of
generations etc
9
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Parent Selection
Individuals are distinguished based on their fitness function value
According to Darwin's evolution theory the best ones should survive and
create new offspring for the next generation
Different methods are available to select the best chromosomes
Roulette wheel selection,
Rank selection,
Boltzman selection,
Tournament selection,
Steady state selection
10
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Parent Selection : Roulette wheel selection
Each individual is selected with a probability proportional to its fitness value
In other words, an individual is selected depending on the percentage contribution to
the total population fitness
Thus, weak solutions are eliminated and strong solutions survive to form the next
generation
 Consider a population containing four strings shown
11
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
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Parent Selection : Roulette wheel selection…
Each string is formed by concatenating four substrings representing variables a, b, c
and d. Length of each string is taken as four bits
First column represents the possible solution in binary form
Second column gives the fitness values of the decoded strings
Third column gives the percentage contribution of each string to the total fitness of
the population
Thus, the probability of selection of candidate 1, as a parent of the next generation is
28.09%
Probabilities of other candidates 2, 3, 4 are 19.59, 12.89 and 39.43 respectively
These probabilities are represented on a pie chart
Then four numbers are randomly generated between 1 and 100
12
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Parent Selection : Roulette wheel selection…
The likeliness of these numbers falling 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
The main disadvantage of this method is 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
13
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Parent Selection: Rank Selection
Population is ranked first
Every chromosome will be allotted with one fitness corresponding to 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 doing this, all the chromosomes 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
14
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Parent Selection
Through selection new individuals cannot get introduced into the population
Selection cannot find new points in the search space
New individuals are generated by genetically-inspired operators known are
crossover and mutation.
15
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Crossover
Crossover can be of either one-point or two-point scheme
One point crossover: Selected pair of strings is cut at some random position and
their segments are swapped to form new pair of strings
Consider two 8-bit strings given by '10011101' and '10101011'
Choose a random crossover point after 3 bits from left
100 | 11101
101 | 01011
Segments are swapped and the resulting strings are
10001011
10111101
16
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Crossover…
Two point crossover: 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
If two crossover points are selected as
100 | 11 | 101
101 | 01 | 011
After swapping both the extreme segments, the resulting strings formed are
10001101
10111011
17
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Mutation
Mutation is applied to each child individually after crossover
Randomly alters each gene with a small probability (generally not greater than 0.01)
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
Sixth bit '0' is changed to '1‘
In mutation process, bits are changed from '1' to '0' or '0' to '1' at the randomly
chosen position of randomly selected strings
18
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Real-coded GAs
 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.
19
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Areas of Application in Water Resources
 Water distribution systems
 Hydrological modeling
 Watershed Management
 Groundwater modeling
 Reservoir Operation
20
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Advantages and Disadvantages of EA
Advantages
 EA can be efficiently used for highly complex problems with multi-objectivity, non-
linearity etc
 Provides not only a single best solution, but the 2nd best, 3rd best and so on as
required.
 Gives quick approximate solutions
 Can incorporate with other local search algorithms
Disadvantages
 Optimal solution cannot be ensured on using EA 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
 Implementation requires good programming skill
21
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
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.
22
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Flow chart of Multiobjective Genetic Algorithm
with Elitism
23
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Multi-objective reservoir system optimization –
Case Study
Bhadra Reservoir –Multipurpose reservoir
Location - Chickmangalur Dt, Karnataka state, India;
75o38’20’’ E longitude and 13o42’ N latitude
Bhadra river
Right turbine
capacity=13,200 kW
Reservoir
PH2
Right bank
canal
PH3
Irrigated area
87, 512 ha
Left turbine
capacity=2,000 kW
PH1
Left bank
canal
Bed turbine
capacity=24,000
kW
Irrigated area
6, 367 ha
River Water Quality
Schematic diagram of Bhadra reservoir Project
24
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Multi Objective Reservoir Operation Model
1.
Minimize
Irrigation deficit (f1):
2.
Maximize
Hydropower production (f2):
Subject to constraints on
System dynamics
Storage bounds
Maximum power production limits
Irrigation demands and
Water quality requirements
25
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Multi Objective Reservoir Operation Model:
Constraints
Reservoir storage continuity constraints
S t 1  S t  I t  ( R1,t  R2,t  R3,t  Et  Ot )
Storage bound constraints
for all t=1, 2,…,12
Smin ≤ St ≤ Smax
Turbine capacity Limits
p R1,t H1,t ≤ E1,max
p Rr,t H2,t ≤ E2,max
for all t=1, 2,…,12
p R3,t H3,t ≤ E3,max
Canal capacity limits
R1,t ≤ C1,max
R2,t ≤ C2,max
Irrigation demands
D1min, t ≤ R1,t ≤ D1max, t
D2min, t ≤ R2,t ≤ D2max, t
Water Quality Requirements
R3,t ≥ MDTt
26
Water Resources Planning and Management: M9L2
for all t=1, 2,…,12
for all t=1, 2,…,NT
for all t=1, 2,…,NT
D Nagesh Kumar, IISc
Pareto optimal solution for reservoir
operation
230
220
210
200
f2
190
gen=50
gen=200
gen=500
180
170
160
150
0
2
4
6
8
10
f1
12
4
x 10
 Improvement in Pareto optimal front over the iterations.
 f1 is annual squared irrigation deficit; f2 is hydropower generated MkWh
27
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
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
28
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Pareto optimal front
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)
29
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Reservoir operating policies
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.
30
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Optimal release policy
 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.
31
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Advantages of MOEAs
 MOEAs are easy to adopt and can provide efficient solutions for multi-objective
problems
 MOEAs are capable of handling nonlinear objectives/ constraints, disconnected
Pareto-fronts, non-convex decision space
 MOEAs can find solutions to extremely complex and high dimensional real-world
applications in reasonable computation time
 MOEAs have high potential for multi-objective optimization of hydrological &
water resources problems
32
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc
Thank You
Water Resources Planning and Management: M9L2
D Nagesh Kumar, IISc