Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fitness Functions.

Similar presentations


Presentation on theme: "Fitness Functions."— Presentation transcript:

1 Fitness Functions

2 Fitness Evaluation A key component in GA Time/quality trade off
Multi-criterion fitness

3 Fitness function Nature: Fitness space structure:
only survival and reproduction count how well do I do in my environment Fitness space structure: Defined by kinship of genotypes and fitness function Advantage: visual representation can be useful when thinking about model design Limitation: ideas might be too simplistic when not working on toy-problems - complex spaces and movements (think crossover!)

4 Fitness space or landscape
0110 0010 0011 Hamming Distance =1 0100 0000 0001 1100 1000 1001 Schema of genetic kinship How we “move” in that landscape over generations is defined by our variability operators, usually mutation and recombination Now add fitness…

5 Fitness space or landscape
0110 0010 0011 0100 0000 0001 fitness 1100 1000 1001 Schema of genetic kinship How we “move” in that landscape over generations is defined by our variability operators, usually mutation and recombination Now add fitness…

6 Fitness landscapes contd.
x/y axes: kinship, i.e. the more genetic resemblance the closer together z axis: fitness Every “snowflake” one individual, search focuses on “promising” regions (due to differential reproduction) Andy Keane, Uni. Of Southampton Animation adapted from

7 Fitness space – Good design
Easy to find the optimum by local search neighboring genotypes have similar fitness (smooth curve  high evolvability) Fitness Genotypes

8 Fitness space - Bad design
Here we will have a hard time finding the optimum Low evolvability (fitness is right/wrong) Either problem not well suited for GA or bad design Fitness Genotypes

9 Fitness space – Mediocre design
Many local optima, so we are likely to find one However not much of a gradient to find global optimum, random search could do as well Fitness Genotypes

10 Dynamic fitness landscape
Fitness does not need to be static over generations Can allow to reach regions otherwise uncovered Natural fitness certainly very dynamic Animation by Michael Herdy, TU Berlin

11 Fitness Function Purpose Parent selection Measure for convergence
For Steady state: Selection of individuals to die Should reflect the value of the chromosome in some “real” way Next to coding, this is the most critical part of a GA

12 Fitness scaling Fitness values are scaled by subtraction and division:
so that worst value is close to 0 and the best value is close to a certain value, typically 2 Chance for the most fit individual is 2 times the average Chance for the least fit individual is close to 0 Problems when the original maximum is very extreme (super-fit) or when the original minimum is very extreme (super-unfit) Can be solved by defining a minimum and/or a maximum value for the fitness Example of Fitness Scaling

13 Fitness windowing Fitness windowing is the same as window scaling, except the amount subtracted is the minimum observed in the n previous generations, with n e.g. 10 Same problems as with scaling

14 Fitness ranking Individuals are numbered in order of increasing fitness The rank in this order is the adjusted fitness Starting number and increment can be chosen in several ways and influence the results No problems with super-fit or super-unfit Fitness ranking is often superior to scaling and windowing

15 Multi-Criterion Fitness
Dominance and indifference For an optimization problem with more than one objective function (fi, i=1,2,…n) given any two solution X1 and X2, then Solution X1 dominates X2 ( X1  X2), if fi(X1)  fi(X2), for all i = 1,…,n Solution X1 is indifferent with X2 ( X1 ~ X2), if X1 does not dominate X2, and X2 does not dominate X1

16 Multi-Criterion Fitness
Pareto Optimal Set If there exists no solution in the search space which dominates any member in the set P, then the solutions belonging to the set P constitute a global Pareto-optimal set. Pareto optimal front Dominance Check global Pareto-optimal set

17 Multi-Criterion Fitness
Weighted sum F(x) = w1f1(x1) + w2f2(x2) +…+wnfn(xn) Problems with using weighted sum? Convex and convex Pareto optimal front Sensitive to the shape of the Pareto-optimal front Selection of weights? Need some pre-knowledge Not reliable for problem involving uncertainties

