10ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Ceres Solver - A fast non-linear least squares minimizer
20ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
30ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// http://code.google.com/p/ceres-solver/
40ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
50ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Redistribution and use in source and binary forms, with or without
60ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// modification, are permitted provided that the following conditions are met:
70ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
80ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// * Redistributions of source code must retain the above copyright notice,
90ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//   this list of conditions and the following disclaimer.
100ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// * Redistributions in binary form must reproduce the above copyright notice,
110ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//   this list of conditions and the following disclaimer in the documentation
120ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//   and/or other materials provided with the distribution.
130ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// * Neither the name of Google Inc. nor the names of its contributors may be
140ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//   used to endorse or promote products derived from this software without
150ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//   specific prior written permission.
160ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
170ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
180ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
190ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
200ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
210ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
220ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
230ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
240ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
250ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
260ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
270ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// POSSIBILITY OF SUCH DAMAGE.
280ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
290ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Author: sameeragarwal@google.com (Sameer Agarwal)
300ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
310ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// When an iteration callback is specified, Ceres calls the callback
320ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// after each minimizer step (if the minimizer has not converged) and
330ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// passes it an IterationSummary object, defined below.
340ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
350ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#ifndef CERES_PUBLIC_ITERATION_CALLBACK_H_
360ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#define CERES_PUBLIC_ITERATION_CALLBACK_H_
370ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
380ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#include "ceres/types.h"
3979397c21138f54fcff6ec067b44b847f1f7e0e98Carlos Hernandez#include "ceres/internal/disable_warnings.h"
400ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
410ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongnamespace ceres {
420ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
430ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// This struct describes the state of the optimizer after each
440ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// iteration of the minimization.
4579397c21138f54fcff6ec067b44b847f1f7e0e98Carlos Hernandezstruct CERES_EXPORT IterationSummary {
460ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  IterationSummary()
470ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong      : iteration(0),
480ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong        step_is_valid(false),
490ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong        step_is_nonmonotonic(false),
500ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong        step_is_successful(false),
510ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong        cost(0.0),
520ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong        cost_change(0.0),
530ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong        gradient_max_norm(0.0),
5479397c21138f54fcff6ec067b44b847f1f7e0e98Carlos Hernandez        gradient_norm(0.0),
550ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong        step_norm(0.0),
560ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong        eta(0.0),
571d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling        step_size(0.0),
581d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling        line_search_function_evaluations(0),
591d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling        line_search_gradient_evaluations(0),
601d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling        line_search_iterations(0),
610ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong        linear_solver_iterations(0),
620ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong        iteration_time_in_seconds(0.0),
630ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong        step_solver_time_in_seconds(0.0),
640ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong        cumulative_time_in_seconds(0.0) {}
650ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
660ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Current iteration number.
670ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  int32 iteration;
680ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
690ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Step was numerically valid, i.e., all values are finite and the
700ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // step reduces the value of the linearized model.
710ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  //
720ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Note: step_is_valid is false when iteration = 0.
730ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  bool step_is_valid;
740ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
750ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Step did not reduce the value of the objective function
760ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // sufficiently, but it was accepted because of the relaxed
770ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // acceptance criterion used by the non-monotonic trust region
780ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // algorithm.
790ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  //
800ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Note: step_is_nonmonotonic is false when iteration = 0;
810ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  bool step_is_nonmonotonic;
820ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
830ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Whether or not the minimizer accepted this step or not. If the
840ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // ordinary trust region algorithm is used, this means that the
850ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // relative reduction in the objective function value was greater
860ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // than Solver::Options::min_relative_decrease. However, if the
870ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // non-monotonic trust region algorithm is used
880ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // (Solver::Options:use_nonmonotonic_steps = true), then even if the
890ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // relative decrease is not sufficient, the algorithm may accept the
900ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // step and the step is declared successful.
910ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  //
920ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Note: step_is_successful is false when iteration = 0.
930ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  bool step_is_successful;
940ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
950ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Value of the objective function.
960ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  double cost;
970ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
980ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Change in the value of the objective function in this
990ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // iteration. This can be positive or negative.
1000ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  double cost_change;
1010ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
1020ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Infinity norm of the gradient vector.
1030ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  double gradient_max_norm;
1040ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
10579397c21138f54fcff6ec067b44b847f1f7e0e98Carlos Hernandez  // 2-norm of the gradient vector.
10679397c21138f54fcff6ec067b44b847f1f7e0e98Carlos Hernandez  double gradient_norm;
10779397c21138f54fcff6ec067b44b847f1f7e0e98Carlos Hernandez
1080ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // 2-norm of the size of the step computed by the optimization
1090ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // algorithm.
1100ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  double step_norm;
1110ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
1120ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // For trust region algorithms, the ratio of the actual change in
1130ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // cost and the change in the cost of the linearized approximation.
1140ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  double relative_decrease;
1150ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
1160ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Size of the trust region at the end of the current iteration. For
1170ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // the Levenberg-Marquardt algorithm, the regularization parameter
1180ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // mu = 1.0 / trust_region_radius.
1190ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  double trust_region_radius;
1200ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
1210ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // For the inexact step Levenberg-Marquardt algorithm, this is the
1220ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // relative accuracy with which the Newton(LM) step is solved. This
1230ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // number affects only the iterative solvers capable of solving
1240ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // linear systems inexactly. Factorization-based exact solvers
1250ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // ignore it.
1260ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  double eta;
1270ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
1281d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling  // Step sized computed by the line search algorithm.
1291d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling  double step_size;
1301d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling
1311d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling  // Number of function value evaluations used by the line search algorithm.
1321d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling  int line_search_function_evaluations;
1331d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling
1341d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling  // Number of function gradient evaluations used by the line search algorithm.
1351d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling  int line_search_gradient_evaluations;
1361d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling
1371d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling  // Number of iterations taken by the line search algorithm.
1381d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling  int line_search_iterations;
1391d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling
1400ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Number of iterations taken by the linear solver to solve for the
1410ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Newton step.
1420ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  int linear_solver_iterations;
1430ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
1441d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling  // All times reported below are wall times.
1451d2624a10e2c559f8ba9ef89eaa30832c0a83a96Sascha Haeberling
1460ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Time (in seconds) spent inside the minimizer loop in the current
1470ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // iteration.
1480ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  double iteration_time_in_seconds;
1490ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
1500ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Time (in seconds) spent inside the trust region step solver.
1510ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  double step_solver_time_in_seconds;
1520ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
1530ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  // Time (in seconds) since the user called Solve().
1540ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  double cumulative_time_in_seconds;
1550ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong};
1560ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
1570ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Interface for specifying callbacks that are executed at the end of
1580ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// each iteration of the Minimizer. The solver uses the return value
1590ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// of operator() to decide whether to continue solving or to
1600ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// terminate. The user can return three values.
1610ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
1620ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// SOLVER_ABORT indicates that the callback detected an abnormal
1630ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// situation. The solver returns without updating the parameter blocks
1640ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// (unless Solver::Options::update_state_every_iteration is set
1650ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// true). Solver returns with Solver::Summary::termination_type set to
1660ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// USER_ABORT.
1670ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
1680ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// SOLVER_TERMINATE_SUCCESSFULLY indicates that there is no need to
1690ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// optimize anymore (some user specified termination criterion has
1700ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// been met). Solver returns with Solver::Summary::termination_type
1710ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// set to USER_SUCCESS.
1720ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
1730ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// SOLVER_CONTINUE indicates that the solver should continue
1740ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// optimizing.
1750ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
1760ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// For example, the following Callback is used internally by Ceres to
1770ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// log the progress of the optimization.
1780ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
1790ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Callback for logging the state of the minimizer to STDERR or STDOUT
1800ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// depending on the user's preferences and logging level.
1810ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
1820ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//   class LoggingCallback : public IterationCallback {
1830ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//    public:
1840ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//     explicit LoggingCallback(bool log_to_stdout)
1850ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//         : log_to_stdout_(log_to_stdout) {}
1860ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
1870ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//     ~LoggingCallback() {}
1880ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
1890ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//     CallbackReturnType operator()(const IterationSummary& summary) {
1900ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//       const char* kReportRowFormat =
1910ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//           "% 4d: f:% 8e d:% 3.2e g:% 3.2e h:% 3.2e "
1920ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//           "rho:% 3.2e mu:% 3.2e eta:% 3.2e li:% 3d";
1930ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//       string output = StringPrintf(kReportRowFormat,
1940ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//                                    summary.iteration,
1950ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//                                    summary.cost,
1960ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//                                    summary.cost_change,
1970ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//                                    summary.gradient_max_norm,
1980ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//                                    summary.step_norm,
1990ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//                                    summary.relative_decrease,
2000ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//                                    summary.trust_region_radius,
2010ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//                                    summary.eta,
2020ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//                                    summary.linear_solver_iterations);
2030ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//       if (log_to_stdout_) {
2040ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//         cout << output << endl;
2050ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//       } else {
2060ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//         VLOG(1) << output;
2070ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//       }
2080ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//       return SOLVER_CONTINUE;
2090ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//     }
2100ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
2110ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//    private:
2120ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//     const bool log_to_stdout_;
2130ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//   };
2140ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong//
21579397c21138f54fcff6ec067b44b847f1f7e0e98Carlos Hernandezclass CERES_EXPORT IterationCallback {
2160ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong public:
2170ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  virtual ~IterationCallback() {}
2180ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong  virtual CallbackReturnType operator()(const IterationSummary& summary) = 0;
2190ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong};
2200ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
2210ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}  // namespace ceres
2220ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong
22379397c21138f54fcff6ec067b44b847f1f7e0e98Carlos Hernandez#include "ceres/internal/reenable_warnings.h"
22479397c21138f54fcff6ec067b44b847f1f7e0e98Carlos Hernandez
2250ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#endif  // CERES_PUBLIC_ITERATION_CALLBACK_H_
226