mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-29 16:40:38 +08:00
Improve Summary::FullReport when line search is used.
Disable reporting of preconditioner when direct factorization is being used. Change-Id: Id264d2292c5cab608724a6a8fab5d588db950468
This commit is contained in:
@@ -716,6 +716,8 @@ class Solver {
|
||||
|
||||
LineSearchDirectionType line_search_direction_type;
|
||||
LineSearchType line_search_type;
|
||||
LineSearchInterpolationType line_search_interpolation_type;
|
||||
NonlinearConjugateGradient nonlinear_conjugate_gradient_type;
|
||||
|
||||
int max_lbfgs_rank;
|
||||
};
|
||||
|
||||
+33
-18
@@ -152,6 +152,7 @@ string Solver::Summary::BriefReport() const {
|
||||
};
|
||||
|
||||
using internal::StringAppendF;
|
||||
using internal::StringPrintf;
|
||||
|
||||
string Solver::Summary::FullReport() const {
|
||||
string report =
|
||||
@@ -224,9 +225,6 @@ string Solver::Summary::FullReport() const {
|
||||
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 @@ string Solver::Summary::FullReport() const {
|
||||
} 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 @@ string Solver::Summary::FullReport() const {
|
||||
|
||||
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);
|
||||
|
||||
@@ -624,6 +624,11 @@ void SolverImpl::LineSearchSolve(const Solver::Options& original_options,
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user