Inferensys

Glossary

Linear Complementarity Problem (LCP)

A Linear Complementarity Problem (LCP) is a mathematical framework used in physics engines to model contact forces and friction, ensuring non-penetration and non-adhesive constraints are satisfied.
Governance lead reviewing model governance framework on laptop, policy documents visible, executive office setup.
PHYSICS SIMULATION

What is Linear Complementarity Problem (LCP)?

A mathematical framework central to modeling contact and friction in physics engines.

A Linear Complementarity Problem (LCP) is a mathematical framework used in physics engines to model contact forces and friction, ensuring non-penetration and non-adhesive constraints are satisfied. Given a matrix M, a vector q, and unknown vectors w and z, it solves for w = Mz + q subject to the complementarity condition w ≥ 0, z ≥ 0, and wᵀz = 0. This structure perfectly captures the "either-or" nature of contact: bodies either touch (with force) or are separate (with zero force).

In rigid body dynamics, the LCP is solved by the constraint solver each time step to compute impulses that prevent interpenetration. Solvers like Projected Gauss-Seidel (PGS) iteratively approximate the solution. The LCP's formulation is crucial for deterministic simulation and stable Sim-to-Real Transfer, as it provides a consistent mathematical model for the complex, discontinuous physics of collisions and resting contact found in real-world robotics.

MATHEMATICAL FRAMEWORK

Key Characteristics of LCPs

The Linear Complementarity Problem (LCP) is a specialized mathematical formulation used in physics engines to model contact mechanics. It enforces non-penetration and friction constraints by solving for forces that satisfy complementarity conditions.

01

Core Complementarity Condition

The defining mathematical structure of an LCP is the complementarity condition. For vectors w and z, the problem requires w ≥ 0, z ≥ 0, and wᵀz = 0. In physics, z often represents contact forces or impulses, and w represents the relative velocities or distances at contact points. The condition wᵀz = 0 means that for each contact, either the force is zero (objects are separating) or the relative velocity is zero (objects are in resting or sliding contact), but not both. This elegantly encodes the non-adhesive nature of standard contact.

02

Modeling Non-Penetration

A primary application is enforcing the non-penetration constraint between rigid bodies. The LCP framework ensures that contact forces are only applied when bodies are touching or interpenetrating, and that these forces are exactly sufficient to push them apart.

  • The gap function (distance between bodies) and the normal force form a complementary pair.
  • If the gap is positive (bodies are separated), the normal force must be zero.
  • If the gap is zero or negative (penetration), a positive normal force must be generated to resolve it. This prevents objects from passing through each other, a fundamental requirement for stable simulation.
03

Incorporating Friction Cones

LCPs naturally extend to model Coulomb friction, which states that the tangential friction force magnitude is bounded by the normal force multiplied by a coefficient of friction. This relationship forms a friction cone.

In simulation, this is typically approximated as a pyramidal friction cone (a linearized version). The LCP is then formulated to solve for both normal and friction forces simultaneously, ensuring that:

  • The friction force lies within the linearized cone.
  • A stick-slip condition is enforced: if the relative tangential velocity is zero (sticking), the friction force can be anywhere inside the cone; if sliding occurs, the friction force must be at the cone's boundary, opposing the slide direction.
04

Formulation as a Linear System

An LCP is derived from the equations of motion and contact constraints. For a rigid body system, the forward dynamics with contact can be expressed as:

M dv = Jᵀ λ + F_ext dt

Where M is the mass matrix, dv is the change in velocity, J is the Jacobian mapping contact forces λ to generalized forces, and F_ext are external forces. Combining this with the complementarity conditions on λ and the relative velocities (J v) transforms the problem into the standard LCP form: w = A z + b, with w ≥ 0, z ≥ 0, wᵀz = 0. The matrix A encodes mass properties and contact geometry, making it positive semi-definite for physical systems, which guarantees solvability.

05

Solution Algorithms (PGS, PI)

