pub fn mpc_control(
a: f64,
b: f64,
state: f64,
setpoint: f64,
horizon: u32,
u_min: f64,
u_max: f64,
steps: u32,
control_penalty: f64,
) -> f64Expand description
One-step Model Predictive Control for a scalar LTI plant x_{k+1} = a·x_k + b·u: search
candidate controls across [u_min, u_max] (a grid of steps+1 points), simulate horizon
steps holding u, and return the u minimising Σ (setpoint − x_k)² + control_penalty·u².
The optimal FIRST move of the receding horizon. Zero-heap (bounded loops, no allocation).