21 #include <gtsam/config.h> 38 result->
update(clique->conditional()->solve(*result));
47 size_t DeltaImpl::UpdateGaussNewtonDelta(
const ISAM2::Roots& roots,
48 const KeySet& replacedKeys,
49 double wildfireThreshold,
51 size_t lastBacksubVariableCount;
53 if (wildfireThreshold <= 0.0) {
57 lastBacksubVariableCount = delta->
size();
61 lastBacksubVariableCount = 0;
64 root, wildfireThreshold, replacedKeys, delta);
66 #if !defined(NDEBUG) && defined(GTSAM_EXTRA_CONSISTENCY_CHECKS) 68 key_delta != delta->
end(); ++key_delta) {
69 assert((*delta)[key_delta->first].allFinite());
74 return lastBacksubVariableCount;
81 size_t* varsUpdated) {
85 bool anyReplaced =
false;
86 for (
Key j : *clique->conditional()) {
98 clique->conditional()->endFrontals()));
101 clique->conditional()->endParents()));
104 Vector RSgProd = clique->conditional()->R() * gR +
105 clique->conditional()->S() * gS;
109 for (
Key frontal : clique->conditional()->frontals()) {
110 Vector& RgProdValue = (*RgProd)[frontal];
111 RgProdValue = RSgProd.segment(vectorPosition, RgProdValue.size());
112 vectorPosition += RgProdValue.size();
119 *varsUpdated += clique->conditional()->nrFrontals();
123 updateRgProd(child, replacedKeys, grad, RgProd, varsUpdated);
131 const KeySet& replacedKeys,
135 size_t varsUpdated = 0;
148 const double gradientSqNorm = gradAtZero.
dot(gradAtZero);
151 double RgNormSq = RgProd.
vector().squaredNorm();
152 double step = -gradientSqNorm / RgNormSq;
155 return step * gradAtZero;
def step(data, isam, result, truth, currPoseIndex)
bool exists(const VALUE &e) const
iterator end()
Iterator over variables.
ptrdiff_t DenseIndex
The index type for Eigen objects.
size_t optimizeWildfireNonRecursive(const ISAM2Clique::shared_ptr &root, double threshold, const KeySet &keys, VectorValues *delta)
void updateRgProd(const ISAM2::sharedClique &clique, const KeySet &replacedKeys, const VectorValues &grad, VectorValues *RgProd, size_t *varsUpdated)
static void optimizeInPlace(const ISAM2::sharedClique &clique, VectorValues *result)
Base::sharedClique sharedClique
Shared pointer to a clique.
Values::const_iterator const_iterator
Const iterator over vector values.
double dot(const VectorValues &v) const
Incremental update functionality (ISAM2) for BayesTree, with fluid relinearization.
FastVector< sharedClique > Roots
VectorValues & update(const VectorValues &values)
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
iterator begin()
Iterator over variables.
std::uint64_t Key
Integer nonlinear key type.