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 to update theEvolutionStart
object, before the evolution start, and update theEvolutionResult
object after the evolution.- Since:
- 6.0
- Version:
- 6.0
- See Also:
EvolutionResult.toUniquePopulation()
,Engine.Builder.interceptor(EvolutionInterceptor)
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default 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 Detail
-
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 evolutionstart
object isnull
-
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 evolutionresult
object isnull
-
compose
default EvolutionInterceptor<G,C> compose(EvolutionInterceptor<G,C> other)
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>,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.- 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>,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.- 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>,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.- 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
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 typeC
- the fitness result type- Returns:
- a new identity interceptor
-
-