make removeDiscreteModes only apply to discrete conditionals

release/4.3a0
Varun Agrawal 2025-01-21 20:48:20 -05:00
parent 22bf9df39a
commit abbbde980f
3 changed files with 5 additions and 20 deletions

View File

@ -88,7 +88,7 @@ HybridBayesNet HybridBayesNet::prune(size_t maxNrLeaves,
}
// Remove the modes (imperative)
result.back()->removeModes(deadModesValues);
result.back()->removeDiscreteModes(deadModesValues);
pruned = *result.back()->asDiscrete();
}

View File

@ -170,7 +170,7 @@ double HybridConditional::evaluate(const HybridValues &values) const {
}
/* ************************************************************************ */
void HybridConditional::removeModes(const DiscreteValues &given) {
void HybridConditional::removeDiscreteModes(const DiscreteValues &given) {
if (this->isDiscrete()) {
auto d = this->asDiscrete();
@ -187,22 +187,6 @@ void HybridConditional::removeModes(const DiscreteValues &given) {
}
}
inner_ = std::make_shared<DiscreteConditional>(dkeys.size(), dkeys, tree);
} else if (this->isHybrid()) {
auto d = this->asHybrid();
HybridGaussianFactor::FactorValuePairs tree = d->factors();
for (auto [key, value] : given) {
tree = tree.choose(key, value);
}
// Get the leftover DiscreteKeys
DiscreteKeys dkeys;
for (DiscreteKey dkey : d->discreteKeys()) {
if (given.count(dkey.first) == 0) {
dkeys.emplace_back(dkey);
}
}
inner_ = std::make_shared<HybridGaussianConditional>(dkeys, tree);
}
}

View File

@ -216,13 +216,14 @@ class GTSAM_EXPORT HybridConditional
}
/**
* @brief Remove the modes whose assignments are given to us.
* @brief Remove the discrete modes whose assignments are given to us.
* Only applies to discrete conditionals.
*
* Imperative method so we can update nodes in the Bayes net or Bayes tree.
*
* @param given The discrete modes whose assignments we know.
*/
void removeModes(const DiscreteValues& given);
void removeDiscreteModes(const DiscreteValues& given);
/// @}