You are on page 1of 14

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

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 x1 length is 12 as shown in the figure. 0 1 0 0 0 1 1 1 0 0 0 1

4, x2

7 and x3 1 . Then the chromosome

x1

x2

x3

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.

D Nagesh Kumar, IISc, Bangalore

M9L2

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

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.

D Nagesh Kumar, IISc, Bangalore

M9L2

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

Start

Generate Initial Population

Encode Generated Population

Evaluate Fitness Functions

Best Individuals R E G E N E R A T I O N Meets Optimization Criteria? Yes

No Selection (select parents)

Stop

Crossover (selected parents)

Mutation (mutate offsprings)

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+1th 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.

D Nagesh Kumar, IISc, Bangalore

M9L2

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

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.

D Nagesh Kumar, IISc, Bangalore

M9L2

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

Table 1 Candidate 1011 0110 1101 1001 0101 0011 1110 1101 0001 0001 1111 1011 1011 1111 1011 1100 Total Fitness value 109 76 50 153 388 Percentage of total fitness 28.09 19.59 12.89 39.43 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

D Nagesh Kumar, IISc, Bangalore

M9L2

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

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
M9L2

D Nagesh Kumar, IISc, Bangalore

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

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 MultiObjective 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.

D Nagesh Kumar, IISc, Bangalore

M9L2

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

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; 75o3820 E longitude and 13o42 N latitude.

D Nagesh Kumar, IISc, Bangalore

M9L2

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

Fig. 3 Schematic diagram of Bhadra reservoir Project

Multi Objective Reservoir Operation Model Objective functions: 1. Minimize irrigation deficit (f1)
SQDV
12 t 1 2

Dl ,t

IRl ,t

12 t 1

Dr ,t

IRr ,t

2. Maximize hydropower production (f2)


E
12 t 1

k1 Rl ,t H l ,t

k2 Rr ,t H r ,t

k3 Rb ,t H b ,t

Subject to constraints in (i) Reservoir storage continuity constraint

St
(ii) Storage bounds

St

It

R1,t

R2,t

R3,t

Et Ot

Smin

St

Smax
E1,max E2 ,max E3,max

(iii)Turbine capacity limits

pR1,t H1,t pR2 ,t H 2 ,t pR3 ,t H 3,t


(iv) Canal capacity limits

D Nagesh Kumar, IISc, Bangalore

M9L2

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

10

R1,t R2 ,t

C1,max C2 ,max

(v) Irrigation demands


D1min ,t D2min ,t R1,t R2 ,t D1max ,t D2max ,t

(vi) Water quality requirements

R3,t

MDTt

Pareto optimal solution for reservoir operation


230 220 210 200

f2
190 180 170 160 150 gen=50 gen=200 gen=500

10

12 x 10
4

f1

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

D Nagesh Kumar, IISc, Bangalore

M9L2

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

11

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)

D Nagesh Kumar, IISc, Bangalore

M9L2

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

12

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.

D Nagesh Kumar, IISc, Bangalore

M9L2

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

13

Fig. 7 Optimal release policy obtained for equal priority case, showing releases in Mm 3 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,

D Nagesh Kumar, IISc, Bangalore

M9L2

Water Resources Systems Planning and Management: Advanced Topics Genetic Algorithms

14

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.

D Nagesh Kumar, IISc, Bangalore

M9L2

You might also like