28 #ifdef GTSAM_USE_BOOST_FEATURES 29 #include <boost/assign/list_inserter.hpp> 45 COLAMD, METIS, NATURAL, CUSTOM
59 template<
typename KEYS>
61 Base(keys.begin(), keys.end()) {
64 #ifdef GTSAM_USE_BOOST_FEATURES 65 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);
99 template<
class FACTOR_GRAPH>
118 template<
class FACTOR_GRAPH>
120 const KeyVector& constrainLast,
bool forceOrder =
false) {
135 bool forceOrder =
false);
145 template<
class FACTOR_GRAPH>
147 const KeyVector& constrainFirst,
bool forceOrder =
false) {
163 const KeyVector& constrainFirst,
bool forceOrder =
false);
174 template<
class FACTOR_GRAPH>
194 template<
class FACTOR_GRAPH>
198 std::stable_sort(keys.begin(), keys.end());
199 return Ordering(keys.begin(), keys.end());
203 template<
class FACTOR_GRAPH>
204 static GTSAM_EXPORT
void CSRFormat(std::vector<int>& xadj,
205 std::vector<int>& adj,
const FACTOR_GRAPH& graph);
210 template<
class FACTOR_GRAPH>
223 template<
class FACTOR_GRAPH>
225 const FACTOR_GRAPH& graph) {
229 switch (orderingType) {
237 throw std::runtime_error(
238 "Ordering::Create error: called with CUSTOM ordering type.");
240 throw std::runtime_error(
241 "Ordering::Create error: called with unknown ordering type.");
251 void print(
const std::string& str =
"",
const KeyFormatter& keyFormatter =
252 DefaultKeyFormatter)
const;
262 const VariableIndex& variableIndex, std::vector<int>& cmember);
264 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 266 friend class boost::serialization::access;
267 template<
class ARCHIVE>
268 void serialize(ARCHIVE & ar,
const unsigned int version) {
269 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:113
Definition: Testable.h:152
Ordering(const KEYS &keys)
Create from a container.
Definition: Ordering.h:60
Definition: Ordering.h:37
static GTSAM_EXPORT void CSRFormat(std::vector< int > &xadj, std::vector< int > &adj, const FACTOR_GRAPH &graph)
METIS Formatting function.
GTSAM_EXPORT Ordering()
Create an empty ordering.
Definition: Ordering.h:53
static GTSAM_EXPORT Ordering Metis(const MetisIndex &met)
Compute an ordering determined by METIS from a VariableIndex.
static Ordering Colamd(const FACTOR_GRAPH &graph)
Definition: Ordering.h:100
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: Ordering.h:49
Definition: Testable.h:112
static Ordering ColamdConstrainedFirst(const FACTOR_GRAPH &graph, const KeyVector &constrainFirst, bool forceOrder=false)
Definition: Ordering.h:146
OrderingType
Type of ordering to use.
Definition: Ordering.h:44
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
Definition: MetisIndex.h:37
static Ordering ColamdConstrained(const FACTOR_GRAPH &graph, const FastMap< Key, int > &groups)
Definition: Ordering.h:175
Definition: chartTesting.h:28
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:86
Definition: VariableIndex.h:41
bool contains(const Key &key) const
Check if key exists in ordering.
This & operator+=(KeyVector &keys)
Append new keys to the ordering as ordering += keys.
FastMap< Key, size_t > invert() const
Invert (not reverse) the ordering - returns a map from key to order position.
static Ordering ColamdConstrainedLast(const FACTOR_GRAPH &graph, const KeyVector &constrainLast, bool forceOrder=false)
Definition: Ordering.h:119
A thin wrapper around std::set that uses boost's fast_pool_allocator.
static Ordering Natural(const FACTOR_GRAPH &fg)
Return a natural Ordering. Typically used by iterative solvers.
Definition: Ordering.h:195
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
Ordering This
Typedef to this class.
Definition: Ordering.h:48