Class SimplificationWorker


  • final class SimplificationWorker
    extends java.lang.Object
    Worker for the Simplifier.
    Since:
    2.0
    Version:
    1.0
    • Method Detail

      • simplify

        public AbstractConverter simplify​(java.util.List<? extends javax.measure.UnitConverter> conversionSteps)
        Description of a brute-force approach:

        Given 'conversionSteps' a list of converters, where order matters, we form a permutation group of all allowed permutations 'reachable' through 'allowed' swapping. Swapping is allowed for 2 consecutive converters that are both multiply transformations (x.isLinear()==true). We search this permutation group for any sequence of converters, that allows simplification:

        For every pair of consecutive converters within a sequence, check whether a simplification is possible (a.isSimpleCompositionWith(b)), then apply simplification and start over.

        Finally sort according to normal-form order.

        Parameters:
        conversionSteps -
        Returns:
      • trySimplify

        private int trySimplify()
      • sortToNormalFormOrder

        private static void sortToNormalFormOrder​(AbstractConverter[] arrayOfConverters)