Inferensys

Glossary

Sequential Quadratic Programming (SQP)

Sequential Quadratic Programming (SQP) is an iterative algorithm for solving nonlinear optimization problems by approximating them with a series of simpler quadratic subproblems.
Engineer optimizing context window usage on laptop, token usage charts visible, technical work session.
NONLINEAR OPTIMIZATION ALGORITHM

What is Sequential Quadratic Programming (SQP)?

Sequential Quadratic Programming (SQP) is a prominent iterative algorithm for solving constrained Nonlinear Programming (NLP) problems, which are central to advanced control methods like Nonlinear Model Predictive Control (NMPC).

Sequential Quadratic Programming (SQP) is an iterative numerical optimization method that solves a constrained Nonlinear Programming (NLP) problem by repeatedly approximating it as a simpler, locally convex Quadratic Programming (QP) subproblem. At each iteration, SQP constructs a QP that models the original problem's Lagrangian using a local quadratic approximation of the objective function and linearizations of the constraints. Solving this QP yields a search direction and step size, updating the solution until convergence to a local optimum that satisfies the Karush-Kuhn-Tucker (KKT) conditions.

In Nonlinear Model Predictive Control (NMPC), SQP is the workhorse solver for the online Optimal Control Problem (OCP). It efficiently handles the nonlinear dynamic model and state and input constraints that define the control task. The algorithm's efficiency is often enhanced via warm-starting, using the solution from the previous control step to initialize the next QP subproblem. This makes SQP particularly suited for the real-time optimization (RTO) requirements of robotic and process control, where a solution must be computed within a strict sampling period.

NONLINEAR OPTIMIZATION ALGORITHM

Key Features of SQP

Sequential Quadratic Programming (SQP) is a prominent iterative algorithm for solving Nonlinear Programming (NLP) problems. It is a cornerstone for Nonlinear Model Predictive Control (NMPC), where it efficiently handles the non-convex optimization required for constrained, dynamic systems.

01

Local Quadratic Approximation

At its core, SQP solves a difficult Nonlinear Programming (NLP) problem by iteratively approximating it with simpler, convex Quadratic Programming (QP) subproblems. At each iteration k, it constructs a local quadratic model of the Lagrangian function (which combines the objective and constraints) around the current iterate (x_k, λ_k). This involves calculating:

  • The gradient of the Lagrangian.
  • An approximation of the Hessian of the Lagrangian (often using BFGS or SR1 quasi-Newton updates). The resulting QP subproblem has a quadratic objective and linearized constraints, which can be solved efficiently with dedicated QP solvers.
02

Superlinear Convergence Rate

When properly implemented with exact second-order derivative information (or high-quality quasi-Newton approximations), SQP exhibits a superlinear convergence rate. This means that near the optimal solution, the error decreases faster than linearly (e.g., ||x_{k+1} - x*|| / ||x_k - x*|| → 0). This property is critical for Real-Time Optimization (RTO) in NMPC, as it allows the algorithm to reach a high-accuracy solution in very few iterations, meeting stringent sampling time requirements. The convergence rate is a key advantage over first-order methods like gradient descent.

03

Exact Hessian & Merit Functions

A major implementation challenge is ensuring global convergence (convergence from any starting point) while maintaining fast local convergence. Two key mechanisms address this:

  • Merit Function: A scalar function (like an l1 or augmented Lagrangian penalty function) that balances reduction in the objective with constraint violation. It determines whether a proposed step should be accepted.
  • Trust-Region Methods: As an alternative to line searches, these methods restrict the step size to a region where the quadratic model is trusted, dynamically adjusting the region size based on model accuracy. These mechanisms allow the algorithm to take reliable progress steps far from the optimum while preserving the superlinear rate near the solution.
04

Active-Set Strategy for Constraints

SQP naturally and efficiently handles both equality and inequality constraints. Each QP subproblem solves for a step that respects linearized versions of the original constraints. A crucial part of the QP solution is identifying the active set—the subset of inequality constraints that are binding (equal to their bound) at the solution of the subproblem. The algorithm's ability to accurately predict and adapt this active set from iteration to iteration is central to its efficiency. This makes SQP particularly well-suited for NMPC problems with tight state and input constraints, such as actuator limits or safety boundaries.

05

Warm-Starting for NMPC

