11#ifndef STAN_MATH_MIX_FUNCTOR_LAPLACE_MARGINAL_DENSITY_ESTIMATOR_HPP
22#define STAN_MATH_MIX_FUNCTOR_LAPLACE_MARGINAL_DENSITY_ESTIMATOR_HPP
33#include < stan/math/prim/fun/Eigen.hpp>
4+ #include < stan/math/prim/fun/generate_laplace_options.hpp>
45#include < stan/math/mix/functor/laplace_likelihood.hpp>
56#include < stan/math/mix/functor/wolfe_line_search.hpp>
67#include < stan/math/rev/meta.hpp>
@@ -31,7 +32,7 @@ namespace math {
3132 */
3233struct laplace_options_base {
3334 /* Size of the blocks in block diagonal hessian*/
34- int hessian_block_size{1 }; // 0
35+ int hessian_block_size{internal::laplace_default_hessian_block_size }; // 0
3536 /* *
3637 * Which linear solver to use inside the Newton step.
3738 *
@@ -47,19 +48,20 @@ struct laplace_options_base {
4748 * `Sigma = K_root * K_root^T` and form `B = I + K_root^T * W * K_root`.
4849 * 3. General LU: form `B = I + Sigma * W` and factorize with LU.
4950 */
50- int solver{1 }; // 1
51+ int solver{internal::laplace_default_solver }; // 1
5152 /* *
5253 * Iterations end when the absolute change in the optimization objective
5354 * is less than this tolerance.
5455 *
5556 * Note: the objective used for convergence is the one optimized by the
5657 * Newton/Wolfe loop (not the final Laplace-corrected log marginal density).
5758 */
58- double tolerance{1.49012e-08 }; // 2
59+ double tolerance{internal::laplace_default_tolerance }; // 2
5960 /* Maximum number of steps*/
60- int max_num_steps{500 }; // 3
61- int allow_fallthrough{true }; // 4
62- laplace_line_search_options line_search; // 5
61+ int max_num_steps{internal::laplace_default_max_num_steps}; // 3
62+ int allow_fallthrough{internal::laplace_default_allow_fallthrough}; // 4
63+ laplace_line_search_options line_search{
64+ internal::laplace_default_max_steps_line_search}; // 5
6365 laplace_options_base () = default ;
6466 laplace_options_base (int hessian_block_size_, int solver_, double tolerance_,
6567 int max_num_steps_, bool allow_fallthrough_,
@@ -102,34 +104,6 @@ struct laplace_options<true> : public laplace_options_base {
102104using laplace_options_default = laplace_options<false >;
103105using laplace_options_user_supplied = laplace_options<true >;
104106
105- /* *
106- * User function for generating laplace options tuple
107- * @param theta_0_size Size of user supplied initial theta
108- * @return tuple representing laplace options exposed to user.
109- */
110- inline auto generate_laplace_options (int theta_0_size) {
111- auto ops = laplace_options_default{};
112- return std::make_tuple (Eigen::VectorXd::Zero (theta_0_size).eval (),
113- ops.tolerance , ops.max_num_steps , ops.solver ,
114- ops.line_search .max_iterations ,
115- static_cast <int >(ops.allow_fallthrough ));
116- }
117-
118- /* *
119- * User function for generating laplace options tuple
120- * @tparam ThetaVec An Eigen vector type for user supplied initial theta
121- * @param theta_0 User supplied initial theta
122- * @return tuple representing laplace options exposed to user.
123- */
124- template <typename ThetaVec, require_eigen_t <ThetaVec>* = nullptr >
125- inline auto generate_laplace_options (ThetaVec&& theta_0) {
126- auto ops = laplace_options_default{};
127- return std::make_tuple (std::forward<ThetaVec>(theta_0), ops.tolerance ,
128- ops.max_num_steps , ops.solver ,
129- ops.line_search .max_iterations ,
130- static_cast <int >(ops.allow_fallthrough ));
131- }
132-
133107namespace internal {
134108
135109template <typename Options>
0 commit comments