Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Genetic Algorithms: the fitness function A chromosome has to be evaluated to determine how good a solution it represents [or how `fit' it is] the method of evaluation is governed by a fitness function. i.e. fitness_function(chromosome) = fitness, where fitness is some numerical measure. The fitness function is problem dependent, and has to take into account the problem constraints The algorithm attempts to minimise or maximise fitness of the population, depending on the design of the fitness function. The design of a suitable chromosome (formulation of the problem) and the development of suitable fitness function are critical to obtaining an optimum solution. Example (1) The timetable example some constraints 1. no two subjects are to be timetable into the same slot. 2. each subject has to be timetabled twice. 3. the more time slots there are between the time table for the same subject, the better the timetable Note: sometimes the problem constraints narrow down the possible chromosome representations there is the concept of an invalid solution [i.e violating constraints 2] constraint 4 suggests that one valid timetable may be `better' than another Chromsome design [see previous lecture] gene value subject [2 bit gene] gene position time slot [8 genes i.e. positions] Some example chromosomes #1 #2 #3 #4 #5 00 00 00 11 10 00 11 00 10 11 10 11 11 00 10 00 01 01 01 01 11 01 01 11 11 11 00 11 10 00 10 10 10 00 00 01 10 10 01 10 Valid chromosomes are #2, #3 and #4 Invalid chromsomes are #1 and #5 Why? How to evaluate `fitness'? maximise fitness? a possibility … fitness_function(invalid chromosome) = 0 fitness_function(valid_chromsome) = total time slots between the same subjects For example fitness_function(#1) = 0 fitness_function(#5) = 0 fitness_function(#2) = 4 [there are 4 slots between subject 00] + 0 [there are no slots between subject 01] + 0 [there are no slots between subject 10] + 0 [there are no slots between subject 11] =4 fitness_function(#3) = 0 [there are no slots between subject 00] + 0 [there are no slots between subject 01] + 0 [there are no slots between subject 10] + 2 [there are no slots between subject 11] =2 fitness_function(#4) = 3 [there are 4 slots between subject 00] + 3 [there are 3 slots between subject 01] + 3 [there are 3 slots between subject 10] + 3 [there are 3 slots between subject 11] = 12 Is this a maximum? Are then any other chromsomes that have this fitness? #4 11 10 00 01 11 10 00 01 10 00 01 01 00 10 11 What about ? #6 11 #7 00 10 01 11 11 00 10 01 fitness_function(#6) = 2 + 0 + 4 + 6 = 12 fitness_function(#7) = 4 + 4 + 4 + 0 = 12 May need to modify fitness_function penalise any for the case where there are adjacent time slots for a given subject e.g. penalise #6,#7 (perhaps subtract 2 from the fitness value) There is a potential problem here. Are some invalid solutions more invalid than others? If we had a population that only contained invalid solutions would effect would this have? Example (2) the file storage optimisation problem some constraints disc space available in each location location 1 (00) location 2 (01) location 3 (10) location 4 (11) 1.0 K 1.5 K 4.0 K 0.3 K Total Storage available is 6.8 K size of each file File File File File File A B C D E 0.2 K 0.1 K 1.2 K 3.0 K 0.9 K Total file size to be stored = 5.4K From the last lecture: a 10 bit chromosome using 5 genes. The gene value is the location, the gene position is the file If the total size of the files stored in a location exceeds the size of that location then we have an invalid solution [i.e. overflow has occurred]. We wish to maximise the amount of free space. the higher the fitness value the `better' the solution may wish to reward a valid solution fitness_function(valid_chromosome) = bonus for valid solution + amount of free space the bonus for a valid solution could be max score for an invalid solution. fitness_function(invalid_chromosome) = total storage space - overflow = 6.8 - overflow IF (valid_chromsome) THEN fitness = bonus for valid solution + amount of free space ELSE fitness = total storage space - overflow ENDIF examples: #1 0100001011 or … 01 File A 00 File B 00 File C 10 File D Interpretation: File A is stored in location 2 File B is stored in location 1 File C is stored in location 1 File D is stored in location 3 File E is stored in location 4 in other words location 1 [00] stores 0.1 + 1.2 = 1.3 K [overflow = 1.3 - 1.0 = 0.3] location 2 [01] stores 0.2 K [free space = 1.3K] location 3 [10] stores 3.0 K [free space = 1.0K] location 4 [11] stores 0.9 K [overflow = 0.9 - 0.3 = 0.6] invalid chromsome: fitness(#1) = 6.8 - 0.9 = 5.7 [error! should be 5.9] 11 File E #2 0000011010 00 File A 00 File B 01 File C 10 File D 10 File E Interpretation: File A is stored in location 1 File B is stored in location 1 File C is stored in location 2 File D is stored in location 3 File E is stored in location 3 in other words location 1 [00] stores 0.1 + 0.2 = 0.3 K [free space = 1.0 - 0.3 = 0.7] location 2 [01] stores 1.2 K [free space = 1.5 - 1.2 = 0.3K] location 3 [10] stores 3.0 + 0.9 = 3.9 K [free space = 4.0 - 3.9 = 0.1K] location 4 [11] stores 0 K [free space = 0.3 - 0 = 0.3] valid chromosome fitness(#2) = 6.8 + (0.7 + 0.3 + 0.1 + 0.3) = 6.8 + 1.4 = 8.2 Another consideration: The evaluation of fitness is algorithmic, design the function for algorithmic simplicity