While analysing a network of Vertices it's not obvious which have constant values.
For example I've got the following code:
private static boolean isConstant(DoubleVertex vertex) {
if ( vertex instanceof ConstantDoubleVertex ){
return true;
} else if ( vertex instanceof DoubleBinaryOpVertex ){
DoubleBinaryOpVertex dbv = (DoubleBinaryOpVertex)vertex;
return isConstant(dbv.getLeft()) && isConstant(dbv.getRight());
}
return false;
}
I think this would be useful as a core part of keanu so it's maintained
Alternatives
The main issue with this would be "custom" vertices from other sources. It may be better to provide an interface that let's code understand a vertex isn't going to change.
Additional context
Eventually this might even allow some automatic optimisations (e.g. cache values if they can never change).
While analysing a network of Vertices it's not obvious which have constant values.
For example I've got the following code:
I think this would be useful as a core part of
keanuso it's maintainedAlternatives
The main issue with this would be "custom" vertices from other sources. It may be better to provide an interface that let's code understand a vertex isn't going to change.
Additional context
Eventually this might even allow some automatic optimisations (e.g. cache values if they can never change).