Safe Haskell | Safe-Infered |
---|
Algorithms for factor elimination
- moralGraph :: (NamedGraph g, FoldableWithVertex g, DirectedGraph g) => g () b -> UndirectedSG () b
- nodeComparisonForTriangulation :: (UndirectedGraph g, Factor f) => g a f -> Vertex -> Vertex -> Ordering
- numberOfAddedEdges :: UndirectedGraph g => g a b -> Vertex -> Int
- triangulate :: Graph g => (Vertex -> Vertex -> Ordering) -> g () b -> ([VertexCluster], g () b)
- minimumSpanningTree :: UndirectedGraph g => g Int f -> Tree () f
- createClusterGraph :: UndirectedGraph g => [VertexCluster] -> g Int VertexCluster
- data Cluster
- createJunctionTree :: (DirectedGraph g, FoldableWithVertex g, NamedGraph g, Factor f, Show f) => (UndirectedSG () f -> Vertex -> Vertex -> Ordering) -> BayesianNetwork g f -> JunctionTree f
- type JunctionTree f = Tree (Separator f) (JTNodeValue f)
- collect :: Factor f => JunctionTree f -> JunctionTree f
- distribute :: Factor f => Maybe (Separator f) -> JunctionTree f -> JunctionTree f
- posterior :: Factor f => JunctionTree f -> DV -> Maybe f
- clearEvidence :: Factor f => JunctionTree f -> JunctionTree f
- updateEvidence :: Factor f => DVISet Int -> JunctionTree f -> JunctionTree f
- junctionTreeProperty_prop :: DirectedSG () String -> Property
- createVerticesJunctionTree :: (DirectedGraph g, FoldableWithVertex g, NamedGraph g) => (UndirectedSG () b -> Vertex -> Vertex -> Ordering) -> g () b -> Tree () VertexCluster
- data VertexCluster
Moral graph
moralGraph :: (NamedGraph g, FoldableWithVertex g, DirectedGraph g) => g () b -> UndirectedSG () bSource
For the junction tree construction, only the vertices are needed during the intermediate steps. So, the moral graph is returned without any vertex data.
Triangulation
nodeComparisonForTriangulation :: (UndirectedGraph g, Factor f) => g a f -> Vertex -> Vertex -> OrderingSource
Node selection comparison function used for triangulating the graph
numberOfAddedEdges :: UndirectedGraph g => g a b -> Vertex -> IntSource
Number of edges added when connecting all neighbors
:: Graph g | |
=> (Vertex -> Vertex -> Ordering) | Criterion function for triangulation |
-> g () b | |
-> ([VertexCluster], g () b) | Returns the clusters and the triangulated graph |
Triangulate a graph using a cost function The result is the triangulated graph and the list of clusters which may not be maximal.
Junction tree
minimumSpanningTree :: UndirectedGraph g => g Int f -> Tree () fSource
Implementing the Prim's algorithm for minimum spanning tree
createClusterGraph :: UndirectedGraph g => [VertexCluster] -> g Int VertexClusterSource
Create the cluster graph
Cluster of discrete variables.
Discrete variables instead of vertices are needed because the
factor are using DV
and we need to find
which factors must be contained in a given cluster.
:: (DirectedGraph g, FoldableWithVertex g, NamedGraph g, Factor f, Show f) | |
=> (UndirectedSG () f -> Vertex -> Vertex -> Ordering) | Weight function on the moral graph |
-> BayesianNetwork g f | Input directed graph |
-> JunctionTree f | Junction tree |
Create a function tree
type JunctionTree f = Tree (Separator f) (JTNodeValue f)Source
The junction tree
Shenoy-Shafer message passing
collect :: Factor f => JunctionTree f -> JunctionTree fSource
Collect phase of the junction tree
distribute :: Factor f => Maybe (Separator f) -> JunctionTree f -> JunctionTree fSource
Distribute phase of the junction tree
posterior :: Factor f => JunctionTree f -> DV -> Maybe fSource
Compute the marginal posterior (if some evidence is set on the junction tree) otherwise compute just the marginal prior.
Evidence
clearEvidence :: Factor f => JunctionTree f -> JunctionTree fSource
Remove evidence in the junction tree
updateEvidence :: Factor f => DVISet Int -> JunctionTree f -> JunctionTree fSource
Update evidence in the tree
Test
createVerticesJunctionTreeSource
:: (DirectedGraph g, FoldableWithVertex g, NamedGraph g) | |
=> (UndirectedSG () b -> Vertex -> Vertex -> Ordering) | Weight function on the moral graph |
-> g () b | Input directed graph |
-> Tree () VertexCluster | Junction tree |
Create a junction tree with only the clusters and no factors
data VertexCluster Source
A cluster containing only the vertices and not yet the factors
Eq VertexCluster | |
Show VertexCluster | |
Show (Tree () VertexCluster) |