org.encog.ml.prg.extension
Class ConstantPool
- java.lang.Object
-
- org.encog.ml.prg.extension.ConstantPool
-
- All Implemented Interfaces:
- java.io.Serializable, ProgramExtensionTemplate
public class ConstantPool extends java.lang.Object implements ProgramExtensionTemplate
Created by jeffh on 9/13/2016.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static double[]COMMON_CONST-
Fields inherited from interface org.encog.ml.prg.extension.ProgramExtensionTemplate
NO_PARAMS, NO_PREC
-
-
Constructor Summary
Constructors Constructor and Description ConstantPool()Construct with common constants, plus 100 random constants between -10 and 10.ConstantPool(java.lang.String theName, double[] thePool)Construct for a specific constant pool.ConstantPool(java.lang.String theName, double[] thePool, int count, GenerateRandom rnd, double low, double high)Construct for a specific constant pool and random constants.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description ExpressionValueevaluate(ProgramNode actual)Evaluate the specified actual program node, using this opcode template.intgetChildNodeCount()intgetDataSize()java.lang.StringgetName()NodeTypegetNodeType()java.util.List<ParamTemplate>getParams()intgetPrecedence()ParamTemplategetReturnValue()booleanisPossibleReturnType(EncogProgramContext context, ValueType rtn)Determines if the specified return type is a possible return type.booleanisVariable()voidrandomize(java.util.Random rnd, java.util.List<ValueType> desiredType, ProgramNode actual, double minValue, double maxValue)Randomize this actual tree node.
-
-
-
Constructor Detail
-
ConstantPool
public ConstantPool(java.lang.String theName, double[] thePool)Construct for a specific constant pool.- Parameters:
theName- The name of the pool.thePool- The pool of values.
-
ConstantPool
public ConstantPool(java.lang.String theName, double[] thePool, int count, GenerateRandom rnd, double low, double high)Construct for a specific constant pool and random constants.- Parameters:
theName- The name of the pool.thePool- The pool of values.count- The number of random values to generate, total size is length of pool + count.rnd- Random number generator.low- The low end of the random range.high- The high end of the random range.
-
ConstantPool
public ConstantPool()
Construct with common constants, plus 100 random constants between -10 and 10.
-
-
Method Detail
-
evaluate
public ExpressionValue evaluate(ProgramNode actual)
Description copied from interface:ProgramExtensionTemplateEvaluate the specified actual program node, using this opcode template.- Specified by:
evaluatein interfaceProgramExtensionTemplate- Parameters:
actual- The tree node in the actual program.- Returns:
- The result of the evaluation.
-
getChildNodeCount
public int getChildNodeCount()
- Specified by:
getChildNodeCountin interfaceProgramExtensionTemplate- Returns:
- Get the number of child nodes that this opcode requires.
-
getDataSize
public int getDataSize()
- Specified by:
getDataSizein interfaceProgramExtensionTemplate- Returns:
- The size of extra data that is stored by this node.
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceProgramExtensionTemplate- Returns:
- Get the name of this opcode.
-
getNodeType
public NodeType getNodeType()
- Specified by:
getNodeTypein interfaceProgramExtensionTemplate- Returns:
- The node type.
-
getParams
public java.util.List<ParamTemplate> getParams()
- Specified by:
getParamsin interfaceProgramExtensionTemplate- Returns:
- The parameters (child nodes) required by this node.
-
getPrecedence
public int getPrecedence()
- Specified by:
getPrecedencein interfaceProgramExtensionTemplate- Returns:
- The operator precedence.
-
getReturnValue
public ParamTemplate getReturnValue()
- Specified by:
getReturnValuein interfaceProgramExtensionTemplate- Returns:
- The return value for this opcode.
-
isPossibleReturnType
public boolean isPossibleReturnType(EncogProgramContext context, ValueType rtn)
Description copied from interface:ProgramExtensionTemplateDetermines if the specified return type is a possible return type.- Specified by:
isPossibleReturnTypein interfaceProgramExtensionTemplate- Parameters:
context- The program context.rtn- The potential return type to check.- Returns:
- True, if the specified type is a possible return type.
-
isVariable
public boolean isVariable()
- Specified by:
isVariablein interfaceProgramExtensionTemplate- Returns:
- Returns true if this node is variable.
-
randomize
public void randomize(java.util.Random rnd, java.util.List<ValueType> desiredType, ProgramNode actual, double minValue, double maxValue)Description copied from interface:ProgramExtensionTemplateRandomize this actual tree node.- Specified by:
randomizein interfaceProgramExtensionTemplate- Parameters:
rnd- Random number generator.desiredType- The desired type of the randomization, if allowed.actual- The actual program node to randomize.minValue- The minimum value to use for randomization.maxValue- The maximum value to use for randomization.
-
-
DMelt 3.0 © DataMelt by jWork.ORG