This is perhaps SQP's most powerful feature in the context of Receding Horizon Control. At each control time step t, the NMPC problem is re-solved with a shifted horizon and new initial state measurement. The solution from the previous time step t-1 (shifted appropriately) provides an excellent initial guess (or warm start) for the primal variables (x, u) and dual variables (λ) (Lagrange multipliers) of the new problem. Because the optimal solution typically changes smoothly between time steps, SQP often requires only 1-2 iterations to reconverge from this warm start, making real-time execution feasible for many nonlinear systems.

06

Connection to KKT Conditions

SQP is derived directly from the Karush-Kuhn-Tucker (KKT) conditions, which are the first-order necessary conditions for optimality in constrained NLP. The QP subproblem solved at each SQP iteration is essentially a Newton or quasi-Newton step applied to the system of nonlinear equations formed by the KKT conditions. This direct root-finding approach on the optimality conditions is why SQP is considered a second-order method and achieves its fast convergence. It simultaneously solves for the optimal primal variables and the corresponding Lagrange multipliers, providing sensitivity information about how constraints affect the optimum.

NMPC SOLVER COMPARISON

SQP vs. Other Nonlinear Optimization Methods

A comparison of Sequential Quadratic Programming (SQP) against other prominent algorithms used to solve the Nonlinear Programming (NLP) problems at the core of Nonlinear Model Predictive Control (NMPC).

Feature / MetricSequential Quadratic Programming (SQP)Interior-Point Method (IPM)Direct Multiple ShootingGenetic Algorithm (GA)

Primary Mathematical Approach

Iteratively solves local Quadratic Programming (QP) approximations of the NLP

Solves a sequence of barrier problems, approaching optimum from interior of feasible region

Discretizes horizon into segments, solves IVPs, enforces continuity via constraints

Population-based stochastic search inspired by biological evolution

Typical Convergence Rate

Local quadratic convergence (near solution)

Superlinear convergence

Depends on underlying NLP solver (e.g., SQP or IPM)

No guaranteed convergence; probabilistic improvement

Handling of Nonlinear Constraints

Explicit linearization of constraints in QP subproblem

Handled via barrier/penalty functions in the modified objective

Explicitly enforced at shooting nodes and via continuity constraints

Typically handled via penalty functions or specialized operators

Suitability for Real-Time NMPC

High (with warm-starting)

Moderate to High (structure-exploiting implementations)

Moderate (requires solving larger, structured NLP)

Very Low (high computational cost per iteration)

Global Optimality Guarantee

Provable Local Convergence to KKT Point

Native Handling of Inequality Constraints

Standard Use of Derivative Information

First & often second derivatives (Hessian)

First & often second derivatives (Hessian)

First & often second derivatives

Primary Advantage for NMPC

Fast local convergence; natural fit for warm-starting from previous solution

Robust handling of inequalities; good for large, sparse problems

Improved numerical stability for unstable systems; natural parallelization

Potential to find global optimum in non-convex, discontinuous problems

Primary Disadvantage for NMPC

Requires good initial guess; may converge to local minima

Can be computationally heavy per iteration; barrier parameter management

Increased problem size (additional variables); more complex implementation

Extremely slow; no convergence guarantees; poor constraint handling

Typical Implementation for NMPC

Real-time iteration (RTI) schemes

Primal-dual methods

Often combined with SQP or IPM as the underlying NLP solver

Generally avoided for online control due to speed

SEQUENTIAL QUADRATIC PROGRAMING (SQP)

Applications and Use Cases

Sequential Quadratic Programming (SQP) is a cornerstone algorithm for solving the complex Nonlinear Programming (NLP) problems at the heart of Nonlinear Model Predictive Control (NMPC). Its primary application is converting these intractable NLPs into a series of simpler, solvable Quadratic Programming (QP) subproblems. This card grid details its critical roles in advanced control and optimization.

01

Core Engine for Nonlinear MPC

SQP is the dominant iterative method for solving the Nonlinear Programming (NLP) problem that must be solved online at each control step in Nonlinear MPC (NMPC). It enables NMPC by:

  • Linearizing the nonlinear system dynamics and constraints around the current state estimate.
  • Approximating the cost function as a quadratic form.
  • Solving the resulting Quadratic Programming (QP) subproblem to find a search direction.
  • Iterating this process until convergence to a (local) optimum for the control sequence. This allows real-time control of systems with significant nonlinearities, such as chemical reactors or agile autonomous vehicles, where linear approximations fail.
02

Real-Time Trajectory Optimization

In robotics and aerospace, SQP enables real-time trajectory optimization for dynamic systems. Applications include:

  • Autonomous Vehicle Path Planning: Computing smooth, collision-free trajectories that respect vehicle dynamics and actuator limits.
  • Robotic Arm Motion Planning: Optimizing joint trajectories for manipulation tasks while minimizing jerk or energy.
  • Rocket Landing Guidance: Solving fuel-optimal descent profiles under complex nonlinear dynamics and state constraints. SQP's ability to handle nonlinear equality and inequality constraints directly is crucial here, as it allows the optimizer to respect physical limits (e.g., torque saturation, obstacle boundaries) throughout the planned motion.
03

Integration with Direct Optimal Control Methods

SQP is not a standalone discretization method but is frequently used as the solver within broader direct optimal control frameworks. It pairs with:

  • Direct Multiple Shooting: The time horizon is split into segments, and SQP solves the large, sparse NLP that results from parameterizing controls and states on each segment and enforcing continuity constraints.
  • Direct Collocation: Both states and controls are discretized, and SQP solves the NLP where the system dynamics are enforced via algebraic constraints at collocation points. These combinations are implemented in tools like ACADO Toolkit and CasADi, where SQP (often with Interior-Point methods) provides the numerical engine to solve the discretized problem efficiently.
04

Handling Hard Constraints in Dynamic Systems

A key advantage of SQP within MPC is its native and rigorous handling of hard constraints. This is vital for:

  • Process Safety: In chemical plant MPC, SQP ensures temperatures and pressures never exceed safe operating limits.
  • Actuator Saturation: Prevents commands that would overdrive motors, valves, or thrusters.
  • Obstacle Avoidance: Encodes collision constraints as nonlinear inequalities for drones or mobile robots. By solving a constrained optimization problem at each step, SQP-based NMPC actively anticipates future constraint violations and adjusts the control plan proactively, unlike traditional control which reacts after a violation occurs.
05

Warm-Starting for Computational Efficiency

The sequential nature of SQP is exploited via warm-starting to meet the strict latency requirements of real-time control (often < 100ms).

  • Mechanism: The optimal solution (and the associated QP matrices) from the previous MPC time step is used to initialize the SQP solver for the current step.
  • Impact: This dramatically reduces the number of SQP iterations needed for convergence, as the system state and optimal solution typically change only incrementally between sampling instants.
  • Result: Enables the use of NMPC with SQP on embedded hardware for fast dynamic systems, such as autonomous quadrotors or automotive active suspension control.
06

Economic and Advanced Process Optimization

Beyond setpoint tracking, SQP enables Economic MPC (EMPC) and complex multi-objective optimization in industrial settings.

  • Economic Objective Minimization: Directly optimizing for profit, energy consumption, or raw material cost using nonlinear cost functions.
  • Batch Process Optimization: Optimizing time-varying trajectories for temperature or feed rates in pharmaceutical or specialty chemical production.
  • Integration with Real-Time Optimization (RTO): Solving steady-state economic optimization problems that provide targets to a lower-level MPC layer. SQP handles the nonlinear process models and economic gradients involved in these non-quadratic, non-convex problems, bridging dynamic control with plant-wide economic performance.
SEQUENTIAL QUADRATIC PROGRAMMING

Frequently Asked Questions

Sequential Quadratic Programming (SQP) is a cornerstone algorithm for solving the Nonlinear Programming (NLP) problems at the heart of advanced control systems like Nonlinear Model Predictive Control (NMPC). These FAQs address its core mechanics, applications, and practical considerations for engineers.

Sequential Quadratic Programming (SQP) is an iterative numerical optimization algorithm designed to solve Nonlinear Programming (NLP) problems by approximating them as a sequence of simpler Quadratic Programming (QP) subproblems. At each iteration, SQP constructs a local quadratic approximation of the Lagrangian (which combines the original cost function and constraints) and linearizes the constraints. It then solves this QP subproblem to find a search direction and step size, updating the solution until convergence criteria are met. This method is prized for its superlinear convergence rate near the solution, making it highly efficient for the real-time optimization required in Nonlinear MPC (NMPC).

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.