17 const Eigen::VectorXd&
y, Eigen::VectorXd& w,
18 FuncName func_to_min, ClassName& holder,
19 double current_barrier_strength,
20 const Eigen::VectorXd& lengthscale_rho0,
27 if (settings.common.stop_requested && settings.common.stop_requested()) {
34 bool hessian_vector_curvature =
37 hessian_vector_curvature =
false;
39 if (settings.common.report_level >= 1) {
41 log_man <<
" nlml_hessian_vector: this objective has no exact NLML "
42 "Hessian-vector product; finite_difference curvature\n";
47 objective_config !=
nullptr
50 lengthscale_rho0, settings);
53 Ctx ctx(
x, x_ind,
y, holder, func_to_min, map_cfg,
55 settings.common.stop_requested);
56 ctx.trace_evaluations = settings.common.report_level >= 3;
58 std::vector<double> wbuf(
static_cast<std::size_t
>(w.size()));
59 Eigen::Map<Eigen::VectorXd>(wbuf.data(), w.size()) = w;
62 rgmin_tensor_borrow_cpu_f64(wbuf.data(), wbuf.size()));
68 rgmin_control_t ctrl{};
71 ctrl.maxiter =
static_cast<size_t>(settings.common.max_iter);
80 rgmin_scg_params_t params{};
82 params.lambda = settings.lambda;
83 params.lambda_limit = settings.lambda_limit;
84 params.tol_sol = settings.common.tolerance_sol;
85 params.tol_func = settings.common.tolerance_func;
86 params.conjugacy = RGMIN_CONJUGACY_LIU_STOREY;
88 rgmin_scg_options_t options{};
89 options.step_tolerance = settings.stationarity_step_stop
90 ? RGMIN_SCG_RELATIVE_EUCLIDEAN
91 : RGMIN_SCG_ABSOLUTE_INFINITY;
93 rgmin_report_t report{};
94 const rgmin_status_t st = rgmin_minimize_scg_with_options(
99 &ctx, xt.get(), &ctrl, ¶ms, &options, &report);
101 if (settings.common.stop_requested && settings.common.stop_requested()) {
105 if (ctx.hessian_vector_fallback) {
107 if (settings.common.report_level >= 1) {
109 log_man <<
" nlml_hessian_vector: the exact NLML Hessian-vector "
110 "product failed during the fit; rgmin's "
111 "finite_difference probe took the later curvatures\n";
114 if (ctx.failure.failed()) {
115 if (settings.common.report_level >= 1) ctx.failure.report();
119 w = Eigen::Map<Eigen::VectorXd>(wbuf.data(), w.size());
121 if (st != RGMIN_SUCCESS) {
125 if (ctrl.maxiter > 0 && report.steps >= ctrl.maxiter) {
void optimize(const gpr::EigenMatrix &x, const Eigen::VectorXd &x_ind, const Eigen::VectorXd &y, Eigen::VectorXd &w, FuncName func_to_min, ClassName &holder, double, const Eigen::VectorXd &lengthscale_rho0=Eigen::VectorXd(), const MapObjectiveConfig *objective_config=nullptr)
MapObjectiveConfig makeMapObjectiveConfig(const gpr::EigenMatrix &x, const Eigen::VectorXd &y, const Eigen::VectorXd &w, double current_barrier_strength, const Eigen::VectorXd &lengthscale_rho0, const gpr::ScgOptimizationSettings &settings, bool robust_signal_anchor=true)