Class ReinsertionDistance

  • All Implemented Interfaces:
    NormalizedPermutationDistanceMeasurer, NormalizedPermutationDistanceMeasurerDouble, PermutationDistanceMeasurer, PermutationDistanceMeasurerDouble

    public final class ReinsertionDistance
    extends Object
    implements NormalizedPermutationDistanceMeasurer
    Reinsertion Distance:

    Reinsertion distance is the count of the number of removal/reinsertion operations needed to transform one permutation into the other.

    This implementation utilizes the observation that the elements that must be removed and reinserted are exactly those elements that are not in the longest common subsequence.

    Runtime: O(n lg n), where n is the permutation length.

    Reinsertion distance more generally was described in:
    V. A. Cicirello and R. Cernera, "Profiling the distance characteristics of mutation operators for permutation-based genetic algorithms," in Proceedings of the 26th FLAIRS Conference. AAAI Press, May 2013, pp. 46–51.

    However, in that paper, it was computed, in O(n^2) time, using an adaptation of string Edit Distance.

    For description of computing it using the length of the longest common subsequence, see:
    V.A. Cicirello, "The Permutation in a Haystack Problem and the Calculus of Search Landscapes," IEEE Transactions on Evolutionary Computation, 20(3):434-446, June 2016.

    However, that paper used an O(n^2) time algorithm for longest common subsequence. This class has been updated to use a more efficient O(n lg n) algorithm for longest common subsequence. It is a version of Hunt et al's algorithm that has been optimized to assume permutations of the integers in [0, (n-1)] with unique elements. The original algorithm of Hunt et al was for general strings that could contain duplicates and which could consist of characters of any alphabet. In that more general case, O(n lg n) was the best case runtime. In our special case, O(n lg n) is worst case runtime.

    See the following for complete details of Hunt et al's algorithm for longest common subsequence:
    J.W. Hunt and T.G. Szymanski, "A fast algorithm for computing longest common subsequences," Communications of the ACM, 20(5):350-353, May, 1977.

    • Constructor Detail

      • ReinsertionDistance

        public ReinsertionDistance()
        Constructs the distance measurer as specified in the class documentation.