|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Objectorg.moeaframework.util.tree.Rules
public class Rules
The rules defining the program syntax. At a minimum, the rules must define the program return type and the set of nodes which can appear in the program.
It is also possible to define program scaffolding, which defines the fixed
initial structure of the program that is not modified by any variation
operators. For example, this can be used to define function prototypes
(similar to automatically defined functions), so that the function appears
in all programs. Any undefined arguments (i.e., null) to a node
will be filled by the genetic programming algorithm.
| Constructor Summary | |
|---|---|
Rules()
Constructs a new set of rules for defining program syntax. |
|
| Method Summary | |
|---|---|
void |
add(Node node)
Adds a node that can appear in programs produced using these rules. |
Node |
buildTreeFull(Class<?> type,
int depth)
Generates an expression tree with the given return type using the full initialization method. |
Node |
buildTreeFull(Node node,
int depth)
Generates an expression tree with the given scaffolding using the full initialization method. |
Node |
buildTreeGrow(Class<?> type,
int depth)
Generates an expression tree with the given return type using the grow initialization method. |
Node |
buildTreeGrow(Node node,
int depth)
Generates an expression tree with the given scaffolding using the grow initialization method. |
List<Node> |
getAvailableNodes()
Returns the list of all nodes which can appear in programs produced using these rules. |
double |
getFunctionCrossoverProbability()
Returns the probability of crossover being applied to a function (non-terminal) node. |
int |
getMaxInitializationDepth()
Returns the maximum depth of the expression trees produced by any initialization routine. |
int |
getMaxVariationDepth()
Returns the maximum depth of the expression trees produced by any variation operator. |
Class<?> |
getReturnType()
Returns the return type of all programs produced using these rules. |
Node |
getScaffolding()
Returns the program scaffolding; or null if the program has no
defined scaffolding. |
protected boolean |
isMutationCompatible(Node original,
Node mutation)
Returns true if the original node can be replaced via point
mutation with the given mutation node and satisfy type safety;
false otherwise. |
List<Node> |
listAvailableCrossoverNodes(Node node,
Class<?> type)
Returns the list of all nodes in the tree rooted at the specified node with the given return type. |
List<Node> |
listAvailableFunctions(Class<?> type)
Returns the list of all available function (non-terminal) nodes with the given return type. |
List<Node> |
listAvailableMutations(Node node)
Returns the list of all available mutations to the given node. |
List<Node> |
listAvailableNodes(Class<?> type)
Returns the list of all available nodes with the given return type. |
List<Node> |
listAvailableTerminals(Class<?> type)
Returns the list of all available terminal nodes with the given return type. |
void |
populateWithArithmetic()
Allows the default arithmetic nodes to appear in programs produced using these rules. |
void |
populateWithConstants()
Allows the default constant nodes to appear in programs produced using these rules. |
void |
populateWithControl()
Allows the default control nodes to appear in programs produced using these rules. |
void |
populateWithDefaults()
Allows all default nodes to appear in programs. |
void |
populateWithLogic()
Allows the default logic nodes to appear in programs produced using these rules. |
void |
populateWithTrig()
Allows the default trigonometric nodes to appear in programs produced using these rules. |
void |
setFunctionCrossoverProbability(double functionCrossoverProbability)
Sets the probability of crossover being applied to a function (non-terminal) node. |
void |
setMaxInitializationDepth(int maxInitializationDepth)
Sets the maximum depth of the expression trees produced by any initialization routine. |
void |
setMaxVariationDepth(int maxVariationDepth)
Sets the maximum depth of the expression trees produced by any variation operator. |
void |
setReturnType(Class<?> returnType)
Sets the return type of all programs produced using these rules. |
void |
setScaffolding(Node scaffolding)
Sets the program scaffolding. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Rules()
| Method Detail |
|---|
public Class<?> getReturnType()
public void setReturnType(Class<?> returnType)
returnType - the return type of all programs produced using these
rulespublic Node getScaffolding()
null if the program has no
defined scaffolding.
null if the program has no
defined scaffoldingpublic void setScaffolding(Node scaffolding)
scaffolding - the program scaffoldingpublic int getMaxInitializationDepth()
public void setMaxInitializationDepth(int maxInitializationDepth)
maxInitializationDepth - the maximum depth of the expression trees
produced by any initialization routinepublic int getMaxVariationDepth()
public void setMaxVariationDepth(int maxVariationDepth)
maxVariationDepth - the maximum depth of the expression trees
produced by any variation operatorpublic double getFunctionCrossoverProbability()
public void setFunctionCrossoverProbability(double functionCrossoverProbability)
(No. of Functions) / (No. of Functions + No. of Terminals).
functionCrossoverProbability - the probability of crossover being
applied to a function (non-terminal) nodepublic void add(Node node)
node - the node that can appear in programs produced using these
rulespublic void populateWithLogic()
And, Or, Not,
Equals, GreaterThan, LessThan,
GreaterThanOrEqual, LessThanOrEqual, and constants
true and false.
public void populateWithArithmetic()
Add, Subtract,
Multiply, Divide, Modulus, Floor,
Ceil, Round, Max, Min, Power,
Square, SquareRoot, Abs, Log,
Log10, Exp, and Sign.
public void populateWithTrig()
Sin, Cos, Tan,
Asin, Acos, Atan, Sinh, Cosh,
Tanh, Asinh, Acosh, and Atanh.
public void populateWithControl()
IfElse, Sequence, and
NOP. Several control nodes are not included in the defaults,
such as For and While. These are not included as they
can easily result in infinite loops. These other control nodes can be
manually added if needed.
public void populateWithConstants()
0, 1,
2, 10, -1, Math.E, and Math.PI.
public void populateWithDefaults()
populateWithLogic(), populateWithArithmetic(),
populateWithTrig(), populateWithControl(), and
populateWithConstants() for details.
public List<Node> getAvailableNodes()
public List<Node> listAvailableCrossoverNodes(Node node,
Class<?> type)
node - the root of the treetype - the required return type
public List<Node> listAvailableMutations(Node node)
node - the node to be mutated
protected boolean isMutationCompatible(Node original,
Node mutation)
true if the original node can be replaced via point
mutation with the given mutation node and satisfy type safety;
false otherwise.
original - the original nodemutation - the mutation node
true if the original node can be replaced via point
mutation with the given mutation node and satisfy type safety;
false otherwisepublic List<Node> listAvailableNodes(Class<?> type)
type - the required return type
public List<Node> listAvailableTerminals(Class<?> type)
type - the required return type
public List<Node> listAvailableFunctions(Class<?> type)
type - the required return type
public Node buildTreeFull(Class<?> type,
int depth)
type - the required return typedepth - the required depth of each leaf node in the tree
public Node buildTreeGrow(Class<?> type,
int depth)
type - the required return typedepth - the maximum depth of each leaf node in the tree
public Node buildTreeFull(Node node,
int depth)
node - the initial scaffolding for the treedepth - the required depth of each leaf node in the tree
public Node buildTreeGrow(Node node,
int depth)
node - the initial scaffolding for the treedepth - the maximum depth of each leaf node in the tree
|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||