27 #include <boost/assign/list_inserter.hpp> 35 typedef std::vector<Key> Base;
41 COLAMD, METIS, NATURAL, CUSTOM
53 template<
typename KEYS>
55 Base(keys.begin(), keys.end()) {
59 template<
typename ITERATOR>
60 Ordering(ITERATOR firstKey, ITERATOR lastKey) :
61 Base(firstKey, lastKey) {
66 boost::assign::list_inserter<boost::assign_detail::call_push_back<This> >
operator+=(
68 return boost::assign::make_list_inserter(
69 boost::assign_detail::call_push_back<This>(*
this))(key);
80 template<
class FACTOR>
99 template<
class FACTOR>
101 const std::vector<Key>& constrainLast,
bool forceOrder =
false) {
115 const VariableIndex& variableIndex,
const std::vector<Key>& constrainLast,
116 bool forceOrder =
false);
126 template<
class FACTOR>
128 const std::vector<Key>& constrainFirst,
bool forceOrder =
false) {
144 const std::vector<Key>& constrainFirst,
bool forceOrder =
false);
155 template<
class FACTOR>
175 template<
class FACTOR>
178 std::vector<Key> keys(src.begin(), src.end());
179 std::stable_sort(keys.begin(), keys.end());
184 template<
class FACTOR>
185 static GTSAM_EXPORT
void CSRFormat(std::vector<int>& xadj,
191 template<
class FACTOR>
200 template<
class FACTOR>
206 switch (orderingType) {
214 throw std::runtime_error(
215 "Ordering::Create error: called with CUSTOM ordering type.");
217 throw std::runtime_error(
218 "Ordering::Create error: called with unknown ordering type.");
227 void print(
const std::string& str =
"",
const KeyFormatter& keyFormatter =
228 DefaultKeyFormatter)
const;
238 const VariableIndex& variableIndex, std::vector<int>& cmember);
242 template<
class ARCHIVE>
243 void serialize(ARCHIVE & ar,
const unsigned int version) {
244 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
static GTSAM_EXPORT Ordering Metis(const MetisIndex &met)
Compute an ordering determined by METIS from a VariableIndex.
Definition: Ordering.cpp:201
static Ordering ColamdConstrained(const FactorGraph< FACTOR > &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:156
Ordering This
Typedef to this class.
Definition: Ordering.h:44
GTSAM_EXPORT Ordering()
Create an empty ordering.
Definition: Ordering.h:49
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:66
OrderingType
Type of ordering to use.
Definition: Ordering.h:40
static GTSAM_EXPORT void CSRFormat(std::vector< int > &xadj, std::vector< int > &adj, const FactorGraph< FACTOR > &graph)
METIS Formatting function.
friend class boost::serialization::access
Serialization function.
Definition: Ordering.h:241
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
static Ordering ColamdConstrainedLast(const FactorGraph< FACTOR > &graph, const std::vector< Key > &constrainLast, bool forceOrder=false)
Compute a fill-reducing ordering using constrained COLAMD from a factor graph (see details for note o...
Definition: Ordering.h:100
The VariableIndex class computes and stores the block column structure of a factor graph...
Definition: VariableIndex.h:42
static Ordering Natural(const FactorGraph< FACTOR > &fg)
Return a natural Ordering. Typically used by iterative solvers.
Definition: Ordering.h:176
Template to create a binary predicate.
Definition: Testable.h:110
FastMap< Key, size_t > invert() const
Invert (not reverse) the ordering - returns a map from key to order position.
Definition: Ordering.cpp:36
bool empty() const
Check if the graph is empty (null factors set by remove() will cause this to return false)...
Definition: FactorGraph.h:265
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
Definition: Ordering.h:33
The MetisIndex class converts a factor graph into the Compressed Sparse Row format for use in METIS a...
Definition: MetisIndex.h:46
A thin wrapper around std::set that uses boost's fast_pool_allocator.
Ordering(ITERATOR firstKey, ITERATOR lastKey)
Create an ordering using iterators over keys.
Definition: Ordering.h:60
KeySet keys() const
Potentially slow function to return all keys involved, sorted, as a set.
Definition: FactorGraph-inst.h:75
A factor graph is a bipartite graph with factor nodes connected to variable nodes.
Definition: BayesTree.h:32
static Ordering ColamdConstrainedFirst(const FactorGraph< FACTOR > &graph, const std::vector< Key > &constrainFirst, bool forceOrder=false)
Compute a fill-reducing ordering using constrained COLAMD from a factor graph (see details for note o...
Definition: Ordering.h:127
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: Ordering.h:45
Ordering(const KEYS &keys)
Create from a container.
Definition: Ordering.h:54
static Ordering Colamd(const FactorGraph< FACTOR > &graph)
Compute a fill-reducing ordering using COLAMD from a factor graph (see details for note on performanc...
Definition: Ordering.h:81
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
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