Class Evaluators

java.lang.Object
io.jenetics.engine.Evaluators

public final class Evaluators extends Object
This class contains factory methods for creating commonly usable Evaluator implementations. By default, the evolution Engine uses the concurrent evaluators (concurrent(Function, Executor)).
Since:
5.0
Version:
5.0
See Also:
  • Method Details

    • serial

      public static <G extends Gene<?, G>, C extends Comparable<? super C>> Evaluator<G,C> serial(Function<? super Genotype<G>,? extends C> fitness)
      Return a new fitness evaluator, which evaluates the fitness function of the population serially in the main thread. Might be useful for testing purpose.
      Type Parameters:
      G - the gene type
      C - the fitness value type
      Parameters:
      fitness - the fitness function
      Returns:
      a new serial fitness evaluator
      Throws:
      NullPointerException - if the fitness function is null
    • serial

      public static <T, G extends Gene<?, G>, C extends Comparable<? super C>> Evaluator<G,C> serial(Function<? super T,? extends C> fitness, Function<? super Genotype<G>,? extends T> decoder)
      Return a new fitness evaluator, which evaluates the fitness function of the population serially in the main thread. Might be useful for testing purpose.
      Type Parameters:
      T - the native fitness domain type
      G - the gene type
      C - the fitness value type
      Parameters:
      fitness - the fitness function
      decoder - the decoder function for the fitness domain
      Returns:
      a new (concurrent) fitness evaluator
      Throws:
      NullPointerException - if one of the arguments is null
    • serial

      public static <T, G extends Gene<?, G>, C extends Comparable<? super C>> Evaluator<G,C> serial(Function<? super T,? extends C> fitness, Codec<T,G> codec)
      Return a new fitness evaluator, which evaluates the fitness function of the population serially in the main thread. Might be useful for testing purpose.
      Type Parameters:
      T - the native fitness domain type
      G - the gene type
      C - the fitness value type
      Parameters:
      fitness - the fitness function
      codec - the codec used for transforming the fitness domain
      Returns:
      a new (concurrent) fitness evaluator
      Throws:
      NullPointerException - if one of the arguments is null
    • concurrent

      public static <G extends Gene<?, G>, C extends Comparable<? super C>> Evaluator<G,C> concurrent(Function<? super Genotype<G>,? extends C> fitness, Executor executor)
      Return a new fitness evaluator, which evaluates the fitness function of the population (concurrently) with the given executor. This is the default evaluator used by the evolution engine.
      Type Parameters:
      G - the gene type
      C - the fitness value type
      Parameters:
      fitness - the fitness function
      executor - the Executor used for evaluating the fitness function
      Returns:
      a new (concurrent) fitness evaluator
      Throws:
      NullPointerException - if one of the arguments is null
    • concurrent

      public static <T, G extends Gene<?, G>, C extends Comparable<? super C>> Evaluator<G,C> concurrent(Function<? super T,? extends C> fitness, Function<? super Genotype<G>,? extends T> decoder, Executor executor)
      Return a new fitness evaluator, which evaluates the fitness function of the population (concurrently) with the given executor. This is the default evaluator used by the evolution engine.
      Type Parameters:
      T - the native fitness domain type
      G - the gene type
      C - the fitness value type
      Parameters:
      fitness - the fitness function, working on the native fitness domain
      decoder - the decoder function for the fitness domain
      executor - the Executor used for evaluating the fitness function
      Returns:
      a new (concurrent) fitness evaluator
      Throws:
      NullPointerException - if one of the arguments is null
    • concurrent

      public static <T, G extends Gene<?, G>, C extends Comparable<? super C>> Evaluator<G,C> concurrent(Function<? super T,? extends C> fitness, Codec<T,G> codec, Executor executor)
      Return a new fitness evaluator, which evaluates the fitness function of the population (concurrently) with the given executor. This is the default evaluator used by the evolution engine.
      Type Parameters:
      T - the native fitness domain type
      G - the gene type
      C - the fitness value type
      Parameters:
      fitness - the fitness function, working on the native fitness domain
      codec - the codec used for transforming the fitness domain
      executor - the Executor used for evaluating the fitness function
      Returns:
      a new (concurrent) fitness evaluator
      Throws:
      NullPointerException - if one of the arguments is null
    • async

      public static <G extends Gene<?, G>, C extends Comparable<? super C>> Evaluator<G,C> async(Function<? super Genotype<G>,? extends Future<C>> fitness)
      Return a new fitness evaluator, which evaluates asynchronous fitness functions.
      Type Parameters:
      G - the gene type
      C - the fitness value type
      Parameters:
      fitness - the asynchronous fitness function
      Returns:
      a new (asynchronous) fitness evaluator
      Throws:
      NullPointerException - if one of the arguments is null
      See Also:
    • async

      public static <T, G extends Gene<?, G>, C extends Comparable<? super C>> Evaluator<G,C> async(Function<? super T,? extends Future<C>> fitness, Function<? super Genotype<G>,? extends T> decoder)
      Return a new fitness evaluator, which evaluates asynchronous fitness functions.
      Type Parameters:
      T - the native fitness domain type
      G - the gene type
      C - the fitness value type
      Parameters:
      fitness - the asynchronous fitness function, working on the native fitness domain
      decoder - the decoder function for the fitness domain
      Returns:
      a new (async) fitness evaluator
      Throws:
      NullPointerException - if one of the arguments is null
    • async

      public static <T, G extends Gene<?, G>, C extends Comparable<? super C>> Evaluator<G,C> async(Function<? super T,? extends Future<C>> fitness, Codec<T,G> codec)
      Return a new fitness evaluator, which evaluates asynchronous fitness functions.
      Type Parameters:
      T - the native fitness domain type
      G - the gene type
      C - the fitness value type
      Parameters:
      fitness - the asynchronous fitness function, working on the native fitness domain
      codec - the codec used for transforming the fitness domain
      Returns:
      a new (async) fitness evaluator
      Throws:
      NullPointerException - if one of the arguments is null
    • completable

      public static <G extends Gene<?, G>, C extends Comparable<? super C>> Evaluator<G,C> completable(Function<? super Genotype<G>,? extends CompletableFuture<C>> fitness)
      Return a new fitness evaluator, which evaluates asynchronous fitness functions.
      Type Parameters:
      G - the gene type
      C - the fitness value type
      Parameters:
      fitness - the asynchronous fitness function
      Returns:
      a new (asynchronous) fitness evaluator
      Throws:
      NullPointerException - if one of the arguments is null
      See Also:
    • completable

      public static <T, G extends Gene<?, G>, C extends Comparable<? super C>> Evaluator<G,C> completable(Function<? super T,? extends CompletableFuture<C>> fitness, Function<? super Genotype<G>,? extends T> decoder)
      Return a new fitness evaluator, which evaluates asynchronous fitness functions.
      Type Parameters:
      T - the native fitness domain type
      G - the gene type
      C - the fitness value type
      Parameters:
      fitness - the asynchronous fitness function, working on the native fitness domain
      decoder - the decoder function for the fitness domain
      Returns:
      a new (async) fitness evaluator
      Throws:
      NullPointerException - if one of the arguments is null
    • completable

      public static <T, G extends Gene<?, G>, C extends Comparable<? super C>> Evaluator<G,C> completable(Function<? super T,? extends CompletableFuture<C>> fitness, Codec<T,G> codec)
      Return a new fitness evaluator, which evaluates asynchronous fitness functions.
      Type Parameters:
      T - the native fitness domain type
      G - the gene type
      C - the fitness value type
      Parameters:
      fitness - the asynchronous fitness function, working on the native fitness domain
      codec - the codec used for transforming the fitness domain
      Returns:
      a new (async) fitness evaluator
      Throws:
      NullPointerException - if one of the arguments is null