iteration_callback.h revision 79397c21138f54fcff6ec067b44b847f1f7e0e98
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Ceres Solver - A fast non-linear least squares minimizer 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright 2010, 2011, 2012 Google Inc. All rights reserved. 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// http://code.google.com/p/ceres-solver/ 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Redistribution and use in source and binary forms, with or without 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// modification, are permitted provided that the following conditions are met: 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * Redistributions of source code must retain the above copyright notice, 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// this list of conditions and the following disclaimer. 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * Redistributions in binary form must reproduce the above copyright notice, 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// this list of conditions and the following disclaimer in the documentation 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// and/or other materials provided with the distribution. 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// * Neither the name of Google Inc. nor the names of its contributors may be 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// used to endorse or promote products derived from this software without 15c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// specific prior written permission. 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// POSSIBILITY OF SUCH DAMAGE. 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Author: sameeragarwal@google.com (Sameer Agarwal) 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// When an iteration callback is specified, Ceres calls the callback 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// after each minimizer step (if the minimizer has not converged) and 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// passes it an IterationSummary object, defined below. 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CERES_PUBLIC_ITERATION_CALLBACK_H_ 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CERES_PUBLIC_ITERATION_CALLBACK_H_ 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ceres/types.h" 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ceres/internal/disable_warnings.h" 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ceres { 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This struct describes the state of the optimizer after each 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// iteration of the minimization. 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct CERES_EXPORT IterationSummary { 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) IterationSummary() 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) : iteration(0), 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) step_is_valid(false), 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) step_is_nonmonotonic(false), 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) step_is_successful(false), 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) cost(0.0), 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) cost_change(0.0), 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gradient_max_norm(0.0), 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gradient_norm(0.0), 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) step_norm(0.0), 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) eta(0.0), 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) step_size(0.0), 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) line_search_function_evaluations(0), 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) line_search_gradient_evaluations(0), 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) line_search_iterations(0), 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) linear_solver_iterations(0), 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) iteration_time_in_seconds(0.0), 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) step_solver_time_in_seconds(0.0), 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) cumulative_time_in_seconds(0.0) {} 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Current iteration number. 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int32 iteration; 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Step was numerically valid, i.e., all values are finite and the 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // step reduces the value of the linearized model. 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Note: step_is_valid is false when iteration = 0. 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool step_is_valid; 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Step did not reduce the value of the objective function 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // sufficiently, but it was accepted because of the relaxed 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // acceptance criterion used by the non-monotonic trust region 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // algorithm. 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Note: step_is_nonmonotonic is false when iteration = 0; 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool step_is_nonmonotonic; 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether or not the minimizer accepted this step or not. If the 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ordinary trust region algorithm is used, this means that the 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // relative reduction in the objective function value was greater 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // than Solver::Options::min_relative_decrease. However, if the 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // non-monotonic trust region algorithm is used 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // (Solver::Options:use_nonmonotonic_steps = true), then even if the 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // relative decrease is not sufficient, the algorithm may accept the 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // step and the step is declared successful. 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Note: step_is_successful is false when iteration = 0. 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool step_is_successful; 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Value of the objective function. 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double cost; 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Change in the value of the objective function in this 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // iteration. This can be positive or negative. 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double cost_change; 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Infinity norm of the gradient vector. 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double gradient_max_norm; 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 2-norm of the gradient vector. 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double gradient_norm; 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 2-norm of the size of the step computed by the optimization 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // algorithm. 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double step_norm; 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // For trust region algorithms, the ratio of the actual change in 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // cost and the change in the cost of the linearized approximation. 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double relative_decrease; 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Size of the trust region at the end of the current iteration. For 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the Levenberg-Marquardt algorithm, the regularization parameter 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // mu = 1.0 / trust_region_radius. 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double trust_region_radius; 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // For the inexact step Levenberg-Marquardt algorithm, this is the 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // relative accuracy with which the Newton(LM) step is solved. This 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // number affects only the iterative solvers capable of solving 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // linear systems inexactly. Factorization-based exact solvers 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ignore it. 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double eta; 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Step sized computed by the line search algorithm. 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double step_size; 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Number of function value evaluations used by the line search algorithm. 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int line_search_function_evaluations; 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Number of function gradient evaluations used by the line search algorithm. 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int line_search_gradient_evaluations; 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Number of iterations taken by the line search algorithm. 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int line_search_iterations; 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Number of iterations taken by the linear solver to solve for the 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Newton step. 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int linear_solver_iterations; 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // All times reported below are wall times. 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Time (in seconds) spent inside the minimizer loop in the current 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // iteration. 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double iteration_time_in_seconds; 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Time (in seconds) spent inside the trust region step solver. 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double step_solver_time_in_seconds; 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Time (in seconds) since the user called Solve(). 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double cumulative_time_in_seconds; 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Interface for specifying callbacks that are executed at the end of 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// each iteration of the Minimizer. The solver uses the return value 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// of operator() to decide whether to continue solving or to 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// terminate. The user can return three values. 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// SOLVER_ABORT indicates that the callback detected an abnormal 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// situation. The solver returns without updating the parameter blocks 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// (unless Solver::Options::update_state_every_iteration is set 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// true). Solver returns with Solver::Summary::termination_type set to 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// USER_ABORT. 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// SOLVER_TERMINATE_SUCCESSFULLY indicates that there is no need to 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// optimize anymore (some user specified termination criterion has 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// been met). Solver returns with Solver::Summary::termination_type 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// set to USER_SUCCESS. 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// SOLVER_CONTINUE indicates that the solver should continue 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// optimizing. 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// For example, the following Callback is used internally by Ceres to 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// log the progress of the optimization. 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Callback for logging the state of the minimizer to STDERR or STDOUT 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// depending on the user's preferences and logging level. 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// class LoggingCallback : public IterationCallback { 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// public: 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// explicit LoggingCallback(bool log_to_stdout) 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// : log_to_stdout_(log_to_stdout) {} 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ~LoggingCallback() {} 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// CallbackReturnType operator()(const IterationSummary& summary) { 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// const char* kReportRowFormat = 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// "% 4d: f:% 8e d:% 3.2e g:% 3.2e h:% 3.2e " 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// "rho:% 3.2e mu:% 3.2e eta:% 3.2e li:% 3d"; 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// string output = StringPrintf(kReportRowFormat, 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// summary.iteration, 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// summary.cost, 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// summary.cost_change, 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// summary.gradient_max_norm, 1985f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// summary.step_norm, 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// summary.relative_decrease, 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// summary.trust_region_radius, 2015f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// summary.eta, 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// summary.linear_solver_iterations); 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// if (log_to_stdout_) { 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// cout << output << endl; 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// } else { 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// VLOG(1) << output; 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// } 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// return SOLVER_CONTINUE; 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// } 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// private: 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// const bool log_to_stdout_; 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// }; 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CERES_EXPORT IterationCallback { 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~IterationCallback() {} 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual CallbackReturnType operator()(const IterationSummary& summary) = 0; 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace ceres 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ceres/internal/reenable_warnings.h" 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CERES_PUBLIC_ITERATION_CALLBACK_H_ 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)