@@ -7,15 +7,15 @@ format.
77The UAI file formats are defined in:
88https://personal.utdallas.edu/~vibhav.gogate/uai16-evaluation/uaiformat.html
99"""
10- function read_uai_file (uai_filepath; factor_eltype = Float64)
10+ function read_model_file (uai_filepath; factor_eltype = Float64)
1111 # Read the uai file into an array of lines
1212 str = open (uai_filepath) do file
1313 read (file, String)
1414 end
15- return read_uai_string (str; factor_eltype)
15+ return read_model_string (str; factor_eltype)
1616end
1717
18- function read_uai_string (str; factor_eltype = Float64)
18+ function read_model_string (str; factor_eltype = Float64)
1919 rawlines = split (str, " \n " )
2020 # Filter out empty lines
2121 lines = filter (! isempty, rawlines)
@@ -71,7 +71,7 @@ file path is an empty string, return empty vectors.
7171The UAI file formats are defined in:
7272https://personal.utdallas.edu/~vibhav.gogate/uai16-evaluation/uaiformat.html
7373"""
74- function read_uai_evid_file (uai_evid_filepath:: AbstractString )
74+ function read_evidence_file (uai_evid_filepath:: AbstractString )
7575 if isempty (uai_evid_filepath)
7676 # No evidence
7777 return Int64[], Int64[]
@@ -104,7 +104,7 @@ as in the model
104104The UAI file formats are defined in:
105105https://personal.utdallas.edu/~vibhav.gogate/uai16-evaluation/uaiformat.html
106106"""
107- function read_uai_mar_file (uai_mar_filepath:: AbstractString ; factor_eltype = Float64)
107+ function read_solution_file (uai_mar_filepath:: AbstractString ; factor_eltype = Float64)
108108
109109 # Read the uai mar file into an array of lines
110110 rawlines = open (uai_mar_filepath) do file
@@ -175,17 +175,22 @@ end
175175"""
176176$(TYPEDSIGNATURES)
177177
178- Read a UAI problem from a file.
178+ Read a UAI problem instance from a file.
179179"""
180- function uai_problem_from_file (uai_filepath:: String ; uai_evid_filepath:: String = " " , uai_mar_filepath:: String = " " , eltype = Float64):: UAIInstance
181- nvars, cards, ncliques, factors = read_uai_file (uai_filepath; factor_eltype = eltype)
182- obsvars, obsvals = read_uai_evid_file (uai_evid_filepath)
183- reference_marginals = isempty (uai_mar_filepath) ? Vector{eltype}[] : read_uai_mar_file (uai_mar_filepath)
180+ function read_instance (
181+ uai_filepath:: AbstractString ;
182+ uai_evid_filepath:: AbstractString = " " ,
183+ uai_mar_filepath:: AbstractString = " " ,
184+ eltype = Float64
185+ ):: UAIInstance
186+ nvars, cards, ncliques, factors = read_model_file (uai_filepath; factor_eltype = eltype)
187+ obsvars, obsvals = read_evidence_file (uai_evid_filepath)
188+ reference_marginals = isempty (uai_mar_filepath) ? Vector{eltype}[] : read_solution_file (uai_mar_filepath)
184189 return UAIInstance (nvars, ncliques, cards, factors, obsvars, obsvals, reference_marginals)
185190end
186191
187- function uai_problem_from_string (uai:: String ; eltype = Float64):: UAIInstance
188- nvars, cards, ncliques, factors = read_uai_string (uai; factor_eltype = eltype)
192+ function read_instance_from_string (uai:: AbstractString ; eltype = Float64):: UAIInstance
193+ nvars, cards, ncliques, factors = read_model_string (uai; factor_eltype = eltype)
189194 return UAIInstance (nvars, ncliques, cards, factors, Int[], Int[], Vector{eltype}[])
190195end
191196
0 commit comments