96 {
97 int numPoints;
98 int maxIterations;
99 bool verbose;
100 string dumpFilename;
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");
107
109
110
112 double a = 2.;
113 double b = 0.4;
114 double lambda = 0.2;
115 Eigen::Vector2d* points = new Eigen::Vector2d[numPoints];
116 for (int i = 0; i < numPoints; ++i) {
118 double y = a *
exp(-lambda * x) + b;
119
121 points[i].x() = x;
122 points[i].y() = y;
123 }
124
125 if (dumpFilename.size() > 0) {
126 ofstream fout(dumpFilename.c_str());
127 for (int i = 0; i < numPoints; ++i) fout << points[i].transpose() << endl;
128 }
129
130
133
134
138 solverProperty));
139
140
141
145 Eigen::Vector3d(1, 1, 1));
147
148 for (int i = 0; i < numPoints; ++i) {
154 }
155
156
160
161 if (verbose) cout << endl;
162
163
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;
170 cout << endl;
171
172
173 delete[] points;
174
175 return 0;
176}
measurement for a point on the curve
the params, a, b, and lambda for a * exp(-lambda * t) + b
virtual void setMeasurement(const Measurement &m)
void setInformation(const InformationType &information)
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)
Jet< T, N > exp(const Jet< T, N > &f)
virtual bool addEdge(HyperGraph::Edge *e)
virtual bool addVertex(HyperGraph::Vertex *v, Data *userData)
describe the properties of a solver