Class StringFactory
- java.lang.Object
-
- org.uncommons.watchmaker.framework.factories.AbstractCandidateFactory<String>
-
- org.uncommons.watchmaker.framework.factories.StringFactory
-
- All Implemented Interfaces:
CandidateFactory<String>
public class StringFactory extends AbstractCandidateFactory<String>
General-purpose candidate factory for EAs that use a fixed-length String encoding. Generates random strings of a fixed length from a given alphabet.
-
-
Constructor Summary
Constructors Constructor Description StringFactory(char[] alphabet, int stringLength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
generateRandomCandidate(Random rng)
Generates a random string of a pre-configured length.-
Methods inherited from class org.uncommons.watchmaker.framework.factories.AbstractCandidateFactory
generateInitialPopulation, generateInitialPopulation
-
-
-
-
Method Detail
-
generateRandomCandidate
public String generateRandomCandidate(Random rng)
Generates a random string of a pre-configured length. Each character is randomly selected from the pre-configured alphabet. The same character may appear multiple times and some characters may not appear at all.- Parameters:
rng
- A source of randomness used to select characters to make up the string.- Returns:
- A randomly generated string.
-
-