Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bartvanerp opened this issue Nov 29, 2022 · 0 comments
Assignees

Comments

@bartvanerp
Copy link
Member

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(), ),
)
@bvdmitri bvdmitri self-assigned this Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👉 Assigned
Development

No branches or pull requests

2 participants