|
49 | 49 | mps_uai = TensorInference.random_tensor_train_uai(ComplexF64, n, chi) |
50 | 50 | bp = BeliefPropgation(mps_uai) |
51 | 51 | @test TensorInference.initial_state(bp) isa TensorInference.BPState |
52 | | - state, info = belief_propagate(bp) |
| 52 | + state, info = belief_propagate(bp; max_iter=100, tol=1e-8) |
53 | 53 | @test info.converged |
54 | 54 | @test info.iterations < 20 |
55 | 55 | mars = marginals(state) |
56 | 56 | tnet = TensorNetworkModel(mps_uai) |
57 | 57 | mars_tnet = marginals(tnet) |
58 | 58 | for v in 1:TensorInference.num_variables(bp) |
59 | | - @test mars[[v]] ≈ mars_tnet[[v]] atol=1e-6 |
| 59 | + @test mars[[v]] ≈ mars_tnet[[v]] atol=1e-4 |
60 | 60 | end |
61 | 61 | end |
62 | 62 |
|
63 | | -@testset "belief propagation on circle" begin |
| 63 | +@testset "belief propagation on circle (Real)" begin |
64 | 64 | n = 10 |
65 | 65 | chi = 3 |
66 | | - mps_uai = TensorInference.random_tensor_train_uai(ComplexF64, n, chi; periodic=true) # FIXME: fail to converge |
| 66 | + mps_uai = TensorInference.random_tensor_train_uai(Float64, n, chi; periodic=true) |
67 | 67 | bp = BeliefPropgation(mps_uai) |
68 | 68 | @test TensorInference.initial_state(bp) isa TensorInference.BPState |
69 | 69 | state, info = belief_propagate(bp; max_iter=100, tol=1e-6) |
|
78 | 78 | end |
79 | 79 | end |
80 | 80 |
|
| 81 | + |
| 82 | +@testset "belief propagation on circle (Complex)" begin |
| 83 | + n = 10 |
| 84 | + chi = 3 |
| 85 | + mps_uai = TensorInference.random_tensor_train_uai(ComplexF64, n, chi; periodic=true) # FIXME: fail to converge |
| 86 | + bp = BeliefPropgation(mps_uai) |
| 87 | + @test TensorInference.initial_state(bp) isa TensorInference.BPState |
| 88 | + state, info = belief_propagate(bp; max_iter=100, tol=1e-6) |
| 89 | + @test info.converged |
| 90 | + @test info.iterations < 100 |
| 91 | + contraction_res = TensorInference.contraction_results(state) |
| 92 | + tnet = TensorNetworkModel(mps_uai) |
| 93 | + mars = marginals(state) |
| 94 | + mars_tnet = marginals(tnet) |
| 95 | + for v in 1:TensorInference.num_variables(bp) |
| 96 | + @test TensorInference.message_converged(mars[[v]], mars_tnet[[v]]; atol=1e-4) |
| 97 | + end |
| 98 | +end |
| 99 | + |
81 | 100 | @testset "marginal uai2014" begin |
82 | 101 | for problem in [problem_from_artifact("uai2014", "MAR", "Promedus", 14), problem_from_artifact("uai2014", "MAR", "ObjectDetection", 42)] |
83 | 102 | optimizer = TreeSA(ntrials = 1, niters = 5, βs = 0.1:0.1:100) |
|
0 commit comments