Top Banner
SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET
38

SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Dec 29, 2015

Download

Documents

Louisa Francis
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

SOFT COMPUTING

(Optimization Techniques using GA)

Dr. N.Uma MaheswariProfessor/CSEPSNA CET

Page 2: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

GA Quick Overview• Developed: USA in the 1970’s• Early names: J. Holland, K. DeJong, D. Goldberg• Typically applied to:

– discrete optimization• Attributed features:

– not too fast– good heuristic for combinatorial problems

• Special Features:– Traditionally emphasizes combining information from good parents

(crossover)– many variants, e.g., reproduction models, operators

04/19/23 Dr.N.Uma Maheswari, PSNACET 2

Page 3: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Search SpaceInitialization

• Initially many individual solutions are randomly generated to

form an initial population, covering the entire range of

possible solutions (the search space)

• Each point in the search space represents one possible solution

marked by its value( fitness)

Selection

A proportion of the existing population is selected to bread a

new bread of generation.04/19/23 Dr.N.Uma Maheswari, PSNACET 3

Page 4: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Search Space cont…

Reproduction

• Generate a second generation population of solutions from those selected

through genetic operators: crossover and mutation.

Termination

• A solution is found that satisfies minimum criteria

• Fixed number of generations found

• Allocated budget (computation, time/money) reached

• The highest ranking solution’s fitness is reaching or has reached

04/19/23 Dr.N.Uma Maheswari, PSNACET 4

Page 5: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Classes of Search Techniques

04/19/23 Dr.N.Uma Maheswari, PSNACET 5

Page 6: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

GeneticsChromosome

• All Living organisms consists of cells. In each cell there is a

same set of Chromosomes.

• Chromosomes are strings of DNA and consists of genes,

blocks of DNA.

• Each gene encodes a trait, for example color of eyes. Possible

settings for a trait (e.g. blue, brown) are called alleles.

Each gene has its own position in the chromosome. This

position is called locus. 04/19/23 Dr.N.Uma Maheswari, PSNACET 6

Page 7: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Genetics Cont…Reproduction

• During reproduction, recombination (or crossover) occurs

first. Genes from parents combine to form a whole new

chromosome. The newly created

offspring can then be mutated. The changes are mainly caused

by errors in copying genes from parents.

• The fitness of an organism is measure by success of the

organism in its life (survival)

04/19/23 Dr.N.Uma Maheswari, PSNACET 7

Page 8: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Principle Of Natural Selection

• “Select The Best, Discard The Rest”

Two important elements required for any problem before a genetic algorithm can be used for a solution are:

Method for representing a solution (encoding)

ex: string of bits, numbers, character

Method for measuring the quality of any proposed solution, using fitness function

ex: Determining total weight04/19/23 Dr.N.Uma Maheswari, PSNACET 8

Page 9: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

GA Elements

04/19/23 Dr.N.Uma Maheswari, PSNACET 9

Page 10: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Nature Vs Computer - MappingNature Computer

PopulationIndividualFitnessChromosomeGeneReproduction

Set of solutions.Solution to a problem.Quality of a solution.Encoding for a Solution.Part of the encoding of a solution.Crossover

04/19/23 Dr.N.Uma Maheswari, PSNACET 10

Page 11: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

04/19/23 Dr.N.Uma Maheswari, PSNACET 11

Page 12: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Genetic algorithms

• Holland’s original GA is now known as the simple genetic algorithm (SGA)

• Other GAs use different:– Representations– Mutations– Crossovers– Selection mechanisms

04/19/23 Dr.N.Uma Maheswari, PSNACET 12

Page 13: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Fitness function

• Quantifies the optimality of a solution (that is, a chromosome): that particular chromosome may be ranked against all the other chromosomes

• A fitness value is assigned to each solution depending on how close it actually is to solving the problem.

• Ideal fitness function correlates closely to goal + quickly computable.

• For instance, knapsack problem

Fitness Function = Total value of the things in the knapsack

04/19/23 Dr.N.Uma Maheswari, PSNACET 13

Page 14: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Encoding

• Encoding of chromosomes is one of the problems, when you

are starting to solve problem with GA. Encoding very depends

on the problem.

• Binary Encoding: In binary encoding every chromosome is a

string of bits, 0 or 1. A101100101100101011100101

B111111100000110000011111

04/19/23 Dr.N.Uma Maheswari, PSNACET 14

Page 15: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Encoding contd…

• Permutation Encoding: In permutation encoding, every

chromosome is a string of numbers, which represents number in a

