statistics = EvolutionStatistics.ofNumber();
public static void main(final String[] args) { RandomRegistry.setRandom(new Random()); final Engine<EnumGene<Integer>, Integer> engine = Engine .builder( Sorting::length, PermutationChromosome.ofInteger(20)) .optimize(Optimize.MINIMUM) .populationSize(1000) //.survivorsSelector(new RouletteWheelSelector<>()) //.offspringSelector(new TruncationSelector<>()) .offspringFraction(0.9) .alterers( new SwapMutator<>(0.01), new PartiallyMatchedCrossover<>(0.3)) .build(); final EvolutionStatistics<Integer, DoubleMomentStatistics> statistics = EvolutionStatistics.ofNumber(); final EvolutionResult<EnumGene<Integer>, Integer> result = engine.stream() .limit(Limits.bySteadyFitness(100)) .limit(2500) .peek(statistics) .collect(EvolutionResult.toBestEvolutionResult()); System.out.println(statistics); System.out.println(result.getBestPhenotype()); }
public static void main(final String[] args) { final Engine<DoubleGene, Double> engine = Engine .builder( RastriginFunction::fitness, // Codec for 'x' vector. Codecs.ofVector(DoubleRange.of(-R, R), N)) .populationSize(500) .optimize(Optimize.MINIMUM) .alterers( new Mutator<>(0.03), new MeanAlterer<>(0.6)) .build(); final EvolutionStatistics<Double, ?> statistics = EvolutionStatistics.ofNumber(); final Phenotype<DoubleGene, Double> best = engine.stream() .limit(bySteadyFitness(7)) .peek(statistics) .collect(toBestPhenotype()); System.out.println(statistics); System.out.println(best); } }
public static void main(final String[] args) { final Knapsack knapsack = Knapsack.of(15, new Random(123)); // Configure and build the evolution engine. final Engine<BitGene, Double> engine = Engine.builder(knapsack) .populationSize(500) .survivorsSelector(new TournamentSelector<>(5)) .offspringSelector(new RouletteWheelSelector<>()) .alterers( new Mutator<>(0.115), new SinglePointCrossover<>(0.16)) .build(); // Create evolution statistics consumer. final EvolutionStatistics<Double, ?> statistics = EvolutionStatistics.ofNumber(); final Phenotype<BitGene, Double> best = engine.stream() // Truncate the evolution stream after 7 "steady" // generations. .limit(bySteadyFitness(7)) // The evolution will stop after maximal 100 // generations. .limit(100) // Update the evaluation statistics after // each generation .peek(statistics) // Collect (reduce) the evolution stream to // its best phenotype. .collect(toBestPhenotype()); System.out.println(statistics); System.out.println(best); }
statistics = EvolutionStatistics.ofNumber();
statistics = EvolutionStatistics.ofNumber();
statistics = EvolutionStatistics.ofNumber();
statistics = EvolutionStatistics.ofNumber();