### CS63 Fall 1005 Lab 10: Experimenting with Genetic Algorithms In class exercise only, nothing to handin

#### INTRODUCTION

In this lab you will learn how to use Pyro's implementation of various evolutionary algorithms. You will then perform a series of experiments to better understand how the parameters of a GA affect its ability to find solutions. You will also compare a GA to a simpler hill climbing method. These exercises are adapted from Melanie Mitchell's An Introduction to Genetic Algorithms.

#### LAB INSTRUCTIONS

• There is a collection of materials available online to help you learn how to use Pyro's evolutionary algorithms. Read through the first half of PyroModuleEvolutionaryAlgorithms. You can move on to the experiments below once you have reviewed the section on GA Implementation Details.

• EXPERIMENT 1:You will do a series of experiments for a problem, varying the mutation and crossover rates, to see how the variations affect the average time required for the GA to find the optimal string. Use the GAMaxBits.py example which we discussed in class as the basis for your experiments. Recall that it uses a fitness function that sums the number of ones in the bit string. Update this program in the following ways:
• The string length should be 100.
• The population size should be 100.
• Use an elite percentage of 0.05.
• Use single-point crossover with a rate of 0.7.
• Use a bitwise mutation rate of 0.001.
• Set the maximum generation to be 300.
Perform 10 runs, and compute the average generation at which the string of all ones is discovered. Perform the same experiment with crossover turned off. Do several other similar experiments, varying the mutation and crossover rates. Create a table to display the average results for each variation you tried. What can you conclude from these results?

• EXPERIMENT 2:You will do a series of experiments for a problem, keeping the mutation rate and crossover rate fixed while varying the population size. Copy the program from the previous experiment and update it to use a fitness function that interprets the bit string as a binary number. Change the isDone method to stop when the largest possible binary number has been found. Then set the remaining paramenters as follows:
• The string length should be 30.
{"ft_lang_label":"__label__en","ft_lang_prob":0.9257874,"math_prob":0.8608372,"size":1023,"snap":"2019-51-2020-05","text_gpt3_token_len":199,"char_repetition_ratio":0.10893033,"word_repetition_ratio":0.011904762,"special_character_ratio":0.20039101,"punctuation_ratio":0.06989247,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9811163,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-12-08T12:57:33Z\",\"WARC-Record-ID\":\"<urn:uuid:1038378c-8a73-4de0-83d2-c4cabff16a2a>\",\"Content-Length\":\"5096\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ec0bd602-7d37-4e58-8469-78c1af470c01>\",\"WARC-Concurrent-To\":\"<urn:uuid:9c7613c5-a0da-4629-b864-eb308ef10495>\",\"WARC-IP-Address\":\"130.58.68.137\",\"WARC-Target-URI\":\"https://www.cs.swarthmore.edu/~meeden/cs63/f05/lab10.html\",\"WARC-Payload-Digest\":\"sha1:RYSH55J6YFQEJ5WIGQCGCXNOJARAU6E4\",\"WARC-Block-Digest\":\"sha1:LJ3DXZ4RDC3P7AJSQ6HP3B7VT2X7SCEW\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-51/CC-MAIN-2019-51_segments_1575540510336.29_warc_CC-MAIN-20191208122818-20191208150818-00400.warc.gz\"}"}