Skip to content

Commit

Permalink
Add normalzie flag in default message update
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 committed Aug 8, 2024
1 parent 9d10b82 commit f221b70
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/caches/beliefpropagationcache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f221b70

Please sign in to comment.