Model Predictive Control: Receding Horizon Algorithm, Two-Zone Thermal Regulation, and Disturbance Rejection

Fundamentals of the Model Predictive Control (MPC) Algorithm

  • Receding Horizon Control Overview:

    • Model Predictive Control (MPC) solves a constrained, finite-horizon optimal control problem at every discrete sampling instant kk.

    • Rather than applying an entire pre-calculated trajectory open-loop, MPC implements only the first calculated control action and shifts the prediction window forward at the subsequent time step, establishing closed-loop feedback.

  • Step-by-Step Algorithmic Procedure:

    • Step 1: State Measurement or Estimation:

      • Measure or estimate the current plant state vector xkx_k, denoted as x^k\hat{x}_k.

      • At the initial step of the horizon (k=0k = 0), the measurement corresponds to the system's initial state x0x_0.

      • In receding-horizon operations, the optimization is re-initialized at each sampling instant with the newly measured or estimated state as the starting point.

    • Step 2: Solve Finite-Horizon Optimal Control:

      • Formulate and solve a constrained finite-horizon optimal control problem spanning a prediction horizon of length NN.

      • The optimization generates an open-loop sequence of optimal control inputs based on the nominal plant dynamics model.

    • Step 3: Obtain Optimal Control Sequence:

      • Extract the computed optimal control input sequence:             Uk∗=[uk∣k∗uk+1∣k∗…uk+N−1∣k∗]TU_k^* = \begin{bmatrix} u_{k|k}^* & u_{k+1|k}^* & \dots & u_{k+N-1|k}^* \end{bmatrix}^T

      • Each element uk+j∣k∗u_{k+j|k}^* represents the predicted optimal control action for time step k+jk+j, determined at sampling instant kk.

    • Step 4: Apply the First Control Action:

      • Apply only the initial control input from the optimal sequence to the physical plant:             uk=uk∣k∗u_k = u_{k|k}^*

      • The remaining planned inputs (uk+1∣k∗,…,uk+N−1∣k∗u_{k+1|k}^*, \dots, u_{k+N-1|k}^*) are discarded for execution.

    • Step 5: Advance Time Horizon and Repeat:

      • Advance the system time step from kk to k+1k+1.

      • Collect the new state measurement or estimate x^k+1\hat{x}_{k+1}, shift the prediction horizon forward by one sampling period, and re-solve the optimization problem.

  • Theoretical Rationale for Full-Horizon Calculation:

    • Computing control inputs across the entire horizon NN ensures that the control action selected at step kk maintains stability, feasibility, and performance along the complete anticipated future trajectory.

    • Solving for the complete sequence prevents the system from driving towards short-term gains that lead to boundary violations or dynamic instability at later stages.

    • In practical control implementations where communication bottlenecks or sensor dropouts occur, the unapplied elements (uk+1∣k∗,…,uk+N−1∣k∗u_{k+1|k}^*, \dots, u_{k+N-1|k}^*) serve as an open-loop fallback trajectory to maintain operation until state feedback is restored.

Mathematical Modeling of Two-Zone Thermal Systems

  • System Description:

    • The controlled plant consists of two thermally connected rooms (zones).

    • Each room is equipped with an independent thermal actuator capable of providing heating or cooling.

  • State and Control Input Vectors:

    • The system state vector xk∈R2x_k \in \mathbb{R}^2 represents the zone temperatures at discrete-time instant kk:         xk=(T1,kT2,k)x_k = \begin{pmatrix} T_{1, k} \\ T_{2, k} \end{pmatrix}         where T1,kT_{1, k} is the temperature of Room 1 and T2,kT_{2, k} is the temperature of Room 2 in degrees Celsius (∘C^\circ\text{C}).

    • The control input vector uk∈R2u_k \in \mathbb{R}^2 represents the thermal input delivered to each room:         uk=(u1,ku2,k)u_k = \begin{pmatrix} u_{1, k} \\ u_{2, k} \end{pmatrix}         where u1,ku_{1, k} governs Room 1 and u2,ku_{2, k} governs Room 2.

  • Discrete-Time Linear Thermal Dynamics:

    • The system dynamics follow a discrete-time linear state-space representation:         xk+1=Axk+Buk+dx_{k+1} = A x_k + B u_k + d

    • The state transition matrix A∈R2×2A \in \mathbb{R}^{2 \times 2} describes thermal retention and inter-zone heat transfer:         A=(0.850.100.100.85)A = \begin{pmatrix} 0.85 & 0.10 \\ 0.10 & 0.85 \end{pmatrix}

      • Diagonal elements (0.850.85) govern the internal thermal retention within each zone per discrete time step.

      • Off-diagonal elements (0.100.10) represent the thermal coupling coefficient between Room 1 and Room 2 via their shared boundary wall.

    • The control input matrix B∈R2×2B \in \mathbb{R}^{2 \times 2} describes actuator authority and cross-zone leakage:         B=(0.400.050.050.40)B = \begin{pmatrix} 0.40 & 0.05 \\ 0.05 & 0.40 \end{pmatrix}

      • Diagonal elements (0.400.40) represent direct heat input to the respective room.

      • Off-diagonal elements (0.050.05) characterize the fraction of heating or cooling that leaks into the adjacent room.

  • Ambient Environment Interaction and Thermal Disturbance Term (dd):

    • The ambient outside temperature is constant at Ta=30 ∘CT_a = 30\,^\circ\text{C}.

    • The term d∈R2d \in \mathbb{R}^2 captures static heat exchange between each room and the external ambient environment:         d=(0.05Ta0.05Ta)=(0.05×300.05×30)=(1.51.5)d = \begin{pmatrix} 0.05 T_a \\ 0.05 T_a \end{pmatrix} = \begin{pmatrix} 0.05 \times 30 \\ 0.05 \times 30 \end{pmatrix} = \begin{pmatrix} 1.5 \\ 1.5 \end{pmatrix}

    • Because the ambient temperature (30 ∘C30\,^\circ\text{C}) exceeds the zone temperatures, external heat conduction constantly introduces a positive baseline heat load of 1.5 ∘C1.5\,^\circ\text{C} per sampling interval into both rooms.

