T
- the sample type@FunctionalInterface public interface Complexity<T>
Error
function.
final Error<Double> error = Error.of(LossFunction::mse, Complexity.ofMaxNodeCount(50));
LossFunction
,
Error
Modifier and Type | Method and Description |
---|---|
double |
apply(Tree<? extends Op<T>,?> program)
Calculates the complexity of the current program (possibly) relative
to the actual error value.
|
static double |
count(Tree<?,?> program,
int maxNodes)
This method uses the node count of a program tree for calculating its
complexity.
|
static <T> Complexity<T> |
ofNodeCount(int maxNodeCount)
Return a complexity measure which counts the number of nodes of a program.
|
double apply(Tree<? extends Op<T>,?> program)
program
- the actual programstatic <T> Complexity<T> ofNodeCount(int maxNodeCount)
T
- the sample typemaxNodeCount
- the maximal node count. The returned complexity will
be one if the program node count is greater or equal the given
count
IllegalArgumentException
- if the max node count
is smaller
than onecount(Tree, int)
static double count(Tree<?,?> program, int maxNodes)
[0, 1]
. If the program contains only one node, zero is returned.
If the node count is bigger or equal maxNodes
, one is returned.
The complexity is calculated in the following way:
final double cc = min(program.size() - 1, maxNodes);
return 1.0 - sqrt(1.0 - (cc*cc)/(maxNodes*maxNodes));
program
- the program used for the complexity measuremaxNodes
- the maximal expected node countprogram
NullPointerException
- if the given program
is null
IllegalArgumentException
- if maxNodes
is smaller than oneofNodeCount(int)
© 2007-2019 Franz Wilhelmstötter (2019-11-18 20:30)