30 using namespace gtsam;
45 expectedValues.
insert(
X(0), -0.999904 * Vector1::Ones());
46 expectedValues.
insert(
X(1), -0.99029 * Vector1::Ones());
47 expectedValues.
insert(
X(2), -1.00971 * Vector1::Ones());
48 expectedValues.
insert(
X(3), -1.0001 * Vector1::Ones());
62 for (
size_t i = 1;
i < 4;
i++) {
69 for (
size_t i = 4;
i <= 7;
i++) {
74 for (
size_t i = 7;
i <= 9;
i++) {
91 expected_delta.
insert(make_pair(
X(0), -Vector1::Ones()));
92 expected_delta.
insert(make_pair(
X(1), -Vector1::Ones()));
93 expected_delta.
insert(make_pair(
X(2), -Vector1::Ones()));
94 expected_delta.
insert(make_pair(
X(3), -Vector1::Ones()));
100 for (
size_t k = 0; k < s.
K; k++) ordering.push_back(
X(k));
102 const auto [hybridBayesNet, remainingFactorGraph] =
120 for (
size_t i = 1;
i < 4;
i++) {
127 for (
size_t i = 4;
i <= 6;
i++) {
132 for (
size_t i = 7;
i <= 9;
i++) {
142 for (
size_t k = 0; k < s.
K; k++) ordering.push_back(
X(k));
144 const auto [hybridBayesNet, remainingFactorGraph] =
148 for (
auto&&
f : *remainingFactorGraph) {
150 assert(discreteFactor);
156 vector<double> probs = {0.012519475, 0.041280228, 0.075018647, 0.081663656,
157 0.037152205, 0.12248971, 0.07349729, 0.08};
161 VectorValues expectedValues = hybridBayesNet->optimize(expectedMPE);
176 for (
size_t i = 1;
i < 4;
i++) {
183 for (
size_t i = 4;
i <= 6;
i++) {
188 for (
size_t i = 7;
i <= 9;
i++) {
195 assignment[
M(0)] = 1;
196 assignment[
M(1)] = 1;
197 assignment[
M(2)] = 1;
205 auto expected_gbt = bayesTree->choose(assignment);
Matrix< RealScalar, Dynamic, Dynamic > M
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
static int runAllTests(TestResult &result)
void update(const HybridGaussianFactorGraph &newFactors, const std::optional< size_t > &maxNrLeaves={}, const std::optional< Ordering > &ordering={}, const HybridBayesTree::Eliminate &function=HybridBayesTree::EliminationTraitsType::DefaultEliminate)
Perform update step with new factors.
std::shared_ptr< This > shared_ptr
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
std::pair< std::shared_ptr< BayesNetType >, std::shared_ptr< FactorGraphType > > eliminatePartialSequential(const Ordering &ordering, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
static const GaussianBayesNet gbn
iterator insert(const std::pair< Key, Vector > &key_value)
const VectorValues & continuous() const
Return the multi-dimensional vector values.
DiscreteValues optimize(OptionalOrderingType orderingType={}) const
Find the maximum probable explanation (MPE) by doing max-product.
TEST(HybridBayesTree, OptimizeMultifrontal)
static enum @1107 ordering
GaussianBayesTree choose(const DiscreteValues &assignment) const
Get the Gaussian Bayes Tree which corresponds to a specific discrete value assignment.
HybridGaussianFactorGraph linearizedFactorGraph
VectorValues optimize() const
Hybrid Bayes Tree, the result of eliminating a HybridJunctionTree.
#define EXPECT(condition)
HybridValues optimize() const
Optimize the hybrid Bayes tree by computing the MPE for the current set of discrete variables and usi...
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
NonlinearISAM isam(relinearizeInterval)
const sharedFactor at(size_t i) const
const DiscreteValues & discrete() const
Return the discrete values.
std::shared_ptr< BayesTreeType > eliminateMultifrontal(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
DiscreteKeys is a set of keys that can be assembled using the & operator.