|
106 | 106 |
|
107 | 107 | function message(bp_cache::BeliefPropagationCache, edge::PartitionEdge)
|
108 | 108 | mts = messages(bp_cache)
|
109 |
| - return get(mts, edge, default_message(bp_cache, edge)) |
| 109 | + return get(() -> default_message(bp_cache, edge), mts, edge) |
110 | 110 | end
|
111 | 111 | function messages(bp_cache::BeliefPropagationCache, edges; kwargs...)
|
112 | 112 | return map(edge -> message(bp_cache, edge; kwargs...), edges)
|
@@ -152,15 +152,16 @@ end
|
152 | 152 | function environment(bp_cache::BeliefPropagationCache, verts::Vector)
|
153 | 153 | partition_verts = partitionvertices(bp_cache, verts)
|
154 | 154 | messages = environment(bp_cache, partition_verts)
|
155 |
| - central_tensors = ITensor[ |
156 |
| - tensornetwork(bp_cache)[v] for v in setdiff(vertices(bp_cache, partition_verts), verts) |
157 |
| - ] |
| 155 | + central_tensors = factors(bp_cache, setdiff(vertices(bp_cache, partition_verts), verts)) |
158 | 156 | return vcat(messages, central_tensors)
|
159 | 157 | end
|
160 | 158 |
|
| 159 | +function factors(bp_cache::BeliefPropagationCache, verts::Vector) |
| 160 | + return ITensor[tensornetwork(bp_cache)[v] for v in verts] |
| 161 | +end |
| 162 | + |
161 | 163 | function factor(bp_cache::BeliefPropagationCache, vertex::PartitionVertex)
|
162 |
| - ptn = partitioned_tensornetwork(bp_cache) |
163 |
| - return collect(eachtensor(subgraph(ptn, vertex))) |
| 164 | + return factors(bp_cache, vertices(bp_cache, vertex)) |
164 | 165 | end
|
165 | 166 |
|
166 | 167 | """
|
|
0 commit comments