Inferensys

Glossary

Projected Gauss-Seidel (PGS) Solver

The Projected Gauss-Seidel (PGS) solver is an iterative numerical method used in physics engines to solve constraint problems, such as contact and joints, by sequentially projecting solutions onto feasible sets.
Developer reviewing semantic search engine results on laptop, relevance scores visible, technical search demo.
PHYSICS SIMULATION ENGINES

What is Projected Gauss-Seidel (PGS) Solver?

A core iterative numerical method for resolving physical constraints in real-time physics engines.

The Projected Gauss-Seidel (PGS) solver is an iterative numerical algorithm used in physics engines to solve Linear Complementarity Problems (LCPs) arising from contact, joint, and friction constraints by sequentially projecting the solution for each variable onto a feasible set. It is a specialized variant of the classic Gauss-Seidel method that incorporates projection operations to enforce physical limits like non-penetration and force non-negativity, making it highly effective for real-time simulations where approximate solutions are acceptable.

PGS operates by solving constraints one at a time in a loop, using the most recent solution values, which promotes fast convergence for contact resolution. Its sequential nature and low memory footprint make it suitable for parallel processing on modern hardware. While less mathematically rigorous than a direct LCP solver, PGS's speed and stability have cemented its role as the standard solver in many game physics engines and robotic simulators for rigid body dynamics.

NUMERICAL METHODS

Key Characteristics of the PGS Solver

The Projected Gauss-Seidel (PGS) solver is an iterative numerical method central to real-time physics engines. It efficiently resolves constraints like contact and joints by sequentially projecting solutions onto physically feasible sets.

01

Sequential Iterative Method

PGS operates by sequentially processing constraints one at a time. Unlike batch methods that solve all constraints simultaneously, it updates the solution for a single constraint and immediately uses that result for the next. This local propagation often converges faster for contact-dominated problems. The core update for a constraint i is:

  • delta_lambda = (b_i - sum(a_ij * lambda_j)) / a_ii
  • lambda_i_new = clamp(lambda_i_old + delta_lambda, lower_bound, upper_bound) where lambda is the constraint impulse (e.g., contact force) and clamping enforces bounds like non-penetration.
02

Projection Onto Feasible Sets

The "Projected" in PGS refers to the operation that enforces physical bounds on the solution. After each local Gauss-Seidel update, the computed value is projected (clamped) onto a feasible interval. For contact constraints, this typically means:

  • Normal forces are projected onto [0, +inf) to prevent adhesive forces (no pulling).
  • Friction forces are projected onto a Coulomb friction cone [-mu * lambda_normal, +mu * lambda_normal]. This projection is what guarantees a physically plausible solution, ensuring objects push apart but do not stick together.
03

Solving Linear Complementarity Problems (LCP)

PGS is specifically designed to solve Linear Complementarity Problems (LCPs), the mathematical formulation of rigid body contact with friction. An LCP states that for contact i:

  • lambda_i >= 0 (force must be non-negative)
  • v_i >= 0 (relative velocity at contact must be non-penetrating)
  • lambda_i * v_i = 0 (complementarity: either force is zero or velocity is zero) PGS finds an approximate solution to this hard problem through iterative projection, making it more robust and faster than direct LCP solvers for real-time applications.
04

Warm Starting

A key performance optimization in PGS is warm starting. The solver reuses the impulse (lambda) values from the previous simulation time step as the initial guess for the current step. Since object positions and contacts change relatively slowly between frames (typically 60Hz or 120Hz), the previous solution is often very close to the new one. This drastically reduces the number of iterations required for convergence, which is critical for maintaining real-time performance in games and interactive simulations.

05

Comparison to Alternative Solvers

PGS is favored in real-time engines for its speed and stability, but trades off some accuracy.

  • Vs. Direct Methods (e.g., Pivoting LCP Solvers): Direct methods are more accurate but have unpredictable O(n³) worst-case time, unsuitable for real-time. PGS offers predictable O(n) per iteration.
  • Vs. Jacobi Methods: A Jacobi solver updates all constraints in parallel using values from the previous iteration. It's more parallelizable but converges slower per iteration than Gauss-Seidel's sequential updates.
  • Vs. Newton Methods: Newton-based solvers (like Sequential Impulse, which is similar to PGS with a full Jacobian) can have faster convergence but may require more complex matrix setups.
06

Application in Constraint Types

PGS is versatile and used to solve various physics constraints:

  • Contact Constraints: Preventing inter-penetration and modeling friction.
  • Joint Constraints: Restricting degrees of freedom between bodies (e.g., hinges, sliders, ball joints).
  • Ragdoll Constraints: Keeping bones within anatomical limits.
  • Soft Constraints: Such as springs or motors, where bounds may be elastic limits or torque limits. The same iterative, bounded solving loop applies, with the Jacobian matrix J defining how each constraint affects body velocities and the effective mass matrix JM⁻¹Jᵀ forming the a_ii term in the update rule.
COMPARISON

PGS vs. Other Constraint Solvers

A technical comparison of the Projected Gauss-Seidel (PGS) solver against other common numerical methods for resolving constraints in physics-based simulations.

Feature / MetricProjected Gauss-Seidel (PGS)Sequential Impulse (SI)Linear Complementarity Problem (LCP) Solver

Core Algorithm

Iterative relaxation with projection

Iterative impulse application

Batched matrix formulation

Primary Use Case

Real-time simulation, contact & joints

Real-time simulation, stable stacking

Offline/High-accuracy simulation, tight constraints

Solution Guarantee

