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)
PrimitiveSet
true
if the primitive set contains at least one terminal node of the specified type, else false
.hasTerminals
in interface PrimitiveSet
public boolean hasFunctions(Type type)
PrimitiveSet
true
if the primitive set contains at least one function which has a return type of the specified type, else false
.hasFunctions
in interface PrimitiveSet
public Node nextTerminal(Type type)
nextTerminal
in interface PrimitiveSet
public Node nextAlternativeTerminal(Node current)
Node
.nextAlternativeTerminal
in interface PrimitiveSet
current
- the current Node
that the returned result should be an alternative to (i.e. not the same as)Node
public Function nextFunction(Type type)
Function
of the specified Type
.nextFunction
in interface PrimitiveSet
type
- the required return type of the Function
Function
with a return type of type
public Function nextAlternativeFunction(Function current)
Function
that is not the same as the specified Function
.nextAlternativeFunction
in interface PrimitiveSet
current
- 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 Function
OakGP Genetic Programming Framework