Interface EvolutionStreamable<G extends Gene<?,​G>,​C extends Comparable<? super C>>

    • Method Detail

      • stream

        EvolutionStream<G,​Cstream​(Supplier<EvolutionStart<G,​C>> start)
        Create a new, possibly infinite, evolution stream with the given evolution start. If an empty 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.
        Parameters:
        start - the data the evolution stream starts with
        Returns:
        a new infinite evolution stream
        Throws:
        NullPointerException - if the given evolution start is null.
      • stream

        EvolutionStream<G,​Cstream​(EvolutionInit<G> init)
        Create a new, possibly infinite, evolution stream with the given initial value. If an empty 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.
        Parameters:
        init - the data the evolution stream is initialized with
        Returns:
        a new infinite evolution stream
        Throws:
        NullPointerException - if the given evolution start is null.
      • stream

        default EvolutionStream<G,​Cstream()
        Create a new, possibly infinite, evolution stream with a newly created population. This method is a shortcut for
        final EvolutionStream<G, C> stream = streamable .stream(() -> EvolutionStart.of(ISeq.empty(), 1));
        Returns:
        a new evolution stream.
      • stream

        default EvolutionStream<G,​Cstream​(EvolutionStart<G,​C> start)
        Create a new, possibly infinite, evolution stream with the given evolution start. If an empty 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.
        Parameters:
        start - the data the evolution stream starts with
        Returns:
        a new infinite evolution iterator
        Throws:
        NullPointerException - if the given evolution start is null.
      • stream

        default EvolutionStream<G,​Cstream​(EvolutionResult<G,​C> result)
        Create a new EvolutionStream starting with a previously evolved EvolutionResult. The stream is initialized with the population of the given result and its total generation EvolutionResult.totalGenerations().
        private static final Problem<Double, DoubleGene, Double> PROBLEM = Problem.of( x -> cos(0.5 + sin(x))*cos(x), Codecs.ofScalar(DoubleRange.of(0.0, 2.0*PI)) ); private static final Engine<DoubleGene, Double> ENGINE = Engine.builder(PROBLEM) .optimize(Optimize.MINIMUM) .offspringSelector(new RouletteWheelSelector<>()) .build(); public static void main(final String[] args) throws IOException { // Result of the first evolution run. final EvolutionResult<DoubleGene, Double> rescue = ENGINE.stream() .limit(Limits.bySteadyFitness(10)) .collect(EvolutionResult.toBestEvolutionResult()); // Save the result of the first run into a file. final Path path = Paths.get("result.bin"); IO.object.write(rescue, path); // Load the previous result and continue evolution. @SuppressWarnings("unchecked") final EvolutionResult<DoubleGene, Double> result = ENGINE .stream((EvolutionResult<DoubleGene, Double>)IO.object.read(path)) .limit(Limits.bySteadyFitness(20)) .collect(EvolutionResult.toBestEvolutionResult()); System.out.println(result.bestPhenotype()); }
        The example above shows how to save an EvolutionResult from a first run, save it to disk and continue the evolution.
        Parameters:
        result - the previously evolved EvolutionResult
        Returns:
        a new evolution stream, which continues a previous one
        Throws:
        NullPointerException - if the given evolution result is null
      • stream

        default EvolutionStream<G,​Cstream​(ISeq<Phenotype<G,​C>> population,
                                                  long generation)
        Create a new, possibly infinite, evolution stream with the given initial population. If an empty 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.
        Parameters:
        population - the initial individuals used for the evolution stream. Missing individuals are created and individuals not needed are skipped.
        generation - the generation the stream starts from; must be greater than zero.
        Returns:
        a new evolution stream.
        Throws:
        NullPointerException - if the given population is null.
        IllegalArgumentException - if the given generation is smaller then one
      • stream

        default EvolutionStream<G,​Cstream​(ISeq<Phenotype<G,​C>> population)
        Create a new, possibly infinite, evolution stream with the given initial population. If an empty 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.
        Parameters:
        population - the initial individuals used for the evolution stream. Missing individuals are created and individuals not needed are skipped.
        Returns:
        a new evolution stream.
        Throws:
        NullPointerException - if the given population is null.
      • stream

        default EvolutionStream<G,​Cstream​(Iterable<Genotype<G>> genotypes,
                                                  long generation)
        Create a new, possibly infinite, evolution stream with the given initial individuals. If an empty Iterable is given, the engines genotype factory is used for creating the population.
        Parameters:
        genotypes - the initial individuals used for the evolution stream. Missing individuals are created and individuals not needed are skipped.
        generation - the generation the stream starts from; must be greater than zero.
        Returns:
        a new evolution stream.
        Throws:
        NullPointerException - if the given genotypes is null.
        IllegalArgumentException - if the given generation is smaller then one
      • stream

        default EvolutionStream<G,​Cstream​(Iterable<Genotype<G>> genotypes)
        Create a new, possibly infinite, evolution stream with the given initial individuals. If an empty Iterable is given, the engines genotype factory is used for creating the population.
        Parameters:
        genotypes - the initial individuals used for the evolution stream. Missing individuals are created and individuals not needed are skipped.
        Returns:
        a new evolution stream.
        Throws:
        NullPointerException - if the given genotypes is null.
      • limit

        default EvolutionStreamable<G,​Climit​(Supplier<? extends Predicate<? super EvolutionResult<G,​C>>> proceed)
        Return a new EvolutionStreamable instance where all created EvolutionStreams are limited by the given predicate. Since some predicates has to maintain internal state, a predicate Supplier must be given instead a plain limiting predicate.
        Parameters:
        proceed - the limiting predicate supplier.
        Returns:
        a new evolution streamable object
        Throws:
        NullPointerException - if the give predicate is null
      • limit

        default EvolutionStreamable<G,​Climit​(long generations)
        Return a new EvolutionStreamable instance where all created EvolutionStreams are limited to the given number of generations.
        Parameters:
        generations - the number of generations after the created evolution streams are truncated
        Returns:
        a new evolution streamable object
        Throws:
        IllegalArgumentException - if the given generations is smaller than zero.