34#include <unordered_set>
46class GTSAM_EXPORT MultifrontalSolverNotSupported :
public std::runtime_error {
48 explicit MultifrontalSolverNotSupported(
const std::string& reason)
49 : std::runtime_error(BuildMessage(reason)) {}
52 static std::string BuildMessage(
const std::string& reason) {
53 std::string message =
"MultifrontalSolver not supported: " + reason +
". ";
55 "Enable GTSAM_ALLOW_DEPRECATED_SINCE_V43 to default to the legacy "
56 "solver, or set linearSolverType = MULTIFRONTAL_CHOLESKY.";
89 std::map<Key, size_t>
dims;
97 using CliquePtr = std::shared_ptr<MultifrontalClique>;
139 size_t firstPhaseSize,
140 const Parameters& params = Parameters{});
149 MultifrontalSolver(PrecomputedData data,
const Ordering& ordering,
150 const Parameters& params = Parameters{});
153 MultifrontalSolver(PrecomputedData data,
const Ordering& ordering,
154 size_t firstPhaseSize,
155 const Parameters& params = Parameters{});
169 static PrecomputedData Precompute(
const GaussianFactorGraph& graph,
170 const Ordering& ordering);
182 void load(
const GaussianFactorGraph& graph);
188 void eliminateInPlace();
194 void eliminateInPlace(
const GaussianFactorGraph& graph);
200 void eliminatePartialInPlace();
203 void eliminatePartialInPlace(
const GaussianFactorGraph& graph);
210 GaussianFactorGraph remainingFactorGraph()
const;
218 GaussianBayesTree computeBayesTree()
const;
225 const VectorValues& updateSolution();
230 const VectorValues& updateSolution(
const VectorValues& retainedSolution);
236 double deltaError(
double* oldError =
nullptr,
237 double* newError =
nullptr)
const;
246 void print(
const std::string& s =
"",
250 friend std::ostream& operator<<(std::ostream& os,
254std::ostream& operator<<(std::ostream& os,
const MultifrontalSolver& solver);
Forest traversal helpers with optional TBB acceleration.
Variable ordering for the elimination algorithm.
Linear Factor Graph where all factors are Gaussians.
Parameters for the imperative multifrontal solver.
Build a symbolic junction tree that stores original factor indices.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition Key.h:35
ForestTraversal(size_t numThreads=std::thread::hardware_concurrency())
Definition ForestTraversal.h:68
A Bayes tree representing a Gaussian density.
Definition GaussianBayesTree.h:53
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition GaussianFactorGraph.h:77
Imperative multifrontal clique structure used by MultifrontalSolver.
Definition MultifrontalClique.h:71
Parameters for gtsam::MultifrontalSolver.
Definition MultifrontalParameters.h:37
Imperative-style multifrontal solver for Gaussian factor graphs.
Definition MultifrontalSolver.h:82
size_t cliqueCount() const
Get the total number of cliques in the solver.
Definition MultifrontalSolver.h:243
double lastOldError_
Cached old linearized error.
Definition MultifrontalSolver.h:113
MultifrontalParameters Parameters
Tuning parameters for traversal and reporting.
Definition MultifrontalSolver.h:85
VectorValues solution_
Cached solution vector.
Definition MultifrontalSolver.h:105
const std::vector< CliquePtr > & roots() const
Accessor for the roots of the elimination tree.
Definition MultifrontalSolver.h:240
Parameters params_
Tunable solver parameters.
Definition MultifrontalSolver.h:112
MultifrontalSolver(const GaussianFactorGraph &graph, const Ordering &ordering, const Parameters ¶ms=Parameters{})
Construct the solver from a factor graph and an ordering.
Definition MultifrontalSolver.cpp:529
MultifrontalClique Node
Node type for tree traversal utilities.
Definition MultifrontalSolver.h:99
bool partiallyEliminated_
Whether partial elimination ran.
Definition MultifrontalSolver.h:109
Ordering ordering_
Complete variable ordering.
Definition MultifrontalSolver.h:110
std::shared_ptr< MultifrontalClique > CliquePtr
Shared pointer to a MultifrontalClique.
Definition MultifrontalSolver.h:97
std::vector< CliquePtr > cliques_
All cliques in the solver.
Definition MultifrontalSolver.h:103
std::unordered_set< Key > fixedKeys_
Keys fixed by constrained factors.
Definition MultifrontalSolver.h:106
bool hasDeltaError_
Whether updateSolution computed it.
Definition MultifrontalSolver.h:115
bool eliminated_
Whether eliminateInPlace() ran.
Definition MultifrontalSolver.h:108
double lastNewError_
Cached new linearized error.
Definition MultifrontalSolver.h:114
size_t firstPhaseSize_
Prefix eliminated in partial mode.
Definition MultifrontalSolver.h:111
bool loaded_
Whether load() has been called.
Definition MultifrontalSolver.h:107
std::map< Key, size_t > dims_
Map from variable key to dimension.
Definition MultifrontalSolver.h:104
std::vector< CliquePtr > roots_
Roots of the elimination tree.
Definition MultifrontalSolver.h:102
Precomputed symbolic and sizing data for multifrontal solver construction.
Definition MultifrontalSolver.h:88
std::vector< size_t > rowCounts
Row counts indexed by factor index.
Definition MultifrontalSolver.h:93
std::map< Key, size_t > dims
Map from variable key to dimension.
Definition MultifrontalSolver.h:89
IndexedJunctionTree indexedJunctionTree
Precomputed indexed junction tree.
Definition MultifrontalSolver.h:92
std::unordered_set< Key > fixedKeys
Keys fixed by constrained factors.
Definition MultifrontalSolver.h:90
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:73
A symbolic junction tree whose factors record the original factor indices from a corresponding (non-s...
Definition IndexedJunctionTree.h:58