# CIS*6080 Genetic Algorithms Instructor:Robert Collier

## Presentation on theme: "CIS*6080 Genetic Algorithms Instructor:Robert Collier"— Presentation transcript:

CIS*6080 Genetic Algorithms Instructor:Robert Collier E-mail:collierr@uoguelph.ca

Robert Collier 2 Map Colouring Colour the regions of a map such that adjacent nodes are assigned different colours.

Robert Collier 3 Graph Colouring Example If the graph is planar, only four colours are necessary. This graph isn't planar, so it might not be possible (with only four colours). How many possible solutions (i.e. candidate solutions) exist? Colour the nodes such that adjacent nodes are assigned different colours.

Robert Collier 4 Graph Colouring Example The graph is made up of 30 nodes and this example is using 4 colours. What would the solution (if one actually exists) actually look like? How many possible solutions are there? At a rate of 1 solution / second, how long will it take to check them all ? Solution = { Node01 = #FF0000, Node02 = #0000FF,..., Node 30 = #007F00} Colours = { #FF0000, #0000FF, #007F00, #FF00FF } Nodes = { Node01, Node02, Node03,..., Node 30} 4 4 4 4 4... 4 = 4 30 = 1 152 921 504 606 846 976 1267650600228229401496703205376 / (60 60 24 365.25) 36 533 877 880 years

Robert Collier 5 Graph Colouring Example The left solution violates 21 constraints while the right solution violates only 3. Therefore we can conclude that the right solution is superior to the left. Even if there is no perfect solution, there is a solution as good or better than all others. There may or may not be a perfect solution to this problem, but consider...

Robert Collier 6 Definition: The Genetic Algorithm The Genetic Algorithm is a Population Simulation that uses the principles of Darwinian Evolution to solve Optimization Problems.

Robert Collier 7 Course Outline Instructor:Robert Collier Office Hours:Wednesdays (by appointment) E-mail:collierr@uoguelph.ca Course Website:http://www.uoguelph.ca/~collierr/CIS6080/index.htm The primary objectives of this course are: to introduce students to the simple genetic algorithm, to explore each of the component processes that drive the mechanism, and to explore many of the different variations on these component processes. The secondary objective of this course is: to teach students how to conduct a comparative evaluation of two algorithms. Course Objectives:

Robert Collier 8 This course introduces the student to basic genetic algorithms, which are based on the process of natural evolution. It is explored in terms of its mathematical foundation and applications to optimization in various domains. Description: Course Outline Evaluation: Assignment 115% Assignment 215% Assignment 315% Final Project55% Optional Bonus Assignment10%

Robert Collier 9 Course Overview Lecture Topics: Week 1Foundational Material Week 2The Simple Genetic Algorithm Weeks 3, 4Component Process: Selection Weeks 5, 6Component Process: Variation Weeks 7, 8 Component Process: Replication Weeks 9, 10 Experimental Design and Statistical Analysis Week 11Genetic Programming, Artificial Life, etc. Week 12Learning Classifier Systems

Robert Collier 10 Foundational Material The Genetic Algorithm is a Population Simulation that uses the principles of Darwinian Evolution to solve Optimization Problems. Optimization Problems is the domain of problems to be solved. Darwinian Evolution provided the inspiration for the technique. Population Simulations model the environment where evolution was observed.

Robert Collier 11 Optimization Problems The objective is to find the best possible solution from the set of feasible solutions. This implies: a) that some solutions are better than others b) there must be a way to quantify relative superiority Contrast the set of Optimization Problems with: Decision Problems Search Problems Counting Problems i.e. Does a particular entity meet certain criteria? i.e. Where is a particular entity located in the space of all entities? i.e. How many of a particular entity are contained in the space of entities?

Robert Collier 12 Optimization Problems The objective is to find the best possible solution from the set of feasible solutions. This implies: a) that some solutions are better than others b) there must be a way to quantify relative superiority Map Colouring Common Optimization Problems:

Robert Collier 13 Windsor London Hamilton Toronto Sudbury Kingston Ottawa North Bay Optimization Problems The objective is to find the best possible solution from the set of feasible solutions. This implies: a) that some solutions are better than others b) there must be a way to quantify relative superiority Common Optimization Problems: Traveling Salesman Windsor London Hamilton Toronto Sudbury Kingston Ottawa North Bay Windsor London Hamilton Toronto Sudbury Kingston Ottawa North Bay

Robert Collier 14 90 100 50 40 30 90 Optimization Problems The objective is to find the best possible solution from the set of feasible solutions. This implies: a) that some solutions are better than others b) there must be a way to quantify relative superiority Common Optimization Problems: Knapsack Problem 90 100 50 40 30

Robert Collier 15 Simplistic Approaches Exhaustive Approach Every element of the set of feasible solutions can be tested. F(x) = x = Greedy Approach A candidate solution can often be constructed in stages, and the component added at each stage is the one offering the most immediate benefit. Example: How can the minimum of y = x 2 be found (without the derivative)? Consider the implications of these approaches? Why look at neighbours? Why the superior neighbour?

Robert Collier 16 Complex Candidate Solution Spaces The set of candidate solutions is typically a space of candidate solutions...... however, this space can be very complex. F'(x) = x =

Robert Collier 17 Complex Candidate Solution Spaces The set of candidate solutions is typically a space of candidate solutions...... however, this space can be very complex. For a two dimensional solution (i.e. an ordered pair (x, y)), the space is often conceptualized as a landscape. An intuitive approach directly results from this analogy... F'(x) = x =

