Add IterationSummary::step_is_nonmonotonic. So that IterationCallback objects know the kind of step that they are dealing with. Change-Id: I7782b211af882bd7b67307c3c23d8021cb56e8ab
diff --git a/include/ceres/ceres.h b/include/ceres/ceres.h index 1ea782a..b28c016 100644 --- a/include/ceres/ceres.h +++ b/include/ceres/ceres.h
@@ -34,8 +34,8 @@ #ifndef CERES_PUBLIC_CERES_H_ #define CERES_PUBLIC_CERES_H_ -#define CERES_VERSION 1.3.0 -#define CERES_ABI_VERSION 1.3.0 +#define CERES_VERSION 1.4.0 +#define CERES_ABI_VERSION 1.4.0 #include "ceres/autodiff_cost_function.h" #include "ceres/cost_function.h"
diff --git a/include/ceres/iteration_callback.h b/include/ceres/iteration_callback.h index 29157d3..57cf0a6 100644 --- a/include/ceres/iteration_callback.h +++ b/include/ceres/iteration_callback.h
@@ -42,6 +42,21 @@ // This struct describes the state of the optimizer after each // iteration of the minimization. struct IterationSummary { + IterationSummary() + : iteration(0), + step_is_valid(false), + step_is_nonmonotonic(false), + step_is_successful(false), + cost(0.0), + cost_change(0.0), + gradient_max_norm(0.0), + step_norm(0.0), + eta(0.0), + linear_solver_iterations(0), + iteration_time_in_seconds(0.0), + step_solver_time_in_seconds(0.0), + cumulative_time_in_seconds(0.0) {} + // Current iteration number. int32 iteration; @@ -51,7 +66,22 @@ // Note: step_is_valid is false when iteration = 0. bool step_is_valid; - // Whether or not the algorithm made progress in this iteration. + // Step did not reduce the value of the objective function + // sufficiently, but it was accepted because of the relaxed + // acceptance criterion used by the non-monotonic trust region + // algorithm. + // + // Note: step_is_nonmonotonic is false when iteration = 0; + bool step_is_nonmonotonic; + + // Whether or not the minimizer accepted this step or not. If the + // ordinary trust region algorithm is used, this means that the + // relative reduction in the objective function value was greater + // than Solver::Options::min_relative_decrease. However, if the + // non-monotonic trust region algorithm is used + // (Solver::Options:use_nonmonotonic_steps = true), then even if the + // relative decrease is not sufficient, the algorithm may accept the + // step and the step is declared successful. // // Note: step_is_successful is false when iteration = 0. bool step_is_successful; @@ -60,8 +90,7 @@ double cost; // Change in the value of the objective function in this - // iteration. This can be positive or negative. Negative change - // means that the step was not successful. + // iteration. This can be positive or negative. double cost_change; // Infinity norm of the gradient vector.
diff --git a/internal/ceres/trust_region_minimizer.cc b/internal/ceres/trust_region_minimizer.cc index 9f93deb..dd49f9e 100644 --- a/internal/ceres/trust_region_minimizer.cc +++ b/internal/ceres/trust_region_minimizer.cc
@@ -397,6 +397,7 @@ accumulated_candidate_model_cost_change += model_cost_change; accumulated_reference_model_cost_change += model_cost_change; if (relative_decrease <= options_.min_relative_decrease) { + iteration_summary.step_is_nonmonotonic = true; VLOG(2) << "Non-monotonic step! " << " relative_decrease: " << relative_decrease << " historical_relative_decrease: "