35 using namespace gtsam;
40 using namespace serializationTestHelpers;
56 "gtsam_GaussianMixtureFactor_Factors");
58 "gtsam_GaussianMixtureFactor_Factors_Leaf");
60 "gtsam_GaussianMixtureFactor_Factors_Choice");
64 "gtsam_GaussianMixture_Conditionals");
66 "gtsam_GaussianMixture_Conditionals_Leaf");
68 "gtsam_GaussianMixture_Conditionals_Choice");
76 TEST(HybridSerialization, GaussianMixtureFactor) {
80 auto A = Matrix::Zero(2, 1);
81 auto b0 = Matrix::Zero(2, 1);
82 auto b1 = Matrix::Ones(2, 1);
83 auto f0 = std::make_shared<JacobianFactor>(
X(0),
A, b0);
84 auto f1 = std::make_shared<JacobianFactor>(
X(0),
A,
b1);
85 std::vector<GaussianFactor::shared_ptr>
factors{f0, f1};
87 const GaussianMixtureFactor factor(continuousKeys, discreteKeys,
factors);
89 EXPECT(equalsObj<GaussianMixtureFactor>(factor));
90 EXPECT(equalsXML<GaussianMixtureFactor>(factor));
91 EXPECT(equalsBinary<GaussianMixtureFactor>(factor));
99 const auto conditional = std::make_shared<GaussianConditional>(
100 GaussianConditional::FromMeanAndStddev(
Z(0), I,
X(0),
Vector1(0), 0.5));
103 EXPECT(equalsObj<HybridConditional>(hc));
104 EXPECT(equalsXML<HybridConditional>(hc));
105 EXPECT(equalsBinary<HybridConditional>(hc));
113 const auto conditional0 = std::make_shared<GaussianConditional>(
114 GaussianConditional::FromMeanAndStddev(
Z(0), I,
X(0),
Vector1(0), 0.5));
115 const auto conditional1 = std::make_shared<GaussianConditional>(
116 GaussianConditional::FromMeanAndStddev(
Z(0), I,
X(0),
Vector1(0), 3));
118 {conditional0, conditional1});
120 EXPECT(equalsObj<GaussianMixture>(gm));
121 EXPECT(equalsXML<GaussianMixture>(gm));
122 EXPECT(equalsBinary<GaussianMixture>(gm));
131 EXPECT(equalsObj<HybridBayesNet>(hbn));
132 EXPECT(equalsXML<HybridBayesNet>(hbn));
133 EXPECT(equalsBinary<HybridBayesNet>(hbn));
142 EXPECT(equalsObj<HybridBayesTree>(hbt));
143 EXPECT(equalsXML<HybridBayesTree>(hbt));
144 EXPECT(equalsBinary<HybridBayesTree>(hbt));
A set of GaussianFactors, indexed by a set of discrete keys.
A hybrid conditional in the Conditional Linear Gaussian scheme.
Matrix< RealScalar, Dynamic, Dynamic > M
static int runAllTests(TestResult &result)
Eigen::Matrix< double, 1, 1 > Vector1
Implementation of a discrete conditional mixture factor. Implements a joint discrete-continuous facto...
const GaussianFactorGraph factors
A Bayes net of Gaussian Conditionals indexed by discrete keys.
HybridGaussianFactorGraph linearizedFactorGraph
A conditional of gaussian mixtures indexed by discrete variables, as part of a Bayes Network...
Hybrid Bayes Tree, the result of eliminating a HybridJunctionTree.
#define EXPECT(condition)
TEST(HybridSerialization, GaussianMixtureFactor)
std::shared_ptr< BayesNetType > eliminateSequential(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
Conditional Gaussian Base class.
static sharedNode Leaf(Key key, const SymbolicFactorGraph &factors)
Point2 f1(const Point3 &p, OptionalJacobian< 2, 3 > H)
std::pair< Key, size_t > DiscreteKey
std::shared_ptr< BayesTreeType > eliminateMultifrontal(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
BOOST_CLASS_EXPORT_GUID(Factor, "gtsam_Factor")
static const DiscreteKey mode(modeKey, 2)
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
The matrix class, also used for vectors and row-vectors.
DiscreteKeys is a set of keys that can be assembled using the & operator.