Fix to Roszman1's certified solution.
Extend nist.cc to test more nonlinear and linear solvers.

(Thanks to Markus Moll for finding the Roszman1 bug)

Change-Id: I92b4bab0771de85f7fe711fb0853f155991f4aaf
diff --git a/data/nist/Roszman1.dat b/data/nist/Roszman1.dat
index 0296837..1d67674 100644
--- a/data/nist/Roszman1.dat
+++ b/data/nist/Roszman1.dat
@@ -14,7 +14,7 @@
                predictor variable is the excited energy state.

                The argument to the ARCTAN function is in radians.

 

-Reference:     Roszman, L., NIST (19??).  

+Reference:     Roszman, L., NIST (19??).

                Quantum Defects for Sulfur I Atom.

 

 

@@ -38,7 +38,7 @@
           Starting Values                  Certified Values

 

         Start 1     Start 2           Parameter     Standard Deviation

-  b1 =      0.1         0.2         2.0196866396E-01  1.9172666023E-02

+  b1 =      0.1         0.2         1.20196866396E-0  1.9172666023E-02

   b2 =     -0.00001    -0.000005   -6.1953516256E-06  3.2058931691E-06

   b3 =   1000        1200           1.2044556708E+03  7.4050983057E+01

   b4 =   -100        -150          -1.8134269537E+02  4.9573513849E+01

diff --git a/examples/nist.cc b/examples/nist.cc
index fb85beb..2c1a4c5 100644
--- a/examples/nist.cc
+++ b/examples/nist.cc
@@ -363,24 +363,29 @@
   double certified_cost = summaries[nist_problem.num_starts()].initial_cost;
 
   int num_success = 0;
+  const int kMinNumMatchingDigits = 4;
   for (int start = 0; start < nist_problem.num_starts(); ++start) {
     const ceres::Solver::Summary& summary = summaries[start];
-    const int num_matching_digits =
-        -std::log10(1e-18 +
-                    fabs(summary.final_cost - certified_cost)
-                    / certified_cost);
-    std::cerr << "start " << start + 1 << " " ;
-    if (num_matching_digits > 4) {
-      ++num_success;
-      std::cerr <<  "SUCCESS";
+
+    int num_matching_digits = 0;
+    if (summary.final_cost < certified_cost) {
+      num_matching_digits = kMinNumMatchingDigits + 1;
     } else {
-      std::cerr << "FAILURE";
+      num_matching_digits =
+          -std::log10(fabs(summary.final_cost - certified_cost) / certified_cost);
     }
-    std::cerr << " digits: " << num_matching_digits;
-    std::cerr << " summary: "
-              << summary.BriefReport()
-              << std::endl;
+
+    if (num_matching_digits <= kMinNumMatchingDigits) {
+      std::cerr << "start " << start + 1 << " " ;
+      std::cerr <<  "FAILURE";
+      std::cerr << " summary: "
+                << summary.BriefReport()
+                << std::endl;
+    } else {
+      ++num_success;
+    }
   }
+
   return num_success;
 }
 
@@ -436,12 +441,45 @@
   // TODO(sameeragarwal): Test more combinations of non-linear and
   // linear solvers.
   ceres::Solver::Options options;
-  options.linear_solver_type = ceres::DENSE_QR;
-  options.max_num_iterations = 2000;
+  options.max_num_iterations = 10000;
   options.function_tolerance *= 1e-10;
   options.gradient_tolerance *= 1e-10;
   options.parameter_tolerance *= 1e-10;
 
+  options.linear_solver_type = ceres::DENSE_QR;
+  options.trust_region_strategy_type = ceres::LEVENBERG_MARQUARDT;
+  std::cerr << "Levenberg-Marquardt - DENSE_QR\n";
+  SolveNISTProblems(options);
+
+  options.trust_region_strategy_type = ceres::DOGLEG;
+  options.dogleg_type = ceres::TRADITIONAL_DOGLEG;
+  std::cerr << "\n\nTraditional Dogleg - DENSE_QR\n\n";
+  SolveNISTProblems(options);
+
+  options.trust_region_strategy_type = ceres::DOGLEG;
+  options.dogleg_type = ceres::SUBSPACE_DOGLEG;
+  std::cerr << "\n\nSubspace Dogleg - DENSE_QR\n\n";
+  SolveNISTProblems(options);
+
+  options.linear_solver_type = ceres::DENSE_NORMAL_CHOLESKY;
+  options.trust_region_strategy_type = ceres::LEVENBERG_MARQUARDT;
+  std::cerr << "Levenberg-Marquardt - DENSE_NORMAL_CHOLESKY\n";
+  SolveNISTProblems(options);
+
+  options.trust_region_strategy_type = ceres::DOGLEG;
+  options.dogleg_type = ceres::TRADITIONAL_DOGLEG;
+  std::cerr << "\n\nTraditional Dogleg - DENSE_NORMAL_CHOLESKY\n\n";
+  SolveNISTProblems(options);
+
+  options.trust_region_strategy_type = ceres::DOGLEG;
+  options.dogleg_type = ceres::SUBSPACE_DOGLEG;
+  std::cerr << "\n\nSubspace Dogleg - DENSE_NORMAL_CHOLESKY\n\n";
+  SolveNISTProblems(options);
+
+  options.linear_solver_type = ceres::CGNR;
+  options.preconditioner_type = ceres::JACOBI;
+  options.trust_region_strategy_type = ceres::LEVENBERG_MARQUARDT;
+  std::cerr << "Levenberg-Marquardt - CGNR + JACOBI\n";
   SolveNISTProblems(options);
 
   return 0;