Click here to load reader

Genetic Algorithms Yohai Trabelsi. Outline Evolution in the nature Genetic Algorithms and Genetic Programming A simple example for Genetic Algorithms

  • View
    227

  • Download
    1

Embed Size (px)

Text of Genetic Algorithms Yohai Trabelsi. Outline Evolution in the nature Genetic Algorithms and Genetic...

Genetic Algorithms

Some Results 1000 games were played against some alpha-beta players.

The Score: 1 point was given for win and 0.5 For drawn.

OutlineEvolution in the natureGenetic Algorithms and Genetic ProgrammingA simple example for Genetic AlgorithmsAn example for Genetic programmingEvolution in the natureGenetic Algorithms and Genetic ProgrammingA simple example for Genetic AlgorithmsAn example for Genetic programmingEvolution in the natureA Chromosome:A string of DNA.Each living cell has some.

Image by Magnus Manske

Each chromosome contains a set of genes.A gene is a block of DNA.Each gene determines some aspect of the organism (e.g., eye colour).

Reproduction in the natureReproduction involves: 1. Recombination of genes from parents. 2. Small amounts of mutation (errors) in copying.

One type of recombination is crossover.

Reproduction involves: 1. Recombination of genes from parents. 2. Small amounts of mutation (errors) in copying.

Right image by Jerry Friedman.

In the nature, fitness describes the ability to survive and reproduce. Images by ShwSie

The evolution cycleUpper left image by Parent selection

RecombinationMutation

Survivor selection

InitializationEvolution in the natureGenetic Algorithms and Genetic ProgrammingA simple example for Genetic AlgorithmsAn example for Genetic programmingSome historyFirst work of computer simulation of evolution- Nils Aall Barricelli(1954)In the 1950s and 1960s several researchers began independently studying evolutionary systems.The field has experienced impressive growth over the past two decades.Genetic AlgorithmsThe research on Genetic Algorithms focuses on imitating the evolution cycle in Algorithms.That method is applicable for many hard search and optimization problems.

InitializationInitialization is the process of making the first generation.During the algorithm our goal will be to improve them by imitating the nature.Termination.In the nature we dont have (yet) a point that the process stops. In many cases an algorithm that runs forever is useless.We should try to find the correct time for terminating the whole process.That time may be after the results are good and/or before the running time is too long.The modified evolution cycleUpper left image by Parent selection

RecombinationMutation

Survivor selectionInitializationtermination

GA-Some definitionsIn any generation there is a group of individuals that belongs to that generation. We call that group population.Fitness will be a function from individuals to real numbers.The product of the recombination process is an offspring.

Genetic ProgrammingGenetic Programming is Genetic Algorithm wherein the population contains programs rather than bitstrings.

Evolution in the natureGenetic Algorithms and Genetic ProgrammingA simple example for Genetic AlgorithmsAn example for Genetic programmingA simple exampleProblem: Find the binary number 11010010.

Initialization We start with 5 random binary numbers with 8 digits each.01001010 10011011011000011010011001010011

The fitness functionThe target: 11010010

fitness(01001010)=-3fitness(10011011)=-3fitness(01100001)=-5fitness(10100110)=-4fitness(01010011)=-2

Parent SelectionIn each generation, some constant number of parents, say, 4 are chosen. Higher is the fitness, greater is the probability of choosing the individual.

RecombinationMutationThe process and its terminationWe repeat the cycle until one of the numbers that we get would have fitness 0 (that is would be identical to the desired one). We expect that it will not be too long in comparison to checking the fitness of all the numbers in the range.Our hope is based on choosing parents with higher fitness and on producing next generations similarly to the nature.Some ResultsEvolution in the natureGenetic Algorithms and Genetic ProgrammingA simple example for Genetic AlgorithmsAn example for Genetic programmingAmerican CheckersMichel32Nl

