22 #include <boost/optional.hpp> 23 #include <boost/shared_ptr.hpp> 29 namespace linearAlgorithms
33 boost::optional<OptimizeData&> parentData;
46 template<
class CLIQUE>
52 const boost::shared_ptr<CLIQUE>& clique,
56 myData.parentData = parentData;
58 for(
Key parent: clique->conditional_->parents())
59 myData.cliqueResults.emplace(parent, myData.parentData->cliqueResults.at(parent));
69 FastVector<VectorValues::const_iterator> parentPointers;
70 parentPointers.reserve(clique->conditional()->nrParents());
71 for(
Key parent: clique->conditional()->parents()) {
72 parentPointers.push_back(myData.cliqueResults.at(parent));
73 dim += parentPointers.back()->second.size();
80 const Vector& parentVector = parentPointer->second;
81 xS.block(vectorPos,0,parentVector.size(),1) = parentVector.block(0,0,parentVector.size(),1);
82 vectorPos += parentVector.size();
90 const Vector rhs = c.
getb() - c.
S() * xS;
93 const Vector solution = c.
R().triangularView<Eigen::Upper>().solve(rhs);
102 collectedResult.
emplace(*frontal, solution.segment(vectorPosition, c.
getDim(frontal)));
103 myData.cliqueResults.emplace(r->first, r);
104 vectorPosition += c.
getDim(frontal);
134 template<
class BAYESTREE>
135 VectorValues optimizeBayesTree(
const BAYESTREE& bayesTree)
137 gttic(linear_optimizeBayesTree);
143 treeTraversal::no_op postVisitor;
146 return preVisitor.collectedResult;
Values::const_iterator const_iterator
Const iterator over vector values.
Definition: VectorValues.h:81
ptrdiff_t DenseIndex
The index type for Eigen objects.
Definition: types.h:63
A conditional Gaussian functions as the node in a Bayes network It has a set of parents y,...
Definition: GaussianConditional.h:36
Conditional Gaussian Base class.
const constBVector getb() const
Get a view of the r.h.s.
Definition: JacobianFactor.h:264
constABlock S() const
Get a view of the parent blocks.
Definition: GaussianConditional.h:100
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Thrown when a linear system is ill-posed.
Definition: linearExceptions.h:94
iterator emplace(Key j, const Vector &value)
Emplace a vector value with key j.
Definition: VectorValues.cpp:88
This class represents a collection of vector-valued variables associated each with a unique integer i...
Definition: VectorValues.h:73
void DepthFirstForestParallel(FOREST &forest, DATA &rootData, VISITOR_PRE &visitorPre, VISITOR_POST &visitorPost, int problemSizeThreshold=10)
Traverse a forest depth-first with pre-order and post-order visits.
Definition: treeTraversal-inst.h:154
An object whose scope defines a block where TBB and OpenMP parallelism are mixed.
Definition: types.h:148
Pre-order visitor for back-substitution in a Bayes tree.
Definition: linearAlgorithms-inst.h:47
virtual DenseIndex getDim(const_iterator variable) const
Return the dimension of the variable pointed to by the given key iterator todo: Remove this in favor ...
Definition: JacobianFactor.h:245
Definition: linearAlgorithms-inst.h:32
constABlock R() const
Return a view of the upper-triangular R block of the conditional.
Definition: GaussianConditional.h:97
FACTOR::const_iterator endFrontals() const
Iterator pointing past the last frontal key.
Definition: Conditional.h:107
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition: Factor.h:118
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition: Factor.h:67
FACTOR::const_iterator beginFrontals() const
Iterator pointing to first frontal key.
Definition: Conditional.h:104