(in branch) In progress refactoring to store gradient for dogleg

release/4.3a0
Richard Roberts 2011-11-29 16:49:12 +00:00
parent e6a43d6330
commit 7a95ccbd86
2 changed files with 30 additions and 13 deletions

View File

@ -730,7 +730,7 @@ namespace gtsam {
this->removeClique(clique); this->removeClique(clique);
// remove path above me // remove path above me
this->removePath(sharedClique(clique->parent_.lock()), bn, orphans); this->removePath(typename BayesTreeClique<CONDITIONAL>::shared_ptr(clique->parent_.lock()), bn, orphans);
// add children to list of orphans (splice also removed them from clique->children_) // add children to list of orphans (splice also removed them from clique->children_)
orphans.splice (orphans.begin(), clique->children_); orphans.splice (orphans.begin(), clique->children_);

View File

@ -304,35 +304,52 @@ namespace gtsam {
* *
* Since our Conditional class already handles multiple frontal variables, * Since our Conditional class already handles multiple frontal variables,
* this Clique contains exactly 1 conditional. * this Clique contains exactly 1 conditional.
*
* This is the default clique type in a BayesTree, but some algorithms, like
* iSAM2 (see ISAM2Clique), use a different clique type in order to store
* extra data along with the clique.
*/ */
template<class CONDITIONAL> template<class CONDITIONAL>
struct BayesTreeClique { struct BayesTreeClique {
};
/* ************************************************************************* */
/**
* This is the base class for BayesTree cliques. The default and standard
* derived type is BayesTreeClique, but some algorithms, like iSAM2, use a
* different clique type in order to store extra data along with the clique.
*/
template<class DERIVED>
struct BayesTreeCliqueBase {
protected: protected:
void assertInvariants() const; void assertInvariants() const;
public: public:
typedef BayesTreeClique<CONDITIONAL> This; typedef BayesTreeClique<DERIVED> This;
typedef CONDITIONAL ConditionalType; typedef DERIVED DerivedType;
typedef boost::shared_ptr<CONDITIONAL> sharedConditional; typedef typename DERIVED::ConditionalType ConditionalType;
typedef boost::shared_ptr<ConditionalType> sharedConditional;
typedef typename boost::shared_ptr<This> shared_ptr; typedef typename boost::shared_ptr<This> shared_ptr;
typedef typename boost::weak_ptr<This> weak_ptr; typedef typename boost::weak_ptr<This> weak_ptr;
typedef typename CONDITIONAL::FactorType FactorType; typedef typename ConditionalType::FactorType FactorType;
typedef typename FactorGraph<FactorType>::Eliminate Eliminate; typedef typename FactorGraph<FactorType>::Eliminate Eliminate;
sharedConditional conditional_; sharedConditional conditional_;
weak_ptr parent_; weak_ptr parent_;
std::list<shared_ptr> children_; std::list<shared_ptr> children_;
friend class BayesTree<CONDITIONAL>; friend class BayesTree<ConditionalType>;
/** Default constructor */ /** Default constructor */
BayesTreeClique() {} BayesTreeCliqueBase() {}
/** Construct from a conditional, leaving parent and child pointers uninitialized */ /** Construct from a conditional, leaving parent and child pointers uninitialized */
BayesTreeClique(const sharedConditional& conditional); BayesTreeCliqueBase(const sharedConditional& conditional);
virtual ~BayesTreeClique() {} virtual ~BayesTreeCliqueBase() {}
/** Construct shared_ptr from a conditional, leaving parent and child pointers uninitialized */ /** Construct shared_ptr from a conditional, leaving parent and child pointers uninitialized */
static shared_ptr Create(const sharedConditional& conditional) { return shared_ptr(new BayesTreeClique(conditional)); } static shared_ptr Create(const sharedConditional& conditional) { return shared_ptr(new BayesTreeClique(conditional)); }
@ -349,10 +366,10 @@ namespace gtsam {
void print(const std::string& s = "") const; void print(const std::string& s = "") const;
/** The arrow operator accesses the conditional */ /** The arrow operator accesses the conditional */
const CONDITIONAL* operator->() const { return conditional_.get(); } const ConditionalType* operator->() const { return conditional_.get(); }
/** The arrow operator accesses the conditional */ /** The arrow operator accesses the conditional */
CONDITIONAL* operator->() { return conditional_.get(); } ConditionalType* operator->() { return conditional_.get(); }
/** Access the conditional */ /** Access the conditional */
const sharedConditional& conditional() const { return conditional_; } const sharedConditional& conditional() const { return conditional_; }
@ -382,7 +399,7 @@ namespace gtsam {
/** return the conditional P(S|Root) on the separator given the root */ /** return the conditional P(S|Root) on the separator given the root */
// TODO: create a cached version // TODO: create a cached version
BayesNet<CONDITIONAL> shortcut(shared_ptr root, Eliminate function); BayesNet<ConditionalType> shortcut(shared_ptr root, Eliminate function);
/** return the marginal P(C) of the clique */ /** return the marginal P(C) of the clique */
FactorGraph<FactorType> marginal(shared_ptr root, Eliminate function); FactorGraph<FactorType> marginal(shared_ptr root, Eliminate function);