Skip to content

Commit e1a3945

Browse files
committed
add uai test
1 parent c2d3075 commit e1a3945

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/belief.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,28 @@ end
7272
for v in 1:TensorInference.num_variables(bp)
7373
@test mars[[v]] mars_tnet[[v]] atol=1e-4
7474
end
75+
end
76+
77+
@testset "marginal uai2014" begin
78+
for problem in [problem_from_artifact("uai2014", "MAR", "Promedus", 14), problem_from_artifact("uai2014", "MAR", "ObjectDetection", 42)]
79+
optimizer = TreeSA(ntrials = 1, niters = 5, βs = 0.1:0.1:100)
80+
evidence = Dict{Int, Int}()
81+
model = read_model(problem)
82+
83+
tn = TensorNetworkModel(model; optimizer, evidence)
84+
mars_tnet = marginals(tn)
85+
86+
code = tn.code.eins
87+
tensors = tn.tensors
88+
size_dict = Dict(i => d for (i, d) in enumerate(model.cards))
89+
90+
bp = BeliefPropgation(model)
91+
state, info = belief_propagate(bp; max_iter=300, tol=1e-6)
92+
@test info.converged
93+
mars = marginals(state)
94+
95+
for v in 1:TensorInference.num_variables(bp)
96+
@test mars[[v]] mars_tnet[[v]] atol=1e-2
97+
end
98+
end
7599
end

0 commit comments

Comments
 (0)