ReactiveMP.jl
ReactiveMP.jl copied to clipboard
Merge elementary factor nodes
With the recent addition of the equality node, it might be interesting to explore whether elementary nodes can be merged for more efficient processing. Specifically I am referring to Table 4 of https://ieeexplore.ieee.org/document/4282128.
For the composite node containing an addition and multiplication node, we can easily create a custom node. This should not cause any major issues during model specification. The original model specification then simply becomes
x[k+1] ~ AddMultiply(x[k], y[k], A) # performs x[k] + A*y[k]
instead of the current
z[k] ~ A*y[k]
x[k+1] ~ x[k] + z[k]
The only downside here is that we lose information about the latent variable z
, which is the trade-off of this new node.
However, the combination of an equality node and a multiplication node will lead to foreseeable problems during model specification, i.e.
x[k] ~ EqMultiply(x[k], y[k], A) # recurrent relationship over x[k]
To solve this, we would need to introduce additional variables to distinguish between the variables around the equality node during model specification, something which we do not necessarily want. Ideally, these kind of structures are automatically identified and optimized during graph creation. Luckily, in this case we do not lose information about the latent variable in the node, as it is connected to an equality node, which we can access from edges around the node.
Adding these rules is definitely a good idea. I would maybe refrain from using the EqMultiply
node for now. I am not sure that the problem you've mentioned is easy to solve. Also creating equality nodes during model specifications it's quite rare.