the gradient remains unchanged resulting in “Minimum trust region radius reached”
zdongchen opened this issue · comments
I am looking for the value of the parameter when the function takes the minimum value. The function form is as
CostFunction::CostFunction(std::vector<std::vector<double>>& p, std::vector<std::vector<double>>& c, int num_x) : p_(p), c_(c), num_x_(num_x) {}
template <typename T>
bool CostFunction::operator()(const T* const* parameters, T* residual) const {
T z = T(0.0);
for(int i = 0; i < p_.size(); ++i) {
T z_i = T(0.0);
T x_sum = T(0.0);
for(int j = 0; j < num_x_; ++j) {
x_sum += c_[i][j] * parameters[0][j];
}
z_i += p_[i][0] + p_[i][1] * x_sum + p_[i][2] * pow(x_sum, 2) + p_[i][3] * pow(x_sum, 3) + p_[i][4] * pow(x_sum, 4);
z += z_i;
}
residual[0] = z;
return true;
}
void Solver(std::vector<std::vector<double>>& p, std::vector<std::vector<double>>& c, const int num_params) {
double x[num_params];
for(int i = 0; i < num_params; ++i) {
x[i] = 0.5;
}
ceres::Problem* problem = new ceres::Problem;
CostFunction* cost_function = new CostFunction(p, c, num_params);
ceres::DynamicAutoDiffCostFunction<CostFunction, 4> dynamic_cost_function(cost_function);
dynamic_cost_function.AddParameterBlock(1);
dynamic_cost_function.SetNumResiduals(1);
problem->AddResidualBlock(&dynamic_cost_function, nullptr, x);
ceres::Solver::Options options;
options.minimizer_progress_to_stdout = true;
ceres::Solver::Summary summary;
ceres::Solve(options, problem, &summary);
std::cout << summary.FullReport() << std::endl;
for(int i = 0; i < num_params; ++i) {
std::cout << "x[" << i << "] = " << x[i] << std::endl;
}
}
the FullReport
iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time
0 1.057330e+04 0.00e+00 3.40e+01 0.00e+00 0.00e+00 1.00e+04 0 3.62e-04 6.05e-04
1 1.635421e+05 -1.53e+05 3.40e+01 0.00e+00 -4.22e+03 5.00e+03 1 1.83e-04 9.05e-04
2 1.635420e+05 -1.53e+05 3.40e+01 0.00e+00 -4.22e+03 1.25e+03 1 9.20e-05 1.36e-03
3 1.635420e+05 -1.53e+05 3.40e+01 0.00e+00 -4.22e+03 1.56e+02 1 3.41e-05 1.51e-03
4 1.635418e+05 -1.53e+05 3.40e+01 0.00e+00 -4.22e+03 9.77e+00 1 1.20e-04 2.02e-03
5 1.635383e+05 -1.53e+05 3.40e+01 0.00e+00 -4.26e+03 3.05e-01 1 3.70e-05 2.18e-03
6 1.635414e+05 -1.53e+05 3.40e+01 0.00e+00 -1.02e+04 4.77e-03 1 2.19e-05 2.25e-03
7 1.635547e+05 -1.53e+05 3.40e+01 0.00e+00 -4.46e+05 3.73e-05 1 3.10e-05 2.37e-03
8 1.635551e+05 -1.53e+05 3.40e+01 0.00e+00 -5.67e+07 1.46e-07 1 1.88e-05 2.42e-03
9 1.635551e+05 -1.53e+05 3.40e+01 0.00e+00 -1.45e+10 2.84e-10 1 3.10e-05 2.53e-03
10 1.635551e+05 -1.53e+05 3.40e+01 0.00e+00 -7.43e+12 2.78e-13 1 2.10e-05 2.58e-03
11 1.635551e+05 -1.53e+05 3.40e+01 0.00e+00 -7.61e+15 1.36e-16 1 4.22e-05 2.76e-03
12 1.635551e+05 -1.53e+05 3.40e+01 0.00e+00 -1.56e+19 3.31e-20 1 1.50e-04 3.03e-03
13 1.635551e+05 -1.53e+05 3.40e+01 0.00e+00 -6.38e+22 4.04e-24 1 2.91e-05 3.14e-03
14 1.635551e+05 -1.53e+05 3.40e+01 0.00e+00 -5.23e+26 2.47e-28 1 2.10e-05 3.19e-03
15 1.635551e+05 -1.53e+05 3.40e+01 0.00e+00 -8.57e+30 7.52e-33 1 6.99e-05 3.35e-03
Solver Summary (v 2.2.0-eigen-(3.4.0)-no_lapack-eigensparse)
Original Reduced
Parameter blocks 1 1
Parameters 1 1
Residual blocks 7 7
Residuals 7 7
Minimizer TRUST_REGION
Trust region strategy LEVENBERG_MARQUARDT
Sparse linear algebra library EIGEN_SPARSE
Given Used
Linear solver SPARSE_NORMAL_CHOLESKY SPARSE_NORMAL_CHOLESKY
Threads 1 1
Linear solver ordering AUTOMATIC 1
Cost:
Initial 1.057330e+04
Final 1.057330e+04
Change 0.000000e+00
Minimizer iterations 16
Successful steps 1
Unsuccessful steps 15
Time (in seconds):
Preprocessor 0.000243
Residual only evaluation 0.000278 (15)
Jacobian & residual evaluation 0.000344 (1)
Linear solver 0.000483 (15)
Minimizer 0.003446
Postprocessor 0.000016
Total 0.003706
Termination: CONVERGENCE (Minimum trust region radius reached. Trust region radius: 7.523164e-33 <= 1.000000e-32)
x[0] = 0.5
x[1] = 0.5
x[2] = 0.5
x[3] = 0.5
x[4] = 0.5
x[5] = 0.5
x[6] = 0.5
btw, the coefficient arrays p and c are as follows
c = [[0,0,0,0,0,-35,-32],
[0,0,0,33,0,0,0],
[0,0,0,-33,0,0,0],
[0,-29,0,0,-29,0,0],
[22,0,27,0,0,35,32],
[0,29,0,0,29,0,32],
[-22,0,-27,0,0,0,0]]
p = [[65.7746,0.240377,0.000291566,4.82587e-08,-8.01918e-11],
[55.2469,0.222333,0.000289126,5.64903e-08,-8.01918e-11],
[85.0069,0.261409,0.00026811,3.31716e-08,-8.01918e-11],
[65.7746,0.240377,0.000291566,4.82587e-08,-8.01918e-11],
[21.3355,0.108407,0.000191211,8.61348e-08,-8.01918e-11],
[29.7129,0.14492,0.00022873,7.87325e-08,-8.01918e-11],
[30.3014,0.147334,0.000231105,7.81974e-08,-8.01918e-11]]
hi, why this is closed, so what does the message " (Minimum trust region radius reached. Trust region radius: 7.523164e-33 <= 1.000000e-32) " means, and is it a good solve result.