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
Class EncogProgramContext

    java.lang.Object
      org.encog.ml.prg.EncogProgramContext

All Implemented Interfaces:
  Serializable

    public class EncogProgramContext

extends Object
implements Serializable

Every EncogProgram must belong to a context. When programs are in a population, they must all share a common context. The context defines attributes that are common to all programs. The following information is stored in a context. The number formatting used. Namely, what type of radix point should strings be parsed/rendered to. The functions, or opcodes, that are available to the program. This defines the set of functions & operators that a program might use. For an Encog Program all operators are treated as functions internally. A operator is essentially a shortcut notation for common functions. The defined variables. These variables are constant for the run of the program, but typically change for each run. They are essentially the variables that make up an algebraic expression. Finally, the return value mapping for the programs.

See Also:
  Serialized Form

Constructor Summary
`EncogProgramContext()` Construct the context with an English number format and an empty function factory.
`EncogProgramContext(CSVFormat format)` Construct a context with the specified number format and an empty function factory.
`EncogProgramContext(CSVFormat theFormat, FunctionFactory theFunctions)` Construct the context with the specified format and function factory.

Method Summary
`void` | `clearDefinedVariables()` Clear the defined variables.
`ProgramNode` | `cloneBranch(EncogProgram targetProgram, ProgramNode sourceBranch)` Clone a branch of the program from the specified node.
`EncogProgram` | `cloneProgram(EncogProgram sourceProgram)` Clone an entire program, keep the same context.
`EncogProgram` | `createProgram(String expression)` Create a new program, using this context.
`void` | `defineVariable(String theName)` Define the specified variable as floating point.
`void` | `defineVariable(String theName, ValueType theVariableType)` Define the specified variable as the specified type.
`void` | `defineVariable(String theName, ValueType theVariableType, int theEnumType, int theEnumValueCount)` Define a variable.
`void` | `defineVariable(VariableMapping mapping)` Define a variable, based on a mapping.
`List<VariableMapping>` | `findVariablesByTypes(List<ValueType> desiredTypes)` Find all of the variables of the specified types.
`List<VariableMapping>` | `getDefinedVariables()`
`int` | `getEnumCount(int enumType)` Get the enum ordinal count for the specified enumeration type.
`CSVFormat` | `getFormat()`
`FunctionFactory` | `getFunctions()`
`int` | `getMaxEnumType()` Get the max enum type for all defined variables.
`VariableMapping` | `getResult()`
`boolean` | `hasEnum()`
`void` | `loadAllFunctions()` Load all known functions as opcodes.
`void` | `setResult(VariableMapping result)`

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

Constructor Detail

### EncogProgramContext

    public EncogProgramContext()

  Construct the context with an English number format and an empty function factory.

### EncogProgramContext

    public EncogProgramContext(CSVFormat format)

  Construct a context with the specified number format and an empty function factory.

  Parameters:
    `format` - The format.

### EncogProgramContext

    public EncogProgramContext(CSVFormat theFormat,
                               FunctionFactory theFunctions)

  Construct the context with the specified format and function factory.

  Parameters:
    `theFormat` - The format.
    `theFunctions` - The function factory.

Method Detail

### clearDefinedVariables

    public void clearDefinedVariables()

  Clear the defined variables.

### cloneBranch

    public ProgramNode cloneBranch(EncogProgram targetProgram,
                                   ProgramNode sourceBranch)

  Clone a branch of the program from the specified node.

  Parameters:
    `targetProgram` - The program that this branch will be "grafted" into.
    `sourceBranch` - The branch to clone, from the source program.
  Returns:
    The cloned branch.

### cloneProgram

    public EncogProgram cloneProgram(EncogProgram sourceProgram)

  Clone an entire program, keep the same context.

  Parameters:
    `sourceProgram` - The source program.
  Returns:
    The cloned program.

### createProgram

    public EncogProgram createProgram(String expression)

  Create a new program, using this context.

  Parameters:
    `expression` - The common expression to compile.
  Returns:
    The resulting program.

### defineVariable

    public void defineVariable(String theName)

  Define the specified variable as floating point.

  Parameters:
    `theName` - The variable name to define.

### defineVariable

    public void defineVariable(String theName,
                               ValueType theVariableType)

  Define the specified variable as the specified type. Don't use this for enums.

  Parameters:
    `theName` - The name of the variable.
    `theVariableType` - The variable type.

### defineVariable

    public void defineVariable(String theName,
                               ValueType theVariableType,
                               int theEnumType,
                               int theEnumValueCount)

  Define a variable.

  Parameters:
    `theName` - The name of the variable.
    `theVariableType` - The type of variable.
    `theEnumType` - The enum type, not used if not an enum type.
    `theEnumValueCount` - The number of values for the enum, not used if not an enum type.

### defineVariable

    public void defineVariable(VariableMapping mapping)

  Define a variable, based on a mapping.

  Parameters:
    `mapping` - The variable mapping.

### findVariablesByTypes

    public List<VariableMapping> findVariablesByTypes(List<ValueType> desiredTypes)

  Find all of the variables of the specified types.

  Parameters:
    `desiredTypes` - The types to look for.
  Returns:
    The variables that matched the specified types.

### getDefinedVariables

    public List<VariableMapping> getDefinedVariables()

  Returns:
    The defined variables.

### getEnumCount

    public int getEnumCount(int enumType)

  Get the enum ordinal count for the specified enumeration type.

  Parameters:
    `enumType` - The enumeration type.
  Returns:
    The ordinal count for the specified enumeration type.

### getFormat

    public CSVFormat getFormat()

  Returns:
    The number formatting used. Namely, what type of radix point should strings be parsed/rendered to.

### getFunctions

    public FunctionFactory getFunctions()

  Returns:
    The functions, or opcodes, that are available to the program. This defines the set of functions & operators that a program might use. For an Encog Program all operators are treated as functions internally. A operator is essentially a shortcut notation for common functions.

### getMaxEnumType

    public int getMaxEnumType()

  Get the max enum type for all defined variables.

  Returns:
    The max enumeration type.

### getResult

    public VariableMapping getResult()

  Returns:
    the result

### hasEnum

    public boolean hasEnum()

  Returns:
    True, if enums are defined.

### loadAllFunctions

    public void loadAllFunctions()

  Load all known functions as opcodes.

### setResult

    public void setResult(VariableMapping result)

  Parameters:
    `result` - the result to set

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.