class funcmin::RgminOpt

Overview

Gradient-only rgmin session on the MAP objective. More…

#include <gpr/ml/RgminOpt.h>
 
class RgminOpt {
public:
    // fields
 
    bool failedOptim = false;
    bool exhaustedIterationBudget = false;
    int completedIterations = 0;
 
    // methods
 
    void setAlgorithmSettings(const gpr::ScgOptimizationSettings& s);
    void setMethod(rgmin::Method m);
    void setMethod(rgmin_method_t m);
    rgmin::Method getMethod() const;
    void setMemory(std::size_t m);
    std::size_t lbfgsPairCap() const;
    std::size_t appliedLbfgsMemoryForTesting() const;
    void setMaxMove(double m);
    void setGradTol(double g);
    void setBox(Eigen::VectorXd lower, Eigen::VectorXd upper);
    void setPersistentSession(bool keep);
    void setInitialLogMove(double distance);
    void setInitialLogMoveWholeSession(bool whole_session);
    void forgetSession();
    std::size_t warmStarts() const;
    std::size_t warmPairs() const;
    std::size_t logicalObjectiveWork() const;
    std::size_t physicalObjectiveWork() const;
 
    template <typename ClassName, typename FuncName>
    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 current_barrier_strength, const Eigen::VectorXd& lengthscale_rho0 = Eigen::VectorXd(), const MapObjectiveConfig* objective_config = nullptr);
 
    template <typename ClassName, typename FuncName>
    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);
 
    static bool methodFromName(const char* name, rgmin_method_t& out);
};

Detailed Documentation

Gradient-only rgmin session on the MAP objective. The solver axis is rgmin::optimize::Method. MAP_LBFGS selects L-BFGS. The C ABI is the hourglass; this class drives the RAII wrap. RgminScg stays separate: rgmin_minimize_scg takes SCG parameters and a curvature callback the generic entry does not carry.

Newton and RFO need an analytic Hessian of the marginal likelihood, which this objective does not supply.

Methods

void setMemory(std::size_t m)

L-BFGS pairs kept by the solver and by the warm-start record. Zero selects the cap rgmin publishes as the default of OptimizeControl::memory, which is also the cap the C ABI uses when a control’s memory is 0.

std::size_t appliedLbfgsMemoryForTesting() const

Pair cap installed on the session of the last fit. Zero before that fit.

void setBox(Eigen::VectorXd lower, Eigen::VectorXd upper)

Coordinate box on x + p. Empty is unbounded on that side.

void setPersistentSession(bool keep)

Transplant the previous fit’s record into the next fit (off by default: every fit then opens a fresh session at the previous optimum with the cold opening step). A sequence of marginal likelihood fits, one per acquisition, minimises objectives that differ by the rows added since the last: the accepted steps of the previous fit, as curvature pairs, still describe the curvature at its optimum. Every fit opens a fresh session (its opening step is scaled to the new gradient); a warm start transplants the pairs into it when the record describes this objective (see warmPairs), and a caller that has found measured rows contradicting the posterior drops the record first (forgetSession). A changed dimension, method, tolerance, step cap or active subspace starts cold, and so does the fit after one that did not converge.

void setInitialLogMove(double distance)

Largest distance the first step of a cold session may move the parameters. Hyperparameters live in log coordinates, so one unit is a factor e in a length scale or an amplitude, and the objective is only meaningful near the start. The opening step of the session is not the unit step along the negative gradient when the gradient is large: the first step is capped through the solver’s Euclidean move cap, which the line searches and trust radii honour, and the caller’s cap is restored after it. Zero leaves the first step to the solver.

void setInitialLogMoveWholeSession(bool whole_session)

How the bound is applied. True (default): the opening step of the session control is lowered so the first trial of a cold session moves at most the bound, set from the gradient norm at the cold start, and it stays lowered for the life of the session, so every line search of the session opens there. False: only the first step of a cold session is capped, through the solver’s move cap.

void forgetSession()

Drop the retained memory: the next fit starts cold.

std::size_t warmStarts() const

Fits that opened after a converged fit of a compatible session (the previous optimum as start; the record consulted when transplanting).

std::size_t warmPairs() const

Curvature pairs the last fit took from the previous fit’s record: zero when the record was dropped as another objective’s (the move it proposes for the new gradient exceeds the opening trust, or the decrease it claims exceeds one nat per parameter).

std::size_t logicalObjectiveWork() const

Objective-count units for the fit under a single-entry request cache.

std::size_t physicalObjectiveWork() const

Executed objective-count units, including final holder restoration.

static bool methodFromName(const char* name, rgmin_method_t& out)

Map a rgmin:<method> spelling onto the solver enum.

Newton and RFO are absent on purpose: both need an analytic Hessian of the marginal likelihood, which the MAP objective does not supply. Accepting their names here would build a session that cannot take a step.