types.h revision 0ae28bd5885b5daa526898fcf7c323dc2c3e1963
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// Enums and other top level class definitions. 320ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// 330ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Note: internal/types.cc defines stringification routines for some 340ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// of these enums. Please update those routines if you extend or 350ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// remove enums from here. 360ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 370ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#ifndef CERES_PUBLIC_TYPES_H_ 380ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#define CERES_PUBLIC_TYPES_H_ 390ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 400ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#include "ceres/internal/port.h" 410ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 420ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongnamespace ceres { 430ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 440ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Basic integer types. These typedefs are in the Ceres namespace to avoid 450ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// conflicts with other packages having similar typedefs. 460ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongtypedef short int16; 470ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongtypedef int int32; 480ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 490ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Argument type used in interfaces that can optionally take ownership 500ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// of a passed in argument. If TAKE_OWNERSHIP is passed, the called 510ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// object takes ownership of the pointer argument, and will call 520ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// delete on it upon completion. 530ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongenum Ownership { 540ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong DO_NOT_TAKE_OWNERSHIP, 550ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong TAKE_OWNERSHIP 560ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}; 570ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 580ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// TODO(keir): Considerably expand the explanations of each solver type. 590ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongenum LinearSolverType { 600ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // These solvers are for general rectangular systems formed from the 610ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // normal equations A'A x = A'b. They are direct solvers and do not 620ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // assume any special problem structure. 630ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 640ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Solve the normal equations using a dense Cholesky solver; based 650ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // on Eigen. 660ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong DENSE_NORMAL_CHOLESKY, 670ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 680ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Solve the normal equations using a dense QR solver; based on 690ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Eigen. 700ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong DENSE_QR, 710ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 720ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Solve the normal equations using a sparse cholesky solver; requires 730ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // SuiteSparse or CXSparse. 740ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong SPARSE_NORMAL_CHOLESKY, 750ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 760ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Specialized solvers, specific to problems with a generalized 770ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // bi-partitite structure. 780ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 790ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Solves the reduced linear system using a dense Cholesky solver; 800ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // based on Eigen. 810ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong DENSE_SCHUR, 820ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 830ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Solves the reduced linear system using a sparse Cholesky solver; 840ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // based on CHOLMOD. 850ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong SPARSE_SCHUR, 860ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 870ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Solves the reduced linear system using Conjugate Gradients, based 880ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // on a new Ceres implementation. Suitable for large scale 890ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // problems. 900ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong ITERATIVE_SCHUR, 910ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 920ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Conjugate gradients on the normal equations. 930ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong CGNR 940ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}; 950ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 960ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongenum PreconditionerType { 970ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Trivial preconditioner - the identity matrix. 980ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong IDENTITY, 990ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1000ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Block diagonal of the Gauss-Newton Hessian. 1010ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong JACOBI, 1020ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1030ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Block diagonal of the Schur complement. This preconditioner may 1040ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // only be used with the ITERATIVE_SCHUR solver. Requires 1050ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // SuiteSparse/CHOLMOD. 1060ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong SCHUR_JACOBI, 1070ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1080ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Visibility clustering based preconditioners. 1090ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // 1100ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // These preconditioners are well suited for Structure from Motion 1110ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // problems, particularly problems arising from community photo 1120ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // collections. These preconditioners use the visibility structure 1130ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // of the scene to determine the sparsity structure of the 1140ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // preconditioner. Requires SuiteSparse/CHOLMOD. 1150ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong CLUSTER_JACOBI, 1160ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong CLUSTER_TRIDIAGONAL 1170ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}; 1180ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1190ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongenum SparseLinearAlgebraLibraryType { 1200ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // High performance sparse Cholesky factorization and approximate 1210ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // minimum degree ordering. 1220ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong SUITE_SPARSE, 1230ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1240ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // A lightweight replacment for SuiteSparse. 1250ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong CX_SPARSE 1260ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}; 1270ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1280ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongenum LinearSolverTerminationType { 1290ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Termination criterion was met. For factorization based solvers 1300ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // the tolerance is assumed to be zero. Any user provided values are 1310ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // ignored. 1320ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong TOLERANCE, 1330ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1340ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Solver ran for max_num_iterations and terminated before the 1350ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // termination tolerance could be satified. 1360ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong MAX_ITERATIONS, 1370ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1380ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Solver is stuck and further iterations will not result in any 1390ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // measurable progress. 1400ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong STAGNATION, 1410ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1420ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Solver failed. Solver was terminated due to numerical errors. The 1430ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // exact cause of failure depends on the particular solver being 1440ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // used. 1450ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong FAILURE 1460ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}; 1470ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1480ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Logging options 1490ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// The options get progressively noisier. 1500ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongenum LoggingType { 1510ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong SILENT, 1520ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong PER_MINIMIZER_ITERATION 1530ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}; 1540ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1550ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Ceres supports different strategies for computing the trust region 1560ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// step. 1570ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongenum TrustRegionStrategyType { 1580ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // The default trust region strategy is to use the step computation 1590ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // used in the Levenberg-Marquardt algorithm. For more details see 1600ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // levenberg_marquardt_strategy.h 1610ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong LEVENBERG_MARQUARDT, 1620ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1630ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Powell's dogleg algorithm interpolates between the Cauchy point 1640ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // and the Gauss-Newton step. It is particularly useful if the 1650ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // LEVENBERG_MARQUARDT algorithm is making a large number of 1660ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // unsuccessful steps. For more details see dogleg_strategy.h. 1670ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // 1680ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // NOTES: 1690ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // 1700ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // 1. This strategy has not been experimented with or tested as 1710ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // extensively as LEVENBERG_MARQUARDT, and therefore it should be 1720ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // considered EXPERIMENTAL for now. 1730ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // 1740ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // 2. For now this strategy should only be used with exact 1750ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // factorization based linear solvers, i.e., SPARSE_SCHUR, 1760ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // DENSE_SCHUR, DENSE_QR and SPARSE_NORMAL_CHOLESKY. 1770ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong DOGLEG 1780ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}; 1790ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1800ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Ceres supports two different dogleg strategies. 1810ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// The "traditional" dogleg method by Powell and the 1820ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// "subspace" method described in 1830ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// R. H. Byrd, R. B. Schnabel, and G. A. Shultz, 1840ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// "Approximate solution of the trust region problem by minimization 1850ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// over two-dimensional subspaces", Mathematical Programming, 1860ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// 40 (1988), pp. 247--263 1870ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongenum DoglegType { 1880ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // The traditional approach constructs a dogleg path 1890ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // consisting of two line segments and finds the furthest 1900ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // point on that path that is still inside the trust region. 1910ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong TRADITIONAL_DOGLEG, 1920ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1930ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // The subspace approach finds the exact minimum of the model 1940ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // constrained to the subspace spanned by the dogleg path. 1950ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong SUBSPACE_DOGLEG 1960ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}; 1970ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 1980ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongenum SolverTerminationType { 1990ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // The minimizer did not run at all; usually due to errors in the user's 2000ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Problem or the solver options. 2010ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong DID_NOT_RUN, 2020ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2030ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // The solver ran for maximum number of iterations specified by the 2040ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // user, but none of the convergence criterion specified by the user 2050ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // were met. 2060ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong NO_CONVERGENCE, 2070ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2080ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Minimizer terminated because 2090ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // (new_cost - old_cost) < function_tolerance * old_cost; 2100ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong FUNCTION_TOLERANCE, 2110ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2120ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Minimizer terminated because 2130ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // max_i |gradient_i| < gradient_tolerance * max_i|initial_gradient_i| 2140ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong GRADIENT_TOLERANCE, 2150ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2160ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Minimized terminated because 2170ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // |step|_2 <= parameter_tolerance * ( |x|_2 + parameter_tolerance) 2180ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong PARAMETER_TOLERANCE, 2190ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2200ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // The minimizer terminated because it encountered a numerical error 2210ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // that it could not recover from. 2220ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong NUMERICAL_FAILURE, 2230ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2240ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Using an IterationCallback object, user code can control the 2250ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // minimizer. The following enums indicate that the user code was 2260ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // responsible for termination. 2270ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2280ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // User's IterationCallback returned SOLVER_ABORT. 2290ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong USER_ABORT, 2300ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2310ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // User's IterationCallback returned SOLVER_TERMINATE_SUCCESSFULLY 2320ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong USER_SUCCESS 2330ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}; 2340ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2350ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// Enums used by the IterationCallback instances to indicate to the 2360ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// solver whether it should continue solving, the user detected an 2370ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// error or the solution is good enough and the solver should 2380ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// terminate. 2390ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongenum CallbackReturnType { 2400ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Continue solving to next iteration. 2410ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong SOLVER_CONTINUE, 2420ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2430ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Terminate solver, and do not update the parameter blocks upon 2440ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // return. Unless the user has set 2450ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Solver:Options:::update_state_every_iteration, in which case the 2460ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // state would have been updated every iteration 2470ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // anyways. Solver::Summary::termination_type is set to USER_ABORT. 2480ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong SOLVER_ABORT, 2490ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2500ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Terminate solver, update state and 2510ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // return. Solver::Summary::termination_type is set to USER_SUCCESS. 2520ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong SOLVER_TERMINATE_SUCCESSFULLY 2530ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}; 2540ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2550ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// The format in which linear least squares problems should be logged 2560ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// when Solver::Options::lsqp_iterations_to_dump is non-empty. 2570ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongenum DumpFormatType { 2580ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Print the linear least squares problem in a human readable format 2590ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // to stderr. The Jacobian is printed as a dense matrix. The vectors 2600ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // D, x and f are printed as dense vectors. This should only be used 2610ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // for small problems. 2620ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong CONSOLE, 2630ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2640ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Write out the linear least squares problem to the directory 2650ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // pointed to by Solver::Options::lsqp_dump_directory as a protocol 2660ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // buffer. linear_least_squares_problems.h/cc contains routines for 2670ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // loading these problems. For details on the on disk format used, 2680ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // see matrix.proto. The files are named lm_iteration_???.lsqp. 2690ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong PROTOBUF, 2700ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2710ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // Write out the linear least squares problem to the directory 2720ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // pointed to by Solver::Options::lsqp_dump_directory as text files 2730ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // which can be read into MATLAB/Octave. The Jacobian is dumped as a 2740ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // text file containing (i,j,s) triplets, the vectors D, x and f are 2750ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // dumped as text files containing a list of their values. 2760ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // 2770ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // A MATLAB/octave script called lm_iteration_???.m is also output, 2780ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong // which can be used to parse and load the problem into memory. 2790ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong TEXTFILE 2800ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}; 2810ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2820ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// For SizedCostFunction and AutoDiffCostFunction, DYNAMIC can be specified for 2830ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// the number of residuals. If specified, then the number of residuas for that 2840ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong// cost function can vary at runtime. 2850ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongenum DimensionType { 2860ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong DYNAMIC = -1 2870ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong}; 2880ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2890ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongconst char* LinearSolverTypeToString(LinearSolverType type); 2900ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongbool StringToLinearSolverType(string value, LinearSolverType* type); 2910ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2920ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongconst char* PreconditionerTypeToString(PreconditionerType type); 2930ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongbool StringToPreconditionerType(string value, PreconditionerType* type); 2940ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 2950ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongconst char* SparseLinearAlgebraLibraryTypeToString( 2960ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong SparseLinearAlgebraLibraryType type); 2970ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongbool StringToSparseLinearAlgebraLibraryType( 2980ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong string value, 2990ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong SparseLinearAlgebraLibraryType* type); 3000ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 3010ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongconst char* TrustRegionStrategyTypeToString(TrustRegionStrategyType type); 3020ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongbool StringToTrustRegionStrategyType(string value, 3030ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong TrustRegionStrategyType* type); 3040ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 3050ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongconst char* DoglegTypeToString(DoglegType type); 3060ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongbool StringToDoglegType(string value, DoglegType* type); 3070ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 3080ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongconst char* LinearSolverTerminationTypeToString( 3090ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong LinearSolverTerminationType type); 3100ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 3110ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongconst char* SolverTerminationTypeToString(SolverTerminationType type); 3120ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 3130ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongbool IsSchurType(LinearSolverType type); 3140ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kongbool IsSparseLinearAlgebraLibraryTypeAvailable( 3150ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong SparseLinearAlgebraLibraryType type); 3160ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 3170ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 3180ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong} // namespace ceres 3190ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong 3200ae28bd5885b5daa526898fcf7c323dc2c3e1963Angus Kong#endif // CERES_PUBLIC_TYPES_H_ 321