Simplified API
parent
1d0f872555
commit
04c7d2edb2
|
@ -197,8 +197,7 @@ HybridBayesNet HybridBayesNet::prune(size_t maxNrLeaves) {
|
||||||
prunedGaussianMixture->prune(*decisionTree); // imperative :-(
|
prunedGaussianMixture->prune(*decisionTree); // imperative :-(
|
||||||
|
|
||||||
// Type-erase and add to the pruned Bayes Net fragment.
|
// Type-erase and add to the pruned Bayes Net fragment.
|
||||||
prunedBayesNetFragment.push_back(
|
prunedBayesNetFragment.push_back(prunedGaussianMixture);
|
||||||
boost::make_shared<HybridConditional>(prunedGaussianMixture));
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Add the non-GaussianMixture conditional
|
// Add the non-GaussianMixture conditional
|
||||||
|
@ -209,21 +208,6 @@ HybridBayesNet HybridBayesNet::prune(size_t maxNrLeaves) {
|
||||||
return prunedBayesNetFragment;
|
return prunedBayesNetFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
|
||||||
GaussianMixture::shared_ptr HybridBayesNet::atMixture(size_t i) const {
|
|
||||||
return at(i)->asMixture();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ************************************************************************* */
|
|
||||||
GaussianConditional::shared_ptr HybridBayesNet::atGaussian(size_t i) const {
|
|
||||||
return at(i)->asGaussian();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ************************************************************************* */
|
|
||||||
DiscreteConditional::shared_ptr HybridBayesNet::atDiscrete(size_t i) const {
|
|
||||||
return at(i)->asDiscrete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
GaussianBayesNet HybridBayesNet::choose(
|
GaussianBayesNet HybridBayesNet::choose(
|
||||||
const DiscreteValues &assignment) const {
|
const DiscreteValues &assignment) const {
|
||||||
|
|
|
@ -63,55 +63,26 @@ class GTSAM_EXPORT HybridBayesNet : public BayesNet<HybridConditional> {
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
/// Add HybridConditional to Bayes Net
|
/// Add HybridConditional to Bayes Net
|
||||||
using Base::add;
|
using Base::emplace_shared;
|
||||||
|
|
||||||
/// Add a Gaussian Mixture to the Bayes Net.
|
/// Add a conditional directly using a pointer.
|
||||||
void addMixture(const GaussianMixture::shared_ptr &ptr) {
|
template <class Conditional>
|
||||||
push_back(HybridConditional(ptr));
|
void emplace_back(Conditional *conditional) {
|
||||||
|
factors_.push_back(boost::make_shared<HybridConditional>(
|
||||||
|
boost::shared_ptr<Conditional>(conditional)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a Gaussian conditional to the Bayes Net.
|
/// Add a conditional directly using a shared_ptr.
|
||||||
void addGaussian(const GaussianConditional::shared_ptr &ptr) {
|
void push_back(boost::shared_ptr<HybridConditional> conditional) {
|
||||||
push_back(HybridConditional(ptr));
|
factors_.push_back(conditional);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a discrete conditional to the Bayes Net.
|
/// Add a conditional directly using implicit conversion.
|
||||||
void addDiscrete(const DiscreteConditional::shared_ptr &ptr) {
|
void push_back(HybridConditional &&conditional) {
|
||||||
push_back(HybridConditional(ptr));
|
factors_.push_back(
|
||||||
|
boost::make_shared<HybridConditional>(std::move(conditional)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a Gaussian Mixture to the Bayes Net.
|
|
||||||
template <typename... T>
|
|
||||||
void emplaceMixture(T &&...args) {
|
|
||||||
push_back(HybridConditional(
|
|
||||||
boost::make_shared<GaussianMixture>(std::forward<T>(args)...)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add a Gaussian conditional to the Bayes Net.
|
|
||||||
template <typename... T>
|
|
||||||
void emplaceGaussian(T &&...args) {
|
|
||||||
push_back(HybridConditional(
|
|
||||||
boost::make_shared<GaussianConditional>(std::forward<T>(args)...)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add a discrete conditional to the Bayes Net.
|
|
||||||
template <typename... T>
|
|
||||||
void emplaceDiscrete(T &&...args) {
|
|
||||||
push_back(HybridConditional(
|
|
||||||
boost::make_shared<DiscreteConditional>(std::forward<T>(args)...)));
|
|
||||||
}
|
|
||||||
|
|
||||||
using Base::push_back;
|
|
||||||
|
|
||||||
/// Get a specific Gaussian mixture by index `i`.
|
|
||||||
GaussianMixture::shared_ptr atMixture(size_t i) const;
|
|
||||||
|
|
||||||
/// Get a specific Gaussian conditional by index `i`.
|
|
||||||
GaussianConditional::shared_ptr atGaussian(size_t i) const;
|
|
||||||
|
|
||||||
/// Get a specific discrete conditional by index `i`.
|
|
||||||
DiscreteConditional::shared_ptr atDiscrete(size_t i) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the Gaussian Bayes Net which corresponds to a specific discrete
|
* @brief Get the Gaussian Bayes Net which corresponds to a specific discrete
|
||||||
* value assignment.
|
* value assignment.
|
||||||
|
|
Loading…
Reference in New Issue