22 #include <boost/assign/list_inserter.hpp>
32 typedef std::vector<Key> Base;
42 template<
typename KEYS>
43 explicit Ordering(
const KEYS& keys) : Base(keys.begin(), keys.end()) {}
46 template<
typename ITERATOR>
47 Ordering(ITERATOR firstKey, ITERATOR lastKey) : Base(firstKey, lastKey) {}
51 boost::assign::list_inserter<boost::assign_detail::call_push_back<This> >
53 return boost::assign::make_list_inserter(boost::assign_detail::call_push_back<This>(*
this))(key);
64 template<
class FACTOR>
79 template<
class FACTOR>
81 const std::vector<Key>& constrainLast,
bool forceOrder =
false) {
91 const std::vector<Key>& constrainLast,
bool forceOrder =
false);
101 template<
class FACTOR>
103 const std::vector<Key>& constrainFirst,
bool forceOrder =
false) {
114 const std::vector<Key>& constrainFirst,
bool forceOrder =
false);
125 template<
class FACTOR>
141 template <
class FACTOR>
144 std::vector<Key> keys(src.begin(), src.end());
145 std::stable_sort(keys.begin(), keys.end());
153 GTSAM_EXPORT
void print(
const std::string& str =
"",
const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const;
155 GTSAM_EXPORT
bool equals(
const Ordering& other,
double tol = 1e-9)
const;
162 const VariableIndex& variableIndex, std::vector<int>& cmember);
166 template<
class ARCHIVE>
167 void serialize(ARCHIVE & ar,
const unsigned int version) {
168 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
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:52
static Ordering Natural(const FactorGraph< FACTOR > &fg)
Return a natural Ordering. Typically used by iterative solvers.
Definition: Ordering.h:142
A factor graph is a bipartite graph with factor nodes connected to variable nodes.
Definition: BayesTree.h:32
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:65
A thin wrapper around std::set that uses boost's fast_pool_allocator.
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:80
FastMap< Key, size_t > invert() const
Invert (not reverse) the ordering - returns a map from key to order position.
Definition: Ordering.cpp:31
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:102
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:126
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: Ordering.h:36
Ordering(const KEYS &keys)
Create from a container.
Definition: Ordering.h:43
Template to create a binary predicate.
Definition: Testable.h:102
The VariableIndex class computes and stores the block column structure of a factor graph...
Definition: VariableIndex.h:42
size_t Key
Integer nonlinear key type.
Definition: types.h:59
Ordering(ITERATOR firstKey, ITERATOR lastKey)
Create an ordering using iterators over keys.
Definition: Ordering.h:47
FastSet< Key > keys() const
Potentially very slow function to return all keys involved.
Definition: FactorGraph-inst.h:75
Definition: Ordering.h:30
Ordering This
Typedef to this class.
Definition: Ordering.h:35
friend class boost::serialization::access
Serialization function.
Definition: Ordering.h:165
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: types.h:62
GTSAM_EXPORT Ordering()
Create an empty ordering.
Definition: Ordering.h:39