18 Multi-Criterion Fitness
Optimizing single objective Maximize: fk(X) Subject to: fj(X) <= Ki, i <> k X in F where F is the solution space. minimum constraints maximum

19 Multi-Criterion Fitness
Weighted sum F(x) = w1f1(x1) + w2f2(x2) +…+wnfn(xn) Problems? Convex and convex Pareto optimal front Sensitive to the shape of the Pareto-optimal front Selection of weights? Need some pre-knowledge Not reliable for problem involving uncertainties

20 Multi-Criterion Fitness
Preference based weighted sum (ISMAUT Imprecisely Specific Multiple Attribute Utility Theory) F(x) = w1f1(x1) + w2f2(x2) +…+wnfn(xn) Preference Given two know individuals X and Y, if we prefer X than Y, then F(X) > F(Y), that is w1(f1(x1)-f1(y1)) +…+wn(fn(xn)-fn(yn)) > 0

21 Multi-Criterion Fitness
All the preferences constitute a linear space Wn={w1,w2,…,wn} w1(f1(x1)-f1(y1)) +…+wn(fn(xn)-fn(yn)) > 0 w1(f1(z1)-f1(p1)) +…+wn(fn(zn)-fn(pn)) > 0, etc For any two new individuals Y’ and Y’’, how to determine which one is more preferable?

22

23

24 Other parameters of GAs

25 Other parameters of GA (1)
Initialization: Population size Random Dedicated greedy algorithm Reproduction: Generational: as described before (insects) Generational with elitism: fixed number of most fit individuals are copied unmodified into new generation Steady state: two parents are selected to reproduce and two parents are selected to die; two offspring are immediately inserted in the pool (mammals)

26 Other parameters of GA (2)
Stop criterion: Number of new chromosomes Number of new and unique chromosomes Number of generations Measure: Best of population Average of population Duplicates Accept all duplicates Avoid too many duplicates, because that degenerates the population (inteelt) No duplicates at all

27 Example run Maxima and Averages of steady state and generational replacement

28 Design Issues

29 Integrating problem knowledge
Always it is integrated to some degree in representation/ mapping Create more complex fitness function Start population chosen instead of a uniform random one Useful e.g. if constraints on range of solutions Possible problems: Loss of diversity and bias

30 Design decisions GAs: high flexibility and adaptability because of many options: Problem representation Genetic operators with parameters Mechanism of selection Size of the population Fitness function Decisions are highly problem dependent Parameters not independent, you cannot optimize them one by one

31 Hints for the parameter search
Find balance between: Exploration (new search regions) Exploitation (exhaustive search in current region) Parameters can be adaptable, e.g. from high in the beginning (exploration) to low (exploitation), or even be subject to evolution themselves Balance influenced by: Mutation, recombination: create indiviuals that are in new regions (diversity!!) fine tuning in current regions Selection: focus on interesting regions

32 Keep in mind Start population has a lot of diversity
“Invest” search time in areas that have proven good in the past  Loss of diversity over evolutionary time Premature convergence: quick loss of diversity poses high risk of getting stuck in local optima Evolvability: Fitness landscape should not be too rugged Heredity of traits Small genetic changes should be mapped to small phenotype changes

33 Learning

34 GA Evolution Accuracy in Percent Generations 100 50 10
Example of monitoring/diagnostic 10 Generations

35 genetic algorithm learning
Fitness criteria Example of diagnostic (2) Generations

36 Fitness value (scaled)
GA variability across replications should be noted! iteration

37 Percent improvement over hillclimber
Do we need a GA? Performance of replications vs. simple hillclimber … iteration

38 Simple Numerical Example of GA

39 An example after Goldberg ‘89 (1)
Simple problem: max x2 over {0,1,…,31} GA approach: Representation: binary code, e.g  13 Population size: 4 1-point crossover, bitwise mutation Roulette wheel selection Random initialization We show one generational cycle done by hand

