Loading...
Searching...
No Matches
RgminOpt.inl
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
5#ifndef GPR_ML_RGMIN_OPT_INL_
6#define GPR_ML_RGMIN_OPT_INL_
7
8#include <algorithm>
9#include <cmath>
10#include <cstdint>
11#include <cstdio>
12#include <limits>
13
14#include "RgminObjective.h"
15
16namespace funcmin {
17
18template <typename ClassName, typename FuncName>
19void RgminOpt::optimize(const gpr::EigenMatrix& x, const Eigen::VectorXd& x_ind,
20 const Eigen::VectorXd& y, Eigen::VectorXd& w,
21 FuncName func_to_min, ClassName& holder,
22 double current_barrier_strength,
23 const Eigen::VectorXd& lengthscale_rho0,
24 const MapObjectiveConfig* objective_config)
25{
26 optimizeImpl(x, x_ind, y, w, func_to_min, holder, current_barrier_strength,
27 lengthscale_rho0, objective_config, nullptr, nullptr);
28}
29
30template <typename ClassName, typename FuncName>
32 const gpr::EigenMatrix& x, const Eigen::VectorXd& x_ind,
33 const Eigen::VectorXd& y, Eigen::VectorXd& w, FuncName func_to_min,
34 ClassName& holder, double current_barrier_strength,
35 const Eigen::VectorXd& lengthscale_rho0,
36 const MapObjectiveConfig* objective_config, double* opening_value_out,
37 double* last_value_out)
38{
39 optimizeImpl(x, x_ind, y, w, func_to_min, holder, current_barrier_strength,
40 lengthscale_rho0, objective_config, opening_value_out,
41 last_value_out);
42}
43
44template <typename ClassName, typename FuncName>
45void RgminOpt::optimizeImpl(const gpr::EigenMatrix& x,
46 const Eigen::VectorXd& x_ind,
47 const Eigen::VectorXd& y, Eigen::VectorXd& w,
48 FuncName func_to_min, ClassName& holder,
49 double current_barrier_strength,
50 const Eigen::VectorXd& lengthscale_rho0,
51 const MapObjectiveConfig* objective_config,
52 double* opening_value_out, double* last_value_out)
53{
54 failedOptim = false;
57 if (opening_value_out != nullptr)
58 *opening_value_out = std::numeric_limits<double>::quiet_NaN();
59 if (last_value_out != nullptr)
60 *last_value_out = std::numeric_limits<double>::quiet_NaN();
61 logical_objective_work = 0;
62 physical_objective_work = 0;
63
64 const MapObjectiveConfig map_cfg =
65 objective_config != nullptr
66 ? *objective_config
67 : makeMapObjectiveConfig(x, y, w, current_barrier_strength,
68 lengthscale_rho0, settings);
69
71
72 Eigen::VectorXd lower = Eigen::VectorXd::Constant(
73 w.size(), -std::numeric_limits<double>::infinity());
74 Eigen::VectorXd upper = -lower;
75 const auto intersect = [&](const Eigen::VectorXd& side, bool is_lower) {
76 if (side.size() == 0) return true;
77 if (side.size() != w.size() || side.array().isNaN().any()) return false;
78 if (is_lower)
79 lower = lower.cwiseMax(side);
80 else
81 upper = upper.cwiseMin(side);
82 return true;
83 };
84 if (!intersect(box_lo, true) || !intersect(box_hi, false) ||
85 !intersect(map_cfg.parameter_lower, true) ||
86 !intersect(map_cfg.parameter_upper, false)) {
87 failedOptim = true;
88 return;
89 }
90 const bool inertial =
91 method == rgmin::Method::Fire || method == rgmin::Method::Fire2;
92 if (inertial && map_cfg.use_magn_ceiling && w.size() > 0) {
93 upper(0) = std::min(
94 upper(0), std::nextafter(map_cfg.max_log_magnSigma2,
95 -std::numeric_limits<double>::infinity()));
96 }
97 if ((lower.array() > upper.array()).any()) {
98 failedOptim = true;
99 return;
100 }
101 const bool has_box =
102 lower.array().isFinite().any() || upper.array().isFinite().any();
103
104 using Ctx = RgminNlmlCtx<ClassName, FuncName>;
105 Ctx ctx(x, x_ind, y, holder, func_to_min, map_cfg, false, true,
106 settings.common.stop_requested);
107 const auto record_work = [&] {
108 logical_objective_work = ctx.logicalObjectiveWork();
109 physical_objective_work = ctx.physicalObjectiveWork();
110 };
111 ctx.trace_evaluations = settings.common.report_level >= 3;
112
113 std::vector<double> wbuf(static_cast<std::size_t>(w.size()));
114 Eigen::Map<Eigen::VectorXd>(wbuf.data(), w.size()) = w;
116 const RgminTensorHandle xt(
117 rgmin_tensor_borrow_cpu_f64(wbuf.data(), wbuf.size()));
118 if (!xt) {
119 failedOptim = true;
120 return;
121 }
122
123 rgmin::OptimizeControl ctrl;
124 ctrl.max_iterations = static_cast<std::size_t>(settings.common.max_iter);
125 ctrl.gtol = gtol > 0.0 ? gtol
126 : std::min(settings.common.tolerance_func,
127 settings.common.tolerance_sol);
128 ctrl.istep = inertial ? 0.1 : 1.0;
129 // A zero memory is "use rgmin's default", not a one-pair history.
130 // OptimizeControl::memory is that default; the C ABI maps 0 to the
131 // same cap. The warm-start record below uses this value, so the
132 // host and the solver keep one history length.
133 ctrl.memory = lbfgsPairCap();
134 // A log-space step of norm log(2) bounds every multiplicative change
135 // in covariance amplitude and length scales between one half and two.
136 // A negative value asks rgmin for no step cap at all: the coordinates
137 // are hyperparameters, not atoms, so the default per-atom cap of a
138 // Cartesian session does not apply.
139 ctrl.maxmove = maxmove > 0.0 ? maxmove : (inertial ? std::log(2.0) : -1.0);
140
141 const auto dim = static_cast<std::size_t>(w.size());
142 // Empty and all-true masks describe the same tangent space. Solver
143 // memory depends on that space, independently of how it is specified.
144 const std::vector<bool> active_parameters =
145 map_cfg.active_parameters.empty() ? std::vector<bool>(dim, true)
146 : map_cfg.active_parameters;
147 // A kept session's memory describes the previous fit; its opening
148 // step, acceptance window and cached point do not transfer to a new
149 // objective. Every fit therefore opens a fresh session, and a warm
150 // start transplants the previous fit's curvature pairs into it.
151 const bool warm =
152 session != nullptr && session_dim == dim && session_method == method &&
153 session_memory == ctrl.memory && session_gtol == ctrl.gtol &&
154 session_maxmove == ctrl.maxmove &&
155 session_active == active_parameters && !retained_s.empty();
156 if (!warm) {
157 retained_s.clear();
158 retained_y.clear();
159 }
160 session.reset();
161 // The penalized, projected gradient at the fit's start: the opening
162 // step scale, and the first point of the pair record.
163 std::vector<double> prev_grad;
164 if (!inertial || opening_value_out != nullptr) {
165 try {
166 const auto& start = ctx.evalAt(w);
167 if (start.retainable()) {
168 double energy = start.energy;
169 Eigen::VectorXd gradient = start.gradient;
170 applyMapPenalty(w, map_cfg, energy, &gradient);
171 if (opening_value_out != nullptr) *opening_value_out = energy;
172 if (!inertial) {
173 projectMapGradient(map_cfg, gradient);
174 prev_grad.assign(gradient.data(),
175 gradient.data() + gradient.size());
176 const double norm = gradient.norm();
177 if (initial_log_move > 0.0 &&
178 initial_log_move_whole_session && std::isfinite(norm) &&
179 norm > 0.0)
180 ctrl.istep =
181 std::min(ctrl.istep, initial_log_move / norm);
182 }
183 }
184 } catch (...) {
185 // The failure latches as it would in the solver's own first
186 // evaluation, and the step loop reports it.
187 ctx.captureCallbackError("objective");
188 }
189 }
190 session = std::make_unique<rgmin::Solver>(method, ctrl.to_control(), dim);
191 // The roundoff window below is now consulted under every acceptance.
192 // The fit still requests no energy acceptance: that is the mode the
193 // window was defined for, and a 0.6 session is created with energy
194 // acceptance otherwise. This is not the capped eOn step: its default
195 // length is 0.2, and a hyperparameter move is not an atomic
196 // displacement.
197 session->set_accept(RGMIN_ACCEPT_NONE);
198 // Hyperparameters are not atoms: clear the per-atom cap rgmin installs
199 // on a Cartesian session by default.
200 session->set_atom_maxmove(0.0);
201 // Hager--Zhang (2005), equations (4.1)--(4.3), uses this relative
202 // value window with the endpoint slope conditions near a minimum.
203 // It is an acceptance policy; gradient stopping remains independent.
204 if (session->set_objective_roundoff(1e-6) != RGMIN_SUCCESS) {
205 session.reset();
206 failedOptim = true;
207 return;
208 }
209 const int highs_status = session->set_highs(true);
210 if (maxmove > 0.0) session->set_maxmove(maxmove);
211 if (has_box) {
212 const int box_status =
213 session->set_box(lower.data(), upper.data(), dim);
214 if (highs_status != 0 || box_status != 0) {
215 session.reset();
216 failedOptim = true;
217 if (settings.common.report_level >= 1) {
218 std::fprintf(stderr,
219 "rgmin MAP optimizer cannot enforce its "
220 "coordinate box.\n");
221 }
222 return;
223 }
224 }
225 session_dim = dim;
226 session_method = method;
227 session_memory = ctrl.memory;
228 session_gtol = ctrl.gtol;
229 session_maxmove = ctrl.maxmove;
230 session_has_box = has_box;
231 session_lower = lower;
232 session_upper = upper;
233 session_active = active_parameters;
234 last_warm_pairs = 0;
235 if (warm) {
236 // Rows added since the last fit change the objective by the
237 // negative log predictive density of those rows, Delta(theta); at the
238 // kept optimum the whole gradient is grad Delta. The record's
239 // inverse-Hessian model H describes the new objective where the
240 // move it proposes for that gradient, d = -H grad Delta, stays
241 // inside the trust the fit gives any opening step: beyond it the
242 // added rows' curvature is not small against the retained one. d
243 // is rgmin's own two-loop product, no evaluation.
244 for (std::size_t k = 0; k < retained_s.size(); ++k)
245 session->push_pair(retained_s[k].data(), retained_y[k].data(), dim);
246 const double trust = initial_log_move > 0.0 ? initial_log_move
247 : maxmove > 0.0 ? maxmove
248 : 1.0;
249 // The decrease the record claims for the added rows is the Newton
250 // decrement -g.d/2. Rows the previous posterior explains carry a
251 // gradient whose expected decrement is of order p k/n nats for p
252 // parameters and k rows added to n (the score has zero mean and
253 // the Fisher information of k rows against that of n); a record
254 // claiming more than one nat per parameter describes rows the fit
255 // cannot treat as a perturbation of the previous one.
256 std::vector<double> direction(dim, 0.0);
257 double move = std::numeric_limits<double>::infinity();
258 double decrement = std::numeric_limits<double>::infinity();
259 if (prev_grad.size() == dim &&
260 session->search_direction(prev_grad.data(), direction.data(),
261 dim) == RGMIN_SUCCESS) {
262 double dd = 0.0, gd = 0.0;
263 for (std::size_t k = 0; k < dim; ++k) {
264 dd += direction[k] * direction[k];
265 gd += direction[k] * prev_grad[k];
266 }
267 move = std::sqrt(dd);
268 decrement = -0.5 * gd;
269 }
270 const double nats_allowed = static_cast<double>(std::count(
271 active_parameters.begin(), active_parameters.end(), true));
272 const bool trusted = persistent_session && std::isfinite(move) &&
273 move <= trust && std::isfinite(decrement) &&
274 decrement <= nats_allowed;
275 if (trusted) {
276 last_warm_pairs = session->pair_count();
277 } else {
278 session->forget();
279 }
280 ++warm_starts;
281 if (settings.common.report_level >= 1) {
282 std::fprintf(stderr,
283 "rgmin MAP optimizer: warm start, %zu pairs of the "
284 "previous fit %s (their move for the new gradient "
285 "%.3g against the opening trust %.3g, their claimed "
286 "decrease %.3g nats against %.3g).\n",
287 trusted ? last_warm_pairs : retained_s.size(),
288 trusted ? "transplanted"
289 : persistent_session ? "dropped as another objective"
290 : "left aside (record off)",
291 move, trust, decrement, nats_allowed);
292 }
293 }
294 retained_s.clear();
295 retained_y.clear();
296 const std::size_t pair_cap = ctrl.memory;
297
298 // A cold session's first step moves at most initial_log_move: the
299 // Euclidean cap bounds the displacement of every method, and the line
300 // searches and the trust radii take their largest trial from it. The
301 // session's own opening step stays at ctrl.istep, and the cap is lifted
302 // to the caller's maxmove once the first step is taken.
303 const bool bound_first_step =
304 !inertial && initial_log_move > 0.0 && !initial_log_move_whole_session;
305 if (bound_first_step) {
306 session->set_maxmove(maxmove > 0.0 ? std::min(maxmove, initial_log_move)
307 : initial_log_move);
308 }
309 rgmin::Report report{};
310 bool step_converged = false;
311 bool have_previous_objective = false;
312 double previous_objective = 0.0;
313 std::size_t flat_steps = 0;
314 double flat_best_grad = std::numeric_limits<double>::infinity();
315 // ctrl.memory is already the resolved pair cap, including rgmin's
316 // default when the caller left memory at 0.
317 const std::size_t flat_window = ctrl.memory;
318 double objective_min = std::numeric_limits<double>::infinity();
319 double objective_max = -std::numeric_limits<double>::infinity();
320 bool wall_clock_stopped = false;
321 try {
322 for (std::size_t iteration = 0;
323 ctrl.max_iterations == 0 || iteration < ctrl.max_iterations;
324 ++iteration) {
325 if (settings.common.stop_requested &&
326 settings.common.stop_requested()) {
327 wall_clock_stopped = true;
328 break;
329 }
330 const std::vector<double> previous = wbuf;
331 ctx.pinAt(Eigen::Map<const Eigen::VectorXd>(wbuf.data(), w.size()));
332 report =
333 session->step(&rgminEval<Ctx>, &rgminGrad<Ctx>, &ctx, xt.get());
334 if (bound_first_step && iteration == 0)
335 session->set_maxmove(maxmove > 0.0 ? maxmove : 0.0);
336 if (ctx.failure.failed()) break;
337 ctx.pinAt(Eigen::Map<const Eigen::VectorXd>(wbuf.data(), w.size()));
338 if (settings.common.report_level >= 2) {
339 std::fprintf(stderr,
340 "[map-rgmin] step=%zu value=%.17g "
341 "gradient_norm=%.17g theta=",
342 report.steps, report.value, report.grad_norm);
343 for (const double parameter: wbuf)
344 std::fprintf(stderr, " %.17g", parameter);
345 std::fprintf(stderr, "\n");
346 }
347 if (!std::isfinite(report.value) ||
348 !std::isfinite(report.grad_norm) ||
349 report.grad_norm <= ctrl.gtol) {
350 break;
351 }
352 // An unlimited session (max_iterations == 0) is a caller-driven
353 // step loop. rgmin then reports StepTolerance after max(n, 2)
354 // accepted steps whose value stays inside the roundoff window
355 // and whose gradient norm stays inside sqrt(eps) of the step
356 // that opened the run. That step is taken; the fit ends.
357 if (ctrl.max_iterations == 0 &&
358 report.stop == RGMIN_STOP_STEP_TOLERANCE) {
359 step_converged = true;
360 break;
361 }
362 if (have_previous_objective) {
363 objective_min = std::min(objective_min, report.value);
364 objective_max = std::max(objective_max, report.value);
365 // Same flat-objective test as SCG: a step inside
366 // tolerance_func of the range already seen. On that stretch
367 // the gradient jitters, so the plateau is a run with no new
368 // gradient low. A finite iteration budget still spends every
369 // step on that plateau.
370 const double flat_scale =
371 settings.common.tolerance_func *
372 (1.0 + (objective_max - objective_min));
373 const bool objective_flat =
374 std::abs(report.value - previous_objective) < flat_scale;
375 // On a flat objective the gradient jitters by more than one
376 // step-to-step difference. A new low, lower than the best
377 // gradient of this flat stretch by the same flat scale, is
378 // still progress. Oscillation inside that band is the plateau.
379 if (!objective_flat) {
380 flat_steps = 0;
381 flat_best_grad = report.grad_norm;
382 } else if (report.grad_norm < flat_best_grad - flat_scale) {
383 flat_steps = 0;
384 flat_best_grad = report.grad_norm;
385 } else {
386 ++flat_steps;
387 flat_best_grad = std::min(flat_best_grad, report.grad_norm);
388 }
389 if (flat_steps >= flat_window) {
390 step_converged = true;
391 break;
392 }
393 }
394 previous_objective = report.value;
395 have_previous_objective = true;
396 objective_min = std::min(objective_min, report.value);
397 objective_max = std::max(objective_max, report.value);
398 if (wbuf == previous) break;
399 if (method == rgmin::Method::Lbfgs && !prev_grad.empty()) {
400 // The accepted point's evaluation is retained by the
401 // context, so the pair costs no objective call.
402 const auto& accepted = ctx.evalAt(
403 Eigen::Map<const Eigen::VectorXd>(wbuf.data(), w.size()));
404 if (accepted.retainable()) {
405 double energy = accepted.energy;
406 Eigen::VectorXd gradient = accepted.gradient;
407 applyMapPenalty(Eigen::Map<const Eigen::VectorXd>(
408 wbuf.data(), w.size()),
409 map_cfg, energy, &gradient);
410 projectMapGradient(map_cfg, gradient);
411 std::vector<double> s_pair(wbuf.size()),
412 y_pair(wbuf.size());
413 for (std::size_t k = 0; k < wbuf.size(); ++k) {
414 s_pair[k] = wbuf[k] - previous[k];
415 y_pair[k] = gradient(static_cast<Eigen::Index>(k)) -
416 prev_grad[k];
417 }
418 if (retained_s.size() == pair_cap) {
419 retained_s.erase(retained_s.begin());
420 retained_y.erase(retained_y.begin());
421 }
422 retained_s.push_back(std::move(s_pair));
423 retained_y.push_back(std::move(y_pair));
424 prev_grad.assign(gradient.data(),
425 gradient.data() + gradient.size());
426 } else {
427 prev_grad.clear();
428 }
429 }
430 // Stationarity on the step, the scale of the refit-skip test
431 // (tolerance_sol times one plus the parameter norm): a move
432 // below the shift that would trigger the next refit ends the
433 // fit as converged.
434 if (settings.stationarity_step_stop) {
435 double step_sq = 0.0, norm_sq = 0.0;
436 for (std::size_t k = 0; k < wbuf.size(); ++k) {
437 const double d = wbuf[k] - previous[k];
438 step_sq += d * d;
439 norm_sq += wbuf[k] * wbuf[k];
440 }
441 const double step_tolerance =
442 settings.common.tolerance_sol * (1.0 + std::sqrt(norm_sq));
443 if (step_tolerance > 0.0 &&
444 std::sqrt(step_sq) <= step_tolerance) {
445 step_converged = true;
446 break;
447 }
448 }
449 }
450 if (!ctx.failure.failed() &&
451 ctx.restoreHolderAt(Eigen::Map<const Eigen::VectorXd>(
452 wbuf.data(), w.size())) != RGMIN_SUCCESS)
453 throw std::runtime_error(
454 "rgmin cannot restore final objective state");
455 } catch (const std::exception& error) {
456 record_work();
457 completedIterations = static_cast<int>(report.steps);
458 if (settings.common.report_level >= 1) {
459 if (ctx.failure.failed())
460 ctx.failure.report();
461 else
462 std::fprintf(stderr, "rgmin MAP optimizer failed: %s\n",
463 error.what());
464 }
465 session.reset();
466 failedOptim = true;
467 return;
468 }
469 record_work();
470 completedIterations = static_cast<int>(report.steps);
471 if (last_value_out != nullptr) *last_value_out = report.value;
472 if (wall_clock_stopped) {
473 session.reset();
474 failedOptim = true;
476 return;
477 }
478 if (ctx.failure.failed()) {
479 if (settings.common.report_level >= 1) ctx.failure.report();
480 session.reset();
481 failedOptim = true;
482 return;
483 }
484 w = Eigen::Map<Eigen::VectorXd>(wbuf.data(), w.size());
485
486 // A fit that stops on an active bound is stationary when the gradient
487 // components that point out of the box are discounted: no admissible
488 // step remains along them, so the box-projected gradient decides.
489 bool box_stationary = false;
490 double projected_norm = report.grad_norm;
491 if (has_box && std::isfinite(report.value) &&
492 std::isfinite(report.grad_norm) && report.grad_norm > ctrl.gtol &&
493 !step_converged) {
494 try {
495 const auto& final_eval = ctx.evalAt(w);
496 if (final_eval.retainable()) {
497 double energy = final_eval.energy;
498 Eigen::VectorXd gradient = final_eval.gradient;
499 applyMapPenalty(w, map_cfg, energy, &gradient);
500 projectMapGradient(map_cfg, gradient);
501 for (Eigen::Index k = 0; k < gradient.size(); ++k) {
502 const double slack = 1e-9 * (1.0 + std::abs(w(k)));
503 const bool out_below = k < lower.size() &&
504 w(k) <= lower(k) + slack &&
505 gradient(k) > 0.0;
506 const bool out_above = k < upper.size() &&
507 w(k) >= upper(k) - slack &&
508 gradient(k) < 0.0;
509 if (out_below || out_above) gradient(k) = 0.0;
510 }
511 projected_norm = gradient.norm();
512 box_stationary = std::isfinite(projected_norm) &&
513 projected_norm <= ctrl.gtol;
514 }
515 } catch (...) {
516 // The final point stays as the solver left it; the unprojected
517 // norm decides below.
518 }
519 }
520
521 const bool converged =
522 std::isfinite(report.value) && std::isfinite(report.grad_norm) &&
523 (report.grad_norm <= ctrl.gtol || step_converged || box_stationary);
524 failedOptim = !converged;
525 exhaustedIterationBudget = !converged && ctrl.max_iterations > 0 &&
526 report.steps >= ctrl.max_iterations;
527 // A fit that did not converge leaves no memory the next fit trusts.
528 if (failedOptim) {
529 session.reset();
530 retained_s.clear();
531 retained_y.clear();
532 }
533 if (failedOptim && settings.common.report_level >= 1) {
534 std::fprintf(stderr,
535 "rgmin MAP optimizer did not converge: value=%.17g "
536 "gradient_norm=%.17g box_projected_norm=%.17g "
537 "tolerance=%.17g steps=%zu\n",
538 report.value, report.grad_norm, projected_norm, ctrl.gtol,
539 report.steps);
540 }
541}
542
543} // namespace funcmin
544
545#endif // GPR_ML_RGMIN_OPT_INL_
@ x
Definition Enums.h:28
@ y
Definition Enums.h:28
bool exhaustedIterationBudget
Definition RgminOpt.h:41
int completedIterations
Definition RgminOpt.h:42
std::size_t lbfgsPairCap() const noexcept
Definition RgminOpt.h:116
void optimizeWithObjectiveValues(const gpr::EigenMatrix &x, const Eigen::VectorXd &x_ind, const Eigen::VectorXd &y, Eigen::VectorXd &w, FuncName func_to_min, ClassName &holder, double barrier_strength, const Eigen::VectorXd &lengthscale_rho0, const MapObjectiveConfig *objective_config, double *opening_value_out, double *last_value_out)
Definition RgminOpt.inl:31
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)
Definition RgminOpt.inl:19
void restoreMapAmplitudeFeasibility(Eigen::VectorXd &w, const MapObjectiveConfig &cfg)
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)
void applyMapPenalty(const Eigen::VectorXd &w, const MapObjectiveConfig &cfg, double &energy, Eigen::VectorXd *gradient)
std::unique_ptr< DLManagedTensorVersioned, RgminTensorDeleter > RgminTensorHandle
rgmin_status_t rgminEval(void *user, const DLManagedTensorVersioned *x, double *value_out) noexcept
rgmin_status_t rgminGrad(void *user, const DLManagedTensorVersioned *x, DLManagedTensorVersioned *grad_out) noexcept
void projectMapGradient(const MapObjectiveConfig &cfg, Eigen::VectorXd &gradient)
void requireCompatibleLibrary()
Definition RgminAbi.h:90
Eigen::Matrix< double, EigenDynamic, EigenDynamic, EigenMatrixStorage > EigenMatrix
Definition Macros.h:20
Eigen::VectorXd parameter_lower
Eigen::VectorXd parameter_upper
std::vector< bool > active_parameters