Build a bookkeeping structure that maps a flat optimization vector
(theta, in real/unconstrained space) to per-component parameter blocks.
This is used throughout the package to:
Define a consistent parameter order for optimization.
Provide an initial parameter vector (theta0) in real space.
Record which subset of theta belongs to each component model.
prepare_optim_layout(model)A list with:
kind: "single" or "sum" depending on the model class.
theta0: named numeric vector of initial parameters in real space.
pnames: (single model) parameter names for the block.
layout: (sum model) list of per-component layouts, each containing:
i (component index), idx (indices into theta0), and pnames
(parameter names for that component).
A time_series_model or sum_model.
The function handles two cases:
time_series_model: returns a single block of parameters.
sum_model: concatenates all component blocks and records their indices.