Interface EvolutionInterceptor<G extends Gene<?,G>,C extends Comparable<? super C>>

Type Parameters:
G - the gene type
C - the fitness result type
All Known Implementing Classes:
FitnessNullifier

public interface EvolutionInterceptor<G extends Gene<?,G>,C extends Comparable<? super C>>
The evolution interceptor allows updating the EvolutionStart object, before the evolution start, and update the EvolutionResult object after the evolution.
Since:
6.0
Version:
6.0
See Also:
  • Method Details

    • before

      default EvolutionStart<G,C> before(EvolutionStart<G,C> start)
      This method is called right before the evaluation of a generation is started.
      Parameters:
      start - the evolution start object
      Returns:
      the possible update evolution start object
      Throws:
      NullPointerException - if the evolution start object is null
    • after

      default EvolutionResult<G,C> after(EvolutionResult<G,C> result)
      This method is called after the evaluation of a generation. If this method alters the evolution result object, the population within this result object is re-evaluated.
      Parameters:
      result - the evolution result object to update
      Returns:
      the possible updated evolution result object
      Throws:
      NullPointerException - if the evolution result object is null
    • compose

      Composes this interceptor with the other one. The before(EvolutionStart) of this interceptor is called after the before method of the other interceptor. And the after(EvolutionResult) of this interceptor is called before the after method of the other interceptor.
      Parameters:
      other - the other, composing interceptor
      Returns:
      a new, composed interceptor
      Throws:
      NullPointerException - if the other interceptor is null
    • of

      static <G extends Gene<?, G>, C extends Comparable<? super C>> EvolutionInterceptor<G,C> of(Function<? super EvolutionStart<G,C>,EvolutionStart<G,C>> before, Function<? super EvolutionResult<G,C>,EvolutionResult<G,C>> after)
      Create a new interceptor instance with the given before and after functions.
      Type Parameters:
      G - the gene type
      C - the fitness result type
      Parameters:
      before - the function executed before each evolution step
      after - the function executed after each evolution step
      Returns:
      a new interceptor instance with the given interceptor functions
      Throws:
      NullPointerException - if one of the functions is null
    • ofBefore

      static <G extends Gene<?, G>, C extends Comparable<? super C>> EvolutionInterceptor<G,C> ofBefore(Function<? super EvolutionStart<G,C>,EvolutionStart<G,C>> before)
      Create a new interceptor instance with the given before function.
      Type Parameters:
      G - the gene type
      C - the fitness result type
      Parameters:
      before - the function executed before each evolution step
      Returns:
      a new interceptor instance with the given interceptor function
      Throws:
      NullPointerException - if the function is null
    • ofAfter

      static <G extends Gene<?, G>, C extends Comparable<? super C>> EvolutionInterceptor<G,C> ofAfter(Function<? super EvolutionResult<G,C>,EvolutionResult<G,C>> after)
      Create a new interceptor instance with the given after function.
      Type Parameters:
      G - the gene type
      C - the fitness result type
      Parameters:
      after - the function executed after each evolution step
      Returns:
      a new interceptor instance with the given interceptor function
      Throws:
      NullPointerException - if the function is null
    • identity

      static <G extends Gene<?, G>, C extends Comparable<? super C>> EvolutionInterceptor<G,C> identity()
      Return an interceptor object which does nothing.
      Type Parameters:
      G - the gene type
      C - the fitness result type
      Returns:
      a new identity interceptor