22 #include <gtsam/dllexport.h> 24 #include <boost/serialization/nvp.hpp> 25 #include <boost/shared_ptr.hpp> 30 namespace serialization {
38 class GaussianFactorGraph;
39 struct PreconditionerParameters;
47 inline bool isUnitWeight()
const {
return (weight == 1.0); }
48 friend std::ostream &operator<<(std::ostream &os,
const Edge &edge);
51 friend class boost::serialization::access;
52 template <
class Archive>
53 void serialize(Archive &ar,
const unsigned int ) {
54 ar &BOOST_SERIALIZATION_NVP(index);
55 ar &BOOST_SERIALIZATION_NVP(weight);
59 typedef std::vector<Edge> Edges;
60 typedef std::vector<size_t> EdgeIndices;
61 typedef Edges::iterator iterator;
62 typedef Edges::const_iterator const_iterator;
70 Subgraph(
const Edges &edges) : edges_(edges) {}
71 Subgraph(
const std::vector<size_t> &indices);
73 inline const Edges &edges()
const {
return edges_; }
74 inline size_t size()
const {
return edges_.size(); }
75 EdgeIndices edgeIndices()
const;
77 iterator begin() {
return edges_.begin(); }
78 const_iterator begin()
const {
return edges_.begin(); }
79 iterator end() {
return edges_.end(); }
80 const_iterator end()
const {
return edges_.end(); }
82 void save(
const std::string &fn)
const;
83 static Subgraph load(
const std::string &fn);
84 friend std::ostream &operator<<(std::ostream &os,
const Subgraph &subgraph);
87 friend class boost::serialization::access;
88 template <
class Archive>
89 void serialize(Archive &ar,
const unsigned int ) {
90 ar &BOOST_SERIALIZATION_NVP(edges_);
96 typedef boost::shared_ptr<SubgraphBuilderParameters> shared_ptr;
105 enum SkeletonWeight {
112 enum AugmentationWeight {
119 } augmentationWeight;
125 : skeletonType(KRUSKAL),
126 skeletonWeight(RANDOM),
127 augmentationWeight(SKELETON),
128 augmentationFactor(1.0) {}
133 virtual void print(std::ostream &os)
const;
134 friend std::ostream &operator<<(std::ostream &os,
135 const PreconditionerParameters &p);
137 static Skeleton skeletonTranslator(
const std::string &s);
138 static std::string skeletonTranslator(Skeleton s);
139 static SkeletonWeight skeletonWeightTranslator(
const std::string &s);
140 static std::string skeletonWeightTranslator(SkeletonWeight w);
141 static AugmentationWeight augmentationWeightTranslator(
const std::string &s);
142 static std::string augmentationWeightTranslator(AugmentationWeight w);
149 typedef std::vector<double> Weights;
160 const std::vector<double> &weights)
const;
166 const std::vector<double> &weights)
const;
167 std::vector<size_t> sample(
const std::vector<double> &weights,
168 const size_t t)
const;
179 std::pair<boost::shared_ptr<GaussianFactorGraph>, boost::shared_ptr<GaussianFactorGraph> >
Definition: SubgraphBuilder.h:44
double augmentationFactor
factor multiplied with n, yields number of extra edges.
Definition: SubgraphBuilder.h:122
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition: GaussianFactorGraph.h:65
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:162
Definition: SubgraphBuilder.h:146
Definition: SubgraphBuilder.h:42
A thin wrapper around std::map that uses boost's fast_pool_allocator.
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:514
Definition: SubgraphBuilder.h:95
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:528
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Typedefs for easier changing of types.