Module org.cicirello.jpt
Class ReversalIndependentDistance
- java.lang.Object
-
- org.cicirello.permutations.distance.ReversalIndependentDistance
-
- All Implemented Interfaces:
PermutationDistanceMeasurer,PermutationDistanceMeasurerDouble
public final class ReversalIndependentDistance extends Object implements PermutationDistanceMeasurer
This class implements the concept of a reversal independent distance measure. This is relevant if the permutation and its reverse have the same problem dependent interpretation.
In this case, this class computes the minimum of distance(p1,p2) and distance(p1,reverse(p2)) for a given distance measure passed as a parameter to the constructor.
-
-
Constructor Summary
Constructors Constructor Description ReversalIndependentDistance(PermutationDistanceMeasurer d)Constructs a distance measure for measuring distance with reversal independence, such that distance = min { distance(p1,p2), distance(p1,reverse(p2)) }
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intdistance(Permutation p1, Permutation p2)Measures the distance between two permutations, with reversal independence: distance = min { distance(p1,p2), distance(p1,reverse(p2)) }-
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.PermutationDistanceMeasurer
distancef
-
-
-
-
Constructor Detail
-
ReversalIndependentDistance
public ReversalIndependentDistance(PermutationDistanceMeasurer d)
Constructs a distance measure for measuring distance with reversal independence, such that distance = min { distance(p1,p2), distance(p1,reverse(p2)) }- Parameters:
d- A distance measure.
-
-
Method Detail
-
distance
public int distance(Permutation p1, Permutation p2)
Measures the distance between two permutations, with reversal independence: distance = min { distance(p1,p2), distance(p1,reverse(p2)) }- Specified by:
distancein interfacePermutationDistanceMeasurer- Parameters:
p1- first permutationp2- second permutation- Returns:
- distance between p1 and p2
- Throws:
IllegalArgumentException- if p1.length() is not equal to p2.length().
-
-