Skip to content

Multiple RequireMarginals with SP and PointMass constraint do not update/ask for missing rule #242

@bartvanerp

Description

@bartvanerp

When using PointMass constraints in SP, the behaviour is incorrect as in this issue on RxInfer. Patching this using RequireMarginals on both adjacent nodes also results in either not updating the variables (example below) or in asking for missing rules (notebook).

Example

using RxInfer, LinearAlgebra

# adds missing rule (solved in addons PR)
@rule Categorical(:out, Marginalisation) (m_p::Dirichlet,) = begin
    return Categorical(normalize(mean(m_p), 1))
end

@model function model_issue()
    y = datavar(Vector{Float64})

    α ~ Dirichlet(0.01 .* ones(3))
    z_old ~ Categorical(α) where { pipeline = RequireMarginal(out) }
    z_new ~ Transition(z_old, diagm(ones(3))) where { pipeline = RequireMarginal(in) }
    y ~ Transition(z_new, diagm(ones(3)))

    return y, z_new, z_old, α

end

@constraints function constraints_issue()
    q(z_old) :: PointMass
end

results_combination = inference(
    model = model_issue(), 
    data  = ( y = [1.0, 0.0, 0.0], ),
    constraints = constraints_issue(),
    returnvars = ( α=KeepLast(), ),
)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions