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.
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. InenergiesSourceCode()thenode_codeis obtained by theremovePrefix()function. Consider the packageXwith custom nodeYof custom typeZ. HereremovePrefix()is called over the node typeX.Y{X.Z}. SinceremovePrefix()is defined asremovePrefix(type::Type) = split(string(type), '.')[end], this function will returnZ}instead of the desiredX{Z}and therefore the Free energy algorithm will contain an average energy contribution defined asF += averageEnergy(Z}, marginals), causing an error.Solution: The
removePrefix()should be extended to check for custom parameterized nodes.