public final class NodeSimplifier extends Object
This can be done by replacing expressions with constant values or removing redundant branches. e.g. The expression:
(+ 7 (* 3 6))can be simplified to the value:
25Note: relies on
Function.isPure()
to identify if a function is referentially transparent and therefore suitable for
replacement with the result of evaluating it.Modifier and Type | Method and Description |
---|---|
static Node |
simplify(Node input)
Attempts to reduce the size of the specified tree structures without altering its functionality.
|
public static Node simplify(Node input)
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 {@code (+ v0 v1)}.
input
- the node to attempt to simplify.input
.Function.simplify(Arguments)
OakGP Genetic Programming Framework