Solving the LCP is computationally intensive. Iterative methods are preferred for real-time physics engines.

  • Projected Gauss-Seidel (PGS): A widely used iterative solver. It cycles through each contact constraint, solving for its force while holding others fixed, and then projects the solution onto the feasible set (force ≥ 0). It is robust and relatively simple to implement.
  • Pivoting Methods (Lemke's Algorithm): Direct methods that can find an exact solution for smaller or medium-sized problems but have worse worst-case complexity for large-scale simulations common in robotics. The choice of solver directly impacts the stability, speed, and determinism of the simulation.
06

Relation to Constraint Solvers

The LCP is the mathematical backbone of many velocity-level constraint solvers in physics engines like Bullet or ODE. It provides a unified framework to handle:

  • Contact constraints (non-penetration).
  • Friction constraints (stick-slip).
  • Joint constraints (e.g., hinges, sliders) can also be formulated as LCPs or similar Mixed LCPs (MLCPs) to enforce limits like joint ranges.

This unification allows a single solver iteration to resolve all interdependent constraints simultaneously, leading to more stable and physically plausible results compared to sequential resolution methods. It is a key differentiator between simple collision response and high-fidelity multibody dynamics.

COMPARISON

LCP vs. Other Constraint Resolution Methods

A feature comparison of the Linear Complementarity Problem (LCP) solver against other common numerical methods used in physics engines to resolve contact and joint constraints.

Feature / MetricLinear Complementarity Problem (LCP)Projected Gauss-Seidel (PGS)Sequential Impulses (SI)

Primary Mathematical Formulation

Solves w = Mz + q, w ≥ 0, z ≥ 0, wᵀz = 0

Iteratively solves linear inequalities Ax ≤ b with projection

Applies corrective impulses per constraint each iteration

Native Support for Friction Cones

Guarantees Non-Penetration (Hard Constraints)

Guarantees Non-Adhesive Forces (wᵀz = 0)

Solution Optimality (for Convex Problems)

Finds a complementarity solution

Finds a feasible solution

Finds a feasible solution

Typical Convergence Behavior

Finite termination for LCPs (e.g., with Lemke)

Linear convergence

Linear convergence

Computational Cost per Iteration

High (matrix operations)

Medium

Low

Common Use Case in Physics Engines

High-accuracy contact with friction (e.g., robotic grasping)

General-purpose contact and joint resolution

Real-time games and interactive applications

APPLICATIONS

Where is the Linear Complementarity Problem Used?

The Linear Complementarity Problem (LCP) is a foundational mathematical framework with critical applications beyond its core role in physics simulation. It provides the computational structure for solving a wide range of equilibrium and optimization challenges.

02

Mathematical Programming & Economics

LCPs are fundamental in operations research and equilibrium economics. They generalize several classic problems:

  • Linear Programming (LP): Can be formulated as an LCP.
  • Quadratic Programming (QP): With certain conditions, the Karush–Kuhn–Tucker (KKT) optimality conditions form an LCP.
  • Bimatrix Game Nash Equilibria: Finding a mixed-strategy Nash equilibrium for a two-player game can be reduced to solving an LCP. This makes LCPs crucial for modeling market equilibria, traffic networks, and competitive strategies where multiple agents with opposing interests reach a stable state.
03

Structural & Mechanical Engineering

LCPs model systems with unilateral constraints that switch states. Key engineering applications include:

  • Contact in Mechanical Assemblies: Analyzing stresses in structures with components that may separate or impact under load.
  • Cable and Tensegrity Structures: Determining which cables are under tension (active) and which are slack (inactive) for a given load.
  • Frictional Contact Problems: Such as the classic frictional beam problem, where a beam contacts a foundation with friction, and regions of stick and slip must be determined. These are complementarity problems because a constraint is either active (e.g., cable taut) or inactive (cable slack), but not both.
04

Computational Geometry

Certain geometric computation and optimization problems are naturally expressed as LCPs. A prominent example is the linear programming problem of finding the smallest enclosing circle or the convex hull of a point set from a specific perspective. The Lemke-Howson algorithm, a pivotal method for solving LCPs, has deep connections to algorithms for finding fixed points and solving for Nash equilibria, which have geometric interpretations in strategy space. This links LCPs to the study of polyhedra and complementary cones.

05

Optimization with Equilibrium Constraints (MPEC)

LCPs appear as sub-problems or constraints in more complex bilevel optimization frameworks. A Mathematical Program with Equilibrium Constraints (MPEC) is an optimization problem where the constraints include an equilibrium condition, often modeled by a Variational Inequality (VI) or an LCP. This is used in:

  • Engineering Design: Optimizing the shape of a structure where the constraint is that it must be in mechanical equilibrium under load (solved via LCP).
  • Economic Policy: A government (upper level) sets taxes to maximize social welfare, constrained by a market that reaches a competitive equilibrium (lower level LCP).
06

Numerical Algorithms & Solvers

The development of robust LCP solvers is a field of numerical analysis with broad impact. Key algorithms include:

  • Lemke's Algorithm: A pivotal method that can process LCPs with positive semi-definite matrices, widely used in economics and engineering.
  • Projected Gauss-Seidel (PGS) & Successive Over-Relaxation (SOR): Iterative methods adapted for the LCP's complementarity condition, favored in real-time physics engines for their speed and simplicity.
  • Interior-Point Methods: Adapted from convex optimization to solve large-scale LCPs efficiently. The performance and robustness of these solvers directly enable the applications in simulation, robotics, and economics.
LINEAR COMPLEMENTARITY PROBLEM

Frequently Asked Questions

A Linear Complementarity Problem (LCP) is a core mathematical formulation used in physics engines to model contact and friction. This FAQ addresses its role in robotics simulation and sim-to-real transfer.

A Linear Complementarity Problem (LCP) is a mathematical framework used in physics engines to model contact forces and friction, ensuring that simulated rigid bodies do not interpenetrate and that contact forces satisfy physical constraints like non-adhesion. It formulates the conditions at a contact point as a system where the force must be zero if bodies are separating (non-penetration) and positive if they are in contact (non-adhesion), with the product of these complementary variables being zero. This is expressed as finding vectors w and z such that w = Mz + q, w ≥ 0, z ≥ 0, and w^T z = 0, where M is a matrix derived from system inertia and contact geometry, and q encodes relative velocities.

In practice, the constraint solver of a physics engine sets up and solves an LCP (or a related Mixed Linear Complementarity Problem (MLCP) for friction) each time step to compute the impulses that correctly resolve collisions and resting contacts for rigid body dynamics. This is fundamental for creating stable, realistic simulations used to train robotic policies via reinforcement learning before sim-to-real transfer.

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.