0

当我在 ceres 求解器教程中运行以下代码时,我遇到了一些问题。

这是代码:

#include <iostream>

#include "ceres/ceres.h"
#include "glog/logging.h"
using ceres::AutoDiffCostFunction;
using ceres::CostFunction;
using ceres::Problem;
using ceres::Solve;
using ceres::Solver;
struct CostFunctor {
    template <typename T>
    bool operator()(const T* const x, T* residual) const {
        residual[0] = 10.0 - x[0];
        return true;
    }
};
int main(int argc, char *argv[])
{
    double x = 0.5;
    const double initial_x = x;
    Problem problem;
    CostFunction* cost_function =
        new AutoDiffCostFunction<CostFunctor, 1, 1>(new CostFunctor);
    problem.AddResidualBlock(cost_function, nullptr, &x);
    Solver::Options options;
    options.minimizer_progress_to_stdout = true;
    Solver::Summary summary;
    Solve(options, &problem, &summary);
    std::cout << summary.BriefReport() << "\n";
    std::cout << "x : " << initial_x << " -> " << x << "\n";
}

我遇到了问题:

E:\study_materials\Computer Version\ceres\ceres-solver-2.0.0\internal\ceres\solver.cc:505 Terminating: Can't use SPARSE_NORMAL_CHOLESKY with Solver::Options::sparse_linear_algebra_library_type = SUITE_SPARSE, because support was not enabled when Ceres Solver was built.

我不知道如何启用此支持,任何帮助将不胜感激。

4

1 回答 1

0

这是什么版本的谷神星求解器?如果稀疏线性代数库不可用,则应默认使用密集求解器 (DENSE_QR)。所以这看起来像是在 ceres 求解器中设置默认值的方式中的一个错误。

于 2022-02-15T19:53:47.650 回答