Skip to content

Replace eval with macros #12

@GiggleLiu

Description

@GiggleLiu

The minimum fix should be like

using JunctionTrees

problem_number = "34"
problem_filename = joinpath("Promedus_" * problem_number)
problem_dir = joinpath(@__DIR__, "../examples/problems/Promedus/", problem_number)
uai_filepath = joinpath(problem_dir, problem_filename * ".uai")
uai_evid_filepath = joinpath(problem_dir, problem_filename * ".uai.evid")
uai_mar_filepath = joinpath(problem_dir, problem_filename * ".uai.MAR")
td_filepath = joinpath(problem_dir, problem_filename * ".tamaki.td")

reference_marginals = JunctionTrees.read_uai_mar_file(uai_mar_filepath)
obsvars, obsvals = JunctionTrees.read_uai_evid_file(uai_evid_filepath)

# ------------------------------------------------------------------------------
# Posterior marginals given evidence
# ------------------------------------------------------------------------------

macro inferencemodel(uai_filepath, uai_evid_filepath)
    compile_algo(
            eval(uai_filepath),
            uai_evid_filepath = eval(uai_evid_filepath),
        )
end

algo = @inferencemodel uai_filepath uai_evid_filepath

marginals = algo(obsvars, obsvals) |> x -> map(y -> y.vals, x)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions