Interface CandidateFactory<T>
-
- Type Parameters:
T
- The type of evolvable entity created by the factory.
- All Known Implementing Classes:
AbstractCandidateFactory
,BitStringFactory
,ListPermutationFactory
,ObjectArrayPermutationFactory
,StringFactory
public interface CandidateFactory<T>
Creates new populations of candidates. For most implementations it will be easiest just to extendAbstractCandidateFactory
and implement the method to generate a single random candidate.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.List<T>
generateInitialPopulation(int populationSize, Random rng)
Creates an initial population of candidates.T
generateRandomCandidate(Random rng)
Randomly create a single candidate solution.
-
-
-
Method Detail
-
generateInitialPopulation
List<T> generateInitialPopulation(int populationSize, Random rng)
Creates an initial population of candidates. If more control is required over the composition of the initial population, consider the overloadedgenerateInitialPopulation(int,Collection,Random)
method.- Parameters:
populationSize
- The number of candidates to create.rng
- The random number generator to use when creating the initial candidates.- Returns:
- An initial population of candidate solutions.
-
generateInitialPopulation
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.- 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.
-
-