serialization support for DecisionTreeFactor
parent
99a3fbac2c
commit
2653c2f8fb
|
|
@ -231,6 +231,16 @@ namespace gtsam {
|
|||
const Names& names = {}) const override;
|
||||
|
||||
/// @}
|
||||
|
||||
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);
|
||||
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(ADT);
|
||||
ar& BOOST_SERIALIZATION_NVP(cardinalities_);
|
||||
}
|
||||
};
|
||||
|
||||
// traits
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include <CppUnitLite/TestHarness.h>
|
||||
#include <gtsam/base/Testable.h>
|
||||
#include <gtsam/base/serializationTestHelpers.h>
|
||||
#include <gtsam/discrete/DecisionTreeFactor.h>
|
||||
#include <gtsam/discrete/DiscreteDistribution.h>
|
||||
#include <gtsam/discrete/Signature.h>
|
||||
|
|
@ -220,6 +221,30 @@ TEST(DecisionTreeFactor, htmlWithValueFormatter) {
|
|||
EXPECT(actual == expected);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
BOOST_CLASS_EXPORT_GUID(DecisionTreeFactor, "gtsam_DecisionTreeFactor");
|
||||
using ADT = AlgebraicDecisionTree<Key>;
|
||||
BOOST_CLASS_EXPORT_GUID(ADT, "gtsam_AlgebraicDecisionTree");
|
||||
BOOST_CLASS_EXPORT_GUID(ADT::Leaf, "gtsam_DecisionTree_Leaf")
|
||||
BOOST_CLASS_EXPORT_GUID(ADT::Choice, "gtsam_DecisionTree_Choice")
|
||||
|
||||
// Check serialization for AlgebraicDecisionTree and the DecisionTreeFactor
|
||||
TEST(DecisionTreeFactor, Serialization) {
|
||||
using namespace serializationTestHelpers;
|
||||
|
||||
DiscreteKey A(1, 2), B(2, 2), C(3, 2);
|
||||
|
||||
DecisionTreeFactor::ADT tree(A & B & C, "1 5 3 7 2 6 4 8");
|
||||
EXPECT(equalsObj<ADT>(tree));
|
||||
EXPECT(equalsXML<DecisionTreeFactor::ADT>(tree));
|
||||
EXPECT(equalsBinary<DecisionTreeFactor::ADT>(tree));
|
||||
|
||||
DecisionTreeFactor f(A & B & C, "1 5 3 7 2 6 4 8");
|
||||
EXPECT(equalsObj<DecisionTreeFactor>(f));
|
||||
EXPECT(equalsXML<DecisionTreeFactor>(f));
|
||||
EXPECT(equalsBinary<DecisionTreeFactor>(f));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
int main() {
|
||||
TestResult tr;
|
||||
|
|
|
|||
Loading…
Reference in New Issue