1
// Ceres Solver - A fast non-linear least squares minimizer
2
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
3
// http://code.google.com/p/ceres-solver/
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are met:
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.
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.
29
// Author: keir@google.com (Keir Mierle)
31
#ifndef CERES_INTERNAL_SOLVER_IMPL_H_
32
#define CERES_INTERNAL_SOLVER_IMPL_H_
36
#include "ceres/internal/port.h"
37
#include "ceres/solver.h"
49
// Mirrors the interface in solver.h, but exposes implementation
50
// details for testing internally.
51
static void Solve(const Solver::Options& options,
52
ProblemImpl* problem_impl,
53
Solver::Summary* summary);
55
// Create the transformed Program, which has all the fixed blocks
56
// and residuals eliminated, and in the case of automatic schur
57
// ordering, has the E blocks first in the resulting program, with
58
// options.num_eliminate_blocks set appropriately.
59
// If fixed_cost is not NULL, the residual blocks that are removed
60
// are evaluated and the sum of their cost is returned in fixed_cost.
61
static Program* CreateReducedProgram(Solver::Options* options,
62
ProblemImpl* problem_impl,
66
// Create the appropriate linear solver, taking into account any
67
// config changes decided by CreateTransformedProgram(). The
68
// selected linear solver, which may be different from what the user
69
// selected; consider the case that the remaining elimininated
70
// blocks is zero after removing fixed blocks.
71
static LinearSolver* CreateLinearSolver(Solver::Options* options,
74
// Reorder the parameter blocks in program using the vector
75
// ordering. A return value of true indicates success and false
76
// indicates an error was encountered whose cause is logged to
78
static bool ApplyUserOrdering(const ProblemImpl& problem_impl,
79
vector<double*>& ordering,
83
// Reorder the residuals for program, if necessary, so that the
84
// residuals involving each E block occur together. This is a
85
// necessary condition for the Schur eliminator, which works on
86
// these "row blocks" in the jacobian.
87
static bool MaybeReorderResidualBlocks(const Solver::Options& options,
91
// Create the appropriate evaluator for the transformed program.
92
static Evaluator* CreateEvaluator(const Solver::Options& options,
96
// Run the minimization for the given evaluator and configuration.
97
static void Minimize(const Solver::Options &options,
100
LinearSolver* linear_solver,
102
Solver::Summary* summary);
104
// Remove the fixed or unused parameter blocks and residuals
105
// depending only on fixed parameters from the problem. Also updates
106
// num_eliminate_blocks, since removed parameters changes the point
107
// at which the eliminated blocks is valid.
108
// If fixed_cost is not NULL, the residual blocks that are removed
109
// are evaluated and the sum of their cost is returned in fixed_cost.
110
static bool RemoveFixedBlocksFromProgram(Program* program,
111
int* num_eliminate_blocks,
116
} // namespace internal
119
#endif // CERES_INTERNAL_SOLVER_IMPL_H_