Class AbstractCandidateFactory<T>

    • Constructor Detail

      • AbstractCandidateFactory

        public AbstractCandidateFactory()
    • Method Detail

      • generateInitialPopulation

        public List<T> generateInitialPopulation​(int populationSize,
                                                 Random rng)
        Randomly, create an initial population of candidates. If some control is required over the composition of the initial population, consider the overloaded generateInitialPopulation(int,Collection,Random) method.
        Specified by:
        generateInitialPopulation in interface CandidateFactory<T>
        Parameters:
        populationSize - The number of candidates to randomly create.
        rng - The random number generator to use when creating the random candidates.
        Returns:
        A randomly generated initial population of candidate solutions.
      • generateInitialPopulation

        public List<T> generateInitialPopulation​(int populationSize,
                                                 Collection<T> seedCandidates,
                                                 Random rng)
        Sometimes it is desirable to seed the initial population with some known good candidates, or partial solutions, in order to provide some hints for the evolution process. This method generates an initial population, seeded with some initial candidates. If the number of seed candidates is less than the required population size, the factory should generate additional candidates to fill the remaining spaces in the population. If the number of seed candidates is less than the required population size, the remainder of the population will be generated randomly via the CandidateFactory.generateRandomCandidate(Random) method.
        Specified by:
        generateInitialPopulation in interface CandidateFactory<T>
        Parameters:
        populationSize - The size of the initial population.
        seedCandidates - Candidates to seed the population with. Number of candidates must be no bigger than the population size.
        rng - The random number generator to use when creating additional candidates to fill the population when the number of seed candidates is insufficient. This can be null if and only if the number of seed candidates provided is sufficient to fully populate the initial population.
        Returns:
        An initial population of candidate solutions, including the specified seed candidates.