java.lang.Object
org.cicirello.permutations.distance.ExactMatchDistance
- All Implemented Interfaces:
NormalizedPermutationDistanceMeasurer
,NormalizedPermutationDistanceMeasurerDouble
,PermutationDistanceMeasurer
,PermutationDistanceMeasurerDouble
public final class ExactMatchDistance
extends Object
implements NormalizedPermutationDistanceMeasurer
Exact Match distance is an extension of Hamming distance but to non-binary strings, in this case,
permutations. It is the count of the number of positions for which the two permutations contain
different elements.
Runtime: O(n), where n is the permutation length.
Exact match distance was introduced in:
S. Ronald, "More distance functions for order-based encodings," in Proc. IEEE CEC. IEEE Press,
1998, pp. 558–563.
-
Constructor Summary
ConstructorDescriptionConstructs the distance measurer as specified in the class documentation. -
Method Summary
Modifier and TypeMethodDescriptionint
distance
(Permutation p1, Permutation p2) Measures the distance between two permutations.int
max
(int length) Computes the maximum possible distance between permutations of a specified length.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.cicirello.permutations.distance.NormalizedPermutationDistanceMeasurer
maxf, normalizedDistance
Methods inherited from interface org.cicirello.permutations.distance.PermutationDistanceMeasurer
distancef
-
Constructor Details
-
ExactMatchDistance
public ExactMatchDistance()Constructs the distance measurer as specified in the class documentation.
-
-
Method Details
-
distance
Measures the distance between two permutations.- Specified by:
distance
in interfacePermutationDistanceMeasurer
- Parameters:
p1
- first permutationp2
- second permutation- Returns:
- distance between p1 and p2
- Throws:
IllegalArgumentException
- if p1.length() is not equal to p2.length().
-
max
public int max(int length) Description copied from interface:NormalizedPermutationDistanceMeasurer
Computes the maximum possible distance between permutations of a specified length.- Specified by:
max
in interfaceNormalizedPermutationDistanceMeasurer
- Parameters:
length
- Permutation length.- Returns:
- the maximum distance between a pair of permutations of the specified length.
-