GraphicalModelLearning.jl icon indicating copy to clipboard operation
GraphicalModelLearning.jl copied to clipboard

Proposal for Graphical Model Data Structure

Open ccoffrin opened this issue 8 years ago • 4 comments

For now we assume discrete models. (something) indicates that something is optional, everything else is required.

A Julia data-structure that can be serialized to JSON as follows,

{
"order":<int>,
"variable_count":<int>,
"alphabet":[<int>,<int>,...,<int>],
"symmetric":<bool>,
("variable_names":[<string>,<string>,...,<string>],)
"terms":[
  {"weight":<float>, "variables":[<int>, <int>,...,<int>]},
  ...
]
}

All values in alphabet should be unique. For now we will require the alphabet to be [-1, 1].

The arrays variable_names must be the same length that is specified by variable_count. The length of variables should be less than or equal to the value of order.

if symmetric is true, then the values in variables should be increasing. All non-increasing orders can be added to the increasing one. Similarly, multiple references to the same variable can be collapsed into lower order terms.

Inside of Julia, it would be nice if the weights could be accessed using a multidimensional array syntax (gm[1,2,4,8]).

ccoffrin avatar Nov 13 '17 16:11 ccoffrin

Should variables be numbered from 0..variable_count-1 or 1..variable_count?

ccoffrin avatar Nov 13 '17 16:11 ccoffrin

Can we enumerate all useful alphabets, e.g. spin, boolean, integer, integer+, real, real+? If so, this is probably better than allowing the user to specify any arbitrary alphabet. integer+ and real+ include 0.

ccoffrin avatar Nov 13 '17 16:11 ccoffrin

Called FactorGraph, are always symmetric

marc-vuffray avatar Nov 13 '17 17:11 marc-vuffray

We can consider a type like this

type FactorGraph{T <: Real, N}
    order::Int
    varible_count::Int
    alphabet::Symbol
    terms::Vector{Dict{Tuple,T}} 
    variable_names::Nullable{Vector{String}}
    FactorGraph(a,b,c) = new(N, a, b, [Dict{Tuple,T}() for n in 1:N], c)
end

If we want the order parameter to be part of the type signature.

ccoffrin avatar Nov 22 '17 05:11 ccoffrin