diff options
Diffstat (limited to 'internal/ceres/solver_impl.h')
-rw-r--r-- | internal/ceres/solver_impl.h | 112 |
1 files changed, 94 insertions, 18 deletions
diff --git a/internal/ceres/solver_impl.h b/internal/ceres/solver_impl.h index 09141ae..ebfb813 100644 --- a/internal/ceres/solver_impl.h +++ b/internal/ceres/solver_impl.h @@ -31,6 +31,7 @@ #ifndef CERES_INTERNAL_SOLVER_IMPL_H_ #define CERES_INTERNAL_SOLVER_IMPL_H_ +#include <set> #include <string> #include <vector> #include "ceres/internal/port.h" @@ -45,6 +46,7 @@ class CoordinateDescentMinimizer; class Evaluator; class LinearSolver; class Program; +class TripletSparseMatrix; class SolverImpl { public: @@ -54,6 +56,33 @@ class SolverImpl { ProblemImpl* problem_impl, Solver::Summary* summary); + static void TrustRegionSolve(const Solver::Options& options, + ProblemImpl* problem_impl, + Solver::Summary* summary); + + // Run the TrustRegionMinimizer for the given evaluator and configuration. + static void TrustRegionMinimize( + const Solver::Options &options, + Program* program, + CoordinateDescentMinimizer* inner_iteration_minimizer, + Evaluator* evaluator, + LinearSolver* linear_solver, + double* parameters, + Solver::Summary* summary); + +#ifndef CERES_NO_LINE_SEARCH_MINIMIZER + static void LineSearchSolve(const Solver::Options& options, + ProblemImpl* problem_impl, + Solver::Summary* summary); + + // Run the LineSearchMinimizer for the given evaluator and configuration. + static void LineSearchMinimize(const Solver::Options &options, + Program* program, + Evaluator* evaluator, + double* parameters, + Solver::Summary* summary); +#endif // CERES_NO_LINE_SEARCH_MINIMIZER + // Create the transformed Program, which has all the fixed blocks // and residuals eliminated, and in the case of automatic schur // ordering, has the E blocks first in the resulting program, with @@ -74,15 +103,6 @@ class SolverImpl { static LinearSolver* CreateLinearSolver(Solver::Options* options, string* error); - // Reorder the parameter blocks in program using the ordering. A - // return value of true indicates success and false indicates an - // error was encountered whose cause is logged to LOG(ERROR). - static bool ApplyUserOrdering(const ProblemImpl::ParameterMap& parameter_map, - const ParameterBlockOrdering* ordering, - Program* program, - string* error); - - // Reorder the residuals for program, if necessary, so that the // residuals involving e block (i.e., the first num_eliminate_block // parameter blocks) occur together. This is a necessary condition @@ -99,15 +119,6 @@ class SolverImpl { Program* program, string* error); - // Run the minimization for the given evaluator and configuration. - static void Minimize(const Solver::Options &options, - Program* program, - CoordinateDescentMinimizer* inner_iteration_minimizer, - Evaluator* evaluator, - LinearSolver* linear_solver, - double* parameters, - Solver::Summary* summary); - // Remove the fixed or unused parameter blocks and residuals // depending only on fixed parameters from the problem. Also updates // num_eliminate_blocks, since removed parameters changes the point @@ -131,6 +142,71 @@ class SolverImpl { const Solver::Options& options, const Program& program, const ProblemImpl::ParameterMap& parameter_map, + Solver::Summary* summary); + + // If the linear solver is of Schur type, then replace it with the + // closest equivalent linear solver. This is done when the user + // requested a Schur type solver but the problem structure makes it + // impossible to use one. + // + // If the linear solver is not of Schur type, the function is a + // no-op. + static void AlternateLinearSolverForSchurTypeLinearSolver( + Solver::Options* options); + + // Create a TripletSparseMatrix which contains the zero-one + // structure corresponding to the block sparsity of the transpose of + // the Jacobian matrix. + // + // Caller owns the result. + static TripletSparseMatrix* CreateJacobianBlockSparsityTranspose( + const Program* program); + + // Reorder the parameter blocks in program using the ordering + static bool ApplyUserOrdering( + const ProblemImpl::ParameterMap& parameter_map, + const ParameterBlockOrdering* parameter_block_ordering, + Program* program, + string* error); + + // Sparse cholesky factorization routines when doing the sparse + // cholesky factorization of the Jacobian matrix, reorders its + // columns to reduce the fill-in. Compute this permutation and + // re-order the parameter blocks. + // + // If the parameter_block_ordering contains more than one + // elimination group and support for constrained fill-reducing + // ordering is available in the sparse linear algebra library + // (SuiteSparse version >= 4.2.0) then the fill reducing + // ordering will take it into account, otherwise it will be ignored. + static bool ReorderProgramForSparseNormalCholesky( + const SparseLinearAlgebraLibraryType sparse_linear_algebra_library_type, + const ParameterBlockOrdering* parameter_block_ordering, + Program* program, + string* error); + + // Schur type solvers require that all parameter blocks eliminated + // by the Schur eliminator occur before others and the residuals be + // sorted in lexicographic order of their parameter blocks. + // + // If the parameter_block_ordering only contains one elimination + // group then a maximal independent set is computed and used as the + // first elimination group, otherwise the user's ordering is used. + // + // If the linear solver type is SPARSE_SCHUR and support for + // constrained fill-reducing ordering is available in the sparse + // linear algebra library (SuiteSparse version >= 4.2.0) then + // columns of the schur complement matrix are ordered to reduce the + // fill-in the Cholesky factorization. + // + // Upon return, ordering contains the parameter block ordering that + // was used to order the program. + static bool ReorderProgramForSchurTypeLinearSolver( + const LinearSolverType linear_solver_type, + const SparseLinearAlgebraLibraryType sparse_linear_algebra_library_type, + const ProblemImpl::ParameterMap& parameter_map, + ParameterBlockOrdering* parameter_block_ordering, + Program* program, string* error); }; |