|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Classes | |
| class | DDPSolution |
Functions | |
| DDPSolution | solve_ddp (np.ndarray x0, np.ndarray u_seq_init, np.ndarray F_ref, np.ndarray MR_ref, ControllerConfig cfg, DynamicsParams dynamics_params, EngineWrapper engine_wrapper, Optional[np.ndarray] w_bar=None, float alpha_init=2.0, float alpha_min=1e-5, float reg_init=1e-4, float reg_factor=5.0, bool use_robustification=True, float gamma_robust=1.0) |
| Tuple[np.ndarray, List[EngineEstimate], float, List[Dict[str, float]]] | forward_rollout (np.ndarray x0, np.ndarray u_seq, np.ndarray F_ref, np.ndarray MR_ref, ControllerConfig cfg, DynamicsParams params, EngineWrapper engine_wrapper, float dt) |
| float | running_cost (np.ndarray x, np.ndarray u, EngineEstimate eng_est, float F_ref, float MR_ref, ControllerConfig cfg, Dict[str, float] constraints, float dt) |
| Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray] | backward_pass (np.ndarray x_seq, np.ndarray u_seq, List[EngineEstimate] eng_estimates, np.ndarray F_ref, np.ndarray MR_ref, ControllerConfig cfg, DynamicsParams params, EngineWrapper engine_wrapper, float dt, float reg, np.ndarray w_bar, bool use_robustification, float gamma_robust) |
| Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray] | cost_derivatives (np.ndarray x, np.ndarray u, EngineEstimate eng_est, float F_ref, float MR_ref, ControllerConfig cfg, float dt, Optional[EngineWrapper] engine_wrapper=None) |
| Tuple[np.ndarray, float, float] | forward_line_search (np.ndarray x0, np.ndarray u_seq, np.ndarray k_seq, np.ndarray K_seq, np.ndarray x_seq_nom, np.ndarray F_ref, np.ndarray MR_ref, ControllerConfig cfg, DynamicsParams params, EngineWrapper engine_wrapper, float dt, float alpha_init, float alpha_min) |
Differential Dynamic Programming (DDP) solver for robust DDP controller. Implements iLQR-style finite-horizon DDP with: - Forward rollout - Backward pass (gradient computation) - Forward line search - Constraint handling (soft penalties + hard violations) - Robustification (uncertainty inflation)
| Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray] engine.control.robust_ddp.ddp_solver.backward_pass | ( | np.ndarray | x_seq, |
| np.ndarray | u_seq, | ||
| List[EngineEstimate] | eng_estimates, | ||
| np.ndarray | F_ref, | ||
| np.ndarray | MR_ref, | ||
| ControllerConfig | cfg, | ||
| DynamicsParams | params, | ||
| EngineWrapper | engine_wrapper, | ||
| float | dt, | ||
| float | reg, | ||
| np.ndarray | w_bar, | ||
| bool | use_robustification, | ||
| float | gamma_robust ) |
Backward pass: compute feedforward k and feedback K gains.
Returns:
--------
k_seq : np.ndarray, shape (N, N_CONTROL)
Feedforward gains
K_seq : np.ndarray, shape (N, N_CONTROL, N_STATE)
Feedback gains
Vx : np.ndarray, shape (N_STATE,)
Value function gradient at initial state
Vxx : np.ndarray, shape (N_STATE, N_STATE)
Value function Hessian at initial state
Definition at line 360 of file ddp_solver.py.
References cost_derivatives(), and max.
Referenced by solve_ddp().
| Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray] engine.control.robust_ddp.ddp_solver.cost_derivatives | ( | np.ndarray | x, |
| np.ndarray | u, | ||
| EngineEstimate | eng_est, | ||
| float | F_ref, | ||
| float | MR_ref, | ||
| ControllerConfig | cfg, | ||
| float | dt, | ||
| Optional[EngineWrapper] | engine_wrapper = None ) |
Compute cost derivatives via finite differences.
Parameters:
-----------
engine_wrapper : EngineWrapper, optional
Engine wrapper for re-estimating engine performance when state changes.
If None, uses approximation (assumes eng_est doesn't change).
Returns:
--------
lx : np.ndarray, shape (N_STATE,)
Cost gradient w.r.t. state
lu : np.ndarray, shape (N_CONTROL,)
Cost gradient w.r.t. control
lxx : np.ndarray, shape (N_STATE, N_STATE)
Cost Hessian w.r.t. state
luu : np.ndarray, shape (N_CONTROL, N_CONTROL)
Cost Hessian w.r.t. control
lux : np.ndarray, shape (N_CONTROL, N_STATE)
Cost cross-derivative
Definition at line 510 of file ddp_solver.py.
References running_cost().
Referenced by backward_pass().
| Tuple[np.ndarray, float, float] engine.control.robust_ddp.ddp_solver.forward_line_search | ( | np.ndarray | x0, |
| np.ndarray | u_seq, | ||
| np.ndarray | k_seq, | ||
| np.ndarray | K_seq, | ||
| np.ndarray | x_seq_nom, | ||
| np.ndarray | F_ref, | ||
| np.ndarray | MR_ref, | ||
| ControllerConfig | cfg, | ||
| DynamicsParams | params, | ||
| EngineWrapper | engine_wrapper, | ||
| float | dt, | ||
| float | alpha_init, | ||
| float | alpha_min ) |
Forward line search: find best step size alpha.
Returns:
--------
u_seq_new : np.ndarray
New control sequence
alpha : float
Step size used
cost_new : float
Cost of new trajectory
Definition at line 638 of file ddp_solver.py.
References forward_rollout(), and min.
Referenced by solve_ddp().
| Tuple[np.ndarray, List[EngineEstimate], float, List[Dict[str, float]]] engine.control.robust_ddp.ddp_solver.forward_rollout | ( | np.ndarray | x0, |
| np.ndarray | u_seq, | ||
| np.ndarray | F_ref, | ||
| np.ndarray | MR_ref, | ||
| ControllerConfig | cfg, | ||
| DynamicsParams | params, | ||
| EngineWrapper | engine_wrapper, | ||
| float | dt ) |
Forward rollout: compute trajectory with current control sequence.
Returns:
--------
x_seq : np.ndarray, shape (N+1, N_STATE)
State trajectory
eng_estimates : List[EngineEstimate]
Engine estimates per step
objective : float
Total cost
constraint_violations : List[Dict[str, float]]
Constraint violations per step
Definition at line 206 of file ddp_solver.py.
References running_cost().
Referenced by forward_line_search(), and solve_ddp().
| float engine.control.robust_ddp.ddp_solver.running_cost | ( | np.ndarray | x, |
| np.ndarray | u, | ||
| EngineEstimate | eng_est, | ||
| float | F_ref, | ||
| float | MR_ref, | ||
| ControllerConfig | cfg, | ||
| Dict[str, float] | constraints, | ||
| float | dt ) |
Compute running cost at one time step.
Cost = qF*(F - F_ref)^2 + qMR*(MR - MR_ref)^2 + qGas*(P_copv_drop) + qSwitch*||u - u_prev||^2
+ constraint_penalties + invalid_estimate_penalties
Definition at line 270 of file ddp_solver.py.
References max.
Referenced by cost_derivatives(), and forward_rollout().
| DDPSolution engine.control.robust_ddp.ddp_solver.solve_ddp | ( | np.ndarray | x0, |
| np.ndarray | u_seq_init, | ||
| np.ndarray | F_ref, | ||
| np.ndarray | MR_ref, | ||
| ControllerConfig | cfg, | ||
| DynamicsParams | dynamics_params, | ||
| EngineWrapper | engine_wrapper, | ||
| Optional[np.ndarray] | w_bar = None, | ||
| float | alpha_init = 2.0, | ||
| float | alpha_min = 1e-5, | ||
| float | reg_init = 1e-4, | ||
| float | reg_factor = 5.0, | ||
| bool | use_robustification = True, | ||
| float | gamma_robust = 1.0 ) |
Solve finite-horizon DDP (iLQR-style) for robust control.
Parameters:
-----------
x0 : np.ndarray, shape (N_STATE,)
Initial state
u_seq_init : np.ndarray, shape (N, N_CONTROL)
Initial control sequence
F_ref : np.ndarray, shape (N,)
Reference thrust sequence [N]
MR_ref : np.ndarray, shape (N,)
Reference mixture ratio sequence
cfg : ControllerConfig
Controller configuration
dynamics_params : DynamicsParams
Dynamics parameters
engine_wrapper : EngineWrapper
Engine wrapper for mass flow estimation
w_bar : np.ndarray, optional, shape (N_STATE,)
Residual bounds for robustification (if None, uses zeros)
alpha_init : float
Initial line search step size
alpha_min : float
Minimum line search step size
reg_init : float
Initial Levenberg-Marquardt regularization
reg_factor : float
Regularization increase/decrease factor
use_robustification : bool
Whether to add robustification term to value function
gamma_robust : float
Robustification weight (for diag(gamma*w_bar^2) term)
Returns:
--------
solution : DDPSolution
DDP solution with optimal control sequence and trajectory
Definition at line 40 of file ddp_solver.py.
References backward_pass(), forward_line_search(), forward_rollout(), and max.