40 Simple example: f(x) = x²
Finding the maximum of a function: f(x) = x² Range [0, 31]  Goal: find max (which is 31² = 961) Binary representation: string length 5 = 32 numbers (0-31) Discrete - natural number = f(x) We calculate fitness on the phenotype

41 F(x) = x² - Start Population
1 00001 String 5 441 21 10101 String 4 100 10 01010 String 3 9 3 00011 String 2 36 6 00110 String 1 fitness value binary New column: f(x), headline: Fitness = function that will be maximized Fittest individual = maximum of function

42 F(x) = x² - Selection Worst one removed 1 00001 String 5 441 21 10101
100 10 01010 String 3 9 3 00011 String 2 36 6 00110 String 1 fitness value binary Worst one removed

43 F(x) = x² - Selection 1 00001 String 5 441 21 10101 String 4 100 10 01010 String 3 9 3 00011 String 2 36 6 00110 String 1 fitness value binary Nature: population size keeps nearly constant because of limited resources GA: algorithm creates boundaries, set limits, keeps population constant Best individual: reproduces twice  keep population size constant

44 F(x) = x² - Selection All others are reproduced once 1 00001 String 5
441 21 10101 String 4 100 10 01010 String 3 9 3 00011 String 2 36 6 00110 String 1 fitness value binary All others are reproduced once

45 x2 example: selection Roulette wheel selection

46 F(x) = x² - Crossover Parents and x-position randomly selected (equal recombination) 2 String 4 String 3 4 String 2 String 1 x-position partner 1 1 1 1 1 String 1: 1 1 1 String 2:

47 F(x) = x² - Crossover Parents and x-position randomly selected (equal recombination) 2 String 4 String 3 4 String 2 String 1 x-position partner 1 1 1 1 1 String 3: 1 1 1 1 1 String 4:

48 X2 example: crossover

49 F(x) = x² - Mutation bit-flip:
Offspring -String 1: (7)  (23) String 4: (21)  (17) Not necessarily only one bit flipped, randomly selected, can be 0 or at most 5 Other strings are recombined, only best mutated

50 X2 example: mutation Suppose this mutation did not happen

51 F(x) = x² Suppose in this variant all individuals in the parent population are replaced by offspring in the new generation (generations are discrete!) New population (Offspring): binary value fitness String 1 10111 23 529 String 2 00010 2 4 String 3 01101 13 169 String 4 10000 16 256 String 5 10001 17 289

52 F(x) = x² - End Iterate until termination condition reached, e.g.:
Number of generations Best fitness Process time No improvements after a number of generations Result after one generation: Best individual: (23) – fitness 529

53 F(x) = x² - Animation Java-Applet (html page) with examples

54 Checkboard Example

55 Checkboard example We are given an n by n checkboard in which every field can have a different colour from a set of four colors. Goal is to achieve a checkboard in a way that there are no neighbours with the same color (not diagonal)

56 Checkboard example (Cont’d)
Chromosomes represent the way the checkboard is colored. Chromosomes are not represented by bitstrings but by bitmatrices The bits in the bitmatrix can have one of the four values 0, 1, 2 or 3, depending on the color. Crossing-over involves matrix manipulation instead of point wise operating. Crossing-over can be combining the parential matrices in a horizontal, vertical, triangular or square way. Mutation remains bitwise changing bits in either one of the other numbers.

57 Checkboard example (Cont’d)
This problem can be seen as a graph with n nodes and (n-1) edges, so the fitness f(x) is defined as: f(x) = 2 · (n-1) ·n

58 Checkboard example (Cont’d)
Fitness curves for different cross-over rules: This kind of analysis should be done by you in homeworks and projects

59 EXAMPLE Drilling for Oil

60 Silly Example - Drilling for Oil
Imagine you had to drill for oil somewhere along a single 1km desert road Problem: choose the best place on the road that produces the most oil per day We could represent each solution as a position on the road Say, a whole number between [ ]

61 Where to drill for oil? 500 1000 Road Solution2 = 900 Solution1 = 300

