public final class PrimitiveSetImpl extends Object implements PrimitiveSet
| Constructor and Description |
|---|
PrimitiveSetImpl(FunctionSet functionSet,
ConstantSet constantSet,
VariableSet variableSet,
Random random,
double ratioVariables)
Constructs a new primitive set consisting of the specified components.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasFunctions(Type type)
Returns
true if the primitive set contains at least one function which has a return type of the specified type, else false. |
boolean |
hasTerminals(Type type)
Returns
true if the primitive set contains at least one terminal node of the specified type, else false. |
Function |
nextAlternativeFunction(Function current)
Returns a randomly selected
Function that is not the same as the specified Function. |
Node |
nextAlternativeTerminal(Node current)
Returns a randomly selected terminal node that is not the same as the specified
Node. |
Function |
nextFunction(Type type)
Returns a randomly selected
Function of the specified Type. |
Node |
nextTerminal(Type type)
Returns a randomly selected terminal node.
|
public PrimitiveSetImpl(FunctionSet functionSet, ConstantSet constantSet, VariableSet variableSet, Random random, double ratioVariables)
functionSet - the set of possible functions to use in the construction of programsconstantSet - the set of possible constants to use in the construction of programsvariableSet - the set of possible variables to use in the construction of programsrandom - used to randomly select components to use in the construction of programsratioVariables - a value in the range 0 to 1 (inclusive) which specifies the proportion of terminal nodes that should represent variables, rather than constantspublic boolean hasTerminals(Type type)
PrimitiveSettrue if the primitive set contains at least one terminal node of the specified type, else false.hasTerminals in interface PrimitiveSetpublic boolean hasFunctions(Type type)
PrimitiveSettrue if the primitive set contains at least one function which has a return type of the specified type, else false.hasFunctions in interface PrimitiveSetpublic Node nextTerminal(Type type)
nextTerminal in interface PrimitiveSetpublic Node nextAlternativeTerminal(Node current)
Node.nextAlternativeTerminal in interface PrimitiveSetcurrent - the current Node that the returned result should be an alternative to (i.e. not the same as)Nodepublic Function nextFunction(Type type)
Function of the specified Type.nextFunction in interface PrimitiveSettype - the required return type of the FunctionFunction with a return type of typepublic Function nextAlternativeFunction(Function current)
Function that is not the same as the specified Function.nextAlternativeFunction in interface PrimitiveSetcurrent - the current Function that the returned result should be an alternative to (i.e. not the same as)Function that is not the same as the specified FunctionOakGP Genetic Programming Framework