% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tune_Lambda.R
\name{.build_tuning_env}
\alias{.build_tuning_env}
\title{Build Tuning Environment}
\usage{
.build_tuning_env(
  y,
  X,
  X_gram,
  Xy,
  smoothing_spline_penalty,
  A,
  R_constraints,
  K,
  p_expansions,
  N_obs,
  custom_penalty_mat,
  colnm_expansions,
  unique_penalty_per_predictor,
  unique_penalty_per_partition,
  meta_penalty,
  family,
  delta,
  order_list,
  observation_weights,
  homogenous_weights,
  parallel,
  parallel_eigen,
  parallel_trace,
  parallel_aga,
  parallel_matmult,
  parallel_unconstrained,
  cl,
  chunk_size,
  num_chunks,
  rem_chunks,
  unconstrained_fit_fxn,
  keep_weighted_Lambda,
  iterate,
  qp_score_function,
  quadprog,
  qp_Amat,
  qp_bvec,
  qp_meq,
  tol,
  sd_y,
  tuning_criterion,
  gcv_gamma,
  constraint_value_vectors,
  glm_weight_function,
  schur_correction_function,
  need_dispersion_for_estimation,
  dispersion_function,
  blockfit,
  just_linear_without_interactions,
  Vhalf,
  VhalfInv,
  verbose,
  include_warnings,
  flat_cols,
  use_blockfit
)
}
\arguments{
\item{gcv_gamma}{Numeric scalar, at least 1; modified-GCV multiplier for the
effective-degrees-of-freedom term.}

\item{flat_cols}{Integer vector; pre-computed flat column indices (passed
in from \code{tune_Lambda} to avoid recomputation).}

\item{use_blockfit}{Logical; pre-computed dispatch flag (passed in from
\code{tune_Lambda}).}
}
\value{
Named list (the "tuning environment").
}
\description{
Assembles a named list containing all pre-computed objects and configuration
needed by the tuning-objective evaluation and gradient functions during
penalty tuning.
This avoids deep nesting of closures and makes the dependencies explicit.
}
\details{
In addition to the standard tuning arguments, the environment stores two
pre-computed blockfit dispatch items:
\describe{
  \item{use_blockfit}{Logical; TRUE when \code{blockfit} is enabled,
    \code{flat_cols} is non-empty, and \code{K > 0}. Mirrors the dispatch
    logic in \code{lgspline.fit} so that the same fitting path is used
    during tuning as during the final fit.}
  \item{flat_cols}{Integer vector; column indices of non-interactive linear
    terms derived from \code{just_linear_without_interactions} and
    \code{colnm_expansions}. Pre-computed once here rather than re-derived
    at every tuning-objective evaluation.}
}
}
\keyword{internal}
