Package io.jenetics

Enum Optimize

    • Method Detail

      • values

        public static Optimize[] 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 (Optimize c : Optimize.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Optimize 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 <T extends Comparable<? super T>> int compare​(T a,
                                                                      T b)
        Compares two comparable objects. Returns a negative integer, zero, or a positive integer as the first argument is better than, equal to, or worse than the second.
        Type Parameters:
        T - the comparable type
        Parameters:
        a - the first object to be compared.
        b - the second object to be compared.
        Returns:
        a negative integer, zero, or a positive integer as the first argument is better than, equal to, or worse than the second.
        Throws:
        NullPointerException - if one of the arguments is null.
      • descending

        public <T extends Comparable<? super T>> Comparator<T> descending()
        Create an appropriate comparator of the given optimization strategy. A collection of comparable objects with the returned comparator will be sorted in descending order, according to the given definition of better and worse.
        final Population<DoubleGene, Double> population = ... population.sort(Optimize.MINIMUM.<Double>descending());
        The code example above will populationSort the population according it's fitness values in ascending order, since lower values are better in this case.
        Type Parameters:
        T - the type of the objects to compare.
        Returns:
        a new Comparator for the type T.
      • ascending

        public <T extends Comparable<? super T>> Comparator<T> ascending()
        Create an appropriate comparator of the given optimization strategy. A collection of comparable objects with the returned comparator will be sorted in ascending order, according to the given definition of better and worse.
        final Population<DoubleGene, Double> population = ... population.sort(Optimize.MINIMUM.<Double>ascending());
        The code example above will populationSort the population according it's fitness values in descending order, since lower values are better in this case.
        Type Parameters:
        T - the type of the objects to compare.
        Returns:
        a new Comparator for the type T.
      • best

        public <C extends Comparable<? super C>> C best​(C a,
                                                        C b)
        Return the best value, according to this optimization direction.
        Type Parameters:
        C - the fitness value type.
        Parameters:
        a - the first value.
        b - the second value.
        Returns:
        the best value. If both values are equal the first one is returned.
      • worst

        public <C extends Comparable<? super C>> C worst​(C a,
                                                         C b)
        Return the worst value, according to this optimization direction.
        Type Parameters:
        C - the fitness value type.
        Parameters:
        a - the first value.
        b - the second value.
        Returns:
        the worst value. If both values are equal the first one is returned.