Class GeneticAlgorithmBuilder<H>

    • Field Detail

      • CROSS_OVER_RATE_DEFAULT

        public static final double CROSS_OVER_RATE_DEFAULT
        The default cross-over rate (0.3).
        See Also:
        Constant Field Values
      • MUTATION_RATE_DEFAULT

        public static final double MUTATION_RATE_DEFAULT
        The default mutation-rate (0.05).
        See Also:
        Constant Field Values
      • GENERATION_SIZE_DEFAULT

        public static final int GENERATION_SIZE_DEFAULT
        The default generation size (100).
        See Also:
        Constant Field Values
    • Constructor Detail

      • GeneticAlgorithmBuilder

        public GeneticAlgorithmBuilder​(@NonNull
                                       @NonNull AlgorithmDefinition<H> inAlgorithmDefinition)
        Creates a new builder.
        Parameters:
        inAlgorithmDefinition - the non-null algorithm definition to generate a genetic algorithm with.
    • Method Detail

      • withCrossOverRate

        public GeneticAlgorithmBuilder<H> withCrossOverRate​(double inRate)
        Defines the cross-over rate to use.
        Parameters:
        inRate - the cross-over rate between 0 and 1.
        Returns:
        this instance.
        Throws:
        IllegalArgumentException - if the valid parameter range is exceeded.
      • withRandom

        public GeneticAlgorithmBuilder<H> withRandom​(@NonNull
                                                     @NonNull Random inRandom)
        Defines the random generator to use.
        Parameters:
        inRandom - the random generator to use.
        Returns:
        this instance.
        Throws:
        IllegalArgumentException - if the valid parameter range is exceeded.
      • withExecutorService

        public GeneticAlgorithmBuilder<H> withExecutorService​(@NonNull
                                                              @NonNull ExecutorService inExecutorService)
        Defines the executor service to use.
        Parameters:
        inExecutorService - the executor service.
        Returns:
        this instance.
        Throws:
        NullPointerException - if the input reference is null.
      • withMutationRate

        public GeneticAlgorithmBuilder<H> withMutationRate​(double rate)
        Defines the mutation rate to use.
        Parameters:
        rate - the mutation rate between 0 and 1.
        Returns:
        this instance.
        Throws:
        IllegalArgumentException - if the valid parameter range is exceeded.
      • withGenerationSize

        public GeneticAlgorithmBuilder<H> withGenerationSize​(int size)
        Defines the generation size to use.
        Parameters:
        size - the generation size greater or equal to 2.
        Returns:
        this instance.
        Throws:
        IllegalArgumentException - if the valid parameter range is exceeded.