Watchmaker Framework for Evolutionary Computation API
(Version 0.7.1)

Class StringFactory

  extended by org.uncommons.watchmaker.framework.factories.AbstractCandidateFactory<String>
      extended by org.uncommons.watchmaker.framework.factories.StringFactory
All Implemented Interfaces:

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.

Daniel Dyer

Constructor Summary
StringFactory(char[] alphabet, int stringLength)
Method Summary
 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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public StringFactory(char[] alphabet,
                     int stringLength)
alphabet - The set of characters that can legally occur within a string generated by this factory.
stringLength - The fixed length of all strings generated by this factory.
Method Detail


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.

rng - A source of randomness used to select characters to make up the string.
A randomly generated string.

Watchmaker Framework for Evolutionary Computation API
(Version 0.7.1)