97{
98 const int n_vars = w.size();
100 if (n_vars == 0) {
102 return;
103 }
104
105 Eigen::VectorXd lower_bounds(n_vars);
106 Eigen::VectorXd upper_bounds(n_vars);
107 for (int i = 0; i < n_vars; ++i) {
108 lower_bounds(i) = std::log(0.2);
109 upper_bounds(i) = std::log(3.0);
110 }
111 upper_bounds(0) = std::log(10);
112
113 ceres::Problem problem;
114 ceres::CostFunction* cost_function =
115 new GprCostFunction<ClassName, FuncName>(x_data, x_ind,
y, func_to_min,
116 holder);
117 problem.AddResidualBlock(cost_function, new ceres::TrivialLoss(), w.data());
118
119 for (int i = 0; i < n_vars; ++i) {
120 problem.SetParameterLowerBound(w.data(), i, lower_bounds(i));
121 problem.SetParameterUpperBound(w.data(), i, upper_bounds(i));
122 }
123
124 ceres::Solver::Options options;
125 options.function_tolerance = settings.common.tolerance_func;
126 options.gradient_tolerance = settings.common.tolerance_sol;
127 options.linear_solver_type = ceres::DENSE_QR;
128 options.line_search_direction_type = ceres::LBFGS;
129 options.max_num_iterations = settings.common.max_iter;
130 options.minimizer_progress_to_stdout = (settings.common.report_level >= 2);
131
132 ceres::Solver::Summary summary;
133 ceres::Solve(options, &problem, &summary);
134
135 if (summary.IsSolutionUsable()) {
137 }
138}