Class NonWrappingOrderCrossover
- All Implemented Interfaces:
PermutationBinaryOperator
,Splittable<CrossoverOperator<Permutation>>
,CrossoverOperator<Permutation>
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 at the left-most index, and jumping over the cross segment, and continuing to the right end to get c1 = [1, 0, 2, 3, 4, 5, 6, 7]. 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, from the left-most open index to the right-most, we end up with c2 = [1, 2, 0, 5, 6, 3, 4, 7].
The worst case runtime of a call to cross
is O(n), where n is the length of the
permutations.
NWOX was introduced in the following paper:
Vincent A. Cicirello. Non-Wrapping Order Crossover: An Order Preserving Crossover Operator that Respects Absolute Position. Proceedings of the Genetic and Evolutionary Computation Conference (GECCO'06), volume 2, pages 1125-1131. ACM Press, July 2006. doi:10.1145/1143997.1144177. [PDF] [BIB] [From the ACM Digital Library]
-
Constructor Summary
ConstructorDescriptionConstructs a non-wrapping order crossover (NWOX) operator. -
Method Summary
Modifier and TypeMethodDescriptionvoid
apply
(int[] raw1, int[] raw2) SeePermutationBinaryOperator
for details of this method.void
cross
(Permutation c1, Permutation c2) Performs 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.
-
Constructor Details
-
NonWrappingOrderCrossover
public NonWrappingOrderCrossover()Constructs a non-wrapping order crossover (NWOX) operator.
-
-
Method Details
-
cross
Description copied from interface:CrossoverOperator
Performs 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.- Specified by:
cross
in interfaceCrossoverOperator<Permutation>
- Parameters:
c1
- A candidate solution subject to the crossover. This method changes the state of c1.c2
- A candidate solution subject to the crossover. This method changes the state of c2.
-
apply
public void apply(int[] raw1, int[] raw2) SeePermutationBinaryOperator
for details of this method. This method is not intended for direct usage. Use thecross(org.cicirello.permutations.Permutation, org.cicirello.permutations.Permutation)
method instead.- Specified by:
apply
in interfacePermutationBinaryOperator
- Parameters:
raw1
- The raw representation of the first permutation.raw2
- The raw representation of the second permutation.
-
split
Description copied from interface:Splittable
Generates 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 theCopyable
interface. 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.- Specified by:
split
in interfaceSplittable<CrossoverOperator<Permutation>>
- Returns:
- A functionally identical copy of the object, or a reference to this if it is both safe and efficient for multiple threads to share a single instance of this Splittable object.
-