solver.h 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  1. // Ceres Solver - A fast non-linear least squares minimizer
  2. // Copyright 2023 Google Inc. All rights reserved.
  3. // http://ceres-solver.org/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are met:
  7. //
  8. // * Redistributions of source code must retain the above copyright notice,
  9. // this list of conditions and the following disclaimer.
  10. // * Redistributions in binary form must reproduce the above copyright notice,
  11. // this list of conditions and the following disclaimer in the documentation
  12. // and/or other materials provided with the distribution.
  13. // * Neither the name of Google Inc. nor the names of its contributors may be
  14. // used to endorse or promote products derived from this software without
  15. // specific prior written permission.
  16. //
  17. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  18. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  21. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  24. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  25. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  26. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  27. // POSSIBILITY OF SUCH DAMAGE.
  28. //
  29. // Author: sameeragarwal@google.com (Sameer Agarwal)
  30. #ifndef CERES_PUBLIC_SOLVER_H_
  31. #define CERES_PUBLIC_SOLVER_H_
  32. #include <cmath>
  33. #include <memory>
  34. #include <string>
  35. #include <unordered_set>
  36. #include <vector>
  37. #include "ceres/crs_matrix.h"
  38. #include "ceres/internal/config.h"
  39. #include "ceres/internal/disable_warnings.h"
  40. #include "ceres/internal/export.h"
  41. #include "ceres/iteration_callback.h"
  42. #include "ceres/ordered_groups.h"
  43. #include "ceres/problem.h"
  44. #include "ceres/types.h"
  45. namespace ceres {
  46. // Interface for non-linear least squares solvers.
  47. class CERES_EXPORT Solver {
  48. public:
  49. virtual ~Solver();
  50. // The options structure contains, not surprisingly, options that control how
  51. // the solver operates. The defaults should be suitable for a wide range of
  52. // problems; however, better performance is often obtainable with tweaking.
  53. //
  54. // The constants are defined inside types.h
  55. struct CERES_EXPORT Options {
  56. // Returns true if the options struct has a valid
  57. // configuration. Returns false otherwise, and fills in *error
  58. // with a message describing the problem.
  59. bool IsValid(std::string* error) const;
  60. // Ceres supports the two major families of optimization strategies -
  61. // Trust Region and Line Search.
  62. //
  63. // 1. The line search approach first finds a descent direction
  64. // along which the objective function will be reduced and then
  65. // computes a step size that decides how far should move along
  66. // that direction. The descent direction can be computed by
  67. // various methods, such as gradient descent, Newton's method and
  68. // Quasi-Newton method. The step size can be determined either
  69. // exactly or inexactly.
  70. //
  71. // 2. The trust region approach approximates the objective
  72. // function using a model function (often a quadratic) over
  73. // a subset of the search space known as the trust region. If the
  74. // model function succeeds in minimizing the true objective
  75. // function the trust region is expanded; conversely, otherwise it
  76. // is contracted and the model optimization problem is solved
  77. // again.
  78. //
  79. // Trust region methods are in some sense dual to line search methods:
  80. // trust region methods first choose a step size (the size of the
  81. // trust region) and then a step direction while line search methods
  82. // first choose a step direction and then a step size.
  83. MinimizerType minimizer_type = TRUST_REGION;
  84. LineSearchDirectionType line_search_direction_type = LBFGS;
  85. LineSearchType line_search_type = WOLFE;
  86. NonlinearConjugateGradientType nonlinear_conjugate_gradient_type =
  87. FLETCHER_REEVES;
  88. // The LBFGS hessian approximation is a low rank approximation to
  89. // the inverse of the Hessian matrix. The rank of the
  90. // approximation determines (linearly) the space and time
  91. // complexity of using the approximation. Higher the rank, the
  92. // better is the quality of the approximation. The increase in
  93. // quality is however is bounded for a number of reasons.
  94. //
  95. // 1. The method only uses secant information and not actual
  96. // derivatives.
  97. //
  98. // 2. The Hessian approximation is constrained to be positive
  99. // definite.
  100. //
  101. // So increasing this rank to a large number will cost time and
  102. // space complexity without the corresponding increase in solution
  103. // quality. There are no hard and fast rules for choosing the
  104. // maximum rank. The best choice usually requires some problem
  105. // specific experimentation.
  106. //
  107. // For more theoretical and implementation details of the LBFGS
  108. // method, please see:
  109. //
  110. // Nocedal, J. (1980). "Updating Quasi-Newton Matrices with
  111. // Limited Storage". Mathematics of Computation 35 (151): 773-782.
  112. int max_lbfgs_rank = 20;
  113. // As part of the (L)BFGS update step (BFGS) / right-multiply step (L-BFGS),
  114. // the initial inverse Hessian approximation is taken to be the Identity.
  115. // However, Oren showed that using instead I * \gamma, where \gamma is
  116. // chosen to approximate an eigenvalue of the true inverse Hessian can
  117. // result in improved convergence in a wide variety of cases. Setting
  118. // use_approximate_eigenvalue_bfgs_scaling to true enables this scaling.
  119. //
  120. // It is important to note that approximate eigenvalue scaling does not
  121. // always improve convergence, and that it can in fact significantly degrade
  122. // performance for certain classes of problem, which is why it is disabled
  123. // by default. In particular it can degrade performance when the
  124. // sensitivity of the problem to different parameters varies significantly,
  125. // as in this case a single scalar factor fails to capture this variation
  126. // and detrimentally downscales parts of the jacobian approximation which
  127. // correspond to low-sensitivity parameters. It can also reduce the
  128. // robustness of the solution to errors in the jacobians.
  129. //
  130. // Oren S.S., Self-scaling variable metric (SSVM) algorithms
  131. // Part II: Implementation and experiments, Management Science,
  132. // 20(5), 863-874, 1974.
  133. bool use_approximate_eigenvalue_bfgs_scaling = false;
  134. // Degree of the polynomial used to approximate the objective
  135. // function. Valid values are BISECTION, QUADRATIC and CUBIC.
  136. //
  137. // BISECTION corresponds to pure backtracking search with no
  138. // interpolation.
  139. LineSearchInterpolationType line_search_interpolation_type = CUBIC;
  140. // If during the line search, the step_size falls below this
  141. // value, it is truncated to zero.
  142. double min_line_search_step_size = 1e-9;
  143. // Line search parameters.
  144. // Solving the line search problem exactly is computationally
  145. // prohibitive. Fortunately, line search based optimization
  146. // algorithms can still guarantee convergence if instead of an
  147. // exact solution, the line search algorithm returns a solution
  148. // which decreases the value of the objective function
  149. // sufficiently. More precisely, we are looking for a step_size
  150. // s.t.
  151. //
  152. // f(step_size) <= f(0) + sufficient_decrease * f'(0) * step_size
  153. //
  154. double line_search_sufficient_function_decrease = 1e-4;
  155. // In each iteration of the line search,
  156. //
  157. // new_step_size >= max_line_search_step_contraction * step_size
  158. //
  159. // Note that by definition, for contraction:
  160. //
  161. // 0 < max_step_contraction < min_step_contraction < 1
  162. //
  163. double max_line_search_step_contraction = 1e-3;
  164. // In each iteration of the line search,
  165. //
  166. // new_step_size <= min_line_search_step_contraction * step_size
  167. //
  168. // Note that by definition, for contraction:
  169. //
  170. // 0 < max_step_contraction < min_step_contraction < 1
  171. //
  172. double min_line_search_step_contraction = 0.6;
  173. // Maximum number of trial step size iterations during each line
  174. // search, if a step size satisfying the search conditions cannot
  175. // be found within this number of trials, the line search will
  176. // terminate.
  177. // The minimum allowed value is 0 for trust region minimizer and 1
  178. // otherwise. If 0 is specified for the trust region minimizer,
  179. // then line search will not be used when solving constrained
  180. // optimization problems.
  181. int max_num_line_search_step_size_iterations = 20;
  182. // Maximum number of restarts of the line search direction algorithm before
  183. // terminating the optimization. Restarts of the line search direction
  184. // algorithm occur when the current algorithm fails to produce a new descent
  185. // direction. This typically indicates a numerical failure, or a breakdown
  186. // in the validity of the approximations used.
  187. int max_num_line_search_direction_restarts = 5;
  188. // The strong Wolfe conditions consist of the Armijo sufficient
  189. // decrease condition, and an additional requirement that the
  190. // step-size be chosen s.t. the _magnitude_ ('strong' Wolfe
  191. // conditions) of the gradient along the search direction
  192. // decreases sufficiently. Precisely, this second condition
  193. // is that we seek a step_size s.t.
  194. //
  195. // |f'(step_size)| <= sufficient_curvature_decrease * |f'(0)|
  196. //
  197. // Where f() is the line search objective and f'() is the derivative
  198. // of f w.r.t step_size (d f / d step_size).
  199. double line_search_sufficient_curvature_decrease = 0.9;
  200. // During the bracketing phase of the Wolfe search, the step size is
  201. // increased until either a point satisfying the Wolfe conditions is
  202. // found, or an upper bound for a bracket containing a point satisfying
  203. // the conditions is found. Precisely, at each iteration of the
  204. // expansion:
  205. //
  206. // new_step_size <= max_step_expansion * step_size.
  207. //
  208. // By definition for expansion, max_step_expansion > 1.0.
  209. double max_line_search_step_expansion = 10.0;
  210. TrustRegionStrategyType trust_region_strategy_type = LEVENBERG_MARQUARDT;
  211. // Type of dogleg strategy to use.
  212. DoglegType dogleg_type = TRADITIONAL_DOGLEG;
  213. // The classical trust region methods are descent methods, in that
  214. // they only accept a point if it strictly reduces the value of
  215. // the objective function.
  216. //
  217. // Relaxing this requirement allows the algorithm to be more
  218. // efficient in the long term at the cost of some local increase
  219. // in the value of the objective function.
  220. //
  221. // This is because allowing for non-decreasing objective function
  222. // values in a principled manner allows the algorithm to "jump over
  223. // boulders" as the method is not restricted to move into narrow
  224. // valleys while preserving its convergence properties.
  225. //
  226. // Setting use_nonmonotonic_steps to true enables the
  227. // non-monotonic trust region algorithm as described by Conn,
  228. // Gould & Toint in "Trust Region Methods", Section 10.1.
  229. //
  230. // The parameter max_consecutive_nonmonotonic_steps controls the
  231. // window size used by the step selection algorithm to accept
  232. // non-monotonic steps.
  233. //
  234. // Even though the value of the objective function may be larger
  235. // than the minimum value encountered over the course of the
  236. // optimization, the final parameters returned to the user are the
  237. // ones corresponding to the minimum cost over all iterations.
  238. bool use_nonmonotonic_steps = false;
  239. int max_consecutive_nonmonotonic_steps = 5;
  240. // Maximum number of iterations for the minimizer to run for.
  241. int max_num_iterations = 50;
  242. // Maximum time for which the minimizer should run for.
  243. double max_solver_time_in_seconds = 1e9;
  244. // Number of threads used by Ceres for evaluating the cost and
  245. // jacobians.
  246. int num_threads = 1;
  247. // Trust region minimizer settings.
  248. double initial_trust_region_radius = 1e4;
  249. double max_trust_region_radius = 1e16;
  250. // Minimizer terminates when the trust region radius becomes
  251. // smaller than this value.
  252. double min_trust_region_radius = 1e-32;
  253. // Lower bound for the relative decrease before a step is
  254. // accepted.
  255. double min_relative_decrease = 1e-3;
  256. // For the Levenberg-Marquadt algorithm, the scaled diagonal of
  257. // the normal equations J'J is used to control the size of the
  258. // trust region. Extremely small and large values along the
  259. // diagonal can make this regularization scheme
  260. // fail. max_lm_diagonal and min_lm_diagonal, clamp the values of
  261. // diag(J'J) from above and below. In the normal course of
  262. // operation, the user should not have to modify these parameters.
  263. double min_lm_diagonal = 1e-6;
  264. double max_lm_diagonal = 1e32;
  265. // Sometimes due to numerical conditioning problems or linear
  266. // solver flakiness, the trust region strategy may return a
  267. // numerically invalid step that can be fixed by reducing the
  268. // trust region size. So the TrustRegionMinimizer allows for a few
  269. // successive invalid steps before it declares NUMERICAL_FAILURE.
  270. int max_num_consecutive_invalid_steps = 5;
  271. // Minimizer terminates when
  272. //
  273. // (new_cost - old_cost) < function_tolerance * old_cost;
  274. //
  275. double function_tolerance = 1e-6;
  276. // Minimizer terminates when
  277. //
  278. // max_i |x - Project(Plus(x, -g(x))| < gradient_tolerance
  279. //
  280. // This value should typically be 1e-4 * function_tolerance.
  281. double gradient_tolerance = 1e-10;
  282. // Minimizer terminates when
  283. //
  284. // |step|_2 <= parameter_tolerance * ( |x|_2 + parameter_tolerance)
  285. //
  286. double parameter_tolerance = 1e-8;
  287. // Linear least squares solver options -------------------------------------
  288. LinearSolverType linear_solver_type =
  289. #if defined(CERES_NO_SPARSE)
  290. DENSE_QR;
  291. #else
  292. SPARSE_NORMAL_CHOLESKY;
  293. #endif
  294. // Type of preconditioner to use with the iterative linear solvers.
  295. PreconditionerType preconditioner_type = JACOBI;
  296. // Type of clustering algorithm to use for visibility based
  297. // preconditioning. This option is used only when the
  298. // preconditioner_type is CLUSTER_JACOBI or CLUSTER_TRIDIAGONAL.
  299. VisibilityClusteringType visibility_clustering_type = CANONICAL_VIEWS;
  300. // Subset preconditioner is a preconditioner for problems with
  301. // general sparsity. Given a subset of residual blocks of a
  302. // problem, it uses the corresponding subset of the rows of the
  303. // Jacobian to construct a preconditioner.
  304. //
  305. // Suppose the Jacobian J has been horizontally partitioned as
  306. //
  307. // J = [P]
  308. // [Q]
  309. //
  310. // Where, Q is the set of rows corresponding to the residual
  311. // blocks in residual_blocks_for_subset_preconditioner.
  312. //
  313. // The preconditioner is the inverse of the matrix Q'Q.
  314. //
  315. // Obviously, the efficacy of the preconditioner depends on how
  316. // well the matrix Q approximates J'J, or how well the chosen
  317. // residual blocks approximate the non-linear least squares
  318. // problem.
  319. //
  320. // If Solver::Options::preconditioner_type == SUBSET, then
  321. // residual_blocks_for_subset_preconditioner must be non-empty.
  322. std::unordered_set<ResidualBlockId>
  323. residual_blocks_for_subset_preconditioner;
  324. // Ceres supports using multiple dense linear algebra libraries for dense
  325. // matrix factorizations. Currently EIGEN, LAPACK and CUDA are the valid
  326. // choices. EIGEN is always available, LAPACK refers to the system BLAS +
  327. // LAPACK library which may or may not be available. CUDA refers to Nvidia's
  328. // GPU based dense linear algebra library, which may or may not be
  329. // available.
  330. //
  331. // This setting affects the DENSE_QR, DENSE_NORMAL_CHOLESKY and DENSE_SCHUR
  332. // solvers. For small to moderate sized problem EIGEN is a fine choice but
  333. // for large problems, an optimized LAPACK + BLAS or CUDA implementation can
  334. // make a substantial difference in performance.
  335. DenseLinearAlgebraLibraryType dense_linear_algebra_library_type = EIGEN;
  336. // Ceres supports using multiple sparse linear algebra libraries for sparse
  337. // matrix ordering and factorizations.
  338. SparseLinearAlgebraLibraryType sparse_linear_algebra_library_type =
  339. #if !defined(CERES_NO_SUITESPARSE)
  340. SUITE_SPARSE;
  341. #elif !defined(CERES_NO_ACCELERATE_SPARSE)
  342. ACCELERATE_SPARSE;
  343. #elif defined(CERES_USE_EIGEN_SPARSE)
  344. EIGEN_SPARSE;
  345. #else
  346. NO_SPARSE;
  347. #endif
  348. // The order in which variables are eliminated in a linear solver
  349. // can have a significant impact on the efficiency and accuracy of
  350. // the method. e.g., when doing sparse Cholesky factorization,
  351. // there are matrices for which a good ordering will give a
  352. // Cholesky factor with O(n) storage, where as a bad ordering will
  353. // result in an completely dense factor.
  354. //
  355. // Sparse direct solvers like SPARSE_NORMAL_CHOLESKY and
  356. // SPARSE_SCHUR use a fill reducing ordering of the columns and
  357. // rows of the matrix being factorized before computing the
  358. // numeric factorization.
  359. //
  360. // This enum controls the type of algorithm used to compute
  361. // this fill reducing ordering. There is no single algorithm
  362. // that works on all matrices, so determining which algorithm
  363. // works better is a matter of empirical experimentation.
  364. //
  365. // The exact behaviour of this setting is affected by the value of
  366. // linear_solver_ordering as described below.
  367. LinearSolverOrderingType linear_solver_ordering_type = AMD;
  368. // Besides specifying the fill reducing ordering via
  369. // linear_solver_ordering_type, Ceres allows the user to provide varying
  370. // amounts of hints to the linear solver about the variable elimination
  371. // ordering to use. This can range from no hints, where the solver is free
  372. // to decide the best possible ordering based on the user's choices like the
  373. // linear solver being used, to an exact order in which the variables should
  374. // be eliminated, and a variety of possibilities in between.
  375. //
  376. // Instances of the ParameterBlockOrdering class are used to communicate
  377. // this information to Ceres.
  378. //
  379. // Formally an ordering is an ordered partitioning of the parameter blocks,
  380. // i.e, each parameter block belongs to exactly one group, and each group
  381. // has a unique non-negative integer associated with it, that determines its
  382. // order in the set of groups.
  383. //
  384. // e.g. Consider the linear system
  385. //
  386. // x + y = 3
  387. // 2x + 3y = 7
  388. //
  389. // There are two ways in which it can be solved. First eliminating x from
  390. // the two equations, solving for y and then back substituting for x, or
  391. // first eliminating y, solving for x and back substituting for y. The user
  392. // can construct three orderings here.
  393. //
  394. // {0: x}, {1: y} - eliminate x first.
  395. // {0: y}, {1: x} - eliminate y first.
  396. // {0: x, y} - Solver gets to decide the elimination order.
  397. //
  398. // Thus, to have Ceres determine the ordering automatically, put all the
  399. // variables in group 0 and to control the ordering for every variable
  400. // create groups 0 ... N-1, one per variable, in the desired
  401. // order.
  402. //
  403. // linear_solver_ordering == nullptr and an ordering where all the parameter
  404. // blocks are in one elimination group mean the same thing - the solver is
  405. // free to choose what it thinks is the best elimination ordering. Therefore
  406. // in the following we will only consider the case where
  407. // linear_solver_ordering is nullptr.
  408. //
  409. // The exact interpretation of this information depends on the values of
  410. // linear_solver_ordering_type and linear_solver_type/preconditioner_type
  411. // and sparse_linear_algebra_type.
  412. //
  413. // Bundle Adjustment
  414. // =================
  415. //
  416. // If the user is using one of the Schur solvers (DENSE_SCHUR,
  417. // SPARSE_SCHUR, ITERATIVE_SCHUR) and chooses to specify an
  418. // ordering, it must have one important property. The lowest
  419. // numbered elimination group must form an independent set in the
  420. // graph corresponding to the Hessian, or in other words, no two
  421. // parameter blocks in in the first elimination group should
  422. // co-occur in the same residual block. For the best performance,
  423. // this elimination group should be as large as possible. For
  424. // standard bundle adjustment problems, this corresponds to the
  425. // first elimination group containing all the 3d points, and the
  426. // second containing the all the cameras parameter blocks.
  427. //
  428. // If the user leaves the choice to Ceres, then the solver uses an
  429. // approximate maximum independent set algorithm to identify the first
  430. // elimination group.
  431. //
  432. // sparse_linear_algebra_library_type = SUITE_SPARSE
  433. // =================================================
  434. //
  435. // linear_solver_ordering_type = AMD
  436. // ---------------------------------
  437. //
  438. // A Constrained Approximate Minimum Degree (CAMD) ordering used where the
  439. // parameter blocks in the lowest numbered group are eliminated first, and
  440. // then the parameter blocks in the next lowest numbered group and so
  441. // on. Within each group, CAMD free to order the parameter blocks as it
  442. // chooses.
  443. //
  444. // linear_solver_ordering_type = NESDIS
  445. // -------------------------------------
  446. //
  447. // a. linear_solver_type = SPARSE_NORMAL_CHOLESKY or
  448. // linear_solver_type = CGNR and preconditioner_type = SUBSET
  449. //
  450. // The value of linear_solver_ordering is ignored and a Nested Dissection
  451. // algorithm is used to compute a fill reducing ordering.
  452. //
  453. // b. linear_solver_type = SPARSE_SCHUR/DENSE_SCHUR/ITERATIVE_SCHUR
  454. //
  455. // ONLY the lowest group are used to compute the Schur complement, and
  456. // Nested Dissection is used to compute a fill reducing ordering for the
  457. // Schur Complement (or its preconditioner).
  458. //
  459. // sparse_linear_algebra_library_type = EIGEN_SPARSE or ACCELERATE_SPARSE
  460. // ======================================================================
  461. //
  462. // a. linear_solver_type = SPARSE_NORMAL_CHOLESKY or
  463. // linear_solver_type = CGNR and preconditioner_type = SUBSET
  464. //
  465. // then the value of linear_solver_ordering is ignored and AMD or NESDIS is
  466. // used to compute a fill reducing ordering as requested by the user.
  467. //
  468. // b. linear_solver_type = SPARSE_SCHUR/DENSE_SCHUR/ITERATIVE_SCHUR
  469. //
  470. // ONLY the lowest group are used to compute the Schur complement, and AMD
  471. // or NESDIS is used to compute a fill reducing ordering for the Schur
  472. // Complement (or its preconditioner).
  473. std::shared_ptr<ParameterBlockOrdering> linear_solver_ordering;
  474. // Use an explicitly computed Schur complement matrix with
  475. // ITERATIVE_SCHUR.
  476. //
  477. // By default this option is disabled and ITERATIVE_SCHUR
  478. // evaluates matrix-vector products between the Schur
  479. // complement and a vector implicitly by exploiting the algebraic
  480. // expression for the Schur complement.
  481. //
  482. // The cost of this evaluation scales with the number of non-zeros
  483. // in the Jacobian.
  484. //
  485. // For small to medium sized problems there is a sweet spot where
  486. // computing the Schur complement is cheap enough that it is much
  487. // more efficient to explicitly compute it and use it for evaluating
  488. // the matrix-vector products.
  489. //
  490. // Enabling this option tells ITERATIVE_SCHUR to use an explicitly
  491. // computed Schur complement.
  492. //
  493. // NOTE: This option can only be used with the SCHUR_JACOBI
  494. // preconditioner.
  495. bool use_explicit_schur_complement = false;
  496. // Sparse Cholesky factorization algorithms use a fill-reducing
  497. // ordering to permute the columns of the Jacobian matrix. There
  498. // are two ways of doing this.
  499. // 1. Compute the Jacobian matrix in some order and then have the
  500. // factorization algorithm permute the columns of the Jacobian.
  501. // 2. Compute the Jacobian with its columns already permuted.
  502. // The first option incurs a significant memory penalty. The
  503. // factorization algorithm has to make a copy of the permuted
  504. // Jacobian matrix, thus Ceres pre-permutes the columns of the
  505. // Jacobian matrix and generally speaking, there is no performance
  506. // penalty for doing so.
  507. // Some non-linear least squares problems are symbolically dense but
  508. // numerically sparse. i.e. at any given state only a small number
  509. // of jacobian entries are non-zero, but the position and number of
  510. // non-zeros is different depending on the state. For these problems
  511. // it can be useful to factorize the sparse jacobian at each solver
  512. // iteration instead of including all of the zero entries in a single
  513. // general factorization.
  514. //
  515. // If your problem does not have this property (or you do not know),
  516. // then it is probably best to keep this false, otherwise it will
  517. // likely lead to worse performance.
  518. // This settings only affects the SPARSE_NORMAL_CHOLESKY solver.
  519. bool dynamic_sparsity = false;
  520. // If use_mixed_precision_solves is true, the Gauss-Newton matrix
  521. // is computed in double precision, but its factorization is
  522. // computed in single precision. This can result in significant
  523. // time and memory savings at the cost of some accuracy in the
  524. // Gauss-Newton step. Iterative refinement is used to recover some
  525. // of this accuracy back.
  526. //
  527. // If use_mixed_precision_solves is true, we recommend setting
  528. // max_num_refinement_iterations to 2-3.
  529. //
  530. // This options is available when linear solver uses sparse or dense
  531. // cholesky factorization, except when sparse_linear_algebra_library_type =
  532. // SUITE_SPARSE.
  533. bool use_mixed_precision_solves = false;
  534. // Number steps of the iterative refinement process to run when
  535. // computing the Gauss-Newton step.
  536. int max_num_refinement_iterations = 0;
  537. // Minimum number of iterations for which the linear solver should
  538. // run, even if the convergence criterion is satisfied.
  539. int min_linear_solver_iterations = 0;
  540. // Maximum number of iterations for which the linear solver should
  541. // run. If the solver does not converge in less than
  542. // max_linear_solver_iterations, then it returns MAX_ITERATIONS,
  543. // as its termination type.
  544. int max_linear_solver_iterations = 500;
  545. // Maximum number of iterations performed by SCHUR_POWER_SERIES_EXPANSION.
  546. // Each iteration corresponds to one more term in the power series expansion
  547. // od the inverse of the Schur complement. This value controls the maximum
  548. // number of iterations whether it is used as a preconditioner or just to
  549. // initialize the solution for ITERATIVE_SCHUR.
  550. int max_num_spse_iterations = 5;
  551. // Use SCHUR_POWER_SERIES_EXPANSION to initialize the solution for
  552. // ITERATIVE_SCHUR. This option can be set true regardless of what
  553. // preconditioner is being used.
  554. bool use_spse_initialization = false;
  555. // When use_spse_initialization is true, this parameter along with
  556. // max_num_spse_iterations controls the number of
  557. // SCHUR_POWER_SERIES_EXPANSION iterations performed for initialization. It
  558. // is not used to control the preconditioner.
  559. double spse_tolerance = 0.1;
  560. // Forcing sequence parameter. The truncated Newton solver uses
  561. // this number to control the relative accuracy with which the
  562. // Newton step is computed.
  563. //
  564. // This constant is passed to ConjugateGradientsSolver which uses
  565. // it to terminate the iterations when
  566. //
  567. // (Q_i - Q_{i-1})/Q_i < eta/i
  568. double eta = 1e-1;
  569. // Normalize the jacobian using Jacobi scaling before calling
  570. // the linear least squares solver.
  571. bool jacobi_scaling = true;
  572. // Some non-linear least squares problems have additional
  573. // structure in the way the parameter blocks interact that it is
  574. // beneficial to modify the way the trust region step is computed.
  575. //
  576. // e.g., consider the following regression problem
  577. //
  578. // y = a_1 exp(b_1 x) + a_2 exp(b_3 x^2 + c_1)
  579. //
  580. // Given a set of pairs{(x_i, y_i)}, the user wishes to estimate
  581. // a_1, a_2, b_1, b_2, and c_1.
  582. //
  583. // Notice here that the expression on the left is linear in a_1
  584. // and a_2, and given any value for b_1, b_2 and c_1, it is
  585. // possible to use linear regression to estimate the optimal
  586. // values of a_1 and a_2. Indeed, its possible to analytically
  587. // eliminate the variables a_1 and a_2 from the problem all
  588. // together. Problems like these are known as separable least
  589. // squares problem and the most famous algorithm for solving them
  590. // is the Variable Projection algorithm invented by Golub &
  591. // Pereyra.
  592. //
  593. // Similar structure can be found in the matrix factorization with
  594. // missing data problem. There the corresponding algorithm is
  595. // known as Wiberg's algorithm.
  596. //
  597. // Ruhe & Wedin (Algorithms for Separable Nonlinear Least Squares
  598. // Problems, SIAM Reviews, 22(3), 1980) present an analysis of
  599. // various algorithms for solving separable non-linear least
  600. // squares problems and refer to "Variable Projection" as
  601. // Algorithm I in their paper.
  602. //
  603. // Implementing Variable Projection is tedious and expensive, and
  604. // they present a simpler algorithm, which they refer to as
  605. // Algorithm II, where once the Newton/Trust Region step has been
  606. // computed for the whole problem (a_1, a_2, b_1, b_2, c_1) and
  607. // additional optimization step is performed to estimate a_1 and
  608. // a_2 exactly.
  609. //
  610. // This idea can be generalized to cases where the residual is not
  611. // linear in a_1 and a_2, i.e., Solve for the trust region step
  612. // for the full problem, and then use it as the starting point to
  613. // further optimize just a_1 and a_2. For the linear case, this
  614. // amounts to doing a single linear least squares solve. For
  615. // non-linear problems, any method for solving the a_1 and a_2
  616. // optimization problems will do. The only constraint on a_1 and
  617. // a_2 is that they do not co-occur in any residual block.
  618. //
  619. // This idea can be further generalized, by not just optimizing
  620. // (a_1, a_2), but decomposing the graph corresponding to the
  621. // Hessian matrix's sparsity structure in a collection of
  622. // non-overlapping independent sets and optimizing each of them.
  623. //
  624. // Setting "use_inner_iterations" to true enables the use of this
  625. // non-linear generalization of Ruhe & Wedin's Algorithm II. This
  626. // version of Ceres has a higher iteration complexity, but also
  627. // displays better convergence behaviour per iteration. Setting
  628. // Solver::Options::num_threads to the maximum number possible is
  629. // highly recommended.
  630. bool use_inner_iterations = false;
  631. // If inner_iterations is true, then the user has two choices.
  632. //
  633. // 1. Let the solver heuristically decide which parameter blocks
  634. // to optimize in each inner iteration. To do this leave
  635. // Solver::Options::inner_iteration_ordering untouched.
  636. //
  637. // 2. Specify a collection of of ordered independent sets. Where
  638. // the lower numbered groups are optimized before the higher
  639. // number groups. Each group must be an independent set. Not
  640. // all parameter blocks need to be present in the ordering.
  641. std::shared_ptr<ParameterBlockOrdering> inner_iteration_ordering;
  642. // Generally speaking, inner iterations make significant progress
  643. // in the early stages of the solve and then their contribution
  644. // drops down sharply, at which point the time spent doing inner
  645. // iterations is not worth it.
  646. //
  647. // Once the relative decrease in the objective function due to
  648. // inner iterations drops below inner_iteration_tolerance, the use
  649. // of inner iterations in subsequent trust region minimizer
  650. // iterations is disabled.
  651. double inner_iteration_tolerance = 1e-3;
  652. LoggingType logging_type = PER_MINIMIZER_ITERATION;
  653. // By default the Minimizer progress is logged to VLOG(1), which
  654. // is sent to STDERR depending on the vlog level. If this flag is
  655. // set to true, and logging_type is not SILENT, the logging output
  656. // is sent to STDOUT.
  657. bool minimizer_progress_to_stdout = false;
  658. // List of iterations at which the minimizer should dump the trust
  659. // region problem. Useful for testing and benchmarking. If empty
  660. // (default), no problems are dumped.
  661. std::vector<int> trust_region_minimizer_iterations_to_dump;
  662. // Directory to which the problems should be written to. Should be
  663. // non-empty if trust_region_minimizer_iterations_to_dump is
  664. // non-empty and trust_region_problem_dump_format_type is not
  665. // CONSOLE.
  666. std::string trust_region_problem_dump_directory = "/tmp";
  667. DumpFormatType trust_region_problem_dump_format_type = TEXTFILE;
  668. // Finite differences options ----------------------------------------------
  669. // Check all jacobians computed by each residual block with finite
  670. // differences. This is expensive since it involves computing the
  671. // derivative by normal means (e.g. user specified, autodiff,
  672. // etc), then also computing it using finite differences. The
  673. // results are compared, and if they differ substantially, details
  674. // are printed to the log.
  675. bool check_gradients = false;
  676. // Relative precision to check for in the gradient checker. If the
  677. // relative difference between an element in a jacobian exceeds
  678. // this number, then the jacobian for that cost term is dumped.
  679. double gradient_check_relative_precision = 1e-8;
  680. // WARNING: This option only applies to the to the numeric
  681. // differentiation used for checking the user provided derivatives
  682. // when when Solver::Options::check_gradients is true. If you are
  683. // using NumericDiffCostFunction and are interested in changing
  684. // the step size for numeric differentiation in your cost
  685. // function, please have a look at
  686. // include/ceres/numeric_diff_options.h.
  687. //
  688. // Relative shift used for taking numeric derivatives when
  689. // Solver::Options::check_gradients is true.
  690. //
  691. // For finite differencing, each dimension is evaluated at
  692. // slightly shifted values; for the case of central difference,
  693. // this is what gets evaluated:
  694. //
  695. // delta = gradient_check_numeric_derivative_relative_step_size;
  696. // f_initial = f(x)
  697. // f_forward = f((1 + delta) * x)
  698. // f_backward = f((1 - delta) * x)
  699. //
  700. // The finite differencing is done along each dimension. The
  701. // reason to use a relative (rather than absolute) step size is
  702. // that this way, numeric differentiation works for functions where
  703. // the arguments are typically large (e.g. 1e9) and when the
  704. // values are small (e.g. 1e-5). It is possible to construct
  705. // "torture cases" which break this finite difference heuristic,
  706. // but they do not come up often in practice.
  707. //
  708. // TODO(keir): Pick a smarter number than the default above! In
  709. // theory a good choice is sqrt(eps) * x, which for doubles means
  710. // about 1e-8 * x. However, I have found this number too
  711. // optimistic. This number should be exposed for users to change.
  712. double gradient_check_numeric_derivative_relative_step_size = 1e-6;
  713. // If update_state_every_iteration is true, then Ceres Solver will
  714. // guarantee that at the end of every iteration and before any
  715. // user provided IterationCallback is called, the parameter blocks
  716. // are updated to the current best solution found by the
  717. // solver. Thus the IterationCallback can inspect the values of
  718. // the parameter blocks for purposes of computation, visualization
  719. // or termination.
  720. // If update_state_every_iteration is false then there is no such
  721. // guarantee, and user provided IterationCallbacks should not
  722. // expect to look at the parameter blocks and interpret their
  723. // values.
  724. bool update_state_every_iteration = false;
  725. // Callbacks that are executed at the end of each iteration of the
  726. // Minimizer. An iteration may terminate midway, either due to
  727. // numerical failures or because one of the convergence tests has
  728. // been satisfied. In this case none of the callbacks are
  729. // executed.
  730. // Callbacks are executed in the order that they are specified in
  731. // this vector. By default, parameter blocks are updated only at the
  732. // end of the optimization, i.e when the Minimizer terminates. This
  733. // behaviour is controlled by update_state_every_iteration. If the
  734. // user wishes to have access to the updated parameter blocks when
  735. // his/her callbacks are executed, then set
  736. // update_state_every_iteration to true.
  737. //
  738. // The solver does NOT take ownership of these pointers.
  739. std::vector<IterationCallback*> callbacks;
  740. };
  741. struct CERES_EXPORT Summary {
  742. // A brief one line description of the state of the solver after
  743. // termination.
  744. std::string BriefReport() const;
  745. // A full multiline description of the state of the solver after
  746. // termination.
  747. std::string FullReport() const;
  748. bool IsSolutionUsable() const;
  749. // Minimizer summary -------------------------------------------------
  750. MinimizerType minimizer_type = TRUST_REGION;
  751. TerminationType termination_type = FAILURE;
  752. // Reason why the solver terminated.
  753. std::string message = "ceres::Solve was not called.";
  754. // Cost of the problem (value of the objective function) before
  755. // the optimization.
  756. double initial_cost = -1.0;
  757. // Cost of the problem (value of the objective function) after the
  758. // optimization.
  759. double final_cost = -1.0;
  760. // The part of the total cost that comes from residual blocks that
  761. // were held fixed by the preprocessor because all the parameter
  762. // blocks that they depend on were fixed.
  763. double fixed_cost = -1.0;
  764. // IterationSummary for each minimizer iteration in order.
  765. std::vector<IterationSummary> iterations;
  766. // Number of minimizer iterations in which the step was accepted. Unless
  767. // use_nonmonotonic_steps is true this is also the number of steps in which
  768. // the objective function value/cost went down.
  769. int num_successful_steps = -1;
  770. // Number of minimizer iterations in which the step was rejected
  771. // either because it did not reduce the cost enough or the step
  772. // was not numerically valid.
  773. int num_unsuccessful_steps = -1;
  774. // Number of times inner iterations were performed.
  775. int num_inner_iteration_steps = -1;
  776. // Total number of iterations inside the line search algorithm
  777. // across all invocations. We call these iterations "steps" to
  778. // distinguish them from the outer iterations of the line search
  779. // and trust region minimizer algorithms which call the line
  780. // search algorithm as a subroutine.
  781. int num_line_search_steps = -1;
  782. // All times reported below are wall times.
  783. // When the user calls Solve, before the actual optimization
  784. // occurs, Ceres performs a number of preprocessing steps. These
  785. // include error checks, memory allocations, and reorderings. This
  786. // time is accounted for as preprocessing time.
  787. double preprocessor_time_in_seconds = -1.0;
  788. // Time spent in the TrustRegionMinimizer.
  789. double minimizer_time_in_seconds = -1.0;
  790. // After the Minimizer is finished, some time is spent in
  791. // re-evaluating residuals etc. This time is accounted for in the
  792. // postprocessor time.
  793. double postprocessor_time_in_seconds = -1.0;
  794. // Some total of all time spent inside Ceres when Solve is called.
  795. double total_time_in_seconds = -1.0;
  796. // Time (in seconds) spent in the linear solver computing the
  797. // trust region step.
  798. double linear_solver_time_in_seconds = -1.0;
  799. // Number of times the Newton step was computed by solving a
  800. // linear system. This does not include linear solves used by
  801. // inner iterations.
  802. int num_linear_solves = -1;
  803. // Time (in seconds) spent evaluating the residual vector.
  804. double residual_evaluation_time_in_seconds = -1.0;
  805. // Number of residual only evaluations.
  806. int num_residual_evaluations = -1;
  807. // Time (in seconds) spent evaluating the jacobian matrix.
  808. double jacobian_evaluation_time_in_seconds = -1.0;
  809. // Number of Jacobian (and residual) evaluations.
  810. int num_jacobian_evaluations = -1;
  811. // Time (in seconds) spent doing inner iterations.
  812. double inner_iteration_time_in_seconds = -1.0;
  813. // Cumulative timing information for line searches performed as part of the
  814. // solve. Note that in addition to the case when the Line Search minimizer
  815. // is used, the Trust Region minimizer also uses a line search when
  816. // solving a constrained problem.
  817. // Time (in seconds) spent evaluating the univariate cost function as part
  818. // of a line search.
  819. double line_search_cost_evaluation_time_in_seconds = -1.0;
  820. // Time (in seconds) spent evaluating the gradient of the univariate cost
  821. // function as part of a line search.
  822. double line_search_gradient_evaluation_time_in_seconds = -1.0;
  823. // Time (in seconds) spent minimizing the interpolating polynomial
  824. // to compute the next candidate step size as part of a line search.
  825. double line_search_polynomial_minimization_time_in_seconds = -1.0;
  826. // Total time (in seconds) spent performing line searches.
  827. double line_search_total_time_in_seconds = -1.0;
  828. // Number of parameter blocks in the problem.
  829. int num_parameter_blocks = -1;
  830. // Number of parameters in the problem.
  831. int num_parameters = -1;
  832. // Dimension of the tangent space of the problem (or the number of
  833. // columns in the Jacobian for the problem). This is different
  834. // from num_parameters if a parameter block is associated with a
  835. // Manifold.
  836. int num_effective_parameters = -1;
  837. // Number of residual blocks in the problem.
  838. int num_residual_blocks = -1;
  839. // Number of residuals in the problem.
  840. int num_residuals = -1;
  841. // Number of parameter blocks in the problem after the inactive
  842. // and constant parameter blocks have been removed. A parameter
  843. // block is inactive if no residual block refers to it.
  844. int num_parameter_blocks_reduced = -1;
  845. // Number of parameters in the reduced problem.
  846. int num_parameters_reduced = -1;
  847. // Dimension of the tangent space of the reduced problem (or the
  848. // number of columns in the Jacobian for the reduced
  849. // problem). This is different from num_parameters_reduced if a
  850. // parameter block in the reduced problem is associated with a
  851. // Manifold.
  852. int num_effective_parameters_reduced = -1;
  853. // Number of residual blocks in the reduced problem.
  854. int num_residual_blocks_reduced = -1;
  855. // Number of residuals in the reduced problem.
  856. int num_residuals_reduced = -1;
  857. // Is the reduced problem bounds constrained.
  858. bool is_constrained = false;
  859. // Number of threads specified by the user for Jacobian and
  860. // residual evaluation.
  861. int num_threads_given = -1;
  862. // Number of threads actually used by the solver for Jacobian and
  863. // residual evaluation.
  864. int num_threads_used = -1;
  865. // Type of the linear solver requested by the user.
  866. LinearSolverType linear_solver_type_given =
  867. #if defined(CERES_NO_SPARSE)
  868. DENSE_QR;
  869. #else
  870. SPARSE_NORMAL_CHOLESKY;
  871. #endif
  872. // Type of the linear solver actually used. This may be different
  873. // from linear_solver_type_given if Ceres determines that the
  874. // problem structure is not compatible with the linear solver
  875. // requested or if the linear solver requested by the user is not
  876. // available, e.g. The user requested SPARSE_NORMAL_CHOLESKY but
  877. // no sparse linear algebra library was available.
  878. LinearSolverType linear_solver_type_used =
  879. #if defined(CERES_NO_SPARSE)
  880. DENSE_QR;
  881. #else
  882. SPARSE_NORMAL_CHOLESKY;
  883. #endif
  884. bool mixed_precision_solves_used = false;
  885. LinearSolverOrderingType linear_solver_ordering_type = AMD;
  886. // Size of the elimination groups given by the user as hints to
  887. // the linear solver.
  888. std::vector<int> linear_solver_ordering_given;
  889. // Size of the parameter groups used by the solver when ordering
  890. // the columns of the Jacobian. This maybe different from
  891. // linear_solver_ordering_given if the user left
  892. // linear_solver_ordering_given blank and asked for an automatic
  893. // ordering, or if the problem contains some constant or inactive
  894. // parameter blocks.
  895. std::vector<int> linear_solver_ordering_used;
  896. // For Schur type linear solvers, this string describes the
  897. // template specialization which was detected in the problem and
  898. // should be used.
  899. std::string schur_structure_given;
  900. // This is the Schur template specialization that was actually
  901. // instantiated and used. The reason this will be different from
  902. // schur_structure_given is because the corresponding template
  903. // specialization does not exist.
  904. //
  905. // Template specializations can be added to ceres by editing
  906. // internal/ceres/generate_template_specializations.py
  907. std::string schur_structure_used;
  908. // True if the user asked for inner iterations to be used as part
  909. // of the optimization.
  910. bool inner_iterations_given = false;
  911. // True if the user asked for inner iterations to be used as part
  912. // of the optimization and the problem structure was such that
  913. // they were actually performed. e.g., in a problem with just one
  914. // parameter block, inner iterations are not performed.
  915. bool inner_iterations_used = false;
  916. // Size of the parameter groups given by the user for performing
  917. // inner iterations.
  918. std::vector<int> inner_iteration_ordering_given;
  919. // Size of the parameter groups given used by the solver for
  920. // performing inner iterations. This maybe different from
  921. // inner_iteration_ordering_given if the user left
  922. // inner_iteration_ordering_given blank and asked for an automatic
  923. // ordering, or if the problem contains some constant or inactive
  924. // parameter blocks.
  925. std::vector<int> inner_iteration_ordering_used;
  926. // Type of the preconditioner requested by the user.
  927. PreconditionerType preconditioner_type_given = IDENTITY;
  928. // Type of the preconditioner actually used. This may be different
  929. // from linear_solver_type_given if Ceres determines that the
  930. // problem structure is not compatible with the linear solver
  931. // requested or if the linear solver requested by the user is not
  932. // available.
  933. PreconditionerType preconditioner_type_used = IDENTITY;
  934. // Type of clustering algorithm used for visibility based
  935. // preconditioning. Only meaningful when the preconditioner_type_used
  936. // is CLUSTER_JACOBI or CLUSTER_TRIDIAGONAL.
  937. VisibilityClusteringType visibility_clustering_type = CANONICAL_VIEWS;
  938. // Type of trust region strategy.
  939. TrustRegionStrategyType trust_region_strategy_type = LEVENBERG_MARQUARDT;
  940. // Type of dogleg strategy used for solving the trust region
  941. // problem.
  942. DoglegType dogleg_type = TRADITIONAL_DOGLEG;
  943. // Type of the dense linear algebra library used.
  944. DenseLinearAlgebraLibraryType dense_linear_algebra_library_type = EIGEN;
  945. // Type of the sparse linear algebra library used.
  946. SparseLinearAlgebraLibraryType sparse_linear_algebra_library_type =
  947. NO_SPARSE;
  948. // Type of line search direction used.
  949. LineSearchDirectionType line_search_direction_type = LBFGS;
  950. // Type of the line search algorithm used.
  951. LineSearchType line_search_type = WOLFE;
  952. // When performing line search, the degree of the polynomial used
  953. // to approximate the objective function.
  954. LineSearchInterpolationType line_search_interpolation_type = CUBIC;
  955. // If the line search direction is NONLINEAR_CONJUGATE_GRADIENT,
  956. // then this indicates the particular variant of non-linear
  957. // conjugate gradient used.
  958. NonlinearConjugateGradientType nonlinear_conjugate_gradient_type =
  959. FLETCHER_REEVES;
  960. // If the type of the line search direction is LBFGS, then this
  961. // indicates the rank of the Hessian approximation.
  962. int max_lbfgs_rank = -1;
  963. };
  964. // Once a least squares problem has been built, this function takes
  965. // the problem and optimizes it based on the values of the options
  966. // parameters. Upon return, a detailed summary of the work performed
  967. // by the preprocessor, the non-linear minimizer and the linear
  968. // solver are reported in the summary object.
  969. virtual void Solve(const Options& options,
  970. Problem* problem,
  971. Solver::Summary* summary);
  972. };
  973. // Helper function which avoids going through the interface.
  974. CERES_EXPORT void Solve(const Solver::Options& options,
  975. Problem* problem,
  976. Solver::Summary* summary);
  977. } // namespace ceres
  978. #include "ceres/internal/reenable_warnings.h"
  979. #endif // CERES_PUBLIC_SOLVER_H_