MPC Optimization Problem Formulation

  • Control Objectives and Setpoints:

    • Initial zone temperatures at time step k=0k = 0 are given by:         x0=(2827) ∘Cx_0 = \begin{pmatrix} 28 \\ 27 \end{pmatrix}\,^\circ\text{C}

    • The desired setpoint target (reference vector r∈R2r \in \mathbb{R}^2) is:         r=(2224) ∘Cr = \begin{pmatrix} 22 \\ 24 \end{pmatrix}\,^\circ\text{C}         requiring Room 1 to be regulated to 22 ∘C22\,^\circ\text{C} and Room 2 to 24 ∘C24\,^\circ\text{C}.

  • Prediction Horizon and Cost Weighting Matrices:

    • Prediction horizon length: N=20N = 20.

    • State tracking error weight matrix Q∈R2×2Q \in \mathbb{R}^{2 \times 2}:         Q=I2=(1001)Q = I_2 = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}

    • Control effort weight matrix R∈R2×2R \in \mathbb{R}^{2 \times 2}:         R=0.1I2=(0.1000.1)R = 0.1 I_2 = \begin{pmatrix} 0.1 & 0 \\ 0 & 0.1 \end{pmatrix}

    • Terminal state tracking error weight matrix P∈R2×2P \in \mathbb{R}^{2 \times 2}:         P=5I2=(5005)P = 5 I_2 = \begin{pmatrix} 5 & 0 \\ 0 & 5 \end{pmatrix}

  • Constrained Finite-Horizon Optimization Formulation:

    • At each sampling instant kk, the MPC controller solves:         min⁡UkJk(Uk)\min_{U_k} J_k(U_k)

    • The cost function JkJ_k consists of stage costs over NN steps and a terminal penalty:         Jk=∑j=0N−1[(xk+j∣k−r)TQ(xk+j∣k−r)+uk+j∣kTRuk+j∣k]+(xk+N∣k−r)TP(xk+N∣k−r)J_k = \sum_{j=0}^{N-1} \left[ (x_{k+j|k} - r)^T Q (x_{k+j|k} - r) + u_{k+j|k}^T R u_{k+j|k} \right] + (x_{k+N|k} - r)^T P (x_{k+N|k} - r)

    • Subject to system dynamic constraints over the prediction horizon:         xk+j+1∣k=Axk+j∣k+Buk+j∣k+d,j=0,1,…,N−1x_{k+j+1|k} = A x_{k+j|k} + B u_{k+j|k} + d, \quad j = 0, 1, \dots, N-1

    • Subject to the state initialization constraint:         xk∣k=x^kx_{k|k} = \hat{x}_k

    • Subject to symmetrical actuator saturation limits:         −20≤u1,k+j∣k≤20,j=0,1,…,N−1-20 \le u_{1, k+j|k} \le 20, \quad j = 0, 1, \dots, N-1         −20≤u2,k+j∣k≤20,j=0,1,…,N−1-20 \le u_{2, k+j|k} \le 20, \quad j = 0, 1, \dots, N-1

  • Structure of the Optimization Decision Vector:

    • The decision vector UkU_k concatenates all future control inputs over the horizon:         Uk=(uk∣kuk+1∣k⋮uk+N−1∣k)U_k = \begin{pmatrix} u_{k|k} \\ u_{k+1|k} \\ \vdots \\ u_{k+N-1|k} \end{pmatrix}

    • Because the system has 22 inputs and a horizon length of N=20N = 20, the total number of decision variables is:         2×N=2×20=402 \times N = 2 \times 20 = 40         yielding Uk∈R40U_k \in \mathbb{R}^{40}.

