HW6 Genetic Algorithms

Evolved Sorting Networks

Due: Monday April 29 at 11:59pm

Develop a genetic algorithm to find a sorting network capable of sorting 16 elements. It's possible for a sorting network to do comparisons in parallel, but for the homework, we will assume that all comparisons occur serially. A serial sorting network can be encoded as an ordered list of pairs. Each pair represents a comparison and potential swap of inputs. For instance (3,5) denotes swapping the element at position 3 with the element at position 5 if the element at position 3 is greater (assuming we are attempting to sort in ascending order). A bubble sort over a six element sorting network could be encoded:
(6,5)(5,4)(4,3)(3,2)(2,1) (6,5)(5,4)(4,3)(3,2) (6,5)(5,4)(4,3) (6,5)(5,4) (6,5)

Recall the basics of genetic algorithms:

  1. Generate n random solutions: Gi.
  2. Evaluate all solutions with the fitness functions Φ()
  3. Select (with replacement) m of the solutions for survival with probability of selection proportional to the relative fitness of the solutions: P(select(Gi)) = Φ(Gi)/Σj Φ(Gj)
  4. Repeatedly select two survivors and combine them through crossover to generate n new solutions: G'i
  5. Optionally, k of the new generation can be copies of the most fit solutions from the previous generation instead of combinations.
  6. Traverse each solution and mutate each subsection with (low) probability Pmut.
  7. Repeat from step 2.

It is impractical to evaluate all n networks on all possible combinations of inputs, even with limited length. Therefore, your fitness function should be evaluated over a subset of the inputs. In addition to maintaining a pool of solutions, you should also maintain a pool of inputs. To prevent your networks from evolving to only solve all but the most difficult inputs, co-evolve the inputs alongside the solutions. The fitness of the inputs (which can be seen as parasites) should be determined by the number of solutions that sort it incorrectly. This way, the fitness function will adapt to force solutions to answer all inputs.

You are responsible for deciding how to handle crossover and mutation. You should use some method to encourage shorter solutions.

Please prepare and submit a well-written report with the following:

The report should be in pdf format and should contain your name, email and EID. The command to submit will be something like: turnin --submit lewfish hw6.