Watchmaker Framework for Evolutionary Computation API
(Version 0.7.1)

org.uncommons.watchmaker.framework.factories
Class StringFactory

java.lang.Object
  extended by org.uncommons.watchmaker.framework.factories.AbstractCandidateFactory<String>
      extended by 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.

Author:
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

StringFactory

public StringFactory(char[] alphabet,
                     int stringLength)
Parameters:
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

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.

Watchmaker Framework for Evolutionary Computation API
(Version 0.7.1)