Approximate, converges to a solution

Approximate, converges to a solution

Exact, mathematically optimal (for convex problems)

Computational Complexity

O(n) per iteration, low constant factor

O(n) per iteration, low constant factor

O(n³) for direct methods, high constant factor

Parallelization Potential

Low (sequential updates)

Low (sequential updates)

High (matrix operations)

Warm Starting Support

Handling of Friction

Approximate, often coupled

Approximate, often staggered

Exact, can be incorporated into matrix

Deterministic Execution

Memory Footprint

Low (stores per-constraint data)

Low (stores per-constraint impulses)

High (stores system Jacobian matrix)

Typical Iteration Count

5-20 for real-time

5-20 for real-time

1 (direct) or variable (iterative)

APPLICATION DOMAINS

Where is PGS Used?

The Projected Gauss-Seidel (PGS) solver is a workhorse algorithm in interactive and real-time physics simulation, prized for its stability and efficiency in handling complex constraint systems.

01

Real-Time Game Physics

PGS is the foundational solver in many real-time game physics engines, such as NVIDIA PhysX and Bullet Physics. Its sequential, iterative nature provides predictable performance and robust handling of stacked objects and persistent contacts, which are common in gameplay scenarios. Key advantages include:

  • Stability with large time steps: Tolerates the variable frame rates common in games.
  • Warm starting: Uses solutions from previous frames to converge faster.
  • Handling of inequality constraints: Efficiently manages non-penetration and friction without solving a full global system matrix.
02

Robotic Simulation & Training

In sim-to-real transfer learning, physics engines like Isaac Sim and MuJoCo utilize PGS and its variants to simulate contact-rich environments for training robotic policies. It is critical for modeling:

  • Grasping and manipulation: Solving contact forces between grippers and objects.
  • Legged locomotion: Resolving foot-ground interactions for walking and running robots.
  • Articulated systems with joints: PGS efficiently handles the mixed constraints of joint limits and contact forces simultaneously, which is essential for simulating complex robotic mechanisms before real-world deployment.
03

Interactive Rigid Body Dynamics

For applications requiring direct user interaction with simulated objects—such as virtual prototyping, digital twins, and interactive design tools—PGS provides the necessary stability. Its projection step ensures constraints like non-penetration are strictly enforced, preventing objects from sinking into each other even under persistent user-applied forces. This makes it ideal for simulating:

  • Particle systems and granular materials (when combined with constraint-based formulations).
  • Complex assemblies of rigid parts connected by joints.
  • Puzzle-like interactions where stability is more critical than absolute physical accuracy.
04

Cloth and Soft Body Simulation

While Position-Based Dynamics (PBD) is often used for real-time deformables, PGS is employed in constraint-based approaches to simulate cloth, ropes, and soft bodies. In this context, distance constraints (to maintain edge lengths) and bending constraints are solved iteratively. The projection in PGS directly corrects vertex positions to satisfy these constraints, making it effective for:

  • Real-time garment simulation on characters.
  • Flag and cable dynamics.
  • Interactive soft object manipulation where two-way coupling with rigid bodies is required.
05

Complementarity Problem Formulation

PGS is a specific iterative method for solving the Linear Complementarity Problem (LCP) formulation of contact physics. It addresses problems of the form Ax + b = w, where x ≥ 0, w ≥ 0, and x⋅w = 0 (the complementarity condition). This mathematically captures the "non-penetration and non-adhesion" nature of contact. PGS solves this by:

  • Sequentially processing each constraint (contact point).
  • Projecting the solution for that constraint onto its feasible set (e.g., force must be non-negative).
  • Updating the system's velocity/force estimates, which influences subsequent constraint solves in the same iteration.
06

Comparison to Alternative Solvers

PGS is chosen over other numerical solvers based on the requirements of the application:

  • vs. Direct Solvers (e.g., Pivoting Methods): PGS is iterative and approximate but offers O(n) complexity per iteration and better stability for ill-conditioned systems (e.g., large mass ratios). Direct solvers are exact but can be O(n³) and fail on indefinite systems.
  • vs. Gradient-Based Methods: PGS is a specialized successive over-relaxation (SOR) method for LCPs, often more robust for contact problems than generic gradient descent.
  • vs. Its Variants: Sequential Impulse (SI) is a nearly identical method often used synonymously. Extended PGS (XPGS) and PGS with Shock Propagation are enhancements that improve convergence for challenging stacks and loops of constraints.
PHYSICS SIMULATION ENGINES

Frequently Asked Questions

The Projected Gauss-Seidel (PGS) solver is a core iterative algorithm in physics engines for resolving constraints like contact and joints. These questions address its mechanics, applications, and role in modern simulation.

The Projected Gauss-Seidel (PGS) solver is an iterative numerical method used in physics engines to resolve systems of inequality constraints, such as contact non-penetration and joint limits, by sequentially projecting solutions onto feasible sets.

It works by processing constraints one at a time in a loop. For each constraint (e.g., a contact point preventing two bodies from overlapping), the solver calculates an impulse or positional correction needed to satisfy that single constraint in isolation, ignoring others temporarily. This correction is "projected" to ensure it adheres to physical limits (e.g., contact forces must be non-adhesive, or friction must obey the Coulomb model). After updating the system state for that constraint, it moves to the next. This loop repeats for many iterations, allowing corrections to propagate through the system until all constraints are approximately satisfied within a tolerance.

Its sequential, local nature makes it highly efficient for parallel processing on GPUs, a key reason for its adoption in real-time engines like NVIDIA PhysX.

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.