1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126 |
- #ifndef CERES_PUBLIC_SOLVER_H_
- #define CERES_PUBLIC_SOLVER_H_
- #include <cmath>
- #include <memory>
- #include <string>
- #include <unordered_set>
- #include <vector>
- #include "ceres/crs_matrix.h"
- #include "ceres/internal/config.h"
- #include "ceres/internal/disable_warnings.h"
- #include "ceres/internal/export.h"
- #include "ceres/iteration_callback.h"
- #include "ceres/ordered_groups.h"
- #include "ceres/problem.h"
- #include "ceres/types.h"
- namespace ceres {
- class CERES_EXPORT Solver {
- public:
- virtual ~Solver();
-
-
-
-
-
- struct CERES_EXPORT Options {
-
-
-
- bool IsValid(std::string* error) const;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MinimizerType minimizer_type = TRUST_REGION;
- LineSearchDirectionType line_search_direction_type = LBFGS;
- LineSearchType line_search_type = WOLFE;
- NonlinearConjugateGradientType nonlinear_conjugate_gradient_type =
- FLETCHER_REEVES;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- int max_lbfgs_rank = 20;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- bool use_approximate_eigenvalue_bfgs_scaling = false;
-
-
-
-
-
- LineSearchInterpolationType line_search_interpolation_type = CUBIC;
-
-
- double min_line_search_step_size = 1e-9;
-
-
-
-
-
-
-
-
-
-
-
- double line_search_sufficient_function_decrease = 1e-4;
-
-
-
-
-
-
-
-
- double max_line_search_step_contraction = 1e-3;
-
-
-
-
-
-
-
-
- double min_line_search_step_contraction = 0.6;
-
-
-
-
-
-
-
-
- int max_num_line_search_step_size_iterations = 20;
-
-
-
-
-
- int max_num_line_search_direction_restarts = 5;
-
-
-
-
-
-
-
-
-
-
-
- double line_search_sufficient_curvature_decrease = 0.9;
-
-
-
-
-
-
-
-
-
- double max_line_search_step_expansion = 10.0;
- TrustRegionStrategyType trust_region_strategy_type = LEVENBERG_MARQUARDT;
-
- DoglegType dogleg_type = TRADITIONAL_DOGLEG;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- bool use_nonmonotonic_steps = false;
- int max_consecutive_nonmonotonic_steps = 5;
-
- int max_num_iterations = 50;
-
- double max_solver_time_in_seconds = 1e9;
-
-
- int num_threads = 1;
-
- double initial_trust_region_radius = 1e4;
- double max_trust_region_radius = 1e16;
-
-
- double min_trust_region_radius = 1e-32;
-
-
- double min_relative_decrease = 1e-3;
-
-
-
-
-
-
-
- double min_lm_diagonal = 1e-6;
- double max_lm_diagonal = 1e32;
-
-
-
-
-
- int max_num_consecutive_invalid_steps = 5;
-
-
-
-
- double function_tolerance = 1e-6;
-
-
-
-
-
- double gradient_tolerance = 1e-10;
-
-
-
-
- double parameter_tolerance = 1e-8;
-
- LinearSolverType linear_solver_type =
- #if defined(CERES_NO_SPARSE)
- DENSE_QR;
- #else
- SPARSE_NORMAL_CHOLESKY;
- #endif
-
- PreconditionerType preconditioner_type = JACOBI;
-
-
-
- VisibilityClusteringType visibility_clustering_type = CANONICAL_VIEWS;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- std::unordered_set<ResidualBlockId>
- residual_blocks_for_subset_preconditioner;
-
-
-
-
-
-
-
-
-
-
-
- DenseLinearAlgebraLibraryType dense_linear_algebra_library_type = EIGEN;
-
-
- SparseLinearAlgebraLibraryType sparse_linear_algebra_library_type =
- #if !defined(CERES_NO_SUITESPARSE)
- SUITE_SPARSE;
- #elif !defined(CERES_NO_ACCELERATE_SPARSE)
- ACCELERATE_SPARSE;
- #elif defined(CERES_USE_EIGEN_SPARSE)
- EIGEN_SPARSE;
- #else
- NO_SPARSE;
- #endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LinearSolverOrderingType linear_solver_ordering_type = AMD;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- std::shared_ptr<ParameterBlockOrdering> linear_solver_ordering;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- bool use_explicit_schur_complement = false;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- bool dynamic_sparsity = false;
-
-
-
-
-
-
-
-
-
-
-
-
-
- bool use_mixed_precision_solves = false;
-
-
- int max_num_refinement_iterations = 0;
-
-
- int min_linear_solver_iterations = 0;
-
-
-
-
- int max_linear_solver_iterations = 500;
-
-
-
-
-
- int max_num_spse_iterations = 5;
-
-
-
- bool use_spse_initialization = false;
-
-
-
-
- double spse_tolerance = 0.1;
-
-
-
-
-
-
-
-
- double eta = 1e-1;
-
-
- bool jacobi_scaling = true;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- bool use_inner_iterations = false;
-
-
-
-
-
-
-
-
-
-
- std::shared_ptr<ParameterBlockOrdering> inner_iteration_ordering;
-
-
-
-
-
-
-
-
-
- double inner_iteration_tolerance = 1e-3;
- LoggingType logging_type = PER_MINIMIZER_ITERATION;
-
-
-
-
- bool minimizer_progress_to_stdout = false;
-
-
-
- std::vector<int> trust_region_minimizer_iterations_to_dump;
-
-
-
-
- std::string trust_region_problem_dump_directory = "/tmp";
- DumpFormatType trust_region_problem_dump_format_type = TEXTFILE;
-
-
-
-
-
-
-
- bool check_gradients = false;
-
-
-
- double gradient_check_relative_precision = 1e-8;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- double gradient_check_numeric_derivative_relative_step_size = 1e-6;
-
-
-
-
-
-
-
-
-
-
-
- bool update_state_every_iteration = false;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- std::vector<IterationCallback*> callbacks;
- };
- struct CERES_EXPORT Summary {
-
-
- std::string BriefReport() const;
-
-
- std::string FullReport() const;
- bool IsSolutionUsable() const;
-
- MinimizerType minimizer_type = TRUST_REGION;
- TerminationType termination_type = FAILURE;
-
- std::string message = "ceres::Solve was not called.";
-
-
- double initial_cost = -1.0;
-
-
- double final_cost = -1.0;
-
-
-
- double fixed_cost = -1.0;
-
- std::vector<IterationSummary> iterations;
-
-
-
- int num_successful_steps = -1;
-
-
-
- int num_unsuccessful_steps = -1;
-
- int num_inner_iteration_steps = -1;
-
-
-
-
-
- int num_line_search_steps = -1;
-
-
-
-
-
- double preprocessor_time_in_seconds = -1.0;
-
- double minimizer_time_in_seconds = -1.0;
-
-
-
- double postprocessor_time_in_seconds = -1.0;
-
- double total_time_in_seconds = -1.0;
-
-
- double linear_solver_time_in_seconds = -1.0;
-
-
-
- int num_linear_solves = -1;
-
- double residual_evaluation_time_in_seconds = -1.0;
-
- int num_residual_evaluations = -1;
-
- double jacobian_evaluation_time_in_seconds = -1.0;
-
- int num_jacobian_evaluations = -1;
-
- double inner_iteration_time_in_seconds = -1.0;
-
-
-
-
-
-
- double line_search_cost_evaluation_time_in_seconds = -1.0;
-
-
- double line_search_gradient_evaluation_time_in_seconds = -1.0;
-
-
- double line_search_polynomial_minimization_time_in_seconds = -1.0;
-
- double line_search_total_time_in_seconds = -1.0;
-
- int num_parameter_blocks = -1;
-
- int num_parameters = -1;
-
-
-
-
- int num_effective_parameters = -1;
-
- int num_residual_blocks = -1;
-
- int num_residuals = -1;
-
-
-
- int num_parameter_blocks_reduced = -1;
-
- int num_parameters_reduced = -1;
-
-
-
-
-
- int num_effective_parameters_reduced = -1;
-
- int num_residual_blocks_reduced = -1;
-
- int num_residuals_reduced = -1;
-
- bool is_constrained = false;
-
-
- int num_threads_given = -1;
-
-
- int num_threads_used = -1;
-
- LinearSolverType linear_solver_type_given =
- #if defined(CERES_NO_SPARSE)
- DENSE_QR;
- #else
- SPARSE_NORMAL_CHOLESKY;
- #endif
-
-
-
-
-
-
- LinearSolverType linear_solver_type_used =
- #if defined(CERES_NO_SPARSE)
- DENSE_QR;
- #else
- SPARSE_NORMAL_CHOLESKY;
- #endif
- bool mixed_precision_solves_used = false;
- LinearSolverOrderingType linear_solver_ordering_type = AMD;
-
-
- std::vector<int> linear_solver_ordering_given;
-
-
-
-
-
-
- std::vector<int> linear_solver_ordering_used;
-
-
-
- std::string schur_structure_given;
-
-
-
-
-
-
-
- std::string schur_structure_used;
-
-
- bool inner_iterations_given = false;
-
-
-
-
- bool inner_iterations_used = false;
-
-
- std::vector<int> inner_iteration_ordering_given;
-
-
-
-
-
-
- std::vector<int> inner_iteration_ordering_used;
-
- PreconditionerType preconditioner_type_given = IDENTITY;
-
-
-
-
-
- PreconditionerType preconditioner_type_used = IDENTITY;
-
-
-
- VisibilityClusteringType visibility_clustering_type = CANONICAL_VIEWS;
-
- TrustRegionStrategyType trust_region_strategy_type = LEVENBERG_MARQUARDT;
-
-
- DoglegType dogleg_type = TRADITIONAL_DOGLEG;
-
- DenseLinearAlgebraLibraryType dense_linear_algebra_library_type = EIGEN;
-
- SparseLinearAlgebraLibraryType sparse_linear_algebra_library_type =
- NO_SPARSE;
-
- LineSearchDirectionType line_search_direction_type = LBFGS;
-
- LineSearchType line_search_type = WOLFE;
-
-
- LineSearchInterpolationType line_search_interpolation_type = CUBIC;
-
-
-
- NonlinearConjugateGradientType nonlinear_conjugate_gradient_type =
- FLETCHER_REEVES;
-
-
- int max_lbfgs_rank = -1;
- };
-
-
-
-
-
- virtual void Solve(const Options& options,
- Problem* problem,
- Solver::Summary* summary);
- };
- CERES_EXPORT void Solve(const Solver::Options& options,
- Problem* problem,
- Solver::Summary* summary);
- }
- #include "ceres/internal/reenable_warnings.h"
- #endif
|