make removeDiscreteModes only apply to discrete conditionals
parent
22bf9df39a
commit
abbbde980f
|
@ -88,7 +88,7 @@ HybridBayesNet HybridBayesNet::prune(size_t maxNrLeaves,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the modes (imperative)
|
// Remove the modes (imperative)
|
||||||
result.back()->removeModes(deadModesValues);
|
result.back()->removeDiscreteModes(deadModesValues);
|
||||||
pruned = *result.back()->asDiscrete();
|
pruned = *result.back()->asDiscrete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()) {
|
if (this->isDiscrete()) {
|
||||||
auto d = this->asDiscrete();
|
auto d = this->asDiscrete();
|
||||||
|
|
||||||
|
@ -187,22 +187,6 @@ void HybridConditional::removeModes(const DiscreteValues &given) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inner_ = std::make_shared<DiscreteConditional>(dkeys.size(), dkeys, tree);
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
* Imperative method so we can update nodes in the Bayes net or Bayes tree.
|
||||||
*
|
*
|
||||||
* @param given The discrete modes whose assignments we know.
|
* @param given The discrete modes whose assignments we know.
|
||||||
*/
|
*/
|
||||||
void removeModes(const DiscreteValues& given);
|
void removeDiscreteModes(const DiscreteValues& given);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue