• No results found

2.6 Algorithm coding

2.6.2 Minimising the evaluations

The first test was to determine how the offspring proportion affects the num- ber of generations required to reach a result. To more closely represent the environment that the algorithm will find in conjunction with the pulse shaper, individuals were used consisting of 1280 elements each ranging from 0–4095. The same ideal solution was used as previously, i.e. sum of val- ues = 0. Because a threshold of 1 would take prohibitively long (in one test no solution was found after two hours of searching and over 200,000 genera- tions) a higher threshold is used. In this case it is the threshold that indicates the average element is 1/3 of the maximum — the actual threshold value is unimportant, as long as it is the same for each test.

A population of 100 was used and various offspring proportions used ranging from 5% to 90%. For each proportion the algorithm was run eight times and the number of generations recorded. Standard deviations of the number of generations taken were found to be 3–6% of the mean with no clear relation to the proportion value. The results are plotted in Figure 2.21. It can be seen that increasing the offspring proportion significantly reduces the number of generations required to reach a result, up until a proportion of around 40–50% (i.e. half the population replaced each generation). Beyond this the improvements are negligible or non-existent.

As has been pointed out, though, from the point of view of the proposed experiments it is the number of evaluations that will determine the overall time taken. Since the GA must evaluate each new individual the total number of evaluations carried out (ignoring the evaluation of the original population) is given by multiplying the offspring proportion by the population (100 in this case) and by the number of generations taken to reach a solution. This is plotted in Figure 2.22, indicating a proportion of between 10% and 30% is optimal.

Offspring proportion (%) 0 20 40 60 80 100 Number of generations 0 1000 2000 3000 4000 5000 6000

Figure 2.21: Plot showing how the number of generations taken to reach a result varies with the proportion of children introduced each generation.

Offspring proportion (%) 0 20 40 60 80 100 Number of evaluations 0 10000 20000 30000 40000

Figure 2.22: Plot showing how the total number of evaluations made by the GA to reach a result varies with the proportion of children introduced each generation.

Population size 0 50 100 150 200 250 Number of generations 0 500 1000 1500 2000 2500 3000

Figure 2.23: Plot showing how the number of generations taken to reach a result varies with population size.

quired to reach a result is the population. Clearly for any given offspring proportion a larger population will mean more evaluations to be carried out each generation, but a larger population should also mean less generations re- quired. To determine these relations an offspring proportion of 30% was used (fitness timing not being an issue during testing) with varying populations from 10 to 200. Again for each population a number of repeat runs of the GA were used and the average taken. The same threshold was used and the standard deviations were found to vary from 2.5–6.5% of the mean with no clear relation to the population size. The results are plotted in Figure 2.23.

It can be seen that larger populations reduce the number of generations required to reach a result and that this effect decreases with increasing pop- ulation size. Again, though, it is the number of evaluations made that is of more importance. This is calculated from the offspring proportion (30%) multiplied by the population size multiplied by the number of generations taken to reach a solution. This is plotted in Figure 2.24

Size of population

0 50 100 150 200 250

Total number of evaluations

0 20000 40000 60000 80000 100000 120000 140000

Figure 2.24: Plot showing how the population size affects the number of evaluations the GA is required to make to reach a result.

larger population reduces the number of generations taken to reach a result, this is more than offset by the correspondingly larger number of evaluations that must be made at each generation. This looks almost linear, suggesting that the greater benefit is provided by making the population as small as possible. Clearly there must be some cut-off point (a population of 1, for instance, could not even breed) but it can be seen that even a population of 10 in which only 3 offspring are produced each generation results in a lower total number of evaluations overall. This is counterintuitive to much of the standard thinking related to GAs, where the focus is on reducing the number of generations required to reach a solution rather than considering the number of evaluations.

In conclusion, then, it has been found that although large populations and high offspring proportions will provide solutions more quickly in terms of numbers of generations, in situations where the time taken to evaluate the fitness of an individual is significant a relatively tiny population and small percentage of offspring will return a solution more quickly in terms of actual time.