Robert Collier 18 Hill Climbing Approach solution = selectRandomSolution() best_fitness_so_far = getFitnessOf(solution) other_solutions_remaining = TRUE WHILE other_solutions_remaining other_solutions_remaining = FALSE other_solutions = getNeighbouringSolutions(solution) FOR EACH neighbouring_solution IN other_solutions IF getFitnessOf(neighbouring_solution) > best_fitness_so_far best_fitness_so_far = getFitnessOf(neighbouring_solution) solution := neighbouring_solution other_solutions_remaining = TRUE END IF END FOR END WHILE RETURN solution

Robert Collier 19 Simulated Annealing Approach solution = selectRandomSolution() current_fitness = getFitnessOf(solution) temperature = starting_temperature WHILE termination_criteria_not_met neighbouring_solution = getRandomNeighbour(solution) IF getFitnessOf(neighbouring_solution) > best_fitness_so_far current_fitness = getFitnessOf(neighbouring_solution) solution = neighbouring_solution ELSE IF random < exp(- (current_fitness - getFitnessOf(neighbouring_solution)) ) temperature current_fitness = getFitnessOf(neighbouring_solution) solution = neighbouring_solution END IF reduce(temperature) END WHILE RETURN solution

Robert Collier 20 Summary of Optimization Problems Optimization Problems are solved by finding the best possible solution (i.e. the optima) from the space of candidate solutions. Some candidate solutions are better than others. Some candidate solutions are closer together and some are further apart. Candidate solution spaces are often complex, and hill climbing alone is not sufficient (as they become trapped at local optima) Processes observed in the natural world (i.e. annealing, evolution) can serve as inspiration for effective optimization approaches.

Robert Collier 21 Foundational Material The Genetic Algorithm is a Population Simulation that uses the principles of Darwinian Evolution to solve Optimization Problems. Optimization Problems is the domain of problems to be solved. Darwinian Evolution provided the inspiration for the technique. Population Simulations model the environment where evolution was observed.

Robert Collier 22 Relevant Biology Chromosomea structure defining an organism's properties Genea component of a chromosome Traita property encoded by one of more genes Allelea possible value setting for a trait Locusa position in a chromosome Genotypethe genetic constitution of an organism Phenotypethe physical constitution of an organism Important Definitions

Robert Collier 23 Context for the Analogous Biology Solution = { Node01 = #FF0000, Node02 = #0000FF,..., Node 50 = #007F00} Solutions to the map colouring problem discussed previously... Colours = { #FF0000, #0000FF, #007F00, #FF00FF } Nodes = { Node01, Node02, Node03,..., Node 50} How could a chromosome be constructed from this information? Possible Encodings:String? Character? Integer? Binary? Other? Integer Valued Chromosome013213021302130132031230... 13203 Binary Chromosome010100101111010101111010... 01011 Traits? Alleles? Loci?

Robert Collier 24 Biomimicry and the Natural World Leonardo Da Vinci's sketch of a flying machine was inspired by the form of a bird. Biomimicry uses natural processes as inspiration for solving problems. Why?... because the natural world has solved many complex problems. How?... through the process of natural selection.

Robert Collier 25 Natural Selection The process by which traits become more or less common, according to the survival and/or reproduction of organisms with those traits. carbonaria typica These moths are an example of a solution to the problem of camouflage.

Robert Collier 26 The Evolutionary Mechanism Jean-Baptiste Lamarck Philosophie Zoologique, 1809 as new modifications will necessarily continue to operate, however slowly, not only will there continually be found new species, new genera, and new orders, but each species will vary in some part of its structure and form... individuals which from special causes are transported into very different situations from those where the others occur, and then constantly submitted to other influences - the former, I say, assume new forms, and then they constitute a new species... believed that traits acquired over an organism's life could be transferred to offspring... believed there were complexifying and adaptive forces at work

Robert Collier 27 Instead of Lamarck's complexifying force, genetic variation causes diversity in the chromosomes of living things, and those better suited to their environment are more likely to survive and pass the various traits to their offspring. Darwin proposed the process of Natural Selection Instead of Lamarck's complexifying force, genetic variation causes diversity in the chromosomes of living things, and those better suited to their environment are more likely to survive and pass the various traits to their offspring. The Evolutionary Mechanism What are the key elements of this process? Variation Evaluation Selection Replication

Robert Collier 28 Summary of Darwinian Evolution Genetic algorithm terminology borrows heavily from biology. The natural world has already solved many complex problems. Natural selection states that variations appear in populations, and those variations that are beneficial are transmitted to future generations. The component processes of the evolutionary mechanism are: Evaluation, Selection, Variation, and Replication Any system with these processes is an evolving system.

Robert Collier 29 Foundational Material The Genetic Algorithm is a Population Simulation that uses the principles of Darwinian Evolution to solve Optimization Problems. Optimization Problems is the domain of problems to be solved. Darwinian Evolution provided the inspiration for the technique. Population Simulations model the environment where evolution was observed.

Robert Collier 30 Simulation Basics "The imitation of the operation of a real-world process or system over time." A population of organisms...... in which the likelihood that an organism survives or reproduces is proportional the degree to which that organism can solve a particular optimization problem. Evaluation SelectionVariation Replication The components of the evolutionary mechanism:

Robert Collier 31 Population Simulation Two Simplifying Assumptions: 1.Each member of the population lives for exactly one generation. 2.The population size never changes (i.e. complete replacement) Population at Time tPopulation at Time t+1 Terminate? The Evolutionary Mechanism

Robert Collier 32 Overview of the Genetic Algorithm Initialization Evaluation Selection Variation Replication Terminate? Termination true false

This graduate level course in genetic algorithms was developed and taught by Robert Collier, MSc, BSc. It was most recently offered at the University of Guelph during the summer 2011 semester. The remaining slides have been omitted from this preview.