Class AbstractCandidateFactory<T>
- java.lang.Object
-
- org.uncommons.watchmaker.framework.factories.AbstractCandidateFactory<T>
-
- Type Parameters:
T
- The type of entity evolved by this engine.
- All Implemented Interfaces:
CandidateFactory<T>
- Direct Known Subclasses:
BitStringFactory
,ListPermutationFactory
,ObjectArrayPermutationFactory
,StringFactory
public abstract class AbstractCandidateFactory<T> extends Object implements CandidateFactory<T>
Convenient base class for implementations ofCandidateFactory
.
-
-
Constructor Summary
Constructors Constructor Description AbstractCandidateFactory()
-
Method Summary
All Methods Instance Methods Concrete 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)
Randomly, create an initial population of candidates.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.uncommons.watchmaker.framework.CandidateFactory
generateRandomCandidate
-
-
-
-
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 overloadedgenerateInitialPopulation(int,Collection,Random)
method.- Specified by:
generateInitialPopulation
in interfaceCandidateFactory<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 theCandidateFactory.generateRandomCandidate(Random)
method.- Specified by:
generateInitialPopulation
in interfaceCandidateFactory<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.
-
-