62 Digging for Oil The set of all possible solutions [ ] is called the search space or state space In this case it’s just one number but it could be many numbers or symbols Often GA’s code numbers in binary producing a bitstring representing a solution In our example we choose 10 bits which is enough to represent

63 Convert drilling locations to binary strings
512 256 128 64 32 16 8 4 2 1 900 300 1023 In GA’s these encoded strings are sometimes called “genotypes” or “chromosomes” and the individual bits are sometimes called “genes”

64 Drilling for Oil Solution1 = 300 (0100101100)
Road 1000 O I L 30 5 Location

65 EXAMPLE Antenna Design

66 Examples - GA in the wild
ST5 Antenna – NASA Evolvable Systems Group

67 ST5 Antenna Needs less power than standard antennae.
Doesn’t require a matching network nor a phasing circuit – two less steps in design and fabrication. More uniform coverage than standard antennae, yielding more reliable performance. Short design cycle – 3 person-months to prototype fabrication, vs. 5-person months on average for conventionally designed antennae. First, there is the potential of needing less power. Antenna ST achieves high gain (2-4dB) across a wider range of elevation angles. This allows a broader range of angles over which maximum data throughput can be achieved. Also, less power from the solar array and batteries may be required. Second, the evolved antenna does not require a matching network nor a phasing circuit, removing two steps in design and fabrication of the antenna. A trivial transmission line may be used for the match on the flight antenna, but simulation results suggest that one is not required. Third, the evolved antenna has more uniform coverage in that it has a uniform pattern with small ripples in the elevations of greatest interest (between 40 and 80 degrees). This allows for reliable performance as elevation angle relative to the ground changes. Finally, the evolved antenna had a shorter design cycle. It was estimated that antenna ST took 3 person-months to design and fabricate the first prototype as compared to 5 person-months for the conventionally designed antenna.

68 EXAMPLE Evolving Mona Lisa

69 Examples - GA in the wild
Image compression – evolving the Mona Lisa Generation 1 Generation 301 This weekend I decided to play around a bit with genetic programming and put evolution to the test, the test of fine art :-) I created a small program that keeps a string of DNA for polygon rendering. The procedure of the program is quite simple: 0) Setup a random DNA string (application start) Copy the current DNA sequence and mutate it slightly Use the new DNA to render polygons onto a canvas Compare the canvas to the source image If the new painting looks more like the source image than the previous painting did, then overwrite the current DNA with the new DNA repeat from 1 Now to the interesting part :-) Could you paint a replica of the Mona Lisa using only 50 semi transparent polygons? Took generations, though began to be recognizable as the Mona Lisa after 10,000 or so. Images above are generation 1, 301, 2716, and Generation Generation 2716

70 Evolving the Mona Lisa Uses only 50 polygons of 6 vertices each.
Population size of 1, no crossover – parent compared with child, and superior image kept. Assuming each polygon has 4 bytes for color (RGBA) and 2 bytes for each of 6 vertices, this image only requires 800 bytes. However, compression time is prohibitive and storage is cheaper than processing time. 

71 More evolved images

72 A brief introduction to Co-evolution
Two or more species evolve and interact through the fitness function Closer to real biological systems Competitive (prey-predator) or Cooperative Examples: Hillis (competitive), other work (cooperative)

73 Evolving Neural Networks
Evolving the architecture of neural network is slightly more complicated, and there have been several ways of doing it. For small nets, a simple matrix represents which neuron connects which, and then this matrix is, in turn, converted into the necessary 'genes', and various combinations of these are evolved.

74 Evolving Neural Networks
Many would think that a learning function could be evolved via genetic programming. Unfortunately, genetic programming combined with neural networks could be incredibly slow, thus impractical. As with many problems, you have to constrain what you are attempting to create. For example, in 1990, David Chalmers attempted to evolve a function as good as the delta rule. He did this by creating a general equation based upon the delta rule with 8 unknowns, which the genetic algorithm then evolved.

