leap_c.parameters.utils¶
Parameter type alias and numpy helpers for stage-varying MPC parameters.
Attributes¶
How a differentiable parameter varies across the MPC horizon. |
Functions¶
|
Broadcast a per-stage default parameter to the batch shape implied by |
|
Return the number of independent segments a |
Module Contents¶
- leap_c.parameters.utils.broadcast_default_param(default: numpy.ndarray | dict[str, numpy.ndarray], obs: numpy.ndarray | torch.Tensor | None = None) numpy.ndarray | dict[str, numpy.ndarray][source]¶
Broadcast a per-stage default parameter to the batch shape implied by
obs.For a batched
obsof shape(B, obs_dim), the default is broadcast to(B, *param_shape). Withoutobs(or a 1-Dobs) the unbatched default is returned. Handles bothnp.ndarrayanddict[str, np.ndarray]defaults.
- leap_c.parameters.utils.n_segments(splits: ParamSplits, N_horizon: int) int[source]¶
Return the number of independent segments a
splitsspecification produces.- Parameters:
splits – The split specification (see
ParamSplits).N_horizon – The MPC horizon length (number of shooting intervals).
- Returns:
1for"global",N_horizon + 1for"stagewise",splitsfor anint, andlen(splits)for a list.- Return type:
The number of segments
- leap_c.parameters.utils.ParamSplits¶
How a differentiable parameter varies across the MPC horizon.
"global": one value shared across all stages."stagewise": one independent value per stage (N+1values total).int: number of equal-sized stage segments.list[int]: explicit stage boundaries (ascending), e.g.[4, 9].