Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

- ΠΛΗ31 ΜΑΘΗΜΑ 4.1 (ΕΚΤΥΠΩΣΗ) by Dimitris Psounis 2313 views
- ΠΛΗ31 ΚΑΡΤΕΣ ΜΑΘΗΜΑΤΟΣ 4.1 by Dimitris Psounis 1938 views
- ΠΛΗ31 ΤΥΠΟΛΟΓΙΟ ΕΝΟΤΗΤΑΣ 4 by Dimitris Psounis 2098 views
- ΠΛΗ31 ΚΑΡΤΕΣ ΜΑΘΗΜΑΤΟΣ 4.4 by Dimitris Psounis 980 views
- ΠΛΗ31 ΜΑΘΗΜΑ 4.4 by Dimitris Psounis 1537 views
- ΠΛΗ31 ΜΑΘΗΜΑ 4.4 (ΕΚΤΥΠΩΣΗ) by Dimitris Psounis 1518 views

No Downloads

Total views

1,499

On SlideShare

0

From Embeds

0

Number of Embeds

3

Shares

0

Downloads

145

Comments

0

Likes

4

No embeds

No notes for slide

- 1. Soft ComputingLecture 06: Introduction “Genetic Algorithms are good at to Genetic Algorithms taking large, potentially huge search spaces and navigating them, looking for optimal combinations of things, solutions you might not otherwise find in a lifetime.” - Salvatore Mangano Computer Design, May 1995
- 2. GENETIC ALGORITHMA biologically inspired model of intelligence and theprinciples of biological evolution are applied to find solutionsto difficult problemsThe problems are not solved by reasoning logically aboutthem; rather populations of competing candidate solutionsare spawned and then evolved to become better solutionsthrough a process patterned after biological evolutionLess worthy candidate solutions tend to die out, while thosethat show promise of solving a problem survive andreproduce by constructing new solutions out of theircomponents
- 3. GENETIC ALGORITHMGA begin with a population of candidate problem solutionsCandidate solutions are evaluated according to their abilityto solve problem instances: only the fittest survive andcombine with each other to produce the next generation ofpossible solutionsThus increasingly powerful solutions emerge in a DarwinianuniverseLearning is viewed as a competition among a population ofevolving candidate problem solutionsThis method is heuristic in nature and it was introduced byJohn Holland in 1975
- 4. GENETIC ALGORITHMBasic Algorithmbegin set time t = 0; initialise population P(t) = {x1t, x2t, …, xnt} of solutions; while the termination condition is not met do begin evaluate fitness of each member of P(t); select some members of P(t) for creating offspring; produce offspring by genetic operators; replace some members with the new offspring; set time t = t + 1; endend
- 5. GENETIC ALGORITHM The Evolutionary Cycle parents selection modification modified offspringinitiate & population evaluation evaluate evaluated offspring deleted members discard
- 6. GENETIC ALGORITHMRepresentation of Solutions: The ChromosomeGene: A basic unit, which represents one characteristic of theindividual. The value of each gene is called an alleleChromosome: A string of genes; it represents an individuali.e. a possible solution of a problem. Each chromosomerepresents a point in the search spacePopulation: A collection of chromosomesAn appropriate chromosome representation is important forthe efficiency and complexity of the GA
- 7. GENETIC ALGORITHMRepresentation of Solutions: The ChromosomeThe classical representation scheme for chromosomes isbinary vectors of fixed lengthIn the case of an I-dimensional search space, eachchromosome consists of I variables with each variableencoded as a bit string
- 8. GENETIC ALGORITHMExample: Cookies ProblemTwo parameters sugar and flour (in kgs). The range for bothis 0 to 9 kgs. Therefore a chromosome will comprise of twogenes called sugar and flour 5 1 Chromosome # 01 2 4 Chromosome # 02
- 9. GENETIC ALGORITHMExample: Expression satisfaction ProblemF = (¬a ∨ c) ∧ (¬a ∨ c ∨ ¬e) ∧ (¬b ∨ c ∨ d ∨ ¬e) ∧ (a ∨ ¬b ∨ c) ∧ (¬e ∨ f)Chromosome: Six binary genes abcdef e.g. 100111
- 10. GENETIC ALGORITHMRepresentation of Solutions: The ChromosomeChromosomes have either binary or real valued genesIn binary coded chromosomes, every gene has two allelesIn real coded chromosomes, a gene can be assigned any value from a domain of values
- 11. GENETIC ALGORITHMModel LearningUse GA to learn the concept Yes Reaction from the FoodAllergy problem’s data
- 12. GENETIC ALGORITHMChromosomes EncodingA potential model of the data can be represented as achromosome with the genetic representation: Gene # 1 Gene # 2 Gene # 3 Gene # 4 Restaurant Meal Day CostThe alleles of genes are:Restaurant gene: Sam, Lobdell, Sarah, XMeal gene: breakfast, lunch, XDay gene: Friday, Saturday, Sunday, XCost gene: cheap, expensive, X
- 13. GENETIC ALGORITHMChromosomes Encoding (Hypotheses Representation)Hypotheses are often represented by bit strings (because theycan be easily manipulated by genetic operators), but othernumerical and symbolic representations are also possibleSet of if-then rules: Specific sub-strings are allocated for encoding each rule pre-condition and post-condition Example: Suppose we have an attribute “Outlook” which can take on values: Sunny, Overcast or Rain
- 14. GENETIC ALGORITHMChromosomes Encoding (Hypotheses Representation)We can represent it with 3 bits: 100 would mean the value Sunny, 010 would mean Overcast & 001 would mean Rain 110 would mean Sunny or Overcast 111 would mean that we don’t care about its valueThe pre-conditions and post-conditions of a rule areencoding by concatenating the individual representation ofattributes
- 15. GENETIC ALGORITHMChromosomes Encoding (Hypotheses Representation)Example: If (Outlook = Overcast or Rain) and Wind = strong then PlayTennis = No can be encoded as 0111001Another rule If Wind = Strong then PlayTennis = Yes can be encoded as 1111010
- 16. GENETIC ALGORITHMChromosomes Encoding (Hypotheses Representation)An hypothesis comprising of both of these rules can beencoded as a chromosome 01110011111010Note that even if an attribute does not appear in a rule, wereserve its place in the chromosome, so that we can havefixed length chromosomes
- 17. GENETIC ALGORITHMVariable size chromosomesSometimes we need a variable size chromosome; e.g. torepresent a set of rulesExample:Suppose we are representing a set of rules by a chromosome If a1 = T and a2 = F then c = T If a2 = T then c = F The chromosome would be 10 01 1 11 10 0 where a1 = T is represented by 10, a2 = F by 01, and so on
- 18. GENETIC ALGORITHMEvaluation/Fitness FunctionIt is used to determine the fitness of a chromosomeCreating a good fitness function is one of the challenging tasks of using GA
- 19. GENETIC ALGORITHMExample: Cookies ProblemTwo parameters sugar and flour (in kgs). The range for bothis 0 to 9 kgs. Therefore a chromosome will comprise of twogenes called sugar and flour 5 1 2 4The fitness function for a chromosome is the taste of theresulting cookies; range of 1 to 9
- 20. GENETIC ALGORITHMExample: Expression satisfaction ProblemF = (¬a ∨ c) ∧ (¬a ∨ c ∨ ¬e) ∧ (¬b ∨ c ∨ d ∨ ¬e) ∧ (a ∨ ¬b ∨ c) ∧ (¬e ∨ f)Chromosome: Six binary genes abcdef e.g. 100111Fitness function: No of clauses having truth value of 1 e.g. 010010 has fitness 2
- 21. GENETIC ALGORITHMModel LearningUse GA to learn the concept Yes Reaction from the FoodAllergy problem’s dataThe fitness function can be the number of training samplescorrectly classified by a chromosome (model)
- 22. GENETIC ALGORITHMPopulation SizeNumber of individuals present and competing in an iteration (generation)If the population size is too large, the processing time is high and the GA tends to take longer to converge upon a solution (because less fit members have to be selected to make up the required population)If the population size is too small, the GA is in danger of premature convergence upon a sub-optimal solution (all chromosomes will soon have identical traits). This is primarily because there may not be enough diversity in the population to allow the GA to escape local optima
- 23. GENETIC ALGORITHMSelection Operators (Algorithms)They are used to select parents from the current populationThe selection is primarily based on the fitness. The better thefitness of a chromosome, the greater its chance of beingselected to be a parent
- 24. GENETIC ALGORITHMSelection Operators: Random SelectionIndividuals are selected randomly with no reference to fitnessat allAll the individuals, good or bad, have an equal chance ofbeing selected
- 25. GENETIC ALGORITHMSelection Operators: Proportional SelectionChromosomes are selected based on their fitness relative tothe fitness of all other chromosomesFor this all the fitness are added to form a sum S and eachchromosome is assigned a relative fitness (which is its fitnessdivided by the total fitness S)A process similar to spinning a roulette wheel is adopted tochoose a parent; the better a chromosome’s relative fitness,the higher its chances of selection
- 26. GENETIC ALGORITHMSelection Operators: Proportional SelectionThe selection of only the most fittest chromosomes may resultin the loss of a correct gene value which may be present in aless fit member (and then the only chance of getting it back isby mutation)One way to overcome this risk is to assign probability ofselection to each chromosome based on its fitnessIn this way even the less fit members have some chance ofsurviving into the next generationChromosomes are selected based on their fitness relative tothe fitness of all other chromosomes
- 27. GENETIC ALGORITHMSelection Operators: Proportional SelectionFor this all the fitness are added to form a sum S and eachchromosome is assigned a relative fitness (which is its fitnessdivided by the total fitness S)A process similar to spinning a roulette wheel is adopted tochoose a parent; the better a chromosome’s relative fitness,the higher its chances of selection
- 28. GENETIC ALGORITHMSelection Operators: Proportional SelectionThe probability of selection of a chromosome “i” may becalculated as pi = fitnessi / ∑ j fitnessjExampleChromosome Fitness Selection Probability 1 7 7/14 2 4 4/14 3 2 2/14 4 1 1/14
- 29. GENETIC ALGORITHMSelection Operators: Proportional Selection
- 30. GENETIC ALGORITHM Selection Operators: Proportional Selection Algorithm1. [Sum] Calculate sum of all chromosome fitnesses in population - sum S.2. [Assign] Assign a range to each chromosome over a line ranging from 0-S.3. [Select] Generate random number from interval (0,S) - r.4. [Select] Select the chromosome belongs to rOf course, step 1 is performed only once for each population.
- 31. GENETIC ALGORITHMSelection Operators: Rank based selectionRank based selection uses the rank ordering of the fitnessvalues to determine the probability of selection and not thefitness values themselvesThis means that the selection probability is independent ofthe actual fitness valueRanking therefore has the advantage that a highly fitindividual will not dominate in the selection process as afunction of the magnitude of its fitness
- 32. GENETIC ALGORITHM Selection Operators: Rank based selectionProportional Selection have problems when the fitnesses differs very much. Forexample, if the best chromosome fitness is 90% of all the roulette wheel thenthe other chromosomes will have very few chances to be selected.Rank selection first ranks the population and then every chromosome receivesfitness from this ranking. The worst will have fitness 1, second worst 2 etc. andthe best will have fitness N (number of chromosomes in population)You can see in following picture, how the situation changes after changingfitness to order number. Before ranking After ranking
- 33. GENETIC ALGORITHMSelection Operators: Rank based selectionThe population is sorted from best to worst according to the fitnessEach chromosome is then assigned a newfitness based on a linear ranking function New Fitness = (P – r) + 1where P = population size, r = fitness rank of the chromosomeIf P = 11, then a chromosome of rank 1 will have a NewFitness of 10 + 1 = 11 & a chromosome of rank 6 will have 6
- 34. GENETIC ALGORITHMSelection Operators: Rank based selectionA user adjusted slope can also be incorporated New Fitness = {(P – r) (max - min)/(P – 1)} + minwhere max and min are set by the user to determine the slope (max - min)/(P – 1) of the functionLet P = 11, max = 8, min = 3,then a chromosome of rank 1 will have a New fitness of 10*5/10 + 3 = 8& a chromosome of rank 6 will have 5*5/10 + 3 = 5.5
- 35. GENETIC ALGORITHMSelection Operators: Rank based selectionOnce the new fitness is assigned, parents are selected by the same roulette wheel procedure used in proportionate selection
- 36. GENETIC ALGORITHMSelection Operators: Tournament SelectionExtracts k individuals from the population with uniform probability (without re-insertion) and makes them play a “tournament”, where the probability for an individual to win is generally proportional to its fitness
- 37. GENETIC ALGORITHMReproduction OperatorsGenetic operators are applied to chromosomes that areselected to be parents, to create offspringBasically of two types: Crossover and MutationCrossover operators create offspring by recombining thechromosomes of selected parentsMutation is used to make small random changes to achromosome in an effort to add diversity to the population
- 38. GENETIC ALGORITHMReproduction Operators: CrossoverCrossover operation takes two candidate solutions anddivides them, swapping components to produce two newcandidates
- 39. GENETIC ALGORITHMReproduction Operators: CrossoverFigure illustrates crossover on bit string patterns of length 8The operator splits them and forms two children whose initialsegment comes from one parent and whose tail comes fromthe otherInput Bit Strings 11#0101# #110#0#1Resulting Strings 11#0#0#1 #110101#
- 40. GENETIC ALGORITHMReproduction Operators: CrossoverTwo genes sugar and flour (in kgs)Crossover operation on chromosomes 5 1 5 4 2 4 2 1
- 41. GENETIC ALGORITHMReproduction Operators: CrossoverThe place of split in the candidate solution is an arbitrarychoice. This split may be at any point in the solutionThis splitting point may be randomly chosen or changedsystematically during the solution processCrossover can unite an individual that is doing well in onedimension with another individual that is doing well in theother dimension
- 42. GENETIC ALGORITHMReproduction Operators: CrossoverTwo types: Single point crossover & Uniform crossoverSingle type crossover This operator takes two parents and randomly selects a single point between two genes to cut both chromosomes into two parts (this point is called cut point) The first part of the first parent is combined with the second part of the second parent to create the first child The first part of the second parent is combined with the second part of first parent to create the second child 1000010 1000001 1110001 1110010
- 43. GENETIC ALGORITHMReproduction Operators: CrossoverUniform crossover The value of each gene of an offspring’s chromosome is randomly taken from either parent This is equivalent to multiple point crossover 1000010 1110001 1010010
- 44. GENETIC ALGORITHMReproduction Operators: Crossover (Variable size chromosomes)Sometimes we need a variable size chromosome; e.g. torepresent a set of rulesExample:Suppose we are representing a set of rules by a chromosome If a1 = T and a2 = F then c = T If a2 = T then c = F The chromosome would be 10 01 1 11 10 0 where a1 = T is represented by 10, a2 = F by 01, and so on
- 45. GENETIC ALGORITHMReproduction Operators: Crossover (Variable size chromosomes)The sub-strings can be considered as a single entity duringcross-over (i.e. crossover point is not allowed in the middle ofthe sub-string)Another way can be to allow all possible crossovers, but assigna very low fitness to resulting chromosomes which haveundesirable sub-string meaning(s)e.g. 01110011111011 would mean, we do not care whether we play tennis ornot
- 46. GENETIC ALGORITHMReproduction Operators: Crossover (Variable size chromosomes)For such chromosomes we use a modified cross-over operatorTo perform a crossover operation on two parents, twocrossover points are first chosen at random in one of theparentsExample: Let the two parents be 10 01 1 11 10 0and 01 11 0 10 01 0
- 47. GENETIC ALGORITHMReproduction Operators: Crossover (Variable size chromosomes)Suppose the crossover points chosen randomly for the firstparent are after bit position 1 and 81st parent 10 01 1 11 10 02nd parent 01 11 0 10 01 0Let d1 denote the distance from the leftmost of these crossoverpoints to the rule boundary immediately to the left d1 = 1Let d2 denote the distance from the rightmost of thesecrossover points to the rule boundary immediately to the left d2 = 3
- 48. GENETIC ALGORITHMReproduction Operators: Crossover (Variable size chromosomes)The crossover points in the second parent are now randomlychosen, subject to the constraint that they must have the samed1 and d2 values1st parent 10 01 1 11 10 0 d1 = 1, d2 = 32nd parent 01 11 0 10 01 0The possible crossover points for the 2nd parent are at bitpositions (1, 3), (1, 8), and (6, 8)2nd parent 01 11 0 10 01 0 d1 = 1, d2 = 3 01 11 0 10 01 0 01 11 0 10 01 0
- 49. GENETIC ALGORITHMReproduction Operators: Crossover (Variable size chromosomes)Suppose crossover points (1, 3) happen to be chosen for the 2ndparent1st parent 10 01 1 11 10 02nd parent 01 11 0 10 01 0The resulting two offspring would be 11 10 0and 00 01 1 11 11 0 10 01 0
- 50. GENETIC ALGORITHMReproduction Operators: MutationMutation is another important genetic operatorMutation takes a single candidate and randomly changessome aspect (gene) of itFor example, mutation may randomly select a bit in thepattern and change it, switching a 1 to a 0 or to # (don’t care)
- 51. GENETIC ALGORITHMReproduction Operators: MutationMutation is important in that the initial population mayexclude an essential component of a solutionFor example, if no member of the initial population has a 1 inthe first position, then crossover in the middle, cannotproduce a child that could become a solution
- 52. GENETIC ALGORITHMReproduction Operators: Mutation Each gene of each offspring is mutated with a given mutation rate pµ (say 0.01) It is hence possible that no gene may be mutated for many generations. On the other hand more than one gene may be mutated in the same generation (or even in the same chromosome) For real valued genes, the value is selected randomly from the alleles If the rate is too low, new traits will appear too slowly in the population. If the rate is too high, each generation will be unrelated to the previous generation
- 53. GENETIC ALGORITHMQ: Is it some kind of learning technique like neural networks ?A: NoQ: Then, what is it ?
- 54. GENETIC ALGORITHM Search Techniqes Calculus Base Enumerative Guided random search Techniques Techniques techniquesFibonacci Sort DFS Dynamic BFS Programming Tabu Search Hill Simulated Evolutionary Climbing Annealing Algorithms Genetic Genetic Programming Algorithms Figure: Taxonomy of searching techniques
- 55. GENETIC ALGORITHMGA 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
- 56. GENETIC ALGORITHMThe MAXONE problem Suppose we want to maximize the number of ones in a string of l binary digits Is it a trivial problem? It may seem so because we know the answer in advance However, we can think of it as maximizing the number of correct answers, each encoded by 1, to l yes/no difficult questions`
- 57. GENETIC ALGORITHMThe MAXONE problem • An individual is encoded (naturally) as a string of l binary digits • The fitness f of a candidate solution to the MAXONE problem is the number of ones in its genetic code • We start with a population of n random strings. Suppose that l = 10 and n = 6
- 58. GENETIC ALGORITHMThe MAXONE problem (initialization step) We toss a fair coin 60 times and get the following initial population: s1 = 1111010101 f (s1) = 7 s2 = 0111000101 f (s2) = 5 s3 = 1110110101 f (s3) = 7 s4 = 0100010011 f (s4) = 4 s5 = 1110111101 f (s5) = 8 s6 = 0100110000 f (s6) = 3
- 59. GENETIC ALGORITHMThe MAXONE problem (selection step)Next we apply fitness proportionate selection withthe roulette wheel method; the individual i havethe probability to chose: f (i ) ∑ f (i ) i We repeat the extraction Area is 1 2 as many times as the n Proportional to fitness number of individuals we value need to have the same 3 parent population size 4 (6 in our case)
- 60. GENETIC ALGORITHMThe MAXONE problem (selection step) Suppose that, after performing selection, we get the following population: s1` = 1111010101 (s1) s2` = 1110110101 (s3) s3` = 1110111101 (s5) s4` = 0111000101 (s2) s5` = 0100010011 (s4) s6` = 1110111101 (s5)
- 61. GENETIC ALGORITHMThe MAXONE problem (crossover step) Next we mate strings for crossover. For each couple we decide according to crossover probability (for instance 0.6) whether to actually perform crossover or not Suppose that we decide to actually perform crossover only for couples (s1`, s2`) and (s5`, s6`). For each couple, we randomly extract a crossover point, for instance 2 for the first and 5 for the second
- 62. GENETIC ALGORITHMThe MAXONE problem (crossover step) Before crossover: s1` = 1111010101 s5` = 0100010011 s2` = 1110110101 s6` = 1110111101 After crossover: s1`` = 1110110101 s5`` = 0100011101 s2`` = 1111010101 s6`` = 1110110011
- 63. GENETIC ALGORITHMThe MAXONE problem (mutation step) The final step is to apply random mutation: for each bit that we are to copy to the new population we allow a small probability of error (for instance 0.1) Before applying mutation: s1`` = 1110110101 s2`` = 1111010101 s3`` = 1110111101 s4`` = 0111000101 s5`` = 0100011101 s `` = 1110110011
- 64. GENETIC ALGORITHMThe MAXONE problem (mutation step) After applying mutation: s1``` = 1110100101 f (s1``` ) = 6 s2``` = 1111110100 f (s2``` ) = 7 s3``` = 1110101111 f (s3``` ) = 8 s4``` = 0111000101 f (s4``` ) = 5 s5``` = 0100011101 f (s5``` ) = 5 s6``` = 1110110001 f (s6``` ) = 6
- 65. GENETIC ALGORITHMThe MAXONE problem (example end) In one generation, the total population fitness changed from 34 to 37, thus improved by ~9% At this point, we go through the same process all over again, until a stopping criterion is met
- 66. GENETIC ALGORITHM Short Assignment:Design a genetic algorithm to learn conjunctiveclassification rules for the Play-Tennis problem.Describe precisely the bit-string encoding of hypothesesand a set of crossover operators. Due Date: 24-05-2012Hint: see Chapter 09, Machine Learning book by Tom. Mitchell
- 67. GENETIC ALGORITHMShort Assignment Data:
- 68. GENETIC ALGORITHMMajor Assignment (10 marks) : Task: you have to analyse some research paper and give your critical analysis in the form of a report. The report will be critically reviewed and accordingly marked. Deliverables: A report + Presentation Relevant Information: The assignment will be prepared within groups. However, the marks will be assigned based on individual performance. Research Topics: the topics will be uploaded on the group
- 69. GENETIC ALGORITHMThe New GenerationThe new offspring can replace the old population without anyfitness comparisonoronly the better ones from the new and old make it to the newgeneration (more processing needed)
- 70. GENETIC ALGORITHMNew Generation: ElitismElitism is a value between 0 and 1, which represents thefraction of the individuals of a population that will beduplicated to the next generationExample P = 20 and elitism = 0.1, then 2 individuals ofcurrent population do not get replacedThe elite chromosome selection may be based on highestfitness valuesIf highest fitness valued chromosomes are carried over to thenext generation, we ensure that the maximum fitness does notdecrease from one generation to next
- 71. GENETIC ALGORITHMNew Generation: Generation GapThe number of individuals replaced in the next generation iscalled generation gapA generation gap of 100% will mean that whole of thepopulation comprises of new chromosomesWe may have a generation gap which is not fixed. In thismethod, the fittest P chromosomes will be selected from theset of current population plus new children, and will form thenew generation
- 72. GENETIC ALGORITHMNew Generation: Number of Duplicates AllowedDuplicates are Chromosomes that are sameIf they are allowed then that chromosome has higher probability of producing an offspring, and may probably create many offspringEliminating duplicates increases the efficiency of the genetic search and reduces the danger of premature convergenceEliminating duplicates means that if an offspring is created which is a duplicate of a chromosome of the current population, we terminate it immediately and create a new one. It increases the processing time in large populations
- 73. GENETIC ALGORITHMTermination RequirementThe GA continues until some termination requirement is met,such as - having a solution whose fitness exceeds some threshold - the fitness of solutions becomes stable & stops improving
- 74. GENETIC ALGORITHMReferencesEngelbrecht Chapter 8 & 9

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment