diff --git a/src/caches/beliefpropagationcache.jl b/src/caches/beliefpropagationcache.jl index 1f465fd9..3b77a0b1 100644 --- a/src/caches/beliefpropagationcache.jl +++ b/src/caches/beliefpropagationcache.jl @@ -32,20 +32,14 @@ default_partitioned_vertices(ψ::AbstractITensorNetwork) = group(v -> v, vertice function default_partitioned_vertices(f::AbstractFormNetwork) return group(v -> original_state_vertex(f, v), vertices(f)) end -default_cache_update_kwargs(cache) = (; maxiter=20, tol=1e-5) +default_cache_update_kwargs(cache) = (; maxiter=25, tol=1e-8) function default_cache_construction_kwargs(alg::Algorithm"bp", ψ::AbstractITensorNetwork) return (; partitioned_vertices=default_partitioned_vertices(ψ)) end function message_diff(message_a::Vector{ITensor}, message_b::Vector{ITensor}) lhs, rhs = contract(message_a), contract(message_b) - @assert issetequal(inds(lhs), inds(rhs)) - c = combiner(inds(lhs)) - lhs *= c - rhs *= c - lhs /= norm(lhs) - rhs /= norm(rhs) - f = abs(dot(lhs, rhs))^2 + f = abs(dot(lhs / norm(lhs), rhs / norm(rhs)))^2 return 1 - f end diff --git a/test/test_gauging.jl b/test/test_gauging.jl index 9eb4ebbf..67b1b5dd 100644 --- a/test/test_gauging.jl +++ b/test/test_gauging.jl @@ -27,9 +27,7 @@ using Test: @test, @testset ψ = random_tensornetwork(rng, s; link_space=χ) # Move directly to vidal gauge - ψ_vidal = VidalITensorNetwork( - ψ; cache_update_kwargs=(; maxiter=20, tol=1e-12, verbose=true) - ) + ψ_vidal = VidalITensorNetwork(ψ; cache_update_kwargs=(; maxiter=30, verbose=true)) @test gauge_error(ψ_vidal) < 1e-8 # Move to symmetric gauge @@ -38,7 +36,7 @@ using Test: @test, @testset bp_cache = cache_ref[] # Test we just did a gauge transform and didn't change the overall network - @test inner(ψ_symm, ψ) / sqrt(inner(ψ_symm, ψ_symm) * inner(ψ, ψ)) ≈ 1.0 + @test inner(ψ_symm, ψ) / sqrt(inner(ψ_symm, ψ_symm) * inner(ψ, ψ)) ≈ 1.0 atol = 1e-8 #Test all message tensors are approximately diagonal even when we keep running BP bp_cache = update(bp_cache; maxiter=10)