|
13 | 13 |
|
14 | 14 | @testset "cached, rescaled contract" begin |
15 | 15 | model_filepath, evidence_filepath, solution_filepath = get_instance_filepaths("Promedus_14", "MAR") |
16 | | - problem = read_instance(model_filepath; evidence_filepath, solution_filepath) |
17 | | - ref_sol = problem.reference_marginals |
| 16 | + instance = read_instance(model_filepath; evidence_filepath, solution_filepath) |
| 17 | + ref_sol = instance.reference_marginals |
18 | 18 | optimizer = TreeSA(ntrials = 1, niters = 5, βs = 0.1:0.1:100) |
19 | | - tn = TensorNetworkModel(problem; optimizer) |
| 19 | + tn = TensorNetworkModel(instance; optimizer) |
20 | 20 | p1 = probability(tn; usecuda = false, rescale = false) |
21 | 21 | p2 = probability(tn; usecuda = false, rescale = true) |
22 | 22 | @test p1 ≈ Array(p2) |
|
30 | 30 |
|
31 | 31 | # compute marginals |
32 | 32 | ti_sol = marginals(tn) |
33 | | - ref_sol[problem.obsvars] .= fill([1.0], length(problem.obsvars)) # imitate dummy vars |
| 33 | + ref_sol[instance.obsvars] .= fill([1.0], length(instance.obsvars)) # imitate dummy vars |
34 | 34 | @test isapprox(ti_sol, ref_sol; atol = 1e-5) |
35 | 35 | end |
36 | 36 |
|
37 | | -function get_problems(problem_set::String) |
| 37 | +function get_problems_names(problem_set::String) |
38 | 38 | # Capture the problem names that belong to the current problem_set |
39 | 39 | regex = Regex("($(problem_set)_\\d*)(\\.uai)\$") |
40 | 40 | return readdir(joinpath(artifact"uai2014", "MAR"); sort = false) |> |
|
61 | 61 | @testset "$(problem_set) problem_set" begin |
62 | 62 |
|
63 | 63 | # Capture the problem names that belong to the current problem set |
64 | | - problems = get_problems(problem_set) |
| 64 | + problem_names = get_problems_names(problem_set) |
65 | 65 |
|
66 | | - for problem in problems |
67 | | - @info "Testing: $problem" |
68 | | - @testset "$(problem)" begin |
69 | | - model_filepath, evidence_filepath, solution_filepath = get_instance_filepaths(problem, "MAR") |
70 | | - problem = read_instance(model_filepath; evidence_filepath, solution_filepath) |
71 | | - ref_sol = problem.reference_marginals |
72 | | - obsvars = problem.obsvars |
| 66 | + for problem_name in problem_names |
| 67 | + @info "Testing: $problem_name" |
| 68 | + @testset "$(problem_name)" begin |
| 69 | + model_filepath, evidence_filepath, solution_filepath = get_instance_filepaths(problem_name, "MAR") |
| 70 | + instance = read_instance(model_filepath; evidence_filepath, solution_filepath) |
| 71 | + ref_sol = instance.reference_marginals |
| 72 | + obsvars = instance.obsvars |
73 | 73 |
|
74 | 74 | # does not optimize over open vertices |
75 | | - tn = TensorNetworkModel(problem; optimizer) |
| 75 | + tn = TensorNetworkModel(instance; optimizer) |
76 | 76 | sc = contraction_complexity(tn).sc |
77 | 77 | sc > 28 && error("space complexity too large! got $(sc)") |
78 | 78 | @debug contraction_complexity(tn) |
|
0 commit comments