|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.encog.ml.ea.genome.BasicGenome
org.encog.ml.prg.EncogProgram
public class EncogProgram
Holds an Encog Programming Language (EPL) program. A Encog program is internally represented as a tree structure. It can be rendered to a variety of forms, such as RPN, common infix expressions, or Latex. The Encog Workbench also allows display as a graphical tree. An Encog Program is both a genome and phenome. No decoding is necessary. Every Encog Program has a context. The context is the same for every Encog Program in a population. The context defines which opcodes should be used, as well as the defined variables. The actual values for the variables are not stored in the context. Rather they are stored in a variable holder. Each program usually has its own variable holder, though it is possible to share.
Constructor Summary | |
---|---|
EncogProgram()
Construct the Encog program and create a default context and variable holder. |
|
EncogProgram(EncogProgramContext theContext)
Construct the Encog program with the specified context, but create a new variable holder. |
|
EncogProgram(EncogProgramContext theContext,
EncogProgramVariables theVariables)
Construct an Encog program using the specified context and variable holder. |
|
EncogProgram(String expression)
Construct an Encog program using the specified expression, but create an empty context and variable holder. |
Method Summary | |
---|---|
double |
calculateError(MLDataSet data)
Calculate the error of the ML method, given a dataset. |
ProgramNode |
compileEPL(String code)
Compile the specified EPL into an actual program node structure, for later execution. |
ProgramNode |
compileExpression(String expression)
Compile the specified expression. |
MLData |
compute(MLData input)
Compute the output from the input MLData. |
void |
copy(Genome source)
Copy from the specified genome into this one. |
String |
dumpAsCommonExpression()
|
ExpressionValue |
evaluate()
Execute the program and return the result. |
ProgramNode |
findNode(int index)
Find the specified node by index. |
String |
generateEPL()
|
EncogProgramContext |
getContext()
|
Object |
getExtraData(String name)
Get extra data that might be needed by user extended opcodes. |
FunctionFactory |
getFunctions()
|
int |
getInputCount()
|
int |
getOutputCount()
|
ValueType |
getReturnType()
|
ProgramNode |
getRootNode()
|
EncogProgramVariables |
getVariables()
|
static boolean |
parseBoolean(String str)
Parse the specified program, or expression, and return the result. |
static ExpressionValue |
parseExpression(String str)
Parse the specified program, or expression, and return the result. |
static double |
parseFloat(String str)
Parse the specified program, or expression, and return the result. |
static String |
parseString(String str)
Parse the specified program, or expression, and return the result. |
void |
replaceNode(ProgramNode replaceThisNode,
ProgramNode replaceWith)
Replace the specified node with another. |
int |
selectRandomVariable(Random rnd,
List<ValueType> desiredTypes)
Select a random variable from the defined variables. |
void |
setExtraData(String name,
Object value)
Set extra data that might be needed by extensions. |
void |
setRootNode(ProgramNode theRootNode)
Set the root node for the program. |
int |
size()
|
String |
toString()
|
Methods inherited from class org.encog.ml.ea.genome.BasicGenome |
---|
getAdjustedScore, getBirthGeneration, getPopulation, getScore, getSpecies, setAdjustedScore, setBirthGeneration, setPopulation, setScore, setSpecies |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public EncogProgram()
public EncogProgram(EncogProgramContext theContext)
theContext
- The context.public EncogProgram(EncogProgramContext theContext, EncogProgramVariables theVariables)
theContext
- The context.theVariables
- The variable holder.public EncogProgram(String expression)
expression
- The expression.Method Detail |
---|
public static boolean parseBoolean(String str)
str
- The program expression.
public static ExpressionValue parseExpression(String str)
str
- The program expression.
public static double parseFloat(String str)
str
- The program expression value.
public static String parseString(String str)
str
- The program expression value.
public double calculateError(MLDataSet data)
calculateError
in interface MLError
data
- The dataset.
public ProgramNode compileEPL(String code)
code
- The code to compile.
public ProgramNode compileExpression(String expression)
expression
- The expression.
public MLData compute(MLData input)
compute
in interface MLRegression
input
- The input to the program.
public void copy(Genome source)
copy
in interface Genome
source
- The source genome.public String dumpAsCommonExpression()
public ExpressionValue evaluate()
public ProgramNode findNode(int index)
index
- The index being sought.
public String generateEPL()
public EncogProgramContext getContext()
public FunctionFactory getFunctions()
public int getInputCount()
getInputCount
in interface MLInput
public int getOutputCount()
getOutputCount
in interface MLOutput
public ValueType getReturnType()
public ProgramNode getRootNode()
public EncogProgramVariables getVariables()
public void replaceNode(ProgramNode replaceThisNode, ProgramNode replaceWith)
replaceThisNode
- The node to replace.replaceWith
- The node that is replacing that node.public int selectRandomVariable(Random rnd, List<ValueType> desiredTypes)
rnd
- A random number generator.desiredTypes
- The desired types that the variable can be.
public void setRootNode(ProgramNode theRootNode)
theRootNode
- The new root node.public int size()
size
in interface Genome
public String toString()
toString
in class BasicGenome
public Object getExtraData(String name)
name
- The name the data was stored under.
public void setExtraData(String name, Object value)
name
- The name of the data stored.value
- The data.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |