genetic algorithms csci-2300 introduction to algorithms

Download Genetic Algorithms CSCI-2300 Introduction to Algorithms

Post on 23-Feb-2016




0 download

Embed Size (px)


Genetic Algorithms CSCI-2300 Introduction to Algorithms. David Goldschmidt, Ph.D. Rensselaer Polytechnic Institute April 28, 2014. Evolutionary Computing. Evolutionary computing produces high-quality partial solutions to problems through natural selection and survival of the fittest - PowerPoint PPT Presentation


Artificial Intelligence CIS 342

Genetic AlgorithmsCSCI-2300 Introduction to AlgorithmsDavid Goldschmidt, Ph.D.Rensselaer Polytechnic InstituteApril 28, 2014Evolutionary ComputingEvolutionary computing produceshigh-quality partial solutions to problems throughnatural selection andsurvival of the fittest

Compare to naturalbiological systems thatadapt and learn over time

Genetic Algorithm ExampleFind the maximum value of function f(x) = x2 + 15x

Represent problem using chromosomes built from four genes:http://www.webgraphing.comGenetic Algorithm ExampleInitial random population of size N = 6:

Genetic Algorithm ExampleDetermine chromosome fitness foreach chromosome:

218 100.0

fitness function here issimply the original functionf(x) = x2 + 15x

Genetic Algorithm ExampleUse fitness ratios to determine which chromosomes are selected for crossoverand mutation operations:Genetic Algorithm ExampleConverge on a near-optimal solution:

Convergence Example

local maximumglobal maximumGenetic Algorithms Step 1Represent the problem domain asa chromosome of fixed lengthUse a fixed number of genes to represent a solutionUse individual bits or characters for efficientmemory use and speed

e.g. Traveling Salesman Problem (TSP)

Genetic Algorithms Step 2Define a fitness function f(x) to measurethe quality of individual chromosomes

The fitness function determineswhich chromosomes carry over to the next generation which chromosomes are crossed over with one anotherwhich chromosomes are individually mutated

Genetic Algorithms Step 3Establish our genetic algorithm parameters:Choose the size of the population, N Set the crossover probability, pc Set the mutation probability, pm

Randomly generate an initial populationof chromosomes: x1, x2, ..., xN

. . .Genetic Algorithms Step 4Calculate the fitness of eachindividual chromosome using f(x): f(x1), f(x2), ..., f(xN)

Order the population based on fitness values

Genetic Algorithms Step 5Using pc, select pairs of chromosomesfor crossover

Using pm, select chromosomes for mutation

Chromosomes are selectedbased on their fitnessvalues using aroulette wheel approach:

Genetic Algorithms Step 6Create a pair of offspring chromosomes by applying a crossover operation:

Genetic Algorithms Step 6Mutate an offspring chromosome by applyinga mutation operation:Genetic Algorithms Steps 7 & 8Step 7:Place all generated offspringchromosomes in a new population

Step 8:Go back to Step 5 until the size of the new population is equal to the size of the initial population, N

Genetic Algorithms Steps 9 & 10Step 9:Replace the initial population withthe new population

Step 10:Go back to Step 4 and repeat the processuntil termination criteria are satisfiedTypically repeat this process for 50-5000+ generations

IterationCrossword Puzzle ConstructionGiven:Dictionary of valid wordsand phrasesEmpty crossword grid

Problem:Fill the crossword grid suchthat all words both acrossand down are valid(assign clues later)

Crossword Puzzle ConstructionGenetic Algorithm (GA)Evolve a solution by crossovers andmutations through many generationsInitial population of crossword grids:Random letters?Random letters based on Scrabble frequencies?Random words from dictionary?Fitness of each grid is number of valid wordsTermination CriteriaWhen do we stop?Pause a genetic algorithm after agiven number of generations, thencheck the fittest chromosomesIf the fittest chromosomes are fitbeyond a given threshold,terminate the genetic algorithm

Also consider stopping when the highest fitness value does not change for a large number of generations

?How long does it take for an algorithm toproduce a solution?Depends on the size of the input andthe complexity of the algorithm

The size of the input is n

The complexity of the algorithm is classifiedbased on its expected run time Computational Complexity

Big-O notation measures the expected run timeof an algorithm (i.e. its computational complexity)Constant time: O(1) Logarithmic time: O(log n) Linear time: O(n) Linearithmic time: O(n log n) Quadratic time: O(n2) Exponential time: O(c n) Factorial time: O(n!) Computational Complexity

PNPGenetic algorithms are often well-suited to producing reasonable solutions to intractable problemsIntractable problems are problems withexcessive computational complexityi.e. in the Nondeterministic Polynomial (NP) class of problems

A reasonable solution is a partial or inexact solution that adequately solves the problem in polynomial time Genetic AlgorithmsConsider the Traveling Salesman Problem (TSP) in which a salesman aims to visit n cities exactly once covering the least distance

Starting at any given node, choose from n1 remaining nodes, then choose from n2 remaining nodes, etc.Testing every possible route takes (n1)! stepssee Genetic Algorithms Exampleyikes!Use a genetic algorithm to evolve a near-optimal solution to the TSPLabel cities A, B, C, D, E, F, etc.Example circuits: ABCDEF, BDAFCE, FBECAD

How do we perform crossover operations?Basic crossovers might result in invalid membersof the populatione.g. combining ABCDEF and BDAFCE may result in ABCFCE Genetic Algorithms ExampleKey challenge of developing a genetic algorithm is often the representation of the problemFor TSP, consider a standard ordering ABCDEF, assigning the code 123456All other sequences encoded based on the removal of letters

Basic crossover works...Genetic Algorithms Example

All other sequences encoded based on the removal of letters from standard orderingSequence BDAFCE has code 231311B is 2 in ABCDEF D is 3 in ACDEF A is 1 in ACEF F is 3 in CEF C is 1 in CE E is 1 in E

Genetic Algorithms Example

Crossing ACEDB with ABCED...

Crossover OperationGenetic Algorithms Example

Combining ACEDB with ABCED......yields ACBED

from A.K. Dewdneys The (New) Turing Omnibus, Computer Science Press, New York, 1993Genetic Algorithms Exampleanother approach: Genetic AlgorithmsAdvantages of genetic algorithms:Often outperform brute force approaches by randomly jumping around the search spaceIdeal for problem domains in which near-optimal (as opposed to exact) solutions are adequate

Disadvantages of genetic algorithms:Might not find any satisfactory partial solutionsTuning can be a challenge


View more >