22#include <gtsam/dllexport.h>
24#include <boost/serialization/version.hpp>
25#include <boost/serialization/nvp.hpp>
26#include <boost/shared_ptr.hpp>
31namespace serialization {
39class GaussianFactorGraph;
40struct PreconditionerParameters;
48 inline bool isUnitWeight()
const {
return (weight == 1.0); }
49 friend std::ostream &operator<<(std::ostream &os,
const Edge &edge);
52 friend class boost::serialization::access;
53 template <
class Archive>
54 void serialize(Archive &ar,
const unsigned int ) {
55 ar &BOOST_SERIALIZATION_NVP(index);
56 ar &BOOST_SERIALIZATION_NVP(weight);
60 typedef std::vector<Edge> Edges;
61 typedef std::vector<size_t> EdgeIndices;
62 typedef Edges::iterator iterator;
63 typedef Edges::const_iterator const_iterator;
71 Subgraph(
const Edges &edges) : edges_(edges) {}
72 Subgraph(
const std::vector<size_t> &indices);
74 inline const Edges &edges()
const {
return edges_; }
75 inline size_t size()
const {
return edges_.size(); }
76 EdgeIndices edgeIndices()
const;
78 iterator begin() {
return edges_.begin(); }
79 const_iterator begin()
const {
return edges_.begin(); }
80 iterator end() {
return edges_.end(); }
81 const_iterator end()
const {
return edges_.end(); }
83 void save(
const std::string &fn)
const;
84 static Subgraph load(
const std::string &fn);
85 friend std::ostream &operator<<(std::ostream &os,
const Subgraph &subgraph);
88 friend class boost::serialization::access;
89 template <
class Archive>
90 void serialize(Archive &ar,
const unsigned int ) {
91 ar &BOOST_SERIALIZATION_NVP(edges_);
97 typedef boost::shared_ptr<SubgraphBuilderParameters> shared_ptr;
106 enum SkeletonWeight {
113 enum AugmentationWeight {
120 } augmentationWeight;
126 : skeletonType(KRUSKAL),
127 skeletonWeight(RANDOM),
128 augmentationWeight(SKELETON),
129 augmentationFactor(1.0) {}
134 virtual void print(std::ostream &os)
const;
135 friend std::ostream &operator<<(std::ostream &os,
136 const PreconditionerParameters &p);
138 static Skeleton skeletonTranslator(
const std::string &s);
139 static std::string skeletonTranslator(Skeleton s);
140 static SkeletonWeight skeletonWeightTranslator(
const std::string &s);
141 static std::string skeletonWeightTranslator(SkeletonWeight w);
142 static AugmentationWeight augmentationWeightTranslator(
const std::string &s);
143 static std::string augmentationWeightTranslator(AugmentationWeight w);
150 typedef std::vector<double> Weights;
161 const std::vector<double> &weights)
const;
167 const std::vector<double> &weights)
const;
168 std::vector<size_t> sample(
const std::vector<double> &weights,
169 const size_t t)
const;
180std::pair<boost::shared_ptr<GaussianFactorGraph>, boost::shared_ptr<GaussianFactorGraph> >
Typedefs for easier changing of types.
A thin wrapper around std::map that uses boost's fast_pool_allocator.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:112
void save(const Matrix &A, const string &s, const string &filename)
save a matrix to file, which can be loaded by matlab
Definition: Matrix.cpp:166
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
std::pair< GaussianFactorGraph::shared_ptr, GaussianFactorGraph::shared_ptr > splitFactorGraph(const GaussianFactorGraph &factorGraph, const Subgraph &subgraph)
Split the graph into a subgraph and the remaining edges.
Definition: SubgraphBuilder.cpp:463
GaussianFactorGraph::shared_ptr buildFactorSubgraph(const GaussianFactorGraph &gfg, const Subgraph &subgraph, const bool clone)
Select the factors in a factor graph according to the subgraph.
Definition: SubgraphBuilder.cpp:449
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition: GaussianFactorGraph.h:69
Definition: SubgraphBuilder.h:43
Definition: SubgraphBuilder.h:45
Definition: SubgraphBuilder.h:96
double augmentationFactor
factor multiplied with n, yields number of extra edges.
Definition: SubgraphBuilder.h:123
Definition: SubgraphBuilder.h:147