GraphGNSSLib
GraphGNSSLib copied to clipboard
Issue with Dynamic Theta Update in Graduated Non-Convexity for Ceres Solver
I am working on implementing the Geman-McClure loss function with a dynamic update of the theta parameter in each iteration to achieve Graduated Non-Convexity (GNC) results in the Ceres Solver. Despite following the recommended approach, my current implementation does not seem to influence the Ceres solver's behavior as expected. I would greatly appreciate your guidance on this matter. Below is a rough outline of my code:
// Geman-McClure else if (loss == "Geman"){ double a =2; loss_function = new GemanMcClureLoss(a); }
// Geman-McClure loss function class class GemanMcClureLoss : public ceres::LossFunction { public: explicit GemanMcClureLoss(double delta) : delta_(delta), delta_square(delta * delta) {}
virtual void Evaluate(double s, double rho[3]) const override
{
const double aux = 1.0 / (delta_ + s);
rho[0] = delta_ * s * aux;
rho[1] = delta_square * aux * aux;
rho[2] = -2. * rho[1] * aux;
}
private: const double delta_; const double delta_square; };
// Main loop for iterating and updating theta int max_iter = 5;
for (int iter = 0; iter < max_iter; ++iter) { ceres::Problem problem;
// Add residual blocks with Geman-McClure loss ceres::CostFunction* cost_function = new ceres::AutoDiffCostFunction<ResidualFunction, 1, 1>(new ResidualFunction(res)); problem.AddResidualBlock(cost_function, loss_function, &initial_x);
// Solver configuration and solving ceres::Solver::Options options; ceres::Solver::Summary summary; ceres::Solve(options, &problem, &summary);
// Update theta value and reset the loss function's theta theta /= 1.4; loss_function->UpdateTheta(theta); }