Repository navigation
Conversation
serialize() only stored the two base classes, so a deserialized conditional came back with an uninitialized negLogConstant_ (0 or NaN in practice) and pruned_ reset to false. negLogConstant_ is returned by negLogConstant(), which HybridConditional::negLogConstant() and HybridBayesNet::negLogConstant() use, and prune() adds it back to the component scalars, so a conditional pruned after a round trip reports the wrong constant too. equals() compares neither member, which is why the existing serialization test passed. Store both members from class version 1 on. Version 0 archives, which hold only the base classes, still load as before.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HybridGaussianConditional::serialize()stores only its two base classes, sonegLogConstant_andpruned_are lost in a round trip. The defaulted constructor leavesnegLogConstant_uninitialized, so a deserialized conditional reports an arbitrary value (0 or NaN when tested) instead of, for the two-component conditional in the existing serialization test, 0.225791.pruned_comes backfalse. The wrong constant is returned bynegLogConstant(),HybridConditional::negLogConstant()andHybridBayesNet::negLogConstant().prune()addsnegLogConstant_back to the component scalars, so pruning a deserialized conditional also gives a conditional withnegLogConstant() == 0.equals()compares neither member, which is whyequalsObj/equalsXML/equalsBinaryin the existing test pass.Both members are now archived from class version 1 on (
BOOST_CLASS_VERSION(gtsam::HybridGaussianConditional, 1)). Version 0 archives contain only the base classes and still load as before. Adding the members without the version check would make them fail withinput stream error.New tests in
gtsam/hybrid/tests/testSerializationHybrid.cpp:HybridSerialization.HybridGaussianConditionalConstantAndPrunedround-trips a pruned two-component conditional through text, XML and binary archives and checksnegLogConstant()andpruned(). It fails on develop with 6 failures (expected 0.225791 but was: 0.000000,deserialized->pruned()) and passes with the change.HybridSerialization.HybridGaussianConditionalVersionZerowrites the version 0 format through a legacy subclass, in the style ofLegacyGaussianBayesTreein testSerializationLinear, and reads it back as aHybridGaussianConditional. It passes on develop and with this change, and fails withinput stream errorif the members are archived without the version check.make check.hybrid(19 tests) passes.