2 GTSAM Copyright 2010-2021, Georgia Tech Research Corporation, 3 Atlanta, Georgia 30332-0415 6 See LICENSE for the license information 8 Unit tests for Discrete Bayes trees. 16 from gtsam
import (DiscreteBayesNet, DiscreteBayesTreeClique,
17 DiscreteConditional, DiscreteFactorGraph, Ordering)
22 """Tests for Discrete Bayes Nets.""" 25 """Test Multifrontal elimination.""" 28 keys = [(j, 2)
for j
in range(15)]
31 bayesNet = DiscreteBayesNet()
33 bayesNet.add(keys[0], [keys[8], keys[12]],
"2/3 1/4 3/2 4/1")
34 bayesNet.add(keys[1], [keys[8], keys[12]],
"4/1 2/3 3/2 1/4")
35 bayesNet.add(keys[2], [keys[9], keys[12]],
"1/4 8/2 2/3 4/1")
36 bayesNet.add(keys[3], [keys[9], keys[12]],
"1/4 2/3 3/2 4/1")
38 bayesNet.add(keys[4], [keys[10], keys[13]],
"2/3 1/4 3/2 4/1")
39 bayesNet.add(keys[5], [keys[10], keys[13]],
"4/1 2/3 3/2 1/4")
40 bayesNet.add(keys[6], [keys[11], keys[13]],
"1/4 3/2 2/3 4/1")
41 bayesNet.add(keys[7], [keys[11], keys[13]],
"1/4 2/3 3/2 4/1")
43 bayesNet.add(keys[8], [keys[12], keys[14]],
"T 1/4 3/2 4/1")
44 bayesNet.add(keys[9], [keys[12], keys[14]],
"4/1 2/3 F 1/4")
45 bayesNet.add(keys[10], [keys[13], keys[14]],
"1/4 3/2 2/3 4/1")
46 bayesNet.add(keys[11], [keys[13], keys[14]],
"1/4 2/3 3/2 4/1")
48 bayesNet.add(keys[12], [keys[14]],
"3/1 3/1")
49 bayesNet.add(keys[13], [keys[14]],
"1/3 3/1")
51 bayesNet.add(keys[14],
"1/3")
54 factorGraph = DiscreteFactorGraph(bayesNet)
60 bayesTree = factorGraph.eliminateMultifrontal(ordering)
68 self.assertFalse(bayesTree.empty())
69 self.assertEqual(12, bayesTree.size())
73 self.assertIsInstance(root, DiscreteBayesTreeClique)
74 self.assertTrue(root.isRoot())
75 self.assertIsInstance(root.conditional(), DiscreteConditional)
78 if __name__ ==
"__main__":
def test_elimination(self)
Double_ range(const Point2_ &p, const Point2_ &q)