public final class limit extends Object
EvolutionStream.limit(Predicate)| Modifier and Type | Method and Description |
|---|---|
static Predicate<Object> |
byExecutionTime(Duration duration)
Return a predicate, which will truncate the evolution stream if the GA
execution exceeds a given time duration.
|
static Predicate<Object> |
byExecutionTime(Duration duration,
Clock clock)
Return a predicate, which will truncate the evolution stream if the GA
execution exceeds a given time duration.
|
static <C extends Comparable<? super C>> |
byFitnessThreshold(C threshold)
Return a predicate, which will truncated the evolution stream if the
best fitness of the current population becomes less than the specified
threshold and the objective is set to minimize the fitness.
|
static Predicate<Object> |
byFixedGeneration(long generation)
Return a predicate, which will truncate the evolution stream after the
given number of generations.
|
static <C extends Comparable<? super C>> |
bySteadyFitness(int generations)
Return a predicate, which will truncate the evolution stream if no
better phenotype could be found after the given number of
generations. |
public static Predicate<Object> byFixedGeneration(long generation)
Stream.limit(long) and exists for
completeness reasons.generation - the number of generations after the evolution stream is
truncatedIllegalArgumentException - if the given generation
is smaller than zero.public static <C extends Comparable<? super C>> Predicate<EvolutionResult<?,C>> bySteadyFitness(int generations)
generations.
final Phenotype<DoubleGene, Double> result = engine.stream()
// Truncate the evolution stream after 5 "steady" generations.
.limit(bySteadyFitness(5))
// The evolution will stop after maximal 100 generations.
.limit(100)
.collect(toBestPhenotype());C - the fitness typegenerations - the number of steady generationsgenerationsIllegalArgumentException - if the generation is smaller than
one.public static Predicate<Object> byExecutionTime(Duration duration, Clock clock)
final Phenotype<DoubleGene, Double> result = engine.stream()
// Truncate the evolution stream after 5 "steady" generations.
.limit(bySteadyFitness(5))
// The evolution will stop after maximal 500 ms.
.limit(byExecutionTime(Duration.ofMillis(500), Clock.systemUTC())
.collect(toBestPhenotype());duration - the duration after the evolution stream will be truncatedclock - the clock used for measure the execution timeNullPointerException - if one of the arguments is nullpublic static Predicate<Object> byExecutionTime(Duration duration)
final Phenotype<DoubleGene, Double> result = engine.stream()
// Truncate the evolution stream after 5 "steady" generations.
.limit(bySteadyFitness(5))
// The evolution will stop after maximal 500 ms.
.limit(byExecutionTime(Duration.ofMillis(500))
.collect(toBestPhenotype());duration - the duration after the evolution stream will be truncatedNullPointerException - if the evolution duration is
nullpublic static <C extends Comparable<? super C>> Predicate<EvolutionResult<?,C>> byFitnessThreshold(C threshold)
final Phenotype<DoubleGene, Double> result = engine.stream()
// Truncate the evolution stream if the best fitness is higher than
// the given threshold of '2.3'.
.limit(byFitnessThreshold(2.3))
// The evolution will stop after maximal 250 generations; guarantees
// the termination (truncation) of the evolution stream.
.limit(250)
.collect(toBestPhenotype());C - the fitness typethreshold - the desired thresholdthreshold.NullPointerException - if the given threshold is
null.© 2007-2016 Franz Wilhelmstötter (2016-04-24 10:25)