75 Other Areas of Applications
Genetic Algorithms can be applied to virtually any problem that has a large search space. Al Biles uses genetic algorithms to filter out 'good' and 'bad' riffs for jazz improvisation. The military uses GAs to evolve equations to differentiate between different radar returns. Stock companies use GA-powered programs to predict the stock market.

76 Symbolic AI versus Genetic Algorithms
Most symbolic AI systems are very static. Most of them can usually only solve one given specific problem, since their architecture was designed for whatever that specific problem was in the first place. Thus, if the given problem were somehow to be changed, these systems could have a hard time adapting to them, since the algorithm that would originally arrive to the solution may be either incorrect or less efficient. Genetic algorithms (or GA) were created to combat these problems; they are basically algorithms based on natural biological evolution.

77 Symbolic AI verus Genetic Algorithms
The architecture of systems that implement genetic algorithms (or GA) are more able to adapt to a wide range of problems. A GA functions by generating a large set of possible solutions to a given problem. It then evaluates each of those solutions, and decides on a "fitness level" (you may recall the phrase: "survival of the fittest") for each solution set. These solutions then breed new solutions. The parent solutions that were more "fit" are more likely to reproduce, while those that were less "fit" are more unlikely to do so. In essence, solutions are evolved over time. This way you evolve your search space scope to a point where you can find the solution. Genetic algorithms can be incredibly efficient if programmed correctly.

78 GA: Hybridization and Parallelization
GAs strengths and weaknesses: Domain independence Hybridization Seed good individuals in the initial population Combine with other Metaheuristics to improve some solutions Parallelization Fitness-evaluation Sub-populations The Island Model

79 Memetic Algorithms (1) Basically, a Memetic Algorithm is a GA with Local Search as improvement mechanism Also known under different names An example of hybridization A meme is a unit of cultural information transferable from one mind to another Sounds like gene: the unit carrying inherited information

80 Memetic Algorithms (2) The experience is that GAs do not necessarily perform well in some problem domains Using Local Search in addition to the population mechanisms proves to be an improvement In a sense this elevates the population search to a search among locally optimal solutions, rather than among any solution in the solution space

81 Issues for GA Practitioners
Basic implementation issues: Representation Population size, mutation rate, ... Selection, deletion policies Crossover, mutation operators Termination Criteria Performance, scalability Solution is only as good as the evaluation function (often hardest part)

82 Benefits of Genetic Algorithms
Concept is easy to understand Modular, separate from application Supports multi-objective optimization Good for “noisy” environments Always an answer; answer gets better with time Inherently parallel; easily distributed

83 Benefits of Genetic Algorithms (cont.)
Many ways to speed up and improve a GA-based application as knowledge about the problem domain is gained Easy to exploit previous or alternate solutions Flexible building blocks for hybrid applications Substantial history and range of use

84 When to Use a GA Alternate methods are too slow or overly complicated
Need an exploratory tool to examine new approaches Problem is similar to one that has already been successfully solved by using a GA Want to hybridize with an existing method Benefits of the GA technology meet key problem requirements

85 EC - General properties
Exploit collective “learning“ process of a population (each individual = one solution = one search point) Evaluation of individuals in their environment = measure of quality = fitness  comparison of individuals Selection favors better individuals who reproduce more often than those that are worse Offspring is generated by random recombination and mutation of selected parents

86 GA: Overview Important characteristics: Population av solutions
Domaine independence – encoding Structure is not exploited Inherent parallell – schema, vocabulary Robust Good mechanisms for intensification Lacking in diversification

87 Genetic Algorithm Codes

