ReactiveBayes / RxInfer.jl

Julia package for automated Bayesian inference on a factor graph with reactive message passing
MIT License
260 stars 24 forks source link

Pointmass constraints with sum-product message passing (interventions Pearl) #32

Open bartvanerp opened 1 year ago

bartvanerp commented 1 year ago

In RxInfer, constraints are enforced after the product of two messages as f(q(x)). For sum-product message passing, this means that first all messages in the graph are computed, after which the constraint is enforced. As a result messages are passed right through the constrained edges and marginals on other edges do not reflect this constraint. Specifically when using PointMass constraints, which can be interpreted as interventions from Pearl, this behaviour is likely not desired as the purpose of the constraints is to prevent an information flow. As a result, marginals on other edges do not reflect this constraint and might be considered wrong: this should be checked.

For now there is a workaround. Consider the constrained variable z as

@constraints function constraints_z()
    q(z) :: PointMass
end

When performing SP this constraint is only enforced after all messages are computed. However, the inference procedure can be enforced to use this marginal distribution for further computations outward of this edge. This can be achieved by adding where { pipeline = RequireMarginal(interfacename) } to the nodes adjacent to the z edge, where the interfacename describes the interface connected to z.

bartvanerp commented 1 year ago

@bvdmitri As discussed today, this should automatically enforce an appropriate factorization.