@@ -0,0 +1,2054 @@
+/*%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.engine;%0A%0Aimport java.util.concurrent.CompletableFuture;%0Aimport java.util.concurrent.Future;%0A%0Aimport org.testng.Assert;%0Aimport org.testng.annotations.Test;%0A%0Aimport io.jenetics.DoubleChromosome;%0Aimport io.jenetics.DoubleGene;%0Aimport io.jenetics.Genotype;%0Aimport io.jenetics.Phenotype;%0Aimport io.jenetics.util.ISeq;%0A%0A/**%0A * @author %3Ca href=%22mailto:franz.wilhelmstoetter@gmail.com%22%3EFranz Wilhelmst%C3%B6tter%3C/a%3E%0A */%0Apublic class FutureEvaluatorTest %7B%0A%0A%09static Future%3CDouble%3E eval(final Genotype%3CDoubleGene%3E gt) %7B%0A%09%09return CompletableFuture.completedFuture(gt.getGene().doubleValue());%0A%09%7D%0A%0A%09@Test%0A%09public void evaluate() %7B%0A%09%09final Genotype%3CDoubleGene%3E gtf = Genotype.of(DoubleChromosome.of(0, 1));%0A%09%09final ISeq%3CPhenotype%3CDoubleGene, Double%3E%3E population = gtf.instances()%0A%09%09%09.limit(100)%0A%09%09%09.map(gt -%3E Phenotype.%3CDoubleGene, Double%3Eof(gt, 1))%0A%09%09%09.collect(ISeq.toISeq());%0A%0A%09%09population.forEach(pt -%3E Assert.assertTrue(pt.nonEvaluated()));%0A%0A%09%09final Evaluator%3CDoubleGene, Double%3E evaluator = Evaluator.async(FutureEvaluatorTest::eval);%0A%09%09final ISeq%3CPhenotype%3CDoubleGene, Double%3E%3E evaluated = evaluator.evaluate(population);%0A%0A%09%09evaluated.forEach(pt -%3E Assert.assertTrue(pt.isEvaluated()));%0A%09%09evaluated.forEach(pt -%3E%0A%09%09%09Assert.assertEquals(pt.getGenotype().getGene().doubleValue(), pt.getFitness()));%0A%09%7D%0A%0A%7D%0A

Add 'FutureEvaluatorTest' class.