Enum Optimum

    • Enum Constant Detail

      • MINIMUM

        public static final Optimum MINIMUM
        Optimizes for minimum values
      • MAXIMUM

        public static final Optimum MAXIMUM
        Optimizes for maximum values
    • Method Detail

      • values

        public static Optimum[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Optimum c : Optimum.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Optimum valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • compare

        public abstract int compare​(double v1,
                                    double v2)
        Compares two values such that the most optimum value would result in being sorted to the front.
        Parameters:
        v1 - the first value
        v2 - the second value
        Returns:
        the result of comparison (optimum value should be < 0)
      • optimum

        public Tuple2<Integer,​Double> optimum​(double[] array)
        Select the best index and value from the given array.
        Parameters:
        array - the array to select from
        Returns:
        the index and value of the best entry
      • optimum

        public <T> Optional<T> optimum​(MStream<T> stream,
                                       SerializableToDoubleFunction<T> function)
        Optimum optional.
        Type Parameters:
        T - the type parameter
        Parameters:
        stream - the stream
        function - the function
        Returns:
        the optional
      • optimum

        public <T> Optional<T> optimum​(Stream<T> stream,
                                       SerializableToDoubleFunction<T> function)
        Optimum optional.
        Type Parameters:
        T - the type parameter
        Parameters:
        stream - the stream
        function - the function
        Returns:
        the optional
      • optimumIndex

        public int optimumIndex​(double[] array)
        Selects the index of the best value in the given array
        Parameters:
        array - the array to select from
        Returns:
        the index of the optimum value
      • optimumIndex

        public int optimumIndex​(float[] array)
        Selects the index of the best value in the given array
        Parameters:
        array - the array to select from
        Returns:
        the index of the optimum value
      • optimumIndex

        public int optimumIndex​(int[] array)
        Selects the index of the best value in the given array
        Parameters:
        array - the array to select from
        Returns:
        the index of the optimum value
      • optimumValue

        public double optimumValue​(@NonNull
                                   @lombok.NonNull double[] array)
        Selects the best value from the given array
        Parameters:
        array - the array to select from
        Returns:
        the most optimum value
      • optimumValue

        public double optimumValue​(@NonNull
                                   @lombok.NonNull float[] array)
        Selects the best value from the given array
        Parameters:
        array - the array to select from
        Returns:
        the most optimum value
      • startingValue

        public abstract double startingValue()
        Gets a value that will also be the worst possible solution.
        Returns:
        the double
      • test

        public abstract boolean test​(double value,
                                     double threshold)
        Test if the given value passes the given threshold based on the direction of the optimum. For MINIMUM this uses a less than equal to operator and for MAXIMUM this uses a greater than equal to operator.
        Parameters:
        value - the value
        threshold - the threshold
        Returns:
        the boolean