Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implementation of a recursive function for this problem: Consider the following

ID: 3658318 • Letter: I

Question

Implementation of a recursive function for this problem: Consider the following recursive definition: Acker ( m, n ) = n + 1 if m = 0 Acker ( m, n ) = Acker ( m - 1, 1 ) if n = 0 Acker ( m, n ) = Acker ( m - 1, Acker ( m, n - 1 ) ) otherwise The above function is called Ackermann's function. It is of interest because it grows rapidly with respect to the sizes of m and n. Implement a recursive method acker() that will compute this function for various values of m and n. Your method will also print out the intermediate values of m and n so that you can trace the recursive computations. In your method main() you will experiment with various values of m and n to see the growth in the number of computations. Run your computation for the following pairs of values of m and n. ( m, n ) = ( 1, 1 ), ( 1, 2 ), ( 2, 1 ), ( 2, 2 )

Explanation / Answer

The three row sums, the three column sums, and the two diagonal sums are 15. Generate magic squares using a genetic algorithm. Generate one magic square for several different values of n. The major challenge in this assignment is the design of your encoding scheme and fitness function. Submit: (short) description of your representation and fitness function, plot of best fitness versus time for each experiment (you can submit one plot with several lines). Genotype encoding: M pairs of values in the range [1..n], where n is the number of inputs. For example: if n=16 (16 inputs), and M=65, then the genome contains 65 pairs (130 values), for example, [(1,6), (5,16),..., (4,12)] that represent the gates. Crossover: one-point crossover at pair boundaries and not within (i.e., crossover point can be between (1,6) and (5,16), but not inside a pair). Mutation: with small probability exchange a pair with a randomly created pair. Fitness: First, let's state the 0-1 principle due to Knuth: A sorting network with n inputs that sorts all 2n sequences of zeroes and ones is a perfect sorting network (i.e., it sorts all sequences of arbitrary values, too). Thus, as fitness measure, we can use the number of sequences sorted correctly (of the 2n), divided by 2n. When 2n becomes too large, use a randomly selected group of test cases of size k (you decide the value of k). This group is selected once per generation, and holds for the entire generation. Every few generations test your best individual on all test cases. Run your GA on the problem for the following values of n and M: n=10, M=31,30,29,28 n=11, M=37,36,35,34 n=12, M=41,40,39,38 n=13, M=47,46,45,44 n=14, M=53,52,51,50 n=15, M=58,57,56,55 n=16, M=62,61,60,59