@@ -0,0 +1,2206 @@
+/*%0A * Java Genetic Algorithm Library (@__identifier__@).%0A * Copyright (c) @__year__@ Franz Wilhelmst%C3%B6tter%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A *%0A * Author:%0A *    Franz Wilhelmst%C3%B6tter (franz.wilhelmstoetter@gmail.com)%0A */%0Apackage io.jenetics.example;%0A%0Aimport java.util.Random;%0Aimport java.util.function.Function;%0A%0Aimport io.jenetics.DoubleGene;%0Aimport io.jenetics.Genotype;%0Aimport io.jenetics.engine.Codec;%0Aimport io.jenetics.engine.Codecs;%0Aimport io.jenetics.engine.Engine;%0Aimport io.jenetics.engine.EvolutionResult;%0Aimport io.jenetics.util.DoubleRange;%0Aimport io.jenetics.util.ISeq;%0Aimport io.jenetics.util.RandomRegistry;%0A%0A/**%0A * This GA produces the same results on every run. The %7B@code RandomRegistry.with%7D%0A * block allows you to %3Cem%3Einject%3C/em%3E a random engine with the same start state%0A * at every call.%0A *%0A * @author %3Ca href=%22mailto:franz.wilhelmstoetter@gmail.com%22%3EFranz Wilhelmst%C3%B6tter%3C/a%3E%0A * @version 4.3%0A * @since 4.3%0A */%0Apublic class ReproducibleGA %7B%0A%0A%09private static final Codec%3CDouble, DoubleGene%3E%0A%09CODEC = Codecs.ofScalar(DoubleRange.of(0, 1));%0A%0A%09public static void main(final String%5B%5D args) %7B%0A%09%09final ISeq%3CGenotype%3CDoubleGene%3E%3E population =%0A%09%09%09RandomRegistry.with(new Random(123), r -%3E%0A%09%09%09%09CODEC.encoding().instances()%0A%09%09%09%09%09.limit(10)%0A%09%09%09%09%09.collect(ISeq.toISeq())%0A%09%09%09);%0A%0A%09%09final Engine%3CDoubleGene, Double%3E engine =%0A%09%09%09Engine.builder(Function.identity(), CODEC)%0A%09%09%09%09.executor(Runnable::run)%0A%09%09%09%09.build();%0A%0A%09%09final EvolutionResult%3CDoubleGene, Double%3E result =%0A%09%09%09RandomRegistry.with(new Random(456), r -%3E%0A%09%09%09%09engine.stream(population)%0A%09%09%09%09%09.limit(100)%0A%09%09%09%09%09.collect(EvolutionResult.toBestEvolutionResult())%0A%09%09%09);%0A%0A%09%09System.out.println(result.getBestPhenotype());%0A%09%7D%0A%0A%7D%0A

Add example for reproducible GA.