88 Genetic Algorithm Codes
An Example Genetic Algorithm Procedure GA{ t = 0; Initialize P(t); Evaluate P(t); While (Not Done) { Parents(t) = Select_Parents(P(t)); Offspring(t) = Procreate(Parents(t)); Evaluate(Offspring(t)); P(t+1)= Select_Survivors(P(t),Offspring(t)); t = t + 1; }

89 Genetic Algorithms: Parent Selection Methods
An Example Genetic Algorithm Procedure GA{ t = 0; Initialize P(t); Evaluate P(t); While (Not Done) { Parents(t) = Select_Parents(P(t)); Offspring(t) = Procreate(Parents(t)); Evaluate(Offspring(t)); P(t+1)= Select_Survivors(P(t),Offspring(t)); t = t + 1; }

90 Genetic Algorithms: Genetic Procreation Operators
An Example Genetic Algorithm Procedure GA{ t = 0; Initialize P(t); Evaluate P(t); While (Not Done) { Parents(t) = Select_Parents(P(t)); Offspring(t) = Procreate(Parents(t)); Evaluate(Offspring(t)); P(t+1)= Select_Survivors(P(t),Offspring(t)); t = t + 1; }

91 Genetic Algorithm: Selecting Who Survives
An Example Genetic Algorithm Procedure GA{ t = 0; Initialize P(t); Evaluate P(t); While (Not Done) { Parents(t) = Select_Parents(P(t)); Offspring(t) = Procreate(Parents(t)); Evaluate(Offspring(t)); P(t+1)= Select_Survivors(P(t),Offspring(t)); t = t + 1; }

92 Some GA Application Types

93 Some Existing GA Programs

94 References Holland, J. (1992), Adaptation in natural and artificial systems , 2nd Ed. Cambridge: MIT Press. Davis, L. (Ed.) (1991), Handbook of genetic algorithms. New York: Van Nostrand Reinhold. Goldberg, D. (1989), Genetic algorithms in search, optimization and machine learning. Addison-Wesley. Fogel, D. (1995), Evolutionary computation: Towards a new philosophy of machine intelligence. Piscataway: IEEE Press. Bäck, T., Hammel, U., and Schwefel, H. (1997), ‘Evolutionary computation: Comments on the history and the current state’, IEEE Trans. On Evol. Comp. 1, (1)

95 Online Resources http://www.spectroscopynow.com
IlliGAL ( GAlib ( Colin Burgess/ Univ of Bristol Comp Sci

96 Introduction to Genetic Algorithms
References C. Darwin. On the Origin of Species by Means of Natural Selection; or, the Preservation of flavored Races in the Struggle for Life. John Murray, London, 1859. W. D. Hillis. Co-Evolving Parasites Improve Simulated Evolution as an Optimization Procedure. Artificial Life 2, vol 10, Addison-Wesley, 1991. J. H. Holland. Adaptation in Natural and Artificial Systems. The University of Michigan Press, Ann Arbor, Michigan, 1975. Z. Michalewicz. Genetic Algorithms + Data Structures = Evolution Programs. Springer-Verlag, Berlin, third edition, 1996. M. Sipper. Machine Nature: The Coming Age of Bio-Inspired Computing. McGraw-Hill, New-York, first edition, 2002. M. Tomassini. Evolutionary algorithms. In E. Sanchez and M. Tomassini, editors, Towards Evolvable Hardware, volume 1062 of Lecture Notes in Computer Science, pages Springer-Verlag, Berlin, 1996. Introduction to Genetic Algorithms

97 Problem 1 In the Travelling Salesman Problem (TSP) a salesman has to find the shortest distance journey that visits a set of cities Assume we know the distance between each city This is known to be a hard problem to solve because the number of possible routes is N! where N = the number of cities There is no simple algorithm that gives the best answer quickly

98 Problem 2 Design a chromosome encoding, a mutation operation and a crossover function for the Travelling Salesman Problem (TSP) Assume number of cities N = 10 After all operations the produced chromosomes should always represent valid possible journeys (visit each city once only) There is no single answer to this, many different schemes have been used previously

99 Sources David Hales Troy Cok Muhannad Harrim Richard Frankel
Assaf Zaritsky J.E.Smith Jennifer Pittman Johannes F. Knabe, Katja Wegner, Maria J. Schilstra


Download ppt "Fitness Functions."

Similar presentations


Ads by Google