Preliminaries: Open this script in the Matlab editor and change the value of the SN variable at the top of the file to your student number, and the value of the range variable to 6 + the final digit of your student number.
Then save and run the file and observe the plots that are generated. Run the file again and this time set visflag=0 (also defined at the top of the script). Using visflag=1 allows you to see graphically how the population changes from one generation to the next in the GA, but is slow to run.
Switch between these settings as needed for the different parts of the assignment.
Exercises
1. Study the ‘Run_GA_basic’ script and the various functions it calls, and hence determine the specification of the chromosomes and the precise form of the GA implementation that is being used, that is, provide details of
(i) the problem encoding and the precision with which x and y are being computed,
(ii) the definition of the fitness function,
(iii) the approach to selection, and
(iv) the crossover and mutation mechanisms used.
2. Conduct a systematic investigation of the performance of the implemented GA with gen_max=20 for mutation rates (mut_rate) of 0, 0.05, 0.1 and 0.4, and population size (pop_size) of 5, 10 and 20. You need to run the algorithm several times for each combination of mutation rate and population size and consider the average behaviour to take account of the stochastic nature of GAs. Comment on the patterns that you observe. What combination works best?
3. With the mutation rate set at 0.05, explore the impact on performance of varying gen_max and pop_size, where the product of gen_max and pop_size is constrained to be 100. (e.g. test combinations such as 10 and 10, 20 and 5, 5 and 20 and 25 and 4. From your investigation, what do you conclude?
4. Modify the ‘Run_GA_basic’ script so that the GA incorporates elitist selection, where the k fittest parents are copied directly into the next generation together with the pop_size ? k fittest offspring. Explore the performance of elitist GA for different values of k, gen_max and pop_size when the mutation rate is 0.1. Hence deduce appropriate values of these parameters for this problem. How does the performance of the elitist GA compare with the basic GA implementation?
5. Rather than using binary genes and chromosomes, design and implement a GA that uses real? valued genes to solve the problem. This means that chromosomes, crossover and mutation operators work directly with real valued genes, and the associated functions will need to be changed accordingly.
6. Compare and contrast the performance of binary versus real valued GAs for solving the optimisation problem.