Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.encog.ml.prg.generator
Class AbstractPrgGenerator

    java.lang.Object
      org.encog.ml.prg.generator.AbstractPrgGenerator

All Implemented Interfaces:
  PopulationGenerator, PrgGenerator, MultiThreadable

Direct Known Subclasses:
  PrgFullGenerator, PrgGrowGenerator, RampedHalfAndHalf

    public abstract class AbstractPrgGenerator

extends Object
implements PrgGenerator, MultiThreadable

The abstract base for Full and Grow program generation.

Constructor Summary
`AbstractPrgGenerator(EncogProgramContext theContext, int theMaxDepth)` Construct the generator.

Method Summary
`void` | `addPopulationMember(PrgPopulation population, EncogProgram prg)` Add a population member from one of the threads.
`EncogProgram` | `attemptCreateGenome(Random rnd, Population pop)` Attempt to create a genome.
`ProgramNode` | `createRandomNode(Random rnd, EncogProgram program, int depthRemaining, List<ValueType> types, boolean includeTerminal, boolean includeFunction)` Create a random note according to the specified paramaters.
`ProgramNode` | `createTerminalNode(Random rnd, EncogProgram program, List<ValueType> types)` Create a terminal node.
`int` | `determineMaxDepth(Random rnd)`
`EncogProgram` | `generate(Random rnd)` Generate a random genome.
`void` | `generate(Random rnd, Population pop)` Generate a random population.
`ProgramExtensionTemplate` | `generateRandomOpcode(Random rnd, List<ProgramExtensionTemplate> opcodes)` Generate a random opcode.
`EncogProgramContext` | `getContext()`
`double` | `getMaxConst()`
`int` | `getMaxDepth()`
`int` | `getMaxGenerationErrors()`
`double` | `getMinConst()`
`RandomFactory` | `getRandomFactory()`
`CalculateScore` | `getScore()`
`int` | `getThreadCount()`
`boolean` | `isHasEnum()`
`void` | `setMaxConst(double maxConst)`
`void` | `setMaxGenerationErrors(int maxGenerationErrors)` Set the maximum errors to allow during generation.
`void` | `setMinConst(double minConst)`
`void` | `setRandomFactory(RandomFactory randomFactory)`
`void` | `setScore(CalculateScore score)`
`void` | `setThreadCount(int numThreads)` Set the number of threads to use.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.encog.ml.prg.generator.PrgGenerator
`createNode`

Constructor Detail

### AbstractPrgGenerator

    public AbstractPrgGenerator(EncogProgramContext theContext,
                                int theMaxDepth)

  Construct the generator.

  Parameters:
    `theContext` - The context that is to be used for generation.
    `theMaxDepth` - The maximum depth to generate to.

Method Detail

### addPopulationMember

    public void addPopulationMember(PrgPopulation population,
                                    EncogProgram prg)

  Add a population member from one of the threads.

  Parameters:
    `population` - The population to add to.
    `prg` - The program to add.

### attemptCreateGenome

    public EncogProgram attemptCreateGenome(Random rnd,
                                            Population pop)

  Attempt to create a genome. Cycle the specified number of times if an error occurs.

  Parameters:
    `rnd` - The random number generator.
    `pop` - The population.
  Returns:
    The generated genome.

### createRandomNode

    public ProgramNode createRandomNode(Random rnd,
                                        EncogProgram program,
                                        int depthRemaining,
                                        List<ValueType> types,
                                        boolean includeTerminal,
                                        boolean includeFunction)

  Create a random note according to the specified paramaters.

  Parameters:
    `rnd` - A random number generator.
    `program` - The program to generate for.
    `depthRemaining` - The depth remaining to generate.
    `types` - The types to generate.
    `includeTerminal` - Should we include terminal nodes.
    `includeFunction` - Should we include function nodes.
  Returns:
    The generated program node.

### createTerminalNode

    public ProgramNode createTerminalNode(Random rnd,
                                          EncogProgram program,
                                          List<ValueType> types)

  Create a terminal node.

  Parameters:
    `rnd` - A random number generator.
    `program` - The program to generate for.
    `types` - The types that we might generate.
  Returns:
    The terminal program node.

### determineMaxDepth

    public int determineMaxDepth(Random rnd)

### generate

    public EncogProgram generate(Random rnd)

  Generate a random genome.

  Specified by:
    `generate` in interface `PopulationGenerator`
  Parameters:
    `rnd` - A random number generator.
  Returns:
    A random genome.

### generate

    public void generate(Random rnd,
                         Population pop)

  Generate a random population.

  Specified by:
    `generate` in interface `PopulationGenerator`
  Parameters:
    `rnd` - Random number generator.
    `pop` - The population to generate into.

### generateRandomOpcode

    public ProgramExtensionTemplate generateRandomOpcode(Random rnd,
                                                         List<ProgramExtensionTemplate> opcodes)

  Generate a random opcode.

  Parameters:
    `rnd` - Random number generator.
    `opcodes` - The opcodes to choose from.
  Returns:
    The selected opcode.

### getContext

    public EncogProgramContext getContext()

  Returns:
    the context

### getMaxConst

    public double getMaxConst()

  Returns:
    the maxConst

### getMaxDepth

    public int getMaxDepth()

  Returns:
    the maxDepth

### getMaxGenerationErrors

    public int getMaxGenerationErrors()

  Specified by:
    `getMaxGenerationErrors` in interface `PrgGenerator`
  Returns:
    the maxGenerationErrors

### getMinConst

    public double getMinConst()

  Returns:
    the minConst

### getRandomFactory

    public RandomFactory getRandomFactory()

  Returns:
    the randomFactory

### getScore

    public CalculateScore getScore()

  Returns:
    the score

### getThreadCount

    public int getThreadCount()

  Specified by:
    `getThreadCount` in interface `MultiThreadable`
  Returns:
    The desired number of threads.

### isHasEnum

    public boolean isHasEnum()

  Returns:
    the hasEnum

### setMaxConst

    public void setMaxConst(double maxConst)

  Parameters:
    `maxConst` - the maxConst to set

### setMaxGenerationErrors

    public void setMaxGenerationErrors(int maxGenerationErrors)

  Description copied from interface: `PrgGenerator`
  Set the maximum errors to allow during generation.

  Specified by:
    `setMaxGenerationErrors` in interface `PrgGenerator`
  Parameters:
    `maxGenerationErrors` - the maxGenerationErrors to set

### setMinConst

    public void setMinConst(double minConst)

  Parameters:
    `minConst` - the minConst to set

### setRandomFactory

    public void setRandomFactory(RandomFactory randomFactory)

  Parameters:
    `randomFactory` - the randomFactory to set

### setScore

    public void setScore(CalculateScore score)

  Parameters:
    `score` - the score to set

### setThreadCount

    public void setThreadCount(int numThreads)

  Description copied from interface: `MultiThreadable`
  Set the number of threads to use.

  Specified by:
    `setThreadCount` in interface `MultiThreadable`
  Parameters:
    `numThreads` - The desired thread count.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2014. All Rights Reserved.