Check return status in nist evaluation.
Previously, the return status was ignored, which meant that e.g. a
numerical failure (which returns 0 final error) would be counted as
correct answer (as the final error is at least as good as the certified
error).
Change-Id: Ia627d5fadf9b20100e628519af794ce0c0b195f4
diff --git a/examples/nist.cc b/examples/nist.cc
index 2b7efad..440ab5c 100644
--- a/examples/nist.cc
+++ b/examples/nist.cc
@@ -85,6 +85,14 @@
}
}
+bool IsSuccessfulTermination(ceres::SolverTerminationType status) {
+ return
+ (status == ceres::FUNCTION_TOLERANCE) ||
+ (status == ceres::GRADIENT_TOLERANCE) ||
+ (status == ceres::PARAMETER_TOLERANCE) ||
+ (status == ceres::USER_SUCCESS);
+}
+
class NISTProblem {
public:
explicit NISTProblem(const std::string& filename) {
@@ -368,7 +376,8 @@
const ceres::Solver::Summary& summary = summaries[start];
int num_matching_digits = 0;
- if (summary.final_cost < certified_cost) {
+ if (IsSuccessfulTermination(summary.termination_type)
+ && summary.final_cost < certified_cost) {
num_matching_digits = kMinNumMatchingDigits + 1;
} else {
num_matching_digits =