@@ -0,0 +1,2097 @@
+/*%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 static io.jenetics.engine.EvolutionResult.toBestPhenotype;%0Aimport static io.jenetics.engine.Limits.bySteadyFitness;%0A%0Aimport io.jenetics.BitChromosome;%0Aimport io.jenetics.BitGene;%0Aimport io.jenetics.Genotype;%0Aimport io.jenetics.Phenotype;%0Aimport io.jenetics.engine.Engine;%0Aimport io.jenetics.engine.EvolutionResult;%0Aimport io.jenetics.engine.EvolutionStatistics;%0A%0A/**%0A * @author %3Ca href=%22mailto:franz.wilhelmstoetter@gmail.com%22%3EFranz Wilhelmst%C3%B6tter%3C/a%3E%0A */%0Apublic class UniquePopulation %7B%0A%0A%09// This method calculates the fitness for a given genotype.%0A%09private static Integer count(final Genotype%3CBitGene%3E gt) %7B%0A%09%09return gt.getChromosome()%0A%09%09%09.as(BitChromosome.class)%0A%09%09%09.bitCount();%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09final Engine%3CBitGene, Integer%3E engine = Engine%0A%09%09%09.builder(%0A%09%09%09%09UniquePopulation::count,%0A%09%09%09%09BitChromosome.of(20, 0.15))%0A%09%09%09// Remove duplicate individuals after each generation.%0A%09%09%09.mapping(EvolutionResult.toUniquePopulation())%0A%09%09%09.build();%0A%0A%09%09// Create evolution statistics consumer.%0A%09%09final EvolutionStatistics%3CInteger, ?%3E%0A%09%09%09statistics = EvolutionStatistics.ofNumber();%0A%0A%09%09final Phenotype%3CBitGene, Integer%3E best = engine.stream()%0A%09%09%09.limit(bySteadyFitness(7))%0A%09%09%09.peek(statistics)%0A%09%09%09.collect(toBestPhenotype());%0A%0A%09%09System.out.println(statistics);%0A%09%09System.out.println(best);%0A%09%7D%0A%0A%7D%0A

Add 'UniquePopulation' example.