Make HybridBayesTree testable and add serialization
parent
8692ae63ea
commit
b16b05ea2c
|
@ -89,8 +89,20 @@ class GTSAM_EXPORT HybridBayesTree : public BayesTree<HybridBayesTreeClique> {
|
||||||
VectorValues optimize(const DiscreteValues& assignment) const;
|
VectorValues optimize(const DiscreteValues& assignment) const;
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** Serialization function */
|
||||||
|
friend class boost::serialization::access;
|
||||||
|
template <class ARCHIVE>
|
||||||
|
void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
|
||||||
|
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// traits
|
||||||
|
template <>
|
||||||
|
struct traits<HybridBayesTree> : public Testable<HybridBayesTree> {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Class for Hybrid Bayes tree orphan subtrees.
|
* @brief Class for Hybrid Bayes tree orphan subtrees.
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* @date August 2022
|
* @date August 2022
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <gtsam/base/serializationTestHelpers.h>
|
||||||
#include <gtsam/discrete/DiscreteFactorGraph.h>
|
#include <gtsam/discrete/DiscreteFactorGraph.h>
|
||||||
#include <gtsam/hybrid/HybridBayesTree.h>
|
#include <gtsam/hybrid/HybridBayesTree.h>
|
||||||
#include <gtsam/hybrid/HybridGaussianISAM.h>
|
#include <gtsam/hybrid/HybridGaussianISAM.h>
|
||||||
|
@ -143,6 +144,20 @@ TEST(HybridBayesTree, Optimize) {
|
||||||
EXPECT(assert_equal(expectedValues, delta.continuous()));
|
EXPECT(assert_equal(expectedValues, delta.continuous()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ****************************************************************************/
|
||||||
|
// Test HybridBayesTree serialization.
|
||||||
|
TEST(HybridBayesTree, Serialization) {
|
||||||
|
Switching s(4);
|
||||||
|
Ordering ordering = s.linearizedFactorGraph.getHybridOrdering();
|
||||||
|
HybridBayesTree hbt =
|
||||||
|
*(s.linearizedFactorGraph.eliminateMultifrontal(ordering));
|
||||||
|
|
||||||
|
using namespace gtsam::serializationTestHelpers;
|
||||||
|
EXPECT(equalsObj<HybridBayesTree>(hbt));
|
||||||
|
EXPECT(equalsXML<HybridBayesTree>(hbt));
|
||||||
|
EXPECT(equalsBinary<HybridBayesTree>(hbt));
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
int main() {
|
int main() {
|
||||||
TestResult tr;
|
TestResult tr;
|
||||||
|
|
Loading…
Reference in New Issue