Inferensys

Glossary

Optimal Control Problem (OCP)

An Optimal Control Problem (OCP) is the mathematical formulation at the core of MPC, defined by a cost function to be minimized, a dynamic model describing the system's evolution, and a set of constraints on states and inputs, all over a specified time horizon.
ML engineer managing model versions on laptop, version history visible, technical Git-like workflow.
CORE FORMULATION

What is an Optimal Control Problem (OCP)?

The Optimal Control Problem (OCP) is the foundational mathematical framework for determining the best possible sequence of actions to steer a dynamic system towards a goal.

An Optimal Control Problem (OCP) is a mathematical optimization framework that determines a sequence of control inputs to minimize a cost function while respecting a dynamic model and constraints on states and inputs over a defined time horizon. It is the core computational problem solved at each step in Model Predictive Control (MPC). The solution is a trajectory of optimal actions that transitions the system from an initial state to a desired objective.

The formal OCP definition comprises four key elements: a dynamic model (e.g., differential equations) predicting state evolution; a cost function quantifying performance goals like tracking error or energy use; path constraints on admissible states and control inputs; and boundary conditions for initial and final states. Solving this constrained optimization yields an optimal control policy, providing the theoretical basis for advanced, predictive automation in robotics, process control, and autonomous systems.

MATHEMATICAL FORMULATION

Core Components of an OCP

An Optimal Control Problem (OCP) is the mathematical core of Model Predictive Control (MPC), defined by a dynamic model, a cost function, and constraints, all optimized over a finite time horizon.

01

Dynamic Model (System Equations)

The dynamic model is a set of mathematical equations, typically ordinary differential equations (ODEs) or difference equations, that describe how the system's state variables evolve over time in response to control inputs and disturbances. This internal model is the predictive engine of the OCP.

  • Continuous-time: dx/dt = f(x(t), u(t), p)
  • Discrete-time: x_{k+1} = f(x_k, u_k, p)

Where x is the state, u is the control input, and p are parameters. The fidelity of this model directly determines the accuracy of the controller's predictions.

02

Cost Function (Objective)

The cost function (or objective function) J is a scalar quantity that the OCP seeks to minimize. It mathematically encodes the control performance goals over the prediction horizon N.

A common quadratic form for tracking is: J = Σ (x_k - x_ref)^T Q (x_k - x_ref) + (u_k - u_ref)^T R (u_k - u_ref)

  • The first term penalizes deviation from a desired state reference trajectory.
  • The second term penalizes excessive control effort.
  • The matrices Q and R are tuning weights that balance these competing objectives.
03

State & Input Constraints

Constraints are mathematical inequalities that define the admissible operating region of the physical system. Explicitly handling these is a primary advantage of MPC.

  • State Constraints: x_min ≤ x(t) ≤ x_max (e.g., position limits, tank levels).
  • Input Constraints: u_min ≤ u(t) ≤ u_max (e.g., actuator saturation, valve limits).
  • Mixed Constraints: May involve both states and inputs.

Constraints can be hard (must never be violated) or soft (allowed violation with a penalty via slack variables to ensure the optimization problem remains feasible).

04

Optimization Horizon

The OCP is solved over a finite optimization horizon, which consists of two key intervals:

  • Prediction Horizon (N_p): The future time window over which the system's behavior is predicted using the dynamic model.
  • Control Horizon (N_c): The (often shorter) window over which control moves are optimized. Control inputs are typically held constant for steps beyond N_c.

The principle of Receding Horizon Control is applied: only the first control input from the optimized sequence is applied to the plant. The horizon then "shifts" forward one step, and the OCP is re-solved with new state measurements, providing feedback and disturbance rejection.

05

Initial Condition

The initial condition x_0 is the estimated or measured state of the system at the start of the current optimization window. It serves as the starting point for all predictions made by the dynamic model.

In practice, the full state is often not directly measurable. Therefore, a state estimator (like a Kalman Filter or Moving Horizon Estimator (MHE)) is used to reconstruct x_0 from available sensor outputs. The accuracy of this initial condition is critical for prediction quality.

06

Numerical Solver

