public final class Var<T> extends Object implements Op<T>, Serializable
Var
operation is a termination
operation, which just returns the value with the defined index of the input
variable array. It is essentially an orthogonal projection of the
n-dimensional input space to the 1-dimensional result space.
final ISeq<? extends Op<Double>> operations = ISeq.of(...);
final ISeq<? extends Op<Double>> terminals = ISeq.of(
Var.of("x", 0), Var.of("y", 1)
);
static double error(final ProgramChromosome<Double> program) {
final double x = ...;
final double y = ...;
final double result = program.apply(x, y);
...
return ...;
}
Modifier and Type | Method and Description |
---|---|
T |
apply(T[] variables) |
int |
arity()
Return the arity of the operation function.
|
boolean |
equals(Object obj) |
int |
hashCode() |
int |
index()
The projection index of the variable.
|
String |
name()
Return the name of the operation.
|
static <T> Var<T> |
of(String name,
int index)
Create a new variable with the given
name and projection
index . |
String |
toString() |
public int index()
public int arity()
Op
public static <T> Var<T> of(String name, int index)
name
and projection
index
.T
- the variable typename
- the variable name. Used when printing the operation tree
(program)index
- the projection indexname
and projection
index
© 2007-2018 Franz Wilhelmstötter (2018-10-28 17:23)