Class EvolutionStreamImpl<G extends Gene<?,G>,C extends Comparable<? super C>>

java.lang.Object
io.jenetics.internal.util.StreamProxy<EvolutionResult<G,C>>
io.jenetics.internal.engine.EvolutionStreamImpl<G,C>
All Implemented Interfaces:
EvolutionStream<G,C>, AutoCloseable, BaseStream<EvolutionResult<G,C>,Stream<EvolutionResult<G,C>>>, Stream<EvolutionResult<G,C>>

public final class EvolutionStreamImpl<G extends Gene<?,G>,C extends Comparable<? super C>> extends StreamProxy<EvolutionResult<G,C>> implements EvolutionStream<G,C>
Since:
3.0
Version:
5.1
  • Constructor Details

  • Method Details

    • limit

      public EvolutionStream<G,C> limit(Predicate<? super EvolutionResult<G,C>> proceed)
      Description copied from interface: EvolutionStream
      Returns a stream consisting of the elements of this stream, truncated when the given proceed predicate returns false.

      General usage example:

      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());
      Note: The evolution result may be null, if your truncation predicate returns false for the initial population.
      final EvolutionResult<DoubleGene, Double> result = engine.stream() .limit(er -> false) .collect(toBestEvolutionResult()); assert result == null;
      Specified by:
      limit in interface EvolutionStream<G extends Gene<?,G>,C extends Comparable<? super C>>
      Parameters:
      proceed - the predicate which determines whether the stream is truncated or not. If the predicate returns false, the evolution stream is truncated.
      Returns:
      the new stream
      See Also:
    • of

      public static <G extends Gene<?, G>, C extends Comparable<? super C>> EvolutionStreamImpl<G,C> of(Supplier<EvolutionStart<G,C>> start, Function<? super EvolutionStart<G,C>,? extends Evolution<G,C>> evolution)