> For the complete documentation index, see [llms.txt](https://ceres-solver-tutorial-cn.gitbook.io/ceres/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ceres-solver-tutorial-cn.gitbook.io/ceres/modeling-non-linear-least-squares/introduction.md).

# Introduction

Ceres 求解器由两个不同的部分组成。一个是问题构建接口，它提供了一套丰富的工具来逐项构建优化问题；另一个是求解接口，它控制着优化算法的具体参数。本章主要介绍使用 Ceres 对优化问题进行建模的任务。[Solving Non-linear Least Squares](http://ceres-solver.org/nnls_solving.html#chapter-nnls-solving) 讨论了使用 Ceres 解决优化问题的各种方法，也就是下一章讨论求解。

Ceres 可以鲁棒的解决以下形式的带有边界约束的非线性最小二乘问题

$$
\min\_{\mathbf{x}}\frac{1}{2}\sum\_{i}^{}\tau *{i}\left ( \parallel f\_i\left(x*{i1}, ..., x\_{ik}\right)\parallel ^2 \right )\ s.t.\ \ l\_j \le x\_j \le \mu\_{j}
$$

表达式 $$\tau *{i}\left(\left|f*{i}\left(x\_{i\_{1}}, \ldots, x\_{i\_{k}}\right)\right|^{2}\right)$$ 在 Ceres 中是一个 `ResidualBlock` ，其中 $$f\_{i}(\cdot)$$ 在 Ceres 中是一个 `CostFunction` ，它的计算又需要 $$x\_{ij}$$ 这些参数的参与， $$\left\[x\_{i\_{1}}, \ldots, x\_{i\_{k}}\right]$$ 统称一个参数块。在大多数优化问题中，小组标量一起出现。例如，平移向量的三个分量和定义相机姿态的四元数的四个分量。我们将这样一组小标量称为 `ParameterBlock`。当然 `ParameterBlock` 也可以只有一个分量。$$l\_{j}$$ and $$u\_{j}$$ 是参数块 $$x\_{j}$$ 的上下界。 $$\tau \_{i}$$ 是一个 `Lossfunction`。它是一个标量函数，用于减小非线性优化问题中的异常值对优化的影响。

在特殊情况下，当 $$\tau *{i}(x)=x$$，是一个恒等映射，并且 $$l*{j}=-\infty$$ and $$u\_{j}=\infty$$ 我们就能得到常见的非线性优化问题形式如下：

$$
\frac{1}{2} \sum\_{i}\left|f\_{i}\left(x\_{i\_{1}}, \ldots, x\_{i\_{k}}\right)\right|^{2}
$$