sequence. Eg:Chrom A:124356765

• Real Value Encoding: In value encoding, every chromosome is a

string of some values. Values can be anything connected to problem,

form numbers, real numbers or chars to some complicated objects.

eg: Chromosome A:  5.3243  0.4556  2.3293  2.4545

• Tree Encoding: In tree encoding every chromosome is a tree of

some objects, such as functions or commands in programming

language.

04/19/23 Dr.N.Uma Maheswari, PSNACET 15

Page 16: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Recombination

Main idea: "Select The Best, Discard The Rest”. The process that chooses solutions to be

preserved and allowed to reproduce and selects which ones must to die out.

• The main goal of the recombination operator is to emphasize the good solutions and eliminate the bad solutions in a population ( while keeping the population size constant )

04/19/23 Dr.N.Uma Maheswari, PSNACET 16

Page 17: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

• Main idea: better individuals get higher chance– Chances proportional to fitness– Implementation: roulette wheel technique

» Assign to each individual a part of the roulette wheel

» Spin the wheel n times to select n individuals

SGA operators: Selection

fitness(A) = 3

fitness(B) = 1

fitness(C) = 2

A C

1/6 = 17%

3/6 = 50%

B

2/6 = 33%

04/19/23

Page 18: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

An example after Goldberg ‘89 (1)

• Simple problem: max x2 over {0,1,…,31}• GA approach:

– Representation: binary code, e.g. 01101 13– Population size: 4– 1-point xover, bitwise mutation – Roulette wheel selection– Random initialisation

• We show one generational cycle done by hand

Page 19: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

So, how to select the best?

Roulette Selection

Rank Selection

Steady State Selection

Tournament Selection

Page 20: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Roulette wheel selection

Main idea: the fitter is the solution with the most chances to be chosen

HOW IT WORKS ?

Page 21: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

x2 example: selection

Page 22: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

X2 example: crossover

Page 23: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

X2 example: mutation

Page 24: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.
Page 25: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Crossover- Many genetic algorithms use strings of binary symbols for chromosomes, as in our Knapsack example, to represent solutions.

Crossover means choosing a random position in the string (say, after 2 digits) and exchanging the segments either to the right or to the left of this point with another string partitioned similarly to produce two new off spring.

04/19/23 Dr.N.Uma Maheswari, PSNACET 25

Crossover

Page 26: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Cross Over-Single-site

Page 27: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Crossover methods

• Single Point Crossover- A random point is chosen on the individual chromosomes (strings) and the genetic material is exchanged at this point.

04/19/23 Dr.N.Uma Maheswari, PSNACET 27

Page 28: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Uniform Crossover using Mask

Page 29: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Two Dimensional Crossover-Matrix Crossover

Page 30: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.
Page 31: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

GA Cycle

Page 32: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Outline of the Basic Genetic Algorithm

1. [Start] Generate random population of n chromosomes (suitable solutions for the problem)

2. [Fitness] Evaluate the fitness f(x) of each chromosome x in the population

3. [New population] Create a new population by repeating following steps until the new population is complete

04/19/23 Dr.N.Uma Maheswari, PSNACET 32

Page 33: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

4. [Selection] Select two parent chromosomes from a population according to their fitness (the better fitness, the bigger chance to be selected) The idea is to choose the better parents.

5. [Crossover] With a crossover probability cross over the parents to form a new offspring (children). If no crossover was performed, offspring is an exact copy of parents.

6. [Mutation] With a mutation probability mutate new offspring at each locus (position in chromosome).

04/19/23 Dr.N.Uma Maheswari, PSNACET 33

Page 34: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

7. [Accepting] Place new offspring in a new population

8. [Replace] Use new generated population for a further run of algorithm

9. [Test] If the end condition is satisfied, stop, and return the best solution in current population

10. [Loop] Go to step 2

04/19/23 Dr.N.Uma Maheswari, PSNACET 34

Page 35: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

Flow Diagram of the Genetic Algorithm Process

04/19/23 Dr.N.Uma Maheswari, PSNACET 35

Describe Problem

Generate InitialSolutions

Test: is initialsolution good enough?

Stop

Select parents to reproduce

Apply crossover process and create a set of offspring

Apply random mutation

Step 1

Step 2

Step 3

Step 4

Step 5

Yes

No

Page 36: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.
Page 37: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.
Page 38: SOFT COMPUTING (Optimization Techniques using GA) Dr. N.Uma Maheswari Professor/CSE PSNA CET.

04/19/23 Dr.N.Uma Maheswari, PSNACET 38