A ``magic square'' of order n is an n-by-n matrix
containing all the integers from 1 to n*n, each one exactly once,
such that all row, column, and diagonal sums are the same.
In other words, it is a permutation of the numbers 1 to n*n,
arranged in a rectangular grid, with the property that each row sum
of the matrix, each column sum, and each diagonal sum is equal
to the same integer.
For example, a magic square of order 3 is
2 7 6
9 5 1
4 3 8
The three row sums, the three column sums, and the two diagonal sums are 15.
Using SGA-C, aGA.java, or simple_ga_prog
from the class directory ~shartley/MCS770,
generate magic squares using a genetic algorithm.
Generate one magic square for as many different values of n as you can.
The major challenge in this assignment is the design of your encoding
scheme and fitness function.
This programming assignment is due in class
Monday, May 6, 1996.
There are three things to turn in electronically using the
submit command:
- A listing of your objective (fitness) function from the SGA-C,
aGA.java, simple_ga_prog.c
or simple_ga_prog.java source code,
plus any other procedures or code you change.
- A listing of your best runs of SGA-C, aGA.java,
or simple_ga_prog.
DO NOT include all generations!
Use the script command and then edit out all but the first few,
a middle few, and the last few generations.
- A write-up answering these questions
describing how you optimized the function using genetic
algorithms and what you learned (about one or two single-spaced page),
and
what problems you encountered while designing, implementing, and
debugging your program and how you solved those problems.
- Your write-up should clearly describe your encoding scheme, fitness
function, crossover operators tried, mutation operators tried,
and parameters that led to successful runs (population size, crossover
and mutation probabilities).
Use the submit command
to turn in file copies of all of the above.
Place them in the Pr3 directory of MCS770.