From f221b709e8dda26864022879994d3294b8511bd5 Mon Sep 17 00:00:00 2001 From: Joey Date: Thu, 8 Aug 2024 12:50:47 -0400 Subject: [PATCH] Add normalzie flag in default message update --- src/caches/beliefpropagationcache.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/caches/beliefpropagationcache.jl b/src/caches/beliefpropagationcache.jl index 2ce338f3..e9a64cda 100644 --- a/src/caches/beliefpropagationcache.jl +++ b/src/caches/beliefpropagationcache.jl @@ -16,10 +16,12 @@ using SimpleTraits: SimpleTraits, Not, @traitfn default_message(inds_e) = ITensor[denseblocks(delta(i)) for i in inds_e] default_messages(ptn::PartitionedGraph) = Dictionary() default_message_norm(m::ITensor) = norm(m) -function default_message_update(contract_list::Vector{ITensor}; kwargs...) +function default_message_update(contract_list::Vector{ITensor}; normalize=true, kwargs...) sequence = optimal_contraction_sequence(contract_list) updated_messages = contract(contract_list; sequence, kwargs...) - updated_messages /= norm(updated_messages) + if normalize + updated_messages /= norm(updated_messages) + end return ITensor[updated_messages] end @traitfn default_bp_maxiter(g::::(!IsDirected)) = is_tree(g) ? 1 : nothing