Lose Checkers The rules are the same as in the original game.The goal is opposite to the goal in the original game: Each player tries to lose all of his pieces.Player wins if he doesnt have any pieces or if he cant do any move.The complexityPrevious workThere are few recent results on Lose checkers.They concentrate either on search or on finding a good evaluation function.They can help to improve good players but they cant produce good players.Improvements on a random player dont worth much.

The algorithmThe individuals will be trees. Each tree will behave like evaluation function for the board states (more details later).A tree represents a chromosome.Each tree contains nodes.A node represents a gene.There are three kinds of nodes:Basic Terminal Nodes.Basic Function Nodes.Domain-Specific Terminal Nodes.

Basic terminal nodesReturnvalue

Return typeNode nameEphemeral Random ConstantFloating pointERCBoolean false valueBooleanFalseBoolean true valueBooleanTrue1Floating pointOne0

Floating pointZeroBasic function nodesDomain-specific nodesEnemyKingCountEnemyManCountEnemyPieceCountFriendlyKingCountFriendlyManCountFriendlyPieceCountFriendlyKingCount EnemyKingCountKingCountFriendlyManCount EnemyManCountManCountFriendlyPieceCount EnemyPieceCountPieceCountKing factor valueKingFactorThe number of plies available to the player MobilityDomain specific- details of a square True iff square emptyIsEmptySquare(X,Y)True iff square occupied by friendly pieceIsFriendlyPiece(X,Y)True iff square occupied by kingIsKingPiece(X,Y)True iff square occupied by manIsManPiece(X,Y)An example for board evaluation tree

The algorithmMake initial populationWhile the termination condition didnt reached:Select the best candidates for being parents.Make the new generation by crossover and mutationEvaluate the fitness of the new generation.

Make initial populationWhile the termination condition didnt reached:Select the best candidates for being parents.Make the new generation by crossover and mutationEvaluate the fitness of the new generation.

The initial population The size of the population is one of the running parameters.We select the trees randomly.Their maximum allowed depth is also a running parameter.We omit the details of the random selection.

Make initial populationWhile the termination condition didnt reached:Select the best candidates for being parents.Make the new generation by crossover and mutationEvaluate the fitness of the new generation.

Selection

Fitness evaluation We define GuideArr to be an array of guide players.Some of them are random players which are useful for evaluating initial runs.Others, alpha-beta players, are based on search up to some level and random behavior since that level.CoPlayNum is the number of players which are selected randomly from the current population for playing with the individual under evaluation.

Image by Jon SullivanFitness evaluation back

Make initial populationWhile the termination condition didnt reached:Select the best candidates for being parents.Make the new generation by crossover and mutationCheck whether the termination condition reachedCrossoverTwo way crossoverRandomly select an internal node in each of the two individuals.Swap the subtrees rooted at these nodes.

One way crossoverRandomly select an internal node in each of the two individuals as a root of selected subtree.One individual (donor) inserts a copy of its selected sub-tree into another individual(receiver), in place of its selected sub-tree, while the donor itself remains unchanged.

Similar to gene transfer in bacteria, image by Y tambeUsing the one way crossover gives the fitter individuals an additional survival advantage.They still can change due to the standard two-way crossover.

MutationWe randomly choose a node in the tree for mutation.We do probabilistic decision whether to use the traditional tree building mutation method or the Local mutation method.The probability for each method is given as a parameter to our algorithm.

Traditional mutationTraditional tree building mutation: Done by replacing the selected node with a new subtree.

The drawback of using only the traditional mutation is that a mutation can change dramatically the fitness of an individual.Local mutationEach node that returns a floating-point value has a floating-point variable attached with it (initialized to 1).The returned value of the node was the normal value multiplied by the variable.The mutation is a small change in the variable.

Make initial populationWhile the termination condition didnt reached:Select the best candidates for being parents.Make the new generation by crossover and mutationCheck whether the termination condition reached

Termination The number of Generations until the termination will be a parameter of our program.

The PlayersUse alpha-beta search algorithm.Evaluate non-terminal states using the individual The depth of the search is 3.There are more methods.