testHybridConditional.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 
20 #include "TinyHybridExample.h"
21 
22 // Include for test suite
24 
25 using namespace gtsam;
26 
30 
31 /* ****************************************************************************/
32 // Check invariants for all conditionals in a tiny Bayes net.
33 TEST(HybridConditional, Invariants) {
34  // Create hybrid Bayes net p(z|x,m)p(x)P(m)
35  auto bn = tiny::createHybridBayesNet();
36 
37  // Create values to check invariants.
38  const VectorValues c{{X(0), Vector1(5.1)}, {Z(0), Vector1(4.9)}};
39  const DiscreteValues d{{M(0), 1}};
40  const HybridValues values{c, d};
41 
42  // Check invariants for p(z|x,m)
43  auto hc0 = bn.at(0);
44  CHECK(hc0->isHybrid());
45 
46  // Check invariants as a GaussianMixture.
47  const auto mixture = hc0->asMixture();
49 
50  // Check invariants as a HybridConditional.
52 
53  // Check invariants for p(x)
54  auto hc1 = bn.at(1);
55  CHECK(hc1->isContinuous());
56 
57  // Check invariants as a GaussianConditional.
58  const auto gaussian = hc1->asGaussian();
61 
62  // Check invariants as a HybridConditional.
64 
65  // Check invariants for p(m)
66  auto hc2 = bn.at(2);
67  CHECK(hc2->isDiscrete());
68 
69  // Check invariants as a DiscreteConditional.
70  const auto discrete = hc2->asDiscrete();
73 
74  // Check invariants as a HybridConditional.
76 }
77 
78 /* ************************************************************************* */
79 int main() {
80  TestResult tr;
81  return TestRegistry::runAllTests(tr);
82 }
83 /* ************************************************************************* */
Key M(std::uint64_t j)
#define CHECK(condition)
Definition: Test.h:108
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:51
static int runAllTests(TestResult &result)
static bool CheckInvariants(const GaussianMixture &conditional, const VALUES &x)
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
leaf::MyValues values
Key X(std::uint64_t j)
Key Z(std::uint64_t j)
#define Z
Definition: icosphere.cpp:21
int main()
#define EXPECT(condition)
Definition: Test.h:150
Eigen::Matrix< double, 1, 1 > Vector1
Definition: Vector.h:41
traits
Definition: chartTesting.h:28
HybridBayesNet createHybridBayesNet(size_t num_measurements=1, bool manyModes=false)
TEST(SmartFactorBase, Pinhole)
const GaussianMixture mixture({Z(0)}, {X(0)}, {mode}, conditionals)
#define X
Definition: icosphere.cpp:20


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:38:22