No history yet

System Discretization

From Continuous to Discrete

Optimal control problems live in a world of continuous time, described by ordinary differential equations (ODEs). But the tools we use to solve them, numerical optimizers, live in a world of discrete numbers. To bridge this gap, we must perform system discretization. This process transforms the smooth, continuous dynamics of our problem into a series of distinct snapshots in time.

The first step is to establish a time grid. We chop the total time horizon, say from t0t_0 to tft_f, into a finite number of segments. These segments are defined by a series of points called nodes or knots, t0,t1,t2,,tNt_0, t_1, t_2, \dots, t_N. The state of our system, x(t)x(t), is now only explicitly considered at these specific nodes, becoming a sequence x0,x1,x2,,xNx_0, x_1, x_2, \dots, x_N. This set of points forms the skeleton of our discretized problem.

The spacing of these nodes doesn't have to be uniform. Placing more nodes in regions where the dynamics change rapidly can improve accuracy without needlessly increasing computational cost everywhere.

Parameterizing the Controls

Just like the state, the control input, u(t)u(t), must also be discretized. Instead of trying to find an entire continuous function, we define its shape over each time interval [tk,tk+1][t_k, t_{k+1}] using a simple, fixed structure. This is called control parameterization.

The most common approach is to assume the control is piecewise-constant. Within each interval, the control value u(t)u(t) is held constant at some value uku_k. The optimizer's job is no longer to find a function, but to find the best sequence of constant values u0,u1,,uN1u_0, u_1, \dots, u_{N-1}. Another option is piecewise-linear, where the control varies linearly from uku_k to uk+1u_{k+1} within the interval. This offers more fidelity at the cost of more complexity.

By parameterizing the control, we have transformed an infinite-dimensional problem (finding a function) into a finite-dimensional one (finding a set of parameters). This is a crucial step toward making the problem solvable for a computer.

Integrating the Dynamics

Now we have the state xkx_k at time tkt_k and a defined control uku_k for the interval [tk,tk+1][t_k, t_{k+1}]. How do we find the state xk+1x_{k+1} at time tk+1t_{k+1}? We must integrate the system's ODE, x˙=f(x(t),u(t))\dot{x} = f(x(t), u(t)), across the time interval.

Since the function ff can be complex and nonlinear, we can't usually find an exact analytical solution. Instead, we use a numerical integration scheme. A popular and robust choice is the fourth-order Runge-Kutta method (RK4). It provides a good balance of accuracy and computational effort.

k1=hf(xk,uk)k2=hf(xk+0.5k1,uk)k3=hf(xk+0.5k2,uk)k4=hf(xk+k3,uk)xk+1=xk+16(k1+2k2+2k3+k4)\begin{aligned} k_1 &= h \cdot f(x_k, u_k) \\ k_2 &= h \cdot f(x_k + 0.5 k_1, u_k) \\ k_3 &= h \cdot f(x_k + 0.5 k_2, u_k) \\ k_4 &= h \cdot f(x_k + k_3, u_k) \\ x_{k+1} &= x_k + \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4) \end{aligned}

The entire RK4 process can be wrapped into a single function, often called an integrator, which we can denote as FF. This function takes the current state xkx_k and control uku_k and returns the next state xk+1x_{k+1}.

xk+1=F(xk,uk)x_{k+1} = F(x_k, u_k)

This equation is the core of the discretization. For each interval, we create an algebraic equality constraint that the optimizer must satisfy: xk+1F(xk,uk)=0x_{k+1} - F(x_k, u_k) = 0. This ensures that the trajectory follows the system dynamics. In methods, these constraints link the states from one node to the next, but the states at each node are treated as independent decision variables by the solver.

Preparing for the Solver

With our discretization scheme in place, we have successfully transformed the original continuous optimal control problem into a large (NLP) problem. The decision variables for the NLP solver are all the states x0,,xNx_0, \dots, x_N and all the control parameters u0,,uN1u_0, \dots, u_{N-1}. The constraints are the equality constraints from our integrator (xk+1F(xk,uk)=0x_{k+1} - F(x_k, u_k) = 0) plus any other path or boundary constraints from the original problem.

To solve this NLP efficiently, gradient-based optimizers need more than just the constraint values. They also need sensitivity information: how does the final state of an interval, xk+1x_{k+1}, change when the initial state, xkx_k, or the control, uku_k, is slightly perturbed? These are the Jacobians, Fxk\frac{\partial F}{\partial x_k} and Fuk\frac{\partial F}{\partial u_k}. These derivatives can be computed through methods like finite differences or, more efficiently, using automatic differentiation on the integrator function.

This complete package of decision variables, constraints, and their derivatives provides the NLP solver with everything it needs to find a dynamically feasible and optimal solution.

Quiz Questions 1/5

What is the primary purpose of system discretization in optimal control?

Quiz Questions 2/5

When a continuous control input, u(t)u(t), is modeled as a sequence of constant values uku_k over each time interval, this approach is called:

This process of discretization is the fundamental bridge between the theoretical world of continuous dynamics and the practical world of numerical optimization.