diff --git a/gtsam/hybrid/HybridGaussianConditional.cpp b/gtsam/hybrid/HybridGaussianConditional.cpp index 2a0b5a875b..58724163ec 100644 --- a/gtsam/hybrid/HybridGaussianConditional.cpp +++ b/gtsam/hybrid/HybridGaussianConditional.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/gtsam/hybrid/HybridGaussianConditional.h b/gtsam/hybrid/HybridGaussianConditional.h index 75138b0dc2..4cc3d31960 100644 --- a/gtsam/hybrid/HybridGaussianConditional.h +++ b/gtsam/hybrid/HybridGaussianConditional.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/gtsam/hybrid/HybridGaussianProductFactor.cpp b/gtsam/hybrid/HybridGaussianProductFactor.cpp index f7b5994f0f..280059f542 100644 --- a/gtsam/hybrid/HybridGaussianProductFactor.cpp +++ b/gtsam/hybrid/HybridGaussianProductFactor.cpp @@ -103,4 +103,10 @@ HybridGaussianProductFactor HybridGaussianProductFactor::removeEmpty() const { return {Base(*this, emptyGaussian)}; } +/* *******************************************************************************/ +std::istream& operator>>(std::istream& is, GaussianFactorGraphValuePair& pair) { + // Dummy, don't do anything + return is; +} + } // namespace gtsam diff --git a/gtsam/hybrid/HybridGaussianProductFactor.h b/gtsam/hybrid/HybridGaussianProductFactor.h index 508113e874..60a58a3a51 100644 --- a/gtsam/hybrid/HybridGaussianProductFactor.h +++ b/gtsam/hybrid/HybridGaussianProductFactor.h @@ -22,6 +22,8 @@ #include #include +#include + namespace gtsam { class HybridGaussianFactor; @@ -115,6 +117,16 @@ class GTSAM_EXPORT HybridGaussianProductFactor HybridGaussianProductFactor removeEmpty() const; ///@} + + private: +#ifdef GTSAM_ENABLE_BOOST_SERIALIZATION + /** Serialization function */ + friend class boost::serialization::access; + template + void serialize(Archive& ar, const unsigned int /*version*/) { + ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base); + } +#endif }; // Testable traits @@ -122,4 +134,14 @@ template <> struct traits : public Testable {}; +/** + * Create a dummy overload of >> for GaussianFactorGraphValuePair + * so that HybridGaussianProductFactor compiles + * with the constructor + * `DecisionTree(const std::vector& labelCs, const std::string& table)`. + * + * Needed to compile on Windows. + */ +std::istream& operator>>(std::istream& is, GaussianFactorGraphValuePair& pair); + } // namespace gtsam diff --git a/gtsam/hybrid/tests/testHybridGaussianFactor.cpp b/gtsam/hybrid/tests/testHybridGaussianFactor.cpp index 71aac8224b..05e05c79b7 100644 --- a/gtsam/hybrid/tests/testHybridGaussianFactor.cpp +++ b/gtsam/hybrid/tests/testHybridGaussianFactor.cpp @@ -104,13 +104,12 @@ TEST(HybridGaussianFactor, Keys) { } /* ************************************************************************* */ -TEST_DISABLED(HybridGaussianFactor, Printing) { +TEST(HybridGaussianFactor, Printing) { using namespace test_constructor; HybridGaussianFactor hybridFactor(m1, {f10, f11}); std::string expected = - R"(HybridGaussianFactor -Hybrid [x1 x2; 1]{ + R"(Hybrid [x1 x2; 1]{ Choice(1) 0 Leaf : A[x1] = [ diff --git a/gtsam/hybrid/tests/testHybridNonlinearFactorGraph.cpp b/gtsam/hybrid/tests/testHybridNonlinearFactorGraph.cpp index b5486c6cdb..bbf427ecb2 100644 --- a/gtsam/hybrid/tests/testHybridNonlinearFactorGraph.cpp +++ b/gtsam/hybrid/tests/testHybridNonlinearFactorGraph.cpp @@ -529,7 +529,7 @@ TEST(HybridNonlinearFactorGraph, Full_Elimination) { /**************************************************************************** * Test printing */ -TEST_DISABLED(HybridNonlinearFactorGraph, Printing) { +TEST(HybridNonlinearFactorGraph, Printing) { Switching self(3); auto linearizedFactorGraph = self.linearizedFactorGraph; @@ -549,7 +549,7 @@ Factor 0 GaussianFactor: A[x0] = [ - 10 + 10 ] b = [ -10 ] No noise model @@ -560,25 +560,25 @@ Hybrid [x0 x1; m0]{ Choice(m0) 0 Leaf : A[x0] = [ - -1 + -1 ] A[x1] = [ - 1 + 1 ] b = [ -1 ] No noise model -scalar: 0 +scalar: 0.918939 1 Leaf : A[x0] = [ - -1 + -1 ] A[x1] = [ - 1 + 1 ] b = [ -0 ] No noise model -scalar: 0 +scalar: 0.918939 } @@ -588,25 +588,25 @@ Hybrid [x1 x2; m1]{ Choice(m1) 0 Leaf : A[x1] = [ - -1 + -1 ] A[x2] = [ - 1 + 1 ] b = [ -1 ] No noise model -scalar: 0 +scalar: 0.918939 1 Leaf : A[x1] = [ - -1 + -1 ] A[x2] = [ - 1 + 1 ] b = [ -0 ] No noise model -scalar: 0 +scalar: 0.918939 } @@ -614,7 +614,7 @@ Factor 3 GaussianFactor: A[x1] = [ - 10 + 10 ] b = [ -10 ] No noise model @@ -623,7 +623,7 @@ Factor 4 GaussianFactor: A[x2] = [ - 10 + 10 ] b = [ -10 ] No noise model diff --git a/gtsam/hybrid/tests/testSerializationHybrid.cpp b/gtsam/hybrid/tests/testSerializationHybrid.cpp index 8258d8615e..5b06312ba4 100644 --- a/gtsam/hybrid/tests/testSerializationHybrid.cpp +++ b/gtsam/hybrid/tests/testSerializationHybrid.cpp @@ -59,6 +59,11 @@ BOOST_CLASS_EXPORT_GUID(HybridGaussianFactor::FactorValuePairs::Leaf, BOOST_CLASS_EXPORT_GUID(HybridGaussianFactor::FactorValuePairs::Choice, "gtsam_HybridGaussianFactor_Factors_Choice"); +BOOST_CLASS_EXPORT_GUID(GaussianFactorGraphValuePair, + "gtsam_GaussianFactorGraphValuePair"); +BOOST_CLASS_EXPORT_GUID(HybridGaussianProductFactor, + "gtsam_HybridGaussianProductFactor"); + BOOST_CLASS_EXPORT_GUID(HybridGaussianConditional, "gtsam_HybridGaussianConditional"); BOOST_CLASS_EXPORT_GUID(HybridGaussianConditional::Conditionals,