1

私はCeresの初心者です(1週間弱調べています)、ceresソルバーを使用してクラス内のコスト関数を解決しようとしています。以下は私のコードのサンプル バージョンです。ceres のコスト関数を設定するのに問題があります。

struct myStruct {
    myStruct() {

    }

    template <typename T>
    bool operator()(const T* params, T* residuals) const {
        Myclass mClass;
        //I need to set the double[14] params to my class
        //mClass.SetParams(params); //params is the array of double[14]
        //call the cost function defined within the class
        //residuals[0] = T(mClass.evaluate());
        //get the double[14] params and residual
        //mclass.GetParams(params)
        return true;
    }

    static ceres::CostFunction* Create() {
        return (new ceres::AutoDiffCostFunction<myStruct, 1,14>(new myStruct()));
    }
]
};

int main(int argc, char** argv)
{   
    google::InitGoogleLogging(argv[0]);
    ceres::Problem problem;
    double[14] initParams;
        ceres::CostFunction* cost_function = myStruct::Create();
        problem.AddResidualBlock(cost_function,
            NULL, *initParams);
    ceres::Solver::Options options;
    options.linear_solver_type = ceres::DENSE_QR;
    options.minimizer_progress_to_stdout = true;

    ceres::Solver::Summary summary;
    ceres::Solve(options, &problem, &summary);
    std::cout << summary.FullReport() << "\n";

    std::cout << "Press any key to continue....";
    getchar();
    return 0;
}

プロセスは次のとおりです。myStruct の operator() 内でクラスに入力する必要がある 14 個のパラメーター initparam[14] の配列があります。

演算子内で initparam にアクセスしようとすると、各要素が double ではなく ceres Jet になっています。

他のブログ投稿からわかることから、ceres のドキュメント ( http://ceres-solver.org/interfacing_with_autodiff.html ) に記載されているこの種のものを実装する必要があるかもしれません。残念ながら、私はセレスについての知識が限られており、これが実際に正しい方法であるかどうかはわかりません. 誰か助けてくれませんか?必要に応じて、さらに情報を提供していただければ幸いです

4

1 に答える 1