Plant-Model Mismatch and External Disturbances

  • Unmodeled Disturbance Injection:

    • To evaluate controller robustness against plant-model mismatch, an unmodeled external thermal disturbance affects Room 1 beginning at discrete time step k=8k = 8.

    • Physical scenario: While both rooms are being actively cooled by air conditioning, a large door or window is opened in Room 1 at time step k=8k = 8, causing hot outside air to rush into Room 1.

  • Mathematical Disturbance Profile (wkw_k):

    • The time-dependent additive disturbance vector wk∈R2w_k \in \mathbb{R}^2 is defined as:         wk={(00),k≤7(1.50),k≥8w_k = \begin{cases} \begin{pmatrix} 0 \\ 0 \end{pmatrix}, & k \le 7 \\ \begin{pmatrix} 1.5 \\ 0 \end{pmatrix}, & k \ge 8 \end{cases}

    • The disturbance acts directly on Room 1 (1.5 ∘C1.5\,^\circ\text{C} additive heat influx per step) with zero direct input into Room 2.

  • Actual Plant Dynamics vs. Nominal Controller Model:

    • The true physical plant evolves according to:         xk+1=Axk+Buk+d+wkx_{k+1} = A x_k + B u_k + d + w_k

    • The nominal internal prediction model utilized by both the Open-Loop Optimal Controller and the MPC internal predictor excludes the disturbance:         xk+1=Axk+Buk+dx_{k+1} = A x_k + B u_k + d

    • Because wkw_k is unmodeled, neither controller possesses predictive knowledge of the disturbance onset or magnitude.

Algorithmic Implementation in MATLAB

  • Nonlinear Optimization Engine:

    • The optimization problem is solved computationally using the MATLAB nonlinear programming solver fmincon.

    • Decision variable structure in fmincon:

      • The vector UU is organized as a flattened column vector of dimension 40×140 \times 1.

      • Indices 11 through 2020 correspond to Room 1 control inputs (u1,k∣k,…,u1,k+N−1∣ku_{1, k|k}, \dots, u_{1, k+N-1|k}).

      • Indices 2121 through 4040 correspond to Room 2 control inputs (u2,k∣k,…,u2,k+N−1∣ku_{2, k|k}, \dots, u_{2, k+N-1|k}).

      • Inside the objective evaluation function, UU is reshaped into a 20×220 \times 2 matrix to evaluate the system dynamics.

    • Actuator limits are supplied directly to fmincon via lower bound vector lb (−20-20 for all 4040 entries) and upper bound vector ub (+20+20 for all 4040 entries).

  • Single-Shooting Formulation:

    • The state dynamics are evaluated inside a trajectory cost function (trajectory_cost), which sequentially calls a system simulation routine (simulate_states).

    • Because state trajectories are propagated forward from the initial state using the nominal state-space equations, state dynamic constraints are inherently satisfied without requiring explicit nonlinear equality constraints (nonlincon).

  • Comparison of Open-Loop Optimal Control vs. Closed-Loop MPC Architectures:

    • Open-Loop Optimal Control Execution:

      • fmincon is invoked once at k=0k = 0 using initial state x0=[2827]T ∘Cx_0 = \begin{bmatrix} 28 & 27 \end{bmatrix}^T\,^\circ\text{C}.

      • The entire resulting optimal input matrix UOL∗∈R2×20U_{\text{OL}}^* \in \mathbb{R}^{2 \times 20} is applied open-loop to the actual plant model containing wkw_k.

      • No feedback measurements are gathered; the trajectory cannot adjust when wkw_k activates at k=8k = 8.

    • Closed-Loop MPC Execution:

      • At each step k∈{0,1,…,19}k \in \{0, 1, \dots, 19\}, the controller acquires the current plant state measurement from the true system:             x^k=xactual,k\hat{x}_k = x_{\text{actual}, k}

      • fmincon solves the finite-horizon problem over horizon N=20N = 20 initialized at x^k\hat{x}_k, using the nominal model (wk=0w_k = 0).

      • The controller extracts the first inputs for Room 1 and Room 2 (u1,k∣k∗u_{1, k|k}^* and u2,k∣k∗u_{2, k|k}^*) and stores them in uMPC.

      • These inputs are injected into the real system (which includes wkw_k), updating the true state to xactual,k+1x_{\text{actual}, k+1}.

      • The process repeats across the operational duration.

Comparative Performance Analysis and Thermal Coupling Dynamics

  • Final Regulation Metrics:

    • Reference target temperatures: Room 1 r1=22 ∘Cr_1 = 22\,^\circ\text{C}, Room 2 r2=24 ∘Cr_2 = 24\,^\circ\text{C}.

    • Open-Loop Optimal Control Results:

      • Final Room 1 temperature: 32 ∘C32\,^\circ\text{C} (deviating by +10 ∘C+10\,^\circ\text{C} above reference, peaking near 32.3 ∘C32.3\,^\circ\text{C}).

      • Final Room 2 temperature: 28 ∘C28\,^\circ\text{C} (deviating by +4 ∘C+4\,^\circ\text{C} above reference).

    • Closed-Loop MPC Results:

      • Final Room 1 temperature: 24 ∘C24\,^\circ\text{C} (deviating by only +2 ∘C+2\,^\circ\text{C} from reference).

      • Final Room 2 temperature: 23 ∘C23\,^\circ\text{C} (tracking within 1 ∘C1\,^\circ\text{C} of reference, stabilizing near setpoint).

  • Disturbance Compensation Behavior:

    • Between k=0k = 0 and k=7k = 7, both control methods drive zone temperatures downward from 28 ∘C28\,^\circ\text{C} and 27 ∘C27\,^\circ\text{C} toward the setpoints.

    • At k=8k = 8, the onset of the disturbance wkw_k injects unmodeled thermal energy into Room 1.

    • The open-loop optimal controller, unable to detect the resulting trajectory divergence, continues executing its precomputed input trajectory, allowing temperatures in Room 1 to climb to 32 ∘C32\,^\circ\text{C}.

    • MPC detects the state divergence at k=8k = 8 through state feedback and immediately recalculates the optimal trajectory, adjusting the control effort in Room 1 to counteract the unexpected heat load.

  • Analysis of Room 2 Thermal Coupling:

    • Room 2 receives no direct disturbance (w2,k=0w_{2, k} = 0 for all kk).

    • The control input trajectories u2,ku_{2, k} for Room 2 in both Open-Loop Optimal Control and MPC are virtually identical throughout the entire time horizon.

    • Despite identical actuator effort in Room 2, open-loop control causes Room 2 to overheat (28 ∘C28\,^\circ\text{C}), whereas MPC achieves regulation near 23–24 ∘C23\text{--}24\,^\circ\text{C}.

    • Root Cause via Thermal Cross-Coupling (A12,A21=0.10A_{12}, A_{21} = 0.10):

      • Under open-loop control, Room 1 overheats to 32 ∘C32\,^\circ\text{C}. Heat conducts through the inter-zone boundary into Room 2, overpowering Room 2's actuator.

      • Under MPC, Room 1 is regulated near 24 ∘C24\,^\circ\text{C}. The inter-zone temperature gradient is eliminated, preventing thermal leakage from destabilizing Room 2.

Course Administration and Final Project Guidelines

  • Final Project Approval Process:

    • Each student must select an academic paper to implement for the course final project and obtain instructor approval.

    • Selection and approval must be finalized as early as possible rather than delaying until the final deadline.

    • A short project proposal must be drafted and submitted in accordance with the final project instruction document.

  • Final Project Presentation Timeline:

    • Final project presentations are scheduled for two weeks from the lecture date, on Tuesday, November 17, 2026.

  • Curriculum Progression:

    • Lecture 20 concludes the Model Predictive Control instructional block.

    • The subsequent lecture begins neural network fundamentals, focusing on neural network modeling and learning-based control systems.

    • A practice homework assignment covering both Optimal Control and MPC will be released over the upcoming weekend.

Questions and Discussion

  • Query Regarding Full-Horizon Input Computation:

    • Question: Why compute a complete sequence of future control inputs (uk∣k∗,…,uk+N−1∣k∗u_{k|k}^*, \dots, u_{k+N-1|k}^*) across the entire prediction horizon if only the first control input (uk∣k∗u_{k|k}^*) is ever applied to the physical system?

    • Answer: Computing inputs across the entire horizon ensures that the selected immediate control action accounts for future dynamics, terminal costs, and system constraints, preventing the system from running off course. Additionally, if sensor measurements, state estimations, or communication signals are temporarily lost, the remaining open-loop sequence provides a valid fallback control plan.

  • Query Regarding Project Paper Selection Deadlines:

    • Question: Was a strict Friday deadline set for selecting and submitting the final project research article?

    • Answer: There is no rigid Friday deadline; however, approval must be obtained as soon as possible because presentations occur on Tuesday, November 17, 2026, and project implementation cannot begin without prior approval of the short proposal.

  • Query Regarding Terminology:

    • Question: What does the abbreviation "OC" stand for?

    • Answer: "OC" stands for Optimal Control.

  • Query Regarding Zero vs. Non-Zero Initial States and Steady-State Targets:

    • Question: Does MPC require an initial state of zero, and how does MPC handle non-zero or varying steady-state reference targets?

    • Answer: MPC does not require a zero initial state; the state measurement x^k\\\hat{x}_k is updated with the actual system state at each time step. Furthermore, target steady states are entirely application-specific and need not be zero (e.g., 22 ∘C22\,^\circ\text{C} and 24 ∘C24\,^\circ\text{C} in the thermal model). In dynamic environments like autonomous vehicle control, reference setpoints and required control inputs vary continuously (e.g., steering angle and lane-centering error adjust when entering a curved road, whereas control efforts remain steady along straight paths).