Package org.moeaframework.core.variable
Class Program
java.lang.Object
org.moeaframework.util.tree.Node
org.moeaframework.core.variable.Program
- All Implemented Interfaces:
Serializable
,Variable
A decision variable for programs. The program is represented as a strongly-typed expression tree.
Note: Although Program
extends Node
, the Program
object must never be altered by the
optimization algorithm. Only its arguments can undergo variation.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncopy()
Returns an independent copy of this decision variable.copyNode()
Returns a copy of this node, but without any children or parents assigned.void
Parses and loads the value of this variable from a string.encode()
Encodes the value of this variable as a string.evaluate
(Environment environment) Evaluates this node in the context of the specified environment.getRules()
Returns the rules defining the program syntax.void
Initializes the program tree using ramped half-and-half initialization.Methods inherited from class org.moeaframework.util.tree.Node
copyTree, getArgument, getArgumentType, getDepth, getFunctionAt, getFunctionAt, getMaximumHeight, getMinimumHeight, getNodeAt, getNodeAt, getNodeAt, getNumberOfArguments, getNumberOfFunctions, getNumberOfFunctions, getNumberOfNodes, getNumberOfNodes, getNumberOfNodes, getNumberOfTerminals, getNumberOfTerminals, getParent, getReturnType, getTerminalAt, getTerminalAt, isFixed, isTerminal, isValid, setArgument, setFixed, setFixedTree, size, toString
-
Constructor Details
-
Program
Constructs a new program variable with the specified syntax rules.- Parameters:
rules
- the rules defining the program syntax
-
-
Method Details
-
getRules
Returns the rules defining the program syntax.- Returns:
- the rules defining the program syntax
-
copy
Description copied from interface:Variable
Returns an independent copy of this decision variable. It is required thatx.copy()
is completely independent fromx
. This means any method invoked onx.copy()
in no way alters the state ofx
and vice versa. It is typically the case thatx.copy().getClass() == x.getClass()
andx.copy().equals(x)
. -
copyNode
Description copied from class:Node
Returns a copy of this node, but without any children or parents assigned. -
evaluate
Description copied from class:Node
Evaluates this node in the context of the specified environment. -
randomize
public void randomize()Initializes the program tree using ramped half-and-half initialization. -
encode
Description copied from interface:Variable
Encodes the value of this variable as a string. This should reflect the internal representation of the value and not necessarily the actual value. For example, a binary-encoded integer should display the bits and not the integer value. Implementations should make an effort to display the value in a meaningful format, but that is not required. Instead, useVariable.toString()
if a human-readable format is required. This method along withVariable.decode(String)
are used primarily for storing values in text files. To make parsing easier, the resulting string must: 1. Only contain ASCII characters 2. Contain no whitespace (no spaces, tabs, newlines, etc.) -
decode
Description copied from interface:Variable
Parses and loads the value of this variable from a string. This must be able to process any string produced byVariable.encode()
.
-