From first principles
Predict a finite trajectory before choosing the first command
Consider a scalar sampled plant \(x_{k+1}=ax_k+bu_k\), with a measured initial state and known coefficients. A predictive controller uses the model repeatedly to compare candidate future command sequences. For two steps, substitute the first state update into the second; each input affects a different interval and the first input also affects the second predicted state through propagation.
Even a one-step horizon shows how a quadratic objective selects a command. Let \(r\) be the desired next state, \(q>0\) a tracking penalty and \(\rho>0\) an effort penalty. Differentiate the objective after substituting its predicted state.
For this single scalar step, an interval limit on \(u_0\) clips the unconstrained minimiser to the nearest feasible endpoint. Over longer horizons the state and input constraints couple the commands. Only the first chosen command is applied before the state is measured again and the prediction repeated.
Derivation and applications
Predict the stopping distance of a sampled axis
A predictive controller can satisfy every instantaneous position bound and still enter a state from which the next position constraint must be violated. To see the role of velocity, consider a frictionless axis moving towards a positive position limit. The command is constant over sample interval \(h\) and bounded in acceleration by \(a>0\). Suppose the current speed \(v\) is positive, the axis must stop without reversing, and a final fractional braking command is allowed. Constant acceleration integrates exactly over each step.
Apply maximum braking for \(n=\lfloor v/(ah)\rfloor\) full samples. The remaining speed \(w=v-nah\) is in \([0,ah)\). During these \(n\) samples the speed decreases linearly, so the travelled distance is their duration times the average of initial and final speed.
If \(w>0\), select \(u=-w/h\) for the last interval. The last step travels \(hw/2\) and ends at rest exactly on a sampling instant. Combining the two contributions yields the minimum stopping distance with this no-reversal and held-command requirement.
Maximum early braking minimises future speeds and hence the travelled distance. The extra term compared with continuous switching is nonnegative and vanishes for an integer number of full braking intervals. A position-only terminal constraint can overlook this extra travel.
Worked example
Check if a carriage can stop before its limit
Let \(v=0.550\) m/s, \(a=2.00\) m/s² and \(h=0.100\) s. Two full braking steps leave \(w=0.150\) m/s. They consume \(0.200(0.550+0.150)/2=0.0700\) m. The final step needs \(u=-1.50\) m/s² and travels 7.50 mm, giving 77.5 mm total. A remaining clearance of 76.0 mm exceeds the continuous stopping distance of 75.6 mm but is insufficient for the sampled axis.
Change the inputs and inspect this calculation below
Second application
Bound the error without knowing the initial speed
For \(a=1.20\) m/s² and \(h=0.200\) s the correction is largest at \(w=ah/2\). Its maximum is
At \(v=0.360\) m/s a full step leaves exactly 0.120 m/s, so the continuous estimate of 54.0 mm increases to 60.0 mm. Reducing the sample interval by half reduces this worst-case excess distance by a factor of four.
Interactive calculation · Change the inputs of this example
Use the adjustable quantities to test the two worked calculations above. The plot recomputes this derivation’s balance or constitutive relation; its numerical readout reports the quantities needed for the forward calculation and the inverse or design question. Keep the fixed assumptions stated in the readout when comparing with the example values.
Predict a sequence before applying the first action
For \(x_{k+1}=Ax_k+Bu_k\) with measured or estimated \(x_k\), successive substitutions give
The initial state sets the free response; the planned input sequence contributes linearly. With quadratic tracking and effort penalties, linear dynamics and linear bounds on states or inputs, planning becomes a convex quadratic programme. At each update apply only the first planned command, acquire a new measurement and solve again. Receding the horizon provides feedback when disturbances make actual motion depart from the earlier prediction.
Solve a two-step constrained problem
Take the dimensionless integrator \(x_{k+1}=x_k+u_k\), \(x_k=2\), and target zero. Minimise \(x_{k+1}^2+x_{k+2}^2+u_k^2+u_{k+1}^2\). With \(u=u_k,v=u_{k+1}\), the objective is \((2+u)^2+(2+u+v)^2+u^2+v^2\). Its stationary equations are
The unconstrained plan \(u=-1.2,\ v=-0.4\) reaches states 0.8 and 0.4. If both input magnitudes are limited to one, the first command is infeasible. Fixing \(u=-1\) and reoptimising the second gives \(v=-0.5\), reaching 1 and 0.5. The derivative with respect to \(u\) points toward smaller \(u\) at this boundary, confirming the active limit.
After applying −1, suppose the new state is exactly 1. The next two-step unconstrained plan scales the original one by one half, giving first action −0.6. The earlier second action was −0.5. This change is consistent even without disturbances, since the new optimisation includes a further future step. A terminal cost approximating the remaining cost of control can reduce this artificial dependence on the planning horizon.
Feasible commands and feasible trajectories differ
A command bound always has feasible choices if zero lies within it. Adding a hard state constraint, such as a position stop, may make all predicted trajectories infeasible from the current state. Before asking for a time-optimal move, compute elementary reachability bounds. With \(|u|\le1\), a scalar integrator can move at most \(N\) units in \(N\) samples. A terminal constraint demanding zero from state 3 in two samples is impossible. Allowing slack in a comfort-related temperature band may be defensible; a physical actuator limit must still be enforced. Report which constraints were active and what performance was sacrificed.
Close the engineering loop
For a practical comparison, first establish a verified baseline with the OneSimulation proportional-loop record. Reconstruct its pole and finite-record bias from the model parameters. This record witnesses how an unconstrained linear loop behaves; it does not itself exercise a predictive optimiser. Now design a separate held-input or constrained test whose command reaches a known bound, record measured timestamps and actuator signals, and compare with a by-hand prediction of the first active limit. The useful performance claims differ: accurate steady tracking, stable sampled dynamics, adequate estimator uncertainty and feasibility under limits each require an observation capable of testing them.
Derive a terminal region that can be maintained indefinitely
A finite-horizon planner can reach a state at its last predicted sample that looks inexpensive but has no feasible continuation. A terminal set provides a constructive remedy. For \(x_{k+1}=Ax_k+Bu_k\), choose local feedback \(u=Kx\). A set \(X_f\) is positively invariant under this feedback if every \(x\in X_f\) satisfies the state and input bounds and \((A+BK)x\in X_f\). Requiring the last predicted state to belong to this set gives the next optimisation a candidate, provided the model is exact and a feasible plan already exists.
To see this, suppose the accepted plan contains controls \(u_0,\ldots,u_{N-1}\) and states \(x_0,\ldots,x_N\in X\), with \(x_N\in X_f\). Apply \(u_0\). At the next time, shift the remaining controls one step and append \(Kx_N\). Its last state is \((A+BK)x_N\), still in \(X_f\). Every intermediate state and command came from the old feasible plan. This argument establishes recursive feasibility for the ideal deterministic system; the cost can then be chosen to establish a separate performance or stability claim.
For an unstable scalar plant \(x^+=1.2x+u\), bounds \(|u|\le0.5,\ |x|\le2\), choose \(u=-0.7x\). The resulting factor is 0.5. Choosing \(|x|\le0.5/0.7=5/7\) protects the local input limit and the next-state magnitude contracts. This interval is one admissible terminal set; it need not be the largest invariant region obtainable with all possible controls.
Construct the two-step feasible region by working backwards
For the same plant, suppose a terminal interval is \([-b,b]\). A current state can reach it in one step if the reachable interval \([1.2x-0.5,1.2x+0.5]\) intersects \([-b,b]\). Solving the two endpoint inequalities gives \(|x|\le(b+0.5)/1.2\), additionally restricted by \(|x|\le2\). Starting from \(b_0=5/7=0.7143\), the one-step interval has half-width \(b_1=1.0119\), and the two-step interval has \(b_2=1.2599\). A current error \(x=1.20\) is therefore feasible for two steps but cannot reach the terminal set in one.
A feasible two-step plan applies \(u_0=u_1=-0.5\). It generates \(x_1=0.94,\ x_2=0.628\), inside the terminal interval. The appended local command is \(-0.7(0.628)=-0.440\), generating \(x_3=0.314\). From \(x=1.40\), however, even two maximal negative commands yield
A solver reporting infeasibility there has identified a physical horizon limitation. Lengthening the horizon can enlarge the feasible region. External disturbances and estimator error can spoil the exact shifted-plan construction, motivating reserve inside the hard bounds or an explicitly disturbance-aware terminal set.
Observe the limiting sequence of backwards-reachable interval widths. Ignoring the physical state cap for a moment, the recursion has fixed point \(b=(b+0.5)/1.2=2.5\). At \(x=2.5\) the strongest negative input merely holds position, and beyond it even that input allows outward divergence. With the stated state limit the physically relevant bound is tighter at 2.0. From \(x=2.0\) the strongest input moves to 1.9, so that boundary can be brought inward over enough samples. This examination distinguishes insufficient horizon from insufficient actuator authority. A solver change cannot rescue a state above the unrestricted 2.5 threshold with the given input, whereas increasing horizon can rescue a feasible physical state that lies just beyond the current backwards-reachable interval.
Now suppose implementation records establish an additive one-step disturbance bound \(|w|\le0.05\) in \(x^+=1.2x+u+w\). At local feedback \(u=-0.7x\), guaranteeing that \([-b,b]\) maps to itself under every such disturbance requires
The terminal interval above satisfies this because \(b=0.7143>0.10\), and the feedback still respects the input limit. To guarantee that a chosen predecessor reaches this interval in one step, the nominal next state needs to lie within \([-b+0.05,b-0.05]\). The robust predecessor half-width is thus \((b-0.05+0.5)/1.2=0.970\), smaller than the nominal 1.012.
Applying the backward rule twice gives the robust two-step half-width \((0.970-0.05+0.5)/1.2=1.183\) when an updated action can be selected at the intermediate state. The previously feasible initial state 1.20 is outside that guarantee. Indeed maximal negative actuation with two consecutive positive disturbances yields
A nominally feasible trajectory and an invariant terminal set alone therefore do not make the whole finite-horizon plan robust. The intermediate constraints and the information available when choosing the next input must also be included in the guarantee.
Locate the first active constraint in a predictive policy
For \(x^+=x+u\), penalise the sum of squared future states and inputs. In one step the unconstrained action is \(-x/2\). Eliminating the second action in a two-step plan gives first action \(-3x/5\). Solve again on the active face once the input bound is reached.

Read values from the plot
| Initial state | Two steps, unconstrained | Two steps, |u| ≤ 1 | One step, |u| ≤ 1 |
|---|---|---|---|
| −3.5 | 2.1 | 1 | 1 |
| −1.75 | 1.05 | 1 | 0.875 |
| 0 | 0 | 0 | 0 |
| 1.75 | −1.05 | −1 | −0.875 |
| 3.5 | −2.1 | −1 | −1 |
Interactive calculation · change the inputs of this example
Raise the actuator penalty and then reduce its magnitude limit. Compare when the one-step and two-step policies first saturate.
The curves below are recalculated from this section’s equations in your browser. The fixed reference plot above remains available for comparison.
Study the full derivation
Predicting a delayed process and testing a Smith controller · System dynamics, feedback and estimation
A heater is upstream of a temperature sensor. Its internal thermal response begins immediately while a material parcel reaches the sensor several seconds later. Build a feedback signal from two model outputs, derive which transfer function loses its delay, and then deliberately introduce a delay mismatch to see why a plausible prediction may fail.