Skip to content

Commit

Permalink
add mpbp exact on infinite graph
Browse files Browse the repository at this point in the history
  • Loading branch information
stecrotti committed Feb 21, 2024
1 parent ebcaf95 commit 40b2fd7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/MatrixProductBP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export
pair_observations_nondirected, pair_obs_undirected_to_directed,
exact_prob, exact_marginals, site_marginals, exact_autocorrelations,
exact_autocovariances, exact_marginal_expectations,
uniform_exact_msg, mpbp_exact,
uniform_exact_msg, mpbp_exact, exact_mpbp_infinite_graph,
SoftMarginSampler, onesample!, onesample, sample!, sample, marginals, pair_marginals,
continuous_sis_sampler, simulate_queue_sis!,
draw_node_observations!, AtomicVector,
Expand Down
17 changes: 16 additions & 1 deletion src/exact.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,19 @@ function marginals(m::ExactMsg)
end
end

is_periodic(bp::MPBP{G,F,V,<:ExactMsg{P},<:ExactMsg{P}}) where {G,F,V,P} = P
is_periodic(bp::MPBP{G,F,V,<:ExactMsg{P},<:ExactMsg{P}}) where {G,F,V,P} = P

function exact_mpbp_infinite_graph(k::Integer, wᵢ::Vector{U}, qi::Int,
ϕᵢ = fill(ones(qi), length(wᵢ));
ψₖᵢ = fill(ones(qi, qi), length(wᵢ)),
periodic = false) where {U<:BPFactor}

T = length(wᵢ) - 1
@assert length(ϕᵢ) == T + 1
@assert length(ψₖᵢ) == T + 1

g = InfiniteRegularGraph(k)
μ = uniform_exact_msg((qi, qi), T; periodic)
b = uniform_exact_msg((qi,), T; periodic)
MPBP(g, [wᵢ], [ϕᵢ], [ψₖᵢ], [μ], [b], [0.0])
end

0 comments on commit 40b2fd7

Please sign in to comment.