Ceres Solver: Wie kann man Lösungsgeschichte erhalten (iterativ während der Lösung gefunden)?C++

Programme in C++. Entwicklerforum
Anonymous
 Ceres Solver: Wie kann man Lösungsgeschichte erhalten (iterativ während der Lösung gefunden)?

Post by Anonymous »

In Ceres Solver, wie man Lösungshistorien erhält (iterativ während der Lösung gefunden)?

Code: Select all

ceres-solver$ git remote -v
origin  https://github.com/ceres-solver/ceres-solver.git (fetch)
origin  https://github.com/ceres-solver/ceres-solver.git (push)

ceres-solver$ git log -1 --oneline
85331393 (HEAD, tag: 2.2.0) Update docs for 2.2.0.

ceres-solver/build$ cmake ..; make # Build with cmake and make

ceres-solver/build$ ./bin/helloworld
iter      cost      cost_change  |gradient|   |step|    tr_ratio  tr_radius  ls_iter  iter_time  total_time
0  4.512500e+01    0.00e+00    9.50e+00   0.00e+00   0.00e+00  1.00e+04        0    7.15e-06    7.22e-05
1  4.511598e-07    4.51e+01    9.50e-04   0.00e+00   1.00e+00  3.00e+04        1    4.60e-05    1.46e-04
2  5.012552e-16    4.51e-07    3.17e-08   9.50e-04   1.00e+00  9.00e+04        1    2.86e-06    1.52e-04
Ceres Solver Report: Iterations: 3, Initial cost: 4.512500e+01, Final cost: 5.012552e-16, Termination: CONVERGENCE
x : 0.5 -> 10
Der Code und der Beispiel werden wie erwartet ausgeführt. (https://ceres-solver.googlesource.com/c ... example.cc) Um die Geschichte der Lösungen zu sichern, während die Lösung in mydata :: xs stattfindet. Hier ist was ich bekomme: < /p>

Code: Select all

ceres-solver$ git diff
diff --git a/examples/helloworld.cc b/examples/helloworld.cc
index c9972fd3..8a454a91 100644
--- a/examples/helloworld.cc
+++ b/examples/helloworld.cc
@@ -36,6 +36,34 @@
#include "ceres/ceres.h"
#include "glog/logging.h"

+class MyData {
+ public:
+  std::vector xs; // History of x.
+};
+
+// MyIterationCallback prints the iteration number, the cost and the value of
+// the parameter blocks every iteration.
+class MyIterationCallback : public ceres::IterationCallback {
+ public:
+  MyIterationCallback(const double* x, MyData* data) : x_(x), data_(data) {}
+
+  ~MyIterationCallback() override = default;
+
+  ceres::CallbackReturnType operator()(
+      const ceres::IterationSummary& summary) final {
+    std::cout

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post