Module io.jenetics.base
Package io.jenetics.engine
Interface EvolutionInterceptor<G extends Gene<?,G>,C extends Comparable<? super C>>
- Type Parameters:
G
- the gene typeC
- 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 Summary
Modifier and TypeMethodDescriptiondefault EvolutionResult
<G, C> after
(EvolutionResult<G, C> result) This method is called after the evaluation of a generation.default EvolutionStart
<G, C> before
(EvolutionStart<G, C> start) This method is called right before the evaluation of a generation is started.default EvolutionInterceptor
<G, C> compose
(EvolutionInterceptor<G, C> other) Composesthis
interceptor with theother
one.static <G extends Gene<?,
G>, C extends Comparable<? super C>>
EvolutionInterceptor<G, C> identity()
Return an interceptor object which does nothing.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 givenbefore
andafter
functions.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 givenafter
function.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 givenbefore
function.
-
Method Details
-
before
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 evolutionstart
object isnull
-
after
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 evolutionresult
object isnull
-
compose
Composesthis
interceptor with theother
one. Thebefore(EvolutionStart)
ofthis
interceptor is called after thebefore
method of theother
interceptor. And theafter(EvolutionResult)
ofthis
interceptor is called before theafter
method of theother
interceptor.- Parameters:
other
- the other, composing interceptor- Returns:
- a new, composed interceptor
- Throws:
NullPointerException
- if theother
interceptor isnull
-
of
static <G extends Gene<?,G>, EvolutionInterceptor<G,C extends Comparable<? super C>> 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 givenbefore
andafter
functions.- Type Parameters:
G
- the gene typeC
- the fitness result type- Parameters:
before
- the function executed before each evolution stepafter
- the function executed after each evolution step- Returns:
- a new interceptor instance with the given interceptor functions
- Throws:
NullPointerException
- if one of the functions isnull
-
ofBefore
static <G extends Gene<?,G>, EvolutionInterceptor<G,C extends Comparable<? super C>> C> ofBefore(Function<? super EvolutionStart<G, C>, EvolutionStart<G, C>> before) Create a new interceptor instance with the givenbefore
function.- Type Parameters:
G
- the gene typeC
- 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 isnull
-
ofAfter
static <G extends Gene<?,G>, EvolutionInterceptor<G,C extends Comparable<? super C>> C> ofAfter(Function<? super EvolutionResult<G, C>, EvolutionResult<G, C>> after) Create a new interceptor instance with the givenafter
function.- Type Parameters:
G
- the gene typeC
- 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 isnull
-
identity
Return an interceptor object which does nothing.- Type Parameters:
G
- the gene typeC
- the fitness result type- Returns:
- a new identity interceptor
-