- All Implemented Interfaces:
Implementation of order crossover (OX). OX selects a random subsection similar to a 2-point crossover for bit-strings. One child gets the positions of the elements in the chosen subsection from parent 1, and the relative order of the remainder of the elements from parent 2. The other child gets the positions of the elements in the chosen subsection from parent 2, and the relative order of the remainder of the elements from parent 1. The relative ordered elements begin just past the random subsection to wrapping around to the beginning of the permutation in a circular fashion.
For example, consider the permutation p1 = [0, 1, 2, 3, 4, 5, 6, 7] and the permutation p2 = [1, 2, 0, 5, 6, 7, 4, 3]. Consider that the random subsection of the permutations begins at index 2 and ends at index 4, inclusive. Thus, one child will get the positions of 2, 3, 4 from p1, and the relative ordering of the rest from p2. First, fill in the 2, 3, 4 from p1 to get c1 = [x, x, 2, 3, 4, x, x, x]. c1 will get the relative order of the rest of the elements from p2, namely 1, 0, 5, 6, 7. Fill these in that order into c1 beginning just past the 4 to get c1 = [6, 7, 2, 3, 4, 1, 0, 5]. In a similar way, c2 begins with the positions of 0, 5, 6 from p2, such that c2 = [x, x, 0, 5, 6, x, x, x]. c2 then gets the relative order of the remainder of the elements from p1, namely 1, 2, 3, 4, 7. After filling these in the given order, we end up with c2 = [4, 7, 0, 5, 6, 1, 2, 3].
The worst case runtime of a call to
cross is O(n), where n is the length of the
OX was introduced in the following paper:
Davis, L. Applying Adaptive Algorithms to Epistatic Domains. Proceedings of the International Joint Conference on Artificial Intelligence, 1985, pp. 162-164.
Constructor SummaryConstructorDescriptionConstructs an order crossover (OX) operator.
Method SummaryModifier and TypeMethodDescription
voidPerforms a crossover for an evolutionary algorithm, such that crossover forms two children from two parents.
split()Generates a functionally identical copy of this object, for use in multithreaded implementations of search algorithms.
OrderCrossoverpublic OrderCrossover()Constructs an order crossover (OX) operator.
crossDescription copied from interface:
CrossoverOperatorPerforms a crossover for an evolutionary algorithm, such that crossover forms two children from two parents. Implementations of this method modify the parameters, transforming the parents into the children.
splitpublic OrderCrossover split()Description copied from interface:
SplittableGenerates a functionally identical copy of this object, for use in multithreaded implementations of search algorithms. The state of the object that is returned may or may not be identical to that of the original. Thus, this is a distinct concept from the functionality of the
Copyableinterface. Classes that implement this interface must ensure that the object returned performs the same functionality, and that it does not share any state data that would be either unsafe or inefficient for concurrent access by multiple threads. The split method is allowed to simply return the this reference, provided that it is both safe and efficient for multiple threads to share a single copy of the Splittable object. The intention is to provide a multithreaded search with the capability to provide spawned threads with their own distinct search operators. Such multithreaded algorithms can call the split method for each thread it spawns to generate a functionally identical copy of the operator, but with independent state.