32 namespace linearAlgorithms
49 template<
class CLIQUE>
55 const std::shared_ptr<CLIQUE>& clique,
59 myData.parentData = &parentData;
61 for(
Key parent: clique->conditional_->parents())
62 myData.cliqueResults.emplace(parent, myData.parentData->cliqueResults.at(parent));
73 parentPointers.reserve(clique->conditional()->nrParents());
74 for(
Key parent: clique->conditional()->parents()) {
75 parentPointers.push_back(myData.cliqueResults.at(parent));
76 dim += parentPointers.back()->second.size();
83 const Vector& parentVector = parentPointer->second;
84 xS.block(vectorPos,0,parentVector.size(),1) = parentVector.block(0,0,parentVector.size(),1);
85 vectorPos += parentVector.size();
92 if (solution.hasNaN()) {
99 auto result = collectedResult.emplace(*frontal, solution.segment(vectorPosition, c.
getDim(frontal)));
101 throw std::runtime_error(
102 "Internal error while optimizing clique. Trying to insert key '" +
DefaultKeyFormatter(*frontal)
106 myData.cliqueResults.emplace(r->first, r);
107 vectorPosition += c.
getDim(frontal);
137 template<
class BAYESTREE>
138 VectorValues optimizeBayesTree(
const BAYESTREE& bayesTree)
140 gttic(linear_optimizeBayesTree);
146 treeTraversal::no_op postVisitor;
149 return preVisitor.collectedResult;
void solveUpperConditional(const Eigen::MatrixBase< RDerived > &R, const Eigen::MatrixBase< SDerived > &S, const Eigen::MatrixBase< DDerived > &d, const Eigen::MatrixBase< ParentsDerived > &parents, Vector *result)
Solve the block upper-triangular system R*x = d - S*parents.
Definition Matrix.h:278
Conditional Gaussian Base class.
Exceptions that may be thrown by linear solver components.
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
FastVector is a type alias to a std::vector with a custom memory allocator.
Definition FastVector.h:33
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
ptrdiff_t DenseIndex
The index type for Eigen objects.
Definition types.h:49
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
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:181
FastMap is a thin wrapper around std::map that uses the boost fast_pool_allocator instead of the defa...
Definition FastMap.h:40
An object whose scope defines a block where TBB and OpenMP parallelism are mixed.
Definition types.h:87
FACTOR::const_iterator endFrontals() const
Iterator pointing past the last frontal key.
Definition Conditional.h:185
FACTOR::const_iterator beginFrontals() const
Iterator pointing to first frontal key.
Definition Conditional.h:182
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition Factor.h:143
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition Factor.h:83
A GaussianConditional functions as the node in a Bayes network.
Definition GaussianConditional.h:43
constABlock R() const
Return a view of the upper-triangular R block of the conditional.
Definition GaussianConditional.h:237
constABlock S() const
Get a view of the parent blocks.
Definition GaussianConditional.h:240
const constBVector getb() const
Get a view of the r.h.s.
Definition JacobianFactor.h:344
DenseIndex getDim(const_iterator variable) const override
Return the dimension of the variable pointed to by the given key iterator todo: Remove this in favor ...
Definition JacobianFactor.h:323
Definition linearAlgorithms-inst.h:35
Pre-order visitor for back-substitution in a Bayes tree.
Definition linearAlgorithms-inst.h:51
Thrown when a linear system is ill-posed.
Definition linearExceptions.h:111
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:73
Values::const_iterator const_iterator
Const iterator over vector values.
Definition VectorValues.h:81