Learning Sorting Networks By Grammars

A compare-exchange network, or CMPX-net, is a sequence of operations of the form [i : j], each of which operates on an array, D, of length N. The network is said to have width N. The length of the network is the number of CMPX’s in the network. For each [i : j], we have i O[j] for each [i : j] in the sequence. A sorting networlc(SNet) is a CMPX-net which will sort D’s contents into nondecreasing order no matter how D’s contents are ordered initially. A merging network (MNet) is a pair containing a CMPX-net of even width, N, and a partition of the indices into two equal-size sets or “sides.” If the data on each side of the partition are sorted initially then the output will be sorted. The space of CMPXnets with n, CMPX’s and width N is large, of size C(N; 2)‘% With MNets, the space is still bigger, since we must multiply the number of networks by the number of partitions, C(N; N/2). We use a genetic algorithm(GA) to search for CMPX-nets which are SNets or MNets. The GA repeatedly samples the space of potential solutions in a series of “generations,” each using the relative “fitness” of the previous generation’s samples to apportion more samples in promising regions. Mutation and especially cross-over operators are applied to generate similar but novel new sample points; this process is iterated until some stopping criterion is achieved. Hillis has had encouraging success using a GA to evolve sorting networks( Hillis 1991). In our work, we represent CMPX-nets by grammars which describe CMPX-nets. Terminals define particular CMPX sequences and nonterminals specify ways in which larger networks are built from smaller ones.