Example #1
0
  /**
   * Create a new <b>infinite</b> evolution stream with the given initial individuals. If an empty
   * {@code Iterable} is given, the engines genotype factory is used for creating the population.
   *
   * @param genotypes the initial individuals used for the evolution stream. Missing individuals are
   *     created and individuals not needed are skipped.
   * @return a new evolution stream.
   * @throws java.lang.NullPointerException if the given {@code genotypes} is {@code null}.
   */
  public EvolutionStream<G, C> stream(final Iterable<Genotype<G>> genotypes) {
    requireNonNull(genotypes);

    return EvolutionStream.of(() -> evolutionStart(genotypes, 1), this::evolve);
  }
Example #2
0
  /**
   * Create a new <b>infinite</b> evolution stream with the given initial population. If an empty
   * {@code Population} is given, the engines genotype factory is used for creating the population.
   * The given population might be the result of an other engine and this method allows to start the
   * evolution with the outcome of an different engine. The fitness function and the fitness scaler
   * are replaced by the one defined for this engine.
   *
   * @param population the initial individuals used for the evolution stream. Missing individuals
   *     are created and individuals not needed are skipped.
   * @param generation the generation the stream starts from; must be greater than zero.
   * @return a new evolution stream.
   * @throws java.lang.NullPointerException if the given {@code population} is {@code null}.
   * @throws IllegalArgumentException if the given {@code generation} is smaller then one
   */
  public EvolutionStream<G, C> stream(final Population<G, C> population, final long generation) {
    requireNonNull(population);
    require.positive(generation);

    return EvolutionStream.of(() -> evolutionStart(population, generation), this::evolve);
  }
Example #3
0
 /**
  * Create a new <b>infinite</b> evolution stream with a newly created population.
  *
  * @return a new evolution stream.
  */
 public EvolutionStream<G, C> stream() {
   return EvolutionStream.of(this::evolutionStart, this::evolve);
 }