jluttine / junction-tree

The junction tree algorithm for (discrete) factor graphs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

None in factor_to_maxclique

jluttine opened this issue · comments

Here's a simple example of a bug:

>>> import junctiontree as jt
>>> jt.create_junction_tree([ ["x"], ["x", "y"], ["x", "y"] ], {"x":2, "y":3})
JunctionTree(tree=[0], separators=[], clique_tree=CliqueGraph(maxcliques=[['x', 'y']], factor_to_maxclique=[None, None, 0], factor_graph=FactorGraph(factors=[['x'], ['x', 'y'], ['x', 'y']], sizes={'x': 2, 'y': 3})))

The problem is Nones in factor_to_maxclique.

@dar326 Any ideas?

The issue happens during triangulation:

>>> fg = jt.FactorGraph([ ["x", "y"], ["x", "y"] ], {"x":2, "y":3})

>>> fg
FactorGraph(factors=[['x', 'y'], ['x', 'y']], sizes={'x': 2, 'y': 3})

>>> fg.triangulate()
CliqueGraph(maxcliques=[['x', 'y']], factor_to_maxclique=[None, 0], factor_graph=FactorGraph(factors=[['x', 'y'], ['x', 'y']], sizes={'x': 2, 'y': 3}))

Or in lower level:

>>> from junctiontree import beliefpropagation as bp
>>> bp.find_triangulation([ ["x", "y"], ["x", "y"] ], {"x":2, "y":3})
([], [['y', 'x'], ['y']], [['x', 'y']], [None, 0])

The code did not support duplicate factors in the factor graph used to construct the junction tree. The changes implemented in #3 fixed this issue so that this library supports factor graphs with duplicate factors.

Closing this ticket.

Nice, thanks!