Improve Summary::FullReport when line search is used.
Disable reporting of preconditioner when direct factorization
is being used.
Change-Id: Id264d2292c5cab608724a6a8fab5d588db950468
diff --git a/internal/ceres/solver.cc b/internal/ceres/solver.cc
index 9ff2d15..426a270 100644
--- a/internal/ceres/solver.cc
+++ b/internal/ceres/solver.cc
@@ -152,6 +152,7 @@
};
using internal::StringAppendF;
+using internal::StringPrintf;
string Solver::Summary::FullReport() const {
string report =
@@ -224,9 +225,6 @@
StringAppendF(&report, "Preconditioner %25s%25s\n",
PreconditionerTypeToString(preconditioner_type),
PreconditionerTypeToString(preconditioner_type));
- } else {
- StringAppendF(&report, "Preconditioner %25s%25s\n",
- "N/A", "N/A");
}
StringAppendF(&report, "Threads % 25d% 25d\n",
@@ -266,18 +264,29 @@
} else {
// LINE_SEARCH HEADER
StringAppendF(&report, "\nMinimizer %19s\n", "LINE_SEARCH");
- if (line_search_direction_type == LBFGS) {
- StringAppendF(&report, "Line search direction %19s(%d)\n",
- LineSearchDirectionTypeToString(line_search_direction_type),
- max_lbfgs_rank);
- } else {
- StringAppendF(&report, "Line search direction %19s\n",
- LineSearchDirectionTypeToString(
- line_search_direction_type));
- }
- StringAppendF(&report, "Line search type %19s\n",
- LineSearchTypeToString(line_search_type));
+
+ string line_search_direction_string;
+ if (line_search_direction_type == LBFGS) {
+ line_search_direction_string = StringPrintf("LBFGS (%d)", max_lbfgs_rank);
+ } else if (line_search_direction_type == NONLINEAR_CONJUGATE_GRADIENT) {
+ line_search_direction_string =
+ NonlinearConjugateGradientTypeToString(
+ nonlinear_conjugate_gradient_type);
+ } else {
+ line_search_direction_string =
+ LineSearchDirectionTypeToString(line_search_direction_type);
+ }
+
+ StringAppendF(&report, "Line search direction %19s\n",
+ line_search_direction_string.c_str());
+
+ const string line_search_type_string =
+ StringPrintf("%s %s",
+ LineSearchInterpolationTypeToString(line_search_interpolation_type),
+ LineSearchTypeToString(line_search_type));
+ StringAppendF(&report, "Line search type %19s\n",
+ line_search_type_string.c_str());
StringAppendF(&report, "\n");
StringAppendF(&report, "%45s %21s\n", "Given", "Used");
@@ -307,10 +316,16 @@
StringAppendF(&report, "\nMinimizer iterations % 16d\n",
num_successful_steps + num_unsuccessful_steps);
- StringAppendF(&report, "Successful steps % 14d\n",
- num_successful_steps);
- StringAppendF(&report, "Unsuccessful steps % 14d\n",
- num_unsuccessful_steps);
+
+ // Successful/Unsuccessful steps only matter in the case of the
+ // trust region solver. Line search terminates when it encounters
+ // the first unsuccessful step.
+ if (minimizer_type == TRUST_REGION) {
+ StringAppendF(&report, "Successful steps % 14d\n",
+ num_successful_steps);
+ StringAppendF(&report, "Unsuccessful steps % 14d\n",
+ num_unsuccessful_steps);
+ }
if (inner_iterations_used) {
StringAppendF(&report, "Steps with inner iterations % 14d\n",
num_inner_iteration_steps);
diff --git a/internal/ceres/solver_impl.cc b/internal/ceres/solver_impl.cc
index 1696e3a..b5d6fcb 100644
--- a/internal/ceres/solver_impl.cc
+++ b/internal/ceres/solver_impl.cc
@@ -624,6 +624,11 @@
original_options.line_search_direction_type;
summary->max_lbfgs_rank = original_options.max_lbfgs_rank;
summary->line_search_type = original_options.line_search_type;
+ summary->line_search_interpolation_type =
+ original_options.line_search_interpolation_type;
+ summary->nonlinear_conjugate_gradient_type =
+ original_options.nonlinear_conjugate_gradient_type;
+
summary->num_parameter_blocks = original_program->NumParameterBlocks();
summary->num_parameters = original_program->NumParameters();
summary->num_residual_blocks = original_program->NumResidualBlocks();