50 bool read(std::istream& )
override {
return false; }
52 bool write(std::ostream& )
const override {
return false; }
57 Eigen::Vector3d::ConstMapType v(update);
72 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
74 bool read(std::istream& )
override {
78 bool write(std::ostream& )
const override {
85 const T& a = params[0];
86 const T& b = params[1];
87 const T& lambda = params[2];
88 T fval = a * exp(-lambda * T(
measurement()(0))) + b;
96int main(
int argc,
char** argv) {
102 arg.
param(
"dump", dumpFilename,
"",
"dump the points into a file");
103 arg.
param(
"numPoints", numPoints, 50,
104 "number of points sampled from the curve");
105 arg.
param(
"i", maxIterations, 10,
"perform n iterations");
106 arg.
param(
"v", verbose,
false,
"verbose output of the optimization process");
115 Eigen::Vector2d* points =
new Eigen::Vector2d[numPoints];
116 for (
int i = 0; i < numPoints; ++i) {
118 double y = a * exp(-lambda * x) + b;
125 if (dumpFilename.size() > 0) {
126 ofstream fout(dumpFilename.c_str());
127 for (
int i = 0; i < numPoints; ++i) fout << points[i].transpose() << endl;
145 Eigen::Vector3d(1, 1, 1));
148 for (
int i = 0; i < numPoints; ++i) {
161 if (verbose) cout << endl;
164 cout <<
"Target curve" << endl;
165 cout <<
"a * exp(-lambda * x) + b" << endl;
166 cout <<
"Iterative least squares solution" << endl;
167 cout <<
"a = " << params->
estimate()(0) << endl;
168 cout <<
"b = " << params->
estimate()(1) << endl;
169 cout <<
"lambda = " << params->
estimate()(2) << endl;
#define G2O_MAKE_AUTO_AD_FUNCTIONS
measurement for a point on the curve
bool read(std::istream &) override
read the vertex from a stream, i.e., the internal state of the vertex
bool write(std::ostream &) const override
write the vertex to a stream
bool operator()(const T *params, T *error) const
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EdgePointOnCurve()
the params, a, b, and lambda for a * exp(-lambda * t) + b
void oplusImpl(const double *update) override
bool read(std::istream &) override
read the vertex from a stream, i.e., the internal state of the vertex
bool write(std::ostream &) const override
write the vertex to a stream
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
void setToOriginImpl() override
sets the node to the origin (used in the multilevel stuff)
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
virtual void setMeasurement(const Measurement &m)
void setInformation(const InformationType &information)
const ErrorVector & error() const
const EstimateType & estimate() const
return the current estimate of the vertex
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
Command line parsing of argc and argv.
bool parseArgs(int argc, char **argv, bool exitOnError=true)
void param(const std::string &name, bool &p, bool defValue, const std::string &desc)
void setVertex(size_t i, Vertex *v)
virtual void setId(int id)
static OptimizationAlgorithmFactory * instance()
return the instance
static double gaussRand(double mean, double sigma)
static double uniformRand(double lowerBndr, double upperBndr)
int optimize(int iterations, bool online=false)
void setVerbose(bool verbose)
virtual bool initializeOptimization(HyperGraph::EdgeSet &eset)
void setAlgorithm(OptimizationAlgorithm *algorithm)
#define __PRETTY_FUNCTION__
#define G2O_USE_OPTIMIZATION_LIBRARY(libraryname)
virtual bool addEdge(HyperGraph::Edge *e)
virtual bool addVertex(HyperGraph::Vertex *v, Data *userData)
describe the properties of a solver