Description
The Free energy code generation should be extended to allow for parameterized factor nodes from custom packages.
In freeEnergySourceCode()
the Free energy algorithm is constructed by looping over the average energies and entropies. In energiesSourceCode()
the node_code
is obtained by the removePrefix()
function. Consider the package X
with custom node Y
of custom type Z
. Here removePrefix()
is called over the node type X.Y{X.Z}
. Since removePrefix()
is defined as removePrefix(type::Type) = split(string(type), '.')[end]
, this function will return Z}
instead of the desired X{Z}
and therefore the Free energy algorithm will contain an average energy contribution defined as F += averageEnergy(Z}, marginals)
, causing an error.
Solution: The removePrefix()
should be extended to check for custom parameterized nodes.