The OCP is a constrained optimization problem that must be solved numerically at each control step. The choice of solver depends on the problem structure:

  • Linear/Quadratic MPC: Results in a Quadratic Program (QP). Solved efficiently with active-set or interior-point methods.
  • Nonlinear MPC (NMPC): Results in a Nonlinear Program (NLP). Solved using Sequential Quadratic Programming (SQP) or interior-point methods.

Real-Time Optimization (RTO) demands that the solver converges to a solution within the controller's sampling period (often milliseconds). Techniques like warm-starting (using the previous solution as an initial guess) are essential for meeting this timing requirement.

MATHEMATICAL FOUNDATION

How Optimal Control Problems Work

An Optimal Control Problem (OCP) is the core mathematical framework for determining the best sequence of actions to steer a dynamic system toward a goal while respecting physical and operational limits.

An Optimal Control Problem (OCP) is a mathematical formulation that defines how to control a dynamic system over time to minimize a cost function while satisfying a dynamic model and a set of state and input constraints. It provides the formal structure for Model Predictive Control (MPC), where this optimization is solved repeatedly in real-time. The problem is defined over a finite prediction horizon, balancing objectives like tracking accuracy, energy use, and safety.

Solving an OCP involves computing a sequence of future control inputs. For linear dynamics with a quadratic cost, this becomes a tractable Quadratic Programming (QP) problem. For nonlinear systems, it transforms into a more complex Nonlinear Programming (NLP). Key design elements include terminal costs and constraints to ensure stability, and techniques like warm-starting to accelerate online computation. The solution dictates the immediate actuator command before the horizon recedes and the process repeats.

FROM THEORY TO ACTUATION

Real-World OCP Applications

The Optimal Control Problem (OCP) is not an abstract exercise; it is the computational engine powering autonomous systems that interact with the physical world. These applications solve the core OCP—minimizing a cost subject to dynamics and constraints—in real-time to achieve precise, safe, and efficient control.

CLASSIFICATION

Types of Optimal Control Problems

A comparison of the primary mathematical formulations for Optimal Control Problems (OCPs), distinguished by their model dynamics, cost function structure, and the nature of constraints.

Problem FeatureLinear-Quadratic Regulator (LQR)Nonlinear Optimal Control (NOCP)Mixed-Integer Optimal Control (MIOCP)Stochastic Optimal Control (SOCP)

Core Dynamic Model

Linear Time-Invariant (LTI)

Nonlinear Differential Equations

Hybrid (Continuous & Discrete)

Stochastic Differential Equations

Typical Cost Function

Quadratic (State & Input)

General Nonlinear

General (with integer variables)

Expectation of a cost

Primary Constraint Type

Unconstrained / Linear

Nonlinear Equality/Inequality

Logic & Integer Constraints

Chance Constraints

Typical Solver Class

Algebraic Riccati Equation (ARE)

Nonlinear Programming (NLP)

Mixed-Integer Programming (MIP)

Dynamic Programming / Convex Approx.

Online Computation

Explicit (Pre-computed)

Numerical (Online Optimization)

Numerical (Online, NP-Hard)

Numerical (Scenario-Based)

Primary Application

Setpoint Regulation

Robotics, Chemical Processes

Systems with Discrete Modes

Finance, Noisy Systems

Stability Guarantees

Global (Nominal)

Local (Requires Design)

Problem-Dependent

Probabilistic

Handles State/Input Limits

OPTIMAL CONTROL PROBLEM (OCP)

Frequently Asked Questions

An Optimal Control Problem (OCP) is the core mathematical formulation for Model Predictive Control (MPC). It defines the objective, dynamics, and limits a controller must respect to achieve optimal performance. These FAQs address its components, solution methods, and role in robotics and automation.

An Optimal Control Problem (OCP) is a mathematical framework for finding a sequence of control inputs that drives a dynamic system from an initial state to a desired state while minimizing a cost function and satisfying constraints on states and inputs over a specified time horizon. It is the fundamental optimization solved at each time step in Model Predictive Control (MPC). The OCP is formally defined by three core elements: a dynamic model (e.g., differential or difference equations) that predicts future states, a cost function (or objective function) to be minimized (e.g., tracking error + control effort), and a set of constraints that define operational limits (e.g., actuator saturation, safety boundaries).

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.