switch formatter and writer arguments
parent
501a6dbd3b
commit
c27cd7a2e8
|
|
@ -133,7 +133,9 @@ class DiscreteBayesTree {
|
||||||
|
|
||||||
#include <gtsam/inference/DotWriter.h>
|
#include <gtsam/inference/DotWriter.h>
|
||||||
class DotWriter {
|
class DotWriter {
|
||||||
DotWriter();
|
DotWriter(double figureWidthInches = 5, double figureHeightInches = 5,
|
||||||
|
bool plotFactorPoints = true, bool connectKeysToFactor = true,
|
||||||
|
bool binaryEdges = true);
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <gtsam/discrete/DiscreteFactorGraph.h>
|
#include <gtsam/discrete/DiscreteFactorGraph.h>
|
||||||
|
|
@ -153,13 +155,13 @@ class DiscreteFactorGraph {
|
||||||
void print(string s = "") const;
|
void print(string s = "") const;
|
||||||
bool equals(const gtsam::DiscreteFactorGraph& fg, double tol = 1e-9) const;
|
bool equals(const gtsam::DiscreteFactorGraph& fg, double tol = 1e-9) const;
|
||||||
|
|
||||||
string dot(const gtsam::DotWriter& dotWriter = gtsam::DotWriter(),
|
string dot(
|
||||||
const gtsam::KeyFormatter& keyFormatter =
|
const gtsam::KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter,
|
||||||
gtsam::DefaultKeyFormatter) const;
|
const gtsam::DotWriter& dotWriter = gtsam::DotWriter()) const;
|
||||||
void saveGraph(string s,
|
void saveGraph(
|
||||||
const gtsam::DotWriter& dotWriter = gtsam::DotWriter(),
|
string s,
|
||||||
const gtsam::KeyFormatter& keyFormatter =
|
const gtsam::KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter,
|
||||||
gtsam::DefaultKeyFormatter) const;
|
const gtsam::DotWriter& dotWriter = gtsam::DotWriter()) const;
|
||||||
|
|
||||||
gtsam::DecisionTreeFactor product() const;
|
gtsam::DecisionTreeFactor product() const;
|
||||||
double operator()(const gtsam::DiscreteValues& values) const;
|
double operator()(const gtsam::DiscreteValues& values) const;
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,15 @@ struct GTSAM_EXPORT DotWriter {
|
||||||
///< the dot of the factor
|
///< the dot of the factor
|
||||||
bool binaryEdges; ///< just use non-dotted edges for binary factors
|
bool binaryEdges; ///< just use non-dotted edges for binary factors
|
||||||
|
|
||||||
DotWriter()
|
explicit DotWriter(double figureWidthInches = 5,
|
||||||
: figureWidthInches(5),
|
double figureHeightInches = 5,
|
||||||
figureHeightInches(5),
|
bool plotFactorPoints = true,
|
||||||
plotFactorPoints(true),
|
bool connectKeysToFactor = true, bool binaryEdges = true)
|
||||||
connectKeysToFactor(true),
|
: figureWidthInches(figureWidthInches),
|
||||||
binaryEdges(true) {}
|
figureHeightInches(figureHeightInches),
|
||||||
|
plotFactorPoints(plotFactorPoints),
|
||||||
|
connectKeysToFactor(connectKeysToFactor),
|
||||||
|
binaryEdges(binaryEdges) {}
|
||||||
|
|
||||||
/// Write out preamble, including size.
|
/// Write out preamble, including size.
|
||||||
void writePreamble(std::ostream* os) const;
|
void writePreamble(std::ostream* os) const;
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,9 @@ FactorIndices FactorGraph<FACTOR>::add_factors(const CONTAINER& factors,
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
template <class FACTOR>
|
template <class FACTOR>
|
||||||
void FactorGraph<FACTOR>::dot(std::ostream& os, const DotWriter& writer,
|
void FactorGraph<FACTOR>::dot(std::ostream& os,
|
||||||
const KeyFormatter& keyFormatter) const {
|
const KeyFormatter& keyFormatter,
|
||||||
|
const DotWriter& writer) const {
|
||||||
writer.writePreamble(&os);
|
writer.writePreamble(&os);
|
||||||
|
|
||||||
// Create nodes for each variable in the graph
|
// Create nodes for each variable in the graph
|
||||||
|
|
@ -153,20 +154,20 @@ void FactorGraph<FACTOR>::dot(std::ostream& os, const DotWriter& writer,
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
template <class FACTOR>
|
template <class FACTOR>
|
||||||
std::string FactorGraph<FACTOR>::dot(const DotWriter& writer,
|
std::string FactorGraph<FACTOR>::dot(const KeyFormatter& keyFormatter,
|
||||||
const KeyFormatter& keyFormatter) const {
|
const DotWriter& writer) const {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
dot(ss, writer, keyFormatter);
|
dot(ss, keyFormatter, writer);
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
template <class FACTOR>
|
template <class FACTOR>
|
||||||
void FactorGraph<FACTOR>::saveGraph(const std::string& filename,
|
void FactorGraph<FACTOR>::saveGraph(const std::string& filename,
|
||||||
const DotWriter& writer,
|
const KeyFormatter& keyFormatter,
|
||||||
const KeyFormatter& keyFormatter) const {
|
const DotWriter& writer) const {
|
||||||
std::ofstream of(filename.c_str());
|
std::ofstream of(filename.c_str());
|
||||||
dot(of, writer, keyFormatter);
|
dot(of, keyFormatter, writer);
|
||||||
of.close();
|
of.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -378,17 +378,18 @@ class FactorGraph {
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
/// Output to graphviz format, stream version.
|
/// Output to graphviz format, stream version.
|
||||||
void dot(std::ostream& os, const DotWriter& writer = DotWriter(),
|
void dot(std::ostream& os,
|
||||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
|
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
|
||||||
|
const DotWriter& writer = DotWriter()) const;
|
||||||
|
|
||||||
/// Output to graphviz format string.
|
/// Output to graphviz format string.
|
||||||
std::string dot(const DotWriter& writer = DotWriter(),
|
std::string dot(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
|
||||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
|
const DotWriter& writer = DotWriter()) const;
|
||||||
|
|
||||||
/// output to file with graphviz format.
|
/// output to file with graphviz format.
|
||||||
void saveGraph(const std::string& filename,
|
void saveGraph(const std::string& filename,
|
||||||
const DotWriter& writer = DotWriter(),
|
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
|
||||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
|
const DotWriter& writer = DotWriter()) const;
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
/// @name Advanced Interface
|
/// @name Advanced Interface
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@
|
||||||
#include <gtsam/linear/linearExceptions.h>
|
#include <gtsam/linear/linearExceptions.h>
|
||||||
#include <gtsam/linear/VectorValues.h>
|
#include <gtsam/linear/VectorValues.h>
|
||||||
#include <gtsam/inference/Ordering.h>
|
#include <gtsam/inference/Ordering.h>
|
||||||
#include <gtsam/inference/DotWriter.h>
|
|
||||||
#include <gtsam/inference/FactorGraph-inst.h>
|
#include <gtsam/inference/FactorGraph-inst.h>
|
||||||
#include <gtsam/config.h> // for GTSAM_USE_TBB
|
#include <gtsam/config.h> // for GTSAM_USE_TBB
|
||||||
|
|
||||||
|
|
@ -92,8 +91,8 @@ bool NonlinearFactorGraph::equals(const NonlinearFactorGraph& other, double tol)
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void NonlinearFactorGraph::dot(std::ostream& os, const Values& values,
|
void NonlinearFactorGraph::dot(std::ostream& os, const Values& values,
|
||||||
const GraphvizFormatting& writer,
|
const KeyFormatter& keyFormatter,
|
||||||
const KeyFormatter& keyFormatter) const {
|
const GraphvizFormatting& writer) const {
|
||||||
writer.writePreamble(&os);
|
writer.writePreamble(&os);
|
||||||
|
|
||||||
// Find bounds (imperative)
|
// Find bounds (imperative)
|
||||||
|
|
@ -139,21 +138,21 @@ void NonlinearFactorGraph::dot(std::ostream& os, const Values& values,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
std::string NonlinearFactorGraph::dot(
|
std::string NonlinearFactorGraph::dot(const Values& values,
|
||||||
const Values& values, const GraphvizFormatting& writer,
|
const KeyFormatter& keyFormatter,
|
||||||
const KeyFormatter& keyFormatter) const {
|
const GraphvizFormatting& writer) const {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
dot(ss, values, writer, keyFormatter);
|
dot(ss, values, keyFormatter, writer);
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void NonlinearFactorGraph::saveGraph(
|
void NonlinearFactorGraph::saveGraph(const std::string& filename,
|
||||||
const std::string& filename, const Values& values,
|
const Values& values,
|
||||||
const GraphvizFormatting& writer,
|
const KeyFormatter& keyFormatter,
|
||||||
const KeyFormatter& keyFormatter) const {
|
const GraphvizFormatting& writer) const {
|
||||||
std::ofstream of(filename);
|
std::ofstream of(filename);
|
||||||
dot(of, values, writer, keyFormatter);
|
dot(of, values, keyFormatter, writer);
|
||||||
of.close();
|
of.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,23 +213,22 @@ namespace gtsam {
|
||||||
using FactorGraph::saveGraph;
|
using FactorGraph::saveGraph;
|
||||||
|
|
||||||
/// Output to graphviz format, stream version, with Values/extra options.
|
/// Output to graphviz format, stream version, with Values/extra options.
|
||||||
void dot(
|
void dot(std::ostream& os, const Values& values,
|
||||||
std::ostream& os, const Values& values,
|
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
|
||||||
const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
|
const GraphvizFormatting& graphvizFormatting =
|
||||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
|
GraphvizFormatting()) const;
|
||||||
|
|
||||||
/// Output to graphviz format string, with Values/extra options.
|
/// Output to graphviz format string, with Values/extra options.
|
||||||
std::string dot(
|
std::string dot(const Values& values,
|
||||||
const Values& values,
|
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
|
||||||
const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
|
const GraphvizFormatting& graphvizFormatting =
|
||||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
|
GraphvizFormatting()) const;
|
||||||
|
|
||||||
/// output to file with graphviz format, with Values/extra options.
|
/// output to file with graphviz format, with Values/extra options.
|
||||||
void saveGraph(
|
void saveGraph(const std::string& filename, const Values& values,
|
||||||
const std::string& filename, const Values& values,
|
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
|
||||||
const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
|
const GraphvizFormatting& graphvizFormatting =
|
||||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
|
GraphvizFormatting()) const;
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -267,7 +266,14 @@ namespace gtsam {
|
||||||
std::ostream& os, const Values& values = Values(),
|
std::ostream& os, const Values& values = Values(),
|
||||||
const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
|
const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
|
||||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const {
|
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const {
|
||||||
dot(os, values, graphvizFormatting, keyFormatter);
|
dot(os, values, keyFormatter, graphvizFormatting);
|
||||||
|
}
|
||||||
|
/** \deprecated */
|
||||||
|
void GTSAM_DEPRECATED saveGraph(
|
||||||
|
const std::string& filename, const Values& values,
|
||||||
|
const GraphvizFormatting& graphvizFormatting = GraphvizFormatting(),
|
||||||
|
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const {
|
||||||
|
saveGraph(filename, values, keyFormatter, graphvizFormatting);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,12 @@ class NonlinearFactorGraph {
|
||||||
// enabling serialization functionality
|
// enabling serialization functionality
|
||||||
void serialize() const;
|
void serialize() const;
|
||||||
|
|
||||||
void saveGraph(const string& s) const;
|
string dot(
|
||||||
|
const gtsam::Values& values,
|
||||||
|
const gtsam::KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter);
|
||||||
|
void saveGraph(const string& s, const gtsam::Values& values,
|
||||||
|
const gtsam::KeyFormatter& keyFormatter =
|
||||||
|
gtsam::DefaultKeyFormatter) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <gtsam/nonlinear/NonlinearFactor.h>
|
#include <gtsam/nonlinear/NonlinearFactor.h>
|
||||||
|
|
@ -782,6 +787,12 @@ class ISAM2 {
|
||||||
|
|
||||||
void printStats() const;
|
void printStats() const;
|
||||||
gtsam::VectorValues gradientAtZero() const;
|
gtsam::VectorValues gradientAtZero() const;
|
||||||
|
|
||||||
|
string dot(const gtsam::KeyFormatter& keyFormatter =
|
||||||
|
gtsam::DefaultKeyFormatter) const;
|
||||||
|
void saveGraph(string s,
|
||||||
|
const gtsam::KeyFormatter& keyFormatter =
|
||||||
|
gtsam::DefaultKeyFormatter) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <gtsam/nonlinear/NonlinearISAM.h>
|
#include <gtsam/nonlinear/NonlinearISAM.h>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue