/** * Create a new evolution {@code Engine.Builder} with the given fitness * function and chromosome templates. * * @param ff the fitness function * @param chromosome the first chromosome * @param chromosomes the chromosome templates * @param <G> the gene type * @param <C> the fitness function result type * @return a new engine builder * @throws java.lang.NullPointerException if one of the arguments is * {@code null}. */ @SafeVarargs public static <G extends Gene<?, G>, C extends Comparable<? super C>> Builder<G, C> builder( final Function<? super Genotype<G>, ? extends C> ff, final Chromosome<G> chromosome, final Chromosome<G>... chromosomes ) { return new Builder<>(Genotype.of(chromosome, chromosomes), ff); }
/** * Create a new evolution {@code Engine.Builder} initialized with the values * of the current evolution {@code Engine}. With this method, the evolution * engine can serve as a template for a new one. * * @return a new engine builder */ public Builder<G, C> builder() { return new Builder<G, C>(_genotypeFactory, _fitnessFunction) .alterers(_alterer) .clock(_clock) .evaluator(_evaluator) .executor(_executor.get()) .fitnessScaler(_fitnessScaler) .maximalPhenotypeAge(_maximalPhenotypeAge) .offspringFraction((double)_offspringCount/(double)getPopulationSize()) .offspringSelector(_offspringSelector) .optimize(_optimize) .phenotypeValidator(_validator) .populationSize(getPopulationSize()) .survivorsSelector(_survivorsSelector) .individualCreationRetries(_individualCreationRetries) .mapping(_mapper); }
/** * Create a new builder, with the current configuration. * * @since 3.1 * * @return a new builder, with the current configuration */ @Override public Builder<G, C> copy() { return new Builder<G, C>(_genotypeFactory, _fitnessFunction) .alterers(_alterer) .clock(_clock) .executor(_executor) .evaluator(_evaluator) .fitnessScaler(_fitnessScaler) .maximalPhenotypeAge(_maximalPhenotypeAge) .offspringFraction(_offspringFraction) .offspringSelector(_offspringSelector) .phenotypeValidator(_validator) .optimize(_optimize) .populationSize(_populationSize) .survivorsSelector(_survivorsSelector) .individualCreationRetries(_individualCreationRetries) .mapping(_mapper); }
/** * Create a new evolution {@code Engine.Builder} with the given fitness * function and genotype factory. * * @param ff the fitness function * @param genotypeFactory the genotype factory * @param <G> the gene type * @param <C> the fitness function result type * @return a new engine builder * @throws java.lang.NullPointerException if one of the arguments is * {@code null}. */ public static <G extends Gene<?, G>, C extends Comparable<? super C>> Builder<G, C> builder( final Function<? super Genotype<G>, ? extends C> ff, final Factory<Genotype<G>> genotypeFactory ) { return new Builder<>(genotypeFactory, ff); }