Due: Monday April 29 at 11:59pmDevelop 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:
Recall the basics of genetic algorithms:
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.