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) Composesthisinterceptor with theotherone.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 givenbeforeandafterfunctions.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 givenafterfunction.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 givenbeforefunction.
-
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 evolutionstartobject 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 evolutionresultobject isnull
-
compose
Composesthisinterceptor with theotherone. Thebefore(EvolutionStart)ofthisinterceptor is called after thebeforemethod of theotherinterceptor. And theafter(EvolutionResult)ofthisinterceptor is called before theaftermethod of theotherinterceptor.- Parameters:
other- the other, composing interceptor- Returns:
- a new, composed interceptor
- Throws:
NullPointerException- if theotherinterceptor 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 givenbeforeandafterfunctions.- 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 givenbeforefunction.- 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 givenafterfunction.- 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
-