De-clutter header
parent
ebebf7ddd5
commit
e04f0afd0e
|
@ -64,47 +64,11 @@ class GTSAM_EXPORT HybridGaussianConditional
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Conditionals conditionals_; ///< a decision tree of Gaussian conditionals.
|
Conditionals conditionals_; ///< a decision tree of Gaussian conditionals.
|
||||||
|
|
||||||
///< Negative-log of the normalization constant (log(\sqrt(|2πΣ|))).
|
///< Negative-log of the normalization constant (log(\sqrt(|2πΣ|))).
|
||||||
///< Take advantage of the neg-log space so everything is a minimization
|
///< Take advantage of the neg-log space so everything is a minimization
|
||||||
double negLogConstant_;
|
double negLogConstant_;
|
||||||
|
|
||||||
/// Helper struct for private constructor.
|
|
||||||
struct ConstructorHelper {
|
|
||||||
KeyVector frontals;
|
|
||||||
KeyVector parents;
|
|
||||||
KeyVector continuousKeys;
|
|
||||||
HybridGaussianFactor::FactorValuePairs pairs;
|
|
||||||
double negLogConstant;
|
|
||||||
ConstructorHelper(const Conditionals &conditionals);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Private constructor
|
|
||||||
HybridGaussianConditional(
|
|
||||||
const DiscreteKeys &discreteParents,
|
|
||||||
const HybridGaussianConditional::Conditionals &conditionals,
|
|
||||||
const ConstructorHelper &helper)
|
|
||||||
: BaseFactor(helper.continuousKeys, discreteParents, helper.pairs),
|
|
||||||
BaseConditional(helper.frontals.size()),
|
|
||||||
conditionals_(conditionals),
|
|
||||||
negLogConstant_(helper.negLogConstant) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Convert a HybridGaussianConditional of conditionals into
|
|
||||||
* a DecisionTree of Gaussian factor graphs.
|
|
||||||
*/
|
|
||||||
GaussianFactorGraphTree asGaussianFactorGraphTree() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Helper function to get the pruner functor.
|
|
||||||
*
|
|
||||||
* @param discreteProbs The pruned discrete probabilities.
|
|
||||||
* @return std::function<GaussianConditional::shared_ptr(
|
|
||||||
* const Assignment<Key> &, const GaussianConditional::shared_ptr &)>
|
|
||||||
*/
|
|
||||||
std::function<GaussianConditional::shared_ptr(
|
|
||||||
const Assignment<Key> &, const GaussianConditional::shared_ptr &)>
|
|
||||||
prunerFunc(const DecisionTreeFactor &discreteProbs);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// @name Constructors
|
/// @name Constructors
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -220,6 +184,33 @@ class GTSAM_EXPORT HybridGaussianConditional
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// Helper struct for private constructor.
|
||||||
|
struct ConstructorHelper {
|
||||||
|
KeyVector frontals, parents, continuousKeys;
|
||||||
|
HybridGaussianFactor::FactorValuePairs pairs;
|
||||||
|
double negLogConstant;
|
||||||
|
/// Compute all variables needed for the private constructor below.
|
||||||
|
ConstructorHelper(const Conditionals &conditionals);
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Private constructor that uses helper struct above.
|
||||||
|
HybridGaussianConditional(
|
||||||
|
const DiscreteKeys &discreteParents,
|
||||||
|
const HybridGaussianConditional::Conditionals &conditionals,
|
||||||
|
const ConstructorHelper &helper)
|
||||||
|
: BaseFactor(helper.continuousKeys, discreteParents, helper.pairs),
|
||||||
|
BaseConditional(helper.frontals.size()),
|
||||||
|
conditionals_(conditionals),
|
||||||
|
negLogConstant_(helper.negLogConstant) {}
|
||||||
|
|
||||||
|
/// Convert to a DecisionTree of Gaussian factor graphs.
|
||||||
|
GaussianFactorGraphTree asGaussianFactorGraphTree() const;
|
||||||
|
|
||||||
|
//// Get the pruner functor from pruned discrete probabilities.
|
||||||
|
std::function<GaussianConditional::shared_ptr(
|
||||||
|
const Assignment<Key> &, const GaussianConditional::shared_ptr &)>
|
||||||
|
prunerFunc(const DecisionTreeFactor &prunedProbabilities);
|
||||||
|
|
||||||
/// Check whether `given` has values for all frontal keys.
|
/// Check whether `given` has values for all frontal keys.
|
||||||
bool allFrontalsGiven(const VectorValues &given) const;
|
bool allFrontalsGiven(const VectorValues &given) const;
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,6 @@ TEST(HybridConditional, Invariants) {
|
||||||
const DiscreteValues d{{M(0), 1}};
|
const DiscreteValues d{{M(0), 1}};
|
||||||
const HybridValues values{c, d};
|
const HybridValues values{c, d};
|
||||||
|
|
||||||
GTSAM_PRINT(bn);
|
|
||||||
|
|
||||||
// Check invariants for p(z|x,m)
|
// Check invariants for p(z|x,m)
|
||||||
auto hc0 = bn.at(0);
|
auto hc0 = bn.at(0);
|
||||||
CHECK(hc0->isHybrid());
|
CHECK(hc0->isHybrid());
|
||||||
|
|
Loading…
Reference in New Issue