public interface Function
Modifier and Type | Method and Description |
---|---|
Object |
evaluate(Arguments arguments,
Assignments assignments)
Returns the result of applying this operation to the specified
Arguments and Assignments . |
default String |
getDisplayName()
Returns the
String value to use in the textual representation of this function. |
Signature |
getSignature()
Returns the return type and argument types associated with this function.
|
default boolean |
isPure()
Returns
true if this function is pure, else returns false . |
default Node |
simplify(Arguments arguments)
Attempts to find a simplified alternative to applying this function to the specified arguments.
|
Object evaluate(Arguments arguments, Assignments assignments)
Arguments
and Assignments
.arguments
- represents the arguments to apply to the operationassignments
- represents values assigned to variables belonging to arguments
arguments
and assignments
Signature getSignature()
default Node simplify(Arguments arguments)
Simplification can occur by replacing expressions with constant values (e.g. replacing (+ 1 1)
with 2
) or removing redundant branches
(e.g. replacing (if (< 2 3) (+ v0 v1) (* v0 v1))
with (+ v0 v1)
.
arguments
- the arguments to be applied to (i.e. evaluated by) this functionnull
if unable to simplify.NodeSimplifier
default String getDisplayName()
String
value to use in the textual representation of this function.default boolean isPure()
true
if this function is pure, else returns false
.
A function is a pure function if it conforms to the following criteria:
If a function is pure then it is referentially transparent. This means that if a function node contains a pure function, and all its arguments are constants, then the function node can be replaced with the result of evaluating it. This avoids unnecessary computation and reduces bloat.
Default implementation always returns true
.
ImpureFunction
OakGP Genetic Programming Framework