# Honors Lab 1 solution

The ProblemA genetic algorithm consists of a population of individuals, where each individual is a bit string (i.e., a list of 0’s and 1’s). For example, 0010101010 could be a genetic algorithm individual. A ﬁtness function interprets an individual and assigns it a ﬁtness that represents how good or bad the solution is. One simple ﬁtness function is counting ones, where an individual’s ﬁtness is simply the number of ones in the bit string. For example, the bit string 011100 would have a ﬁtness of 3. Your Task 1. Create one random individual. The individual should be a list of length 100. Each bit should be assigned randomly to a 0 or a 1. (Hint: Check out the random package for python.) 2. Write a counting ones ﬁtness function. Your function should accept an individual as input and return the number of ones as output. 1

You'll get 1 file (23.9KB)