Skip to content

Commit

Permalink
undo test change
Browse files Browse the repository at this point in the history
  • Loading branch information
varunagrawal committed Oct 9, 2024
1 parent e87d1fb commit 99a39e6
Showing 1 changed file with 108 additions and 106 deletions.
214 changes: 108 additions & 106 deletions gtsam/hybrid/tests/testSerializationHybrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,112 +39,114 @@ using symbol_shorthand::Z;

using namespace serializationTestHelpers;

// BOOST_CLASS_EXPORT_GUID(Factor, "gtsam_Factor");
// BOOST_CLASS_EXPORT_GUID(HybridFactor, "gtsam_HybridFactor");
// BOOST_CLASS_EXPORT_GUID(JacobianFactor, "gtsam_JacobianFactor");
// BOOST_CLASS_EXPORT_GUID(GaussianConditional, "gtsam_GaussianConditional");
// BOOST_CLASS_EXPORT_GUID(DiscreteConditional, "gtsam_DiscreteConditional");

// 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_AlgebraicDecisionTree_Leaf");
// BOOST_CLASS_EXPORT_GUID(ADT::Choice, "gtsam_AlgebraicDecisionTree_Choice")

// BOOST_CLASS_EXPORT_GUID(HybridGaussianFactor, "gtsam_HybridGaussianFactor");
// BOOST_CLASS_EXPORT_GUID(HybridGaussianFactor::FactorValuePairs,
// "gtsam_HybridGaussianFactor_Factors");
// BOOST_CLASS_EXPORT_GUID(HybridGaussianFactor::FactorValuePairs::Leaf,
// "gtsam_HybridGaussianFactor_Factors_Leaf");
// BOOST_CLASS_EXPORT_GUID(HybridGaussianFactor::FactorValuePairs::Choice,
// "gtsam_HybridGaussianFactor_Factors_Choice");

// BOOST_CLASS_EXPORT_GUID(GaussianFactorGraphValuePair,
// "gtsam_GaussianFactorGraphValuePair");

// BOOST_CLASS_EXPORT_GUID(HybridGaussianConditional,
// "gtsam_HybridGaussianConditional");
// BOOST_CLASS_EXPORT_GUID(HybridGaussianConditional::Conditionals,
// "gtsam_HybridGaussianConditional_Conditionals");
// BOOST_CLASS_EXPORT_GUID(HybridGaussianConditional::Conditionals::Leaf,
// "gtsam_HybridGaussianConditional_Conditionals_Leaf");
// BOOST_CLASS_EXPORT_GUID(HybridGaussianConditional::Conditionals::Choice,
// "gtsam_HybridGaussianConditional_Conditionals_Choice");
// // Needed since GaussianConditional::FromMeanAndStddev uses it
// BOOST_CLASS_EXPORT_GUID(noiseModel::Isotropic, "gtsam_noiseModel_Isotropic");

// BOOST_CLASS_EXPORT_GUID(HybridBayesNet, "gtsam_HybridBayesNet");

// /* ****************************************************************************/
// // Test HybridGaussianFactor serialization.
// TEST(HybridSerialization, HybridGaussianFactor) {
// DiscreteKey discreteKey{M(0), 2};

// auto A = Matrix::Zero(2, 1);
// auto b0 = Matrix::Zero(2, 1);
// auto b1 = Matrix::Ones(2, 1);
// auto f0 = std::make_shared<JacobianFactor>(X(0), A, b0);
// auto f1 = std::make_shared<JacobianFactor>(X(0), A, b1);
// std::vector<GaussianFactor::shared_ptr> factors{f0, f1};

// const HybridGaussianFactor factor(discreteKey, factors);

// EXPECT(equalsObj<HybridGaussianFactor>(factor));
// EXPECT(equalsXML<HybridGaussianFactor>(factor));
// EXPECT(equalsBinary<HybridGaussianFactor>(factor));
// }

// /* ****************************************************************************/
// // Test HybridConditional serialization.
// TEST(HybridSerialization, HybridConditional) {
// const DiscreteKey mode(M(0), 2);
// Matrix1 I = Matrix1::Identity();
// const auto conditional = std::make_shared<GaussianConditional>(
// GaussianConditional::FromMeanAndStddev(Z(0), I, X(0), Vector1(0), 0.5));
// const HybridConditional hc(conditional);

// EXPECT(equalsObj<HybridConditional>(hc));
// EXPECT(equalsXML<HybridConditional>(hc));
// EXPECT(equalsBinary<HybridConditional>(hc));
// }

// /* ****************************************************************************/
// // Test HybridGaussianConditional serialization.
// TEST(HybridSerialization, HybridGaussianConditional) {
// const DiscreteKey mode(M(0), 2);
// Matrix1 I = Matrix1::Identity();
// const auto conditional0 = std::make_shared<GaussianConditional>(
// GaussianConditional::FromMeanAndStddev(Z(0), I, X(0), Vector1(0), 0.5));
// const auto conditional1 = std::make_shared<GaussianConditional>(
// GaussianConditional::FromMeanAndStddev(Z(0), I, X(0), Vector1(0), 3));
// const HybridGaussianConditional gm(mode, {conditional0, conditional1});

// EXPECT(equalsObj<HybridGaussianConditional>(gm));
// EXPECT(equalsXML<HybridGaussianConditional>(gm));
// EXPECT(equalsBinary<HybridGaussianConditional>(gm));
// }

// /* ****************************************************************************/
// // Test HybridBayesNet serialization.
// TEST(HybridSerialization, HybridBayesNet) {
// Switching s(2);
// HybridBayesNet hbn = *(s.linearizedFactorGraph.eliminateSequential());

// EXPECT(equalsObj<HybridBayesNet>(hbn));
// EXPECT(equalsXML<HybridBayesNet>(hbn));
// EXPECT(equalsBinary<HybridBayesNet>(hbn));
// }

// /* ****************************************************************************/
// // Test HybridBayesTree serialization.
// TEST(HybridSerialization, HybridBayesTree) {
// Switching s(2);
// HybridBayesTree hbt = *(s.linearizedFactorGraph.eliminateMultifrontal());

// EXPECT(equalsObj<HybridBayesTree>(hbt));
// EXPECT(equalsXML<HybridBayesTree>(hbt));
// EXPECT(equalsBinary<HybridBayesTree>(hbt));
// }
BOOST_CLASS_EXPORT_GUID(Factor, "gtsam_Factor");
BOOST_CLASS_EXPORT_GUID(HybridFactor, "gtsam_HybridFactor");
BOOST_CLASS_EXPORT_GUID(JacobianFactor, "gtsam_JacobianFactor");
BOOST_CLASS_EXPORT_GUID(GaussianConditional, "gtsam_GaussianConditional");
BOOST_CLASS_EXPORT_GUID(DiscreteConditional, "gtsam_DiscreteConditional");

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_AlgebraicDecisionTree_Leaf");
BOOST_CLASS_EXPORT_GUID(ADT::Choice, "gtsam_AlgebraicDecisionTree_Choice")

BOOST_CLASS_EXPORT_GUID(HybridGaussianFactor, "gtsam_HybridGaussianFactor");
BOOST_CLASS_EXPORT_GUID(HybridGaussianFactor::FactorValuePairs,
"gtsam_HybridGaussianFactor_Factors");
BOOST_CLASS_EXPORT_GUID(HybridGaussianFactor::FactorValuePairs::Leaf,
"gtsam_HybridGaussianFactor_Factors_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,
"gtsam_HybridGaussianConditional_Conditionals");
BOOST_CLASS_EXPORT_GUID(HybridGaussianConditional::Conditionals::Leaf,
"gtsam_HybridGaussianConditional_Conditionals_Leaf");
BOOST_CLASS_EXPORT_GUID(HybridGaussianConditional::Conditionals::Choice,
"gtsam_HybridGaussianConditional_Conditionals_Choice");
// Needed since GaussianConditional::FromMeanAndStddev uses it
BOOST_CLASS_EXPORT_GUID(noiseModel::Isotropic, "gtsam_noiseModel_Isotropic");

BOOST_CLASS_EXPORT_GUID(HybridBayesNet, "gtsam_HybridBayesNet");

/* ****************************************************************************/
// Test HybridGaussianFactor serialization.
TEST(HybridSerialization, HybridGaussianFactor) {
DiscreteKey discreteKey{M(0), 2};

auto A = Matrix::Zero(2, 1);
auto b0 = Matrix::Zero(2, 1);
auto b1 = Matrix::Ones(2, 1);
auto f0 = std::make_shared<JacobianFactor>(X(0), A, b0);
auto f1 = std::make_shared<JacobianFactor>(X(0), A, b1);
std::vector<GaussianFactor::shared_ptr> factors{f0, f1};

const HybridGaussianFactor factor(discreteKey, factors);

EXPECT(equalsObj<HybridGaussianFactor>(factor));
EXPECT(equalsXML<HybridGaussianFactor>(factor));
EXPECT(equalsBinary<HybridGaussianFactor>(factor));
}

/* ****************************************************************************/
// Test HybridConditional serialization.
TEST(HybridSerialization, HybridConditional) {
const DiscreteKey mode(M(0), 2);
Matrix1 I = Matrix1::Identity();
const auto conditional = std::make_shared<GaussianConditional>(
GaussianConditional::FromMeanAndStddev(Z(0), I, X(0), Vector1(0), 0.5));
const HybridConditional hc(conditional);

EXPECT(equalsObj<HybridConditional>(hc));
EXPECT(equalsXML<HybridConditional>(hc));
EXPECT(equalsBinary<HybridConditional>(hc));
}

/* ****************************************************************************/
// Test HybridGaussianConditional serialization.
TEST(HybridSerialization, HybridGaussianConditional) {
const DiscreteKey mode(M(0), 2);
Matrix1 I = Matrix1::Identity();
const auto conditional0 = std::make_shared<GaussianConditional>(
GaussianConditional::FromMeanAndStddev(Z(0), I, X(0), Vector1(0), 0.5));
const auto conditional1 = std::make_shared<GaussianConditional>(
GaussianConditional::FromMeanAndStddev(Z(0), I, X(0), Vector1(0), 3));
const HybridGaussianConditional gm(mode, {conditional0, conditional1});

EXPECT(equalsObj<HybridGaussianConditional>(gm));
EXPECT(equalsXML<HybridGaussianConditional>(gm));
EXPECT(equalsBinary<HybridGaussianConditional>(gm));
}

/* ****************************************************************************/
// Test HybridBayesNet serialization.
TEST(HybridSerialization, HybridBayesNet) {
Switching s(2);
HybridBayesNet hbn = *(s.linearizedFactorGraph.eliminateSequential());

EXPECT(equalsObj<HybridBayesNet>(hbn));
EXPECT(equalsXML<HybridBayesNet>(hbn));
EXPECT(equalsBinary<HybridBayesNet>(hbn));
}

/* ****************************************************************************/
// Test HybridBayesTree serialization.
TEST(HybridSerialization, HybridBayesTree) {
Switching s(2);
HybridBayesTree hbt = *(s.linearizedFactorGraph.eliminateMultifrontal());

EXPECT(equalsObj<HybridBayesTree>(hbt));
EXPECT(equalsXML<HybridBayesTree>(hbt));
EXPECT(equalsBinary<HybridBayesTree>(hbt));
}

/* ************************************************************************* */
int main() {
Expand Down

0 comments on commit 99a39e6

Please sign in to comment.