28 #include <boost/assign/list_inserter.hpp> 42 COLAMD, METIS, NATURAL, CUSTOM
54 template<
typename KEYS>
56 Base(keys.begin(), keys.end()) {
60 template<
typename ITERATOR>
61 Ordering(ITERATOR firstKey, ITERATOR lastKey) :
62 Base(firstKey, lastKey) {
67 boost::assign::list_inserter<boost::assign_detail::call_push_back<This> >
operator+=(
69 return boost::assign::make_list_inserter(
70 boost::assign_detail::call_push_back<This>(*
this))(key);
81 template<
class FACTOR_GRAPH>
100 template<
class FACTOR_GRAPH>
102 const KeyVector& constrainLast,
bool forceOrder =
false) {
117 bool forceOrder =
false);
127 template<
class FACTOR_GRAPH>
129 const KeyVector& constrainFirst,
bool forceOrder =
false) {
145 const KeyVector& constrainFirst,
bool forceOrder =
false);
156 template<
class FACTOR_GRAPH>
176 template<
class FACTOR_GRAPH>
180 std::stable_sort(keys.begin(), keys.end());
185 template<
class FACTOR_GRAPH>
186 static GTSAM_EXPORT
void CSRFormat(std::vector<int>& xadj,
187 std::vector<int>& adj,
const FACTOR_GRAPH& graph);
192 template<
class FACTOR_GRAPH>
201 template<
class FACTOR_GRAPH>
203 const FACTOR_GRAPH& graph) {
207 switch (orderingType) {
215 throw std::runtime_error(
216 "Ordering::Create error: called with CUSTOM ordering type.");
218 throw std::runtime_error(
219 "Ordering::Create error: called with unknown ordering type.");
228 void print(
const std::string& str =
"",
const KeyFormatter& keyFormatter =
229 DefaultKeyFormatter)
const;
232 bool equals(
const Ordering& other,
double tol = 1e-9)
const;
239 const VariableIndex& variableIndex, std::vector<int>& cmember);
243 template<
class ARCHIVE>
244 void serialize(ARCHIVE & ar,
const unsigned int version) {
245 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
static Ordering Natural(const FACTOR_GRAPH &fg)
Return a natural Ordering. Typically used by iterative solvers.
Definition: Ordering.h:177
boost::assign::list_inserter< boost::assign_detail::call_push_back< This > > operator+=(Key key)
Add new variables to the ordering as ordering += key1, key2, ...
Definition: Ordering.h:67
static Ordering ColamdConstrained(const FACTOR_GRAPH &graph, const FastMap< Key, int > &groups)
Compute a fill-reducing ordering using constrained COLAMD from a factor graph (see details for note o...
Definition: Ordering.h:157
The MetisIndex class converts a factor graph into the Compressed Sparse Row format for use in METIS a...
Definition: MetisIndex.h:45
GTSAM_EXPORT Ordering()
Create an empty ordering.
Definition: Ordering.h:50
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
static GTSAM_EXPORT void CSRFormat(std::vector< int > &xadj, std::vector< int > &adj, const FACTOR_GRAPH &graph)
METIS Formatting function.
The VariableIndex class computes and stores the block column structure of a factor graph.
Definition: VariableIndex.h:43
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
A thin wrapper around std::set that uses boost's fast_pool_allocator.
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
static Ordering Colamd(const FACTOR_GRAPH &graph)
Compute a fill-reducing ordering using COLAMD from a factor graph (see details for note on performanc...
Definition: Ordering.h:82
friend class boost::serialization::access
Serialization function.
Definition: Ordering.h:242
Ordering This
Typedef to this class.
Definition: Ordering.h:45
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: Ordering.h:46
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:56
FastMap< Key, size_t > invert() const
Invert (not reverse) the ordering - returns a map from key to order position.
Definition: Ordering.cpp:36
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
static Ordering ColamdConstrainedFirst(const FACTOR_GRAPH &graph, const KeyVector &constrainFirst, bool forceOrder=false)
Compute a fill-reducing ordering using constrained COLAMD from a factor graph (see details for note o...
Definition: Ordering.h:128
Ordering(const KEYS &keys)
Create from a container.
Definition: Ordering.h:55
static GTSAM_EXPORT Ordering Metis(const MetisIndex &met)
Compute an ordering determined by METIS from a VariableIndex.
Definition: Ordering.cpp:212
OrderingType
Type of ordering to use.
Definition: Ordering.h:41
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
static Ordering ColamdConstrainedLast(const FACTOR_GRAPH &graph, const KeyVector &constrainLast, bool forceOrder=false)
Compute a fill-reducing ordering using constrained COLAMD from a factor graph (see details for note o...
Definition: Ordering.h:101
Ordering(ITERATOR firstKey, ITERATOR lastKey)
Create an ordering using iterators over keys.
Definition: Ordering.h:61
Definition: Ordering.h:34