A constraint-based solver is a numerical algorithm within a physics engine that calculates the forces required to satisfy a set of kinematic and dynamic constraints, such as joint limits or the non-penetration of contacting bodies. It typically formulates the problem as a Linear Complementarity Problem (LCP) or a similar optimization to find a physically consistent solution for all interacting objects at each simulation time step.
Glossary
Constraint-Based Solver

What is a Constraint-Based Solver?
A core algorithm in physics engines that enforces physical rules by solving numerical optimization problems.
In robotics simulation, this solver is fundamental for accurate contact dynamics and articulated body motion. Unlike simpler penalty-based methods, it directly enforces constraints, producing stable, jitter-free simulations essential for training robust control policies and enabling reliable sim-to-real transfer of robotic behaviors learned in virtual environments.
Key Characteristics of Constraint-Based Solvers
Constraint-based solvers are the numerical core of high-fidelity physics engines, responsible for calculating forces to satisfy physical interactions like joint limits and object contacts. Their design directly impacts simulation stability, speed, and physical accuracy.
Constraint Formulation
The solver's first step is to mathematically define the constraints the system must satisfy. These are typically expressed as equalities (e.g., g(q) = 0 for a fixed joint) or inequalities (e.g., h(q) ≥ 0 for non-penetration). Common constraint types include:
- Holonomic constraints (dependent on position only, like a hinge joint).
- Non-holonomic constraints (dependent on velocity, like a wheel's rolling constraint).
- Unilateral constraints (inequality constraints for contacts). The precision of this formulation determines the physical realism of interactions like stacking and grasping.
Linear Complementarity Problem (LCP)
Many constraint-based solvers, especially for rigid-body contact, reduce to solving a Linear Complementarity Problem (LCP). An LCP finds vectors w and z that satisfy:
w = Mz + q
w ≥ 0, z ≥ 0
wᵀz = 0
Here, M is a matrix encoding system inertia and constraint geometry, q encodes external forces and violation, z represents constraint impulses/forces, and w represents relative velocities. The complementarity condition (wᵀz = 0) elegantly models the on/off nature of contact: forces exist only when bodies are touching (velocity = 0). Solvers like Projected Gauss-Seidel (PGS) are commonly used to iteratively solve this.
Iterative vs. Direct Solution Methods
Solvers use two primary numerical approaches:
- Iterative Methods (e.g., PGS, Jacobi): Make successive approximations to the solution. They are generally faster for large systems (many contacts) and can handle indefinite matrices but may converge slowly for high-friction or ill-conditioned problems.
- Direct Methods (e.g., Pivoting, Dantzig): Attempt to compute an exact solution in a finite number of steps. They are more accurate and robust for small, challenging systems but have higher computational complexity (O(n³)), making them less suitable for dense, real-time simulations with hundreds of contacts.
Baumgarte Stabilization
A critical technique for handling constraint drift, where numerical integration errors cause constraints (like a joint) to slowly violate over time. Baumgarte stabilization adds corrective penalty terms to the velocity-level constraint equation:
Ċ + αC + β∫C dt = 0
Where C is the position-level constraint error. The parameters α and β act like a PD controller, applying virtual forces to pull the system back to a valid state. While effective, poor tuning can make the simulation appear "springy" or add unwanted damping, creating a trade-off between stability and physical accuracy.
Warm Starting
A performance optimization where the solver initializes its solution vector with values from the previous simulation time step. Since object positions and contact configurations change gradually between frames, the required constraint forces are often similar. Warm starting provides the iterative solver with a high-quality initial guess, significantly reducing the number of iterations needed for convergence. This is essential for achieving real-time performance in complex scenes with persistent contacts, such as a robot hand grasping an object.
Constraint Force Mixing (CFM) & Error Reduction Parameter (ERP)
Two key parameters that soften constraints to improve numerical stability.
- Constraint Force Mixing (CFM): Adds a virtual "spring" to the constraint, making the system matrix positive definite and thus easier to solve. It effectively allows constraints to be slightly violated in exchange for solver robustness.
- Error Reduction Parameter (ERP): Controls the rate at which constraint error is corrected per time step, similar to Baumgarte stabilization. An ERP of 1 attempts to correct all error in one step; lower values correct it over multiple steps. Tuning CFM and ERP is a fundamental part of configuring engines like Bullet or ODE to prevent jittering or "exploding" simulations.
Constraint-Based vs. Penalty-Based Methods
A comparison of the two primary numerical approaches for enforcing physical constraints, such as joint limits and non-penetration, within a physics engine's time step.
| Feature / Metric | Constraint-Based Method | Penalty-Based Method |
|---|---|---|
Core Numerical Formulation | Solves a Linear Complementarity Problem (LCP) or Quadratic Program (QP) to find constraint-satisfying forces. | Adds virtual spring-damper forces at constraint violations; solves a standard equation of motion. |
Constraint Satisfaction | ||
Exact Enforcement | Hard constraints are enforced to within solver tolerance (e.g., < 0.01 mm penetration). | Constraints are approximated; persistent small violations (e.g., 0.1-1 mm penetration) are typical. |
Numerical Stiffness | Moderate. Depends on the condition of the constraint Jacobian. | High. Requires small time steps to maintain stability of stiff spring forces. |
Computational Cost per Step | Higher. Requires solving a constrained optimization problem. | Lower. Involves calculating explicit forces and solving an unconstrained system. |
Stability with Large Time Steps | Good. Solution remains physically valid even with Δt > 1 ms. | Poor. Requires very small Δt (often < 0.5 ms) to prevent explosive instability. |
Handling of Complex Contact (e.g., Stacking) | Excellent. Natively models complementarity (force only when in contact). | Poor. Prone to jitter, sinking, and energy gain in multi-contact scenarios. |
Implementation Complexity | High. Requires specialized solvers (e.g., PGS, Dantzig). | Low. Can be implemented with standard ODE integration. |
Typical Use Case | High-fidelity robotic simulation (MuJoCo, Bullet). | Real-time applications with simple geometry (video games, early simulators). |
Physics Engines Using Constraint-Based Solvers
A constraint-based solver is the core algorithm in a physics engine that calculates forces to satisfy kinematic and dynamic constraints, such as joint limits or contact non-penetration, by solving a numerical optimization problem like a Linear Complementarity Problem (LCP).
The Linear Complementarity Problem (LCP)
The Linear Complementarity Problem (LCP) is the canonical mathematical formulation at the heart of most constraint-based solvers. It solves for unknown forces (λ) that satisfy a set of complementarity conditions derived from physical laws:
- Non-penetration: Contact forces must be zero when objects are separating and positive when in contact.
- Friction Cone: Frictional forces must lie within a cone defined by the coefficient of friction and the normal force. The solver finds a solution where λ ≥ 0, Aλ + b ≥ 0, and λᵀ(Aλ + b) = 0, where matrix A encodes system inertia and constraint geometry, and vector b encodes relative velocities and biases.
Constraint Types: From Joints to Contacts
Constraint-based solvers handle diverse physical interactions by modeling them as mathematical constraints:
- Holonomic Constraints: Define fixed geometric relationships, like a revolute joint enforcing a constant distance between two body attachment points.
- Non-Holonomic Constraints: Involve velocities, like a wheel that cannot slip sideways.
- Inequality Constraints: Model unilateral contacts and joint limits. A contact constraint is an inequality that prevents inter-penetration (gap ≥ 0) but allows separation. The solver's job is to compute the Lagrange multipliers (constraint forces) that satisfy all these conditions simultaneously at each time step.
Numerical Solution: Projected Gauss-Seidel (PGS)
Projected Gauss-Seidel (PGS) is a widely used iterative algorithm for solving the LCP in real-time physics engines. Instead of solving all constraints simultaneously in one large matrix operation (which is computationally expensive), PGS solves constraints one-at-a-time in a loop:
- It iterates over each constraint, solving for its force while treating forces from other constraints as fixed.
- After each local solve, it immediately projects the solution to enforce limits (e.g., force must be non-negative).
- This process repeats for multiple iterations until convergence. PGS is favored for its simplicity, low memory footprint, and warm-starting capability (using the solution from the previous time step as an initial guess).
Impulse vs. Force-Based Resolution
Constraint solvers can operate in the velocity/impulse domain or the acceleration/force domain, leading to different stability characteristics:
- Impulse-Based (Velocity-Level): Solves for instantaneous velocity changes (impulses) to satisfy constraints. This method directly corrects penetration by applying impulses that separate objects. It's common in game physics engines for its simplicity in handling stacking and resting contacts.
- Force-Based (Acceleration-Level): Solves for constraint forces over the time step, integrating them to update velocities and positions. This approach is more physically accurate and stable for stiff systems like precise robotic manipulators but can be more computationally intensive. Hybrid approaches, like the Sequential Impulse method, are also prevalent.
Primary Engines: MuJoCo & Bullet
Key physics engines renowned for their constraint-based solvers:
- MuJoCo (Multi-Joint dynamics with Contact): Uses a primal constraint formulation and a custom Newton-type solver. Its constraint model is exceptionally smooth, avoiding the "hard" boundaries of traditional LCPs, which facilitates stable simulation and efficient gradient computation for reinforcement learning. It natively supports equality, inequality, and elliptic (friction cone) constraints.
- Bullet Physics: Employs a Sequential Impulse solver, a variant of PGS. It is highly optimized for gaming and robotics, featuring a split impulse method for persistent contact stacking and support for various constraint types through its Generic 6-Dof Constraint.
- ODE (Open Dynamics Engine): Uses a Dantzig LCP solver for more accurate, but slower, solutions and a QuickStep PGS solver for real-time performance.
Advantages for Robotic Simulation
Constraint-based solvers are preferred in high-fidelity robotic simulation due to key advantages:
- Stability with Persistent Contact: They excel at simulating stable stacking, grasping, and locomotion—scenarios where bodies are in continuous contact—without the jitter or energy drift common in penalty-based methods.
- Physical Accuracy: By directly enforcing non-penetration and friction laws as constraints, they produce more physically plausible contact forces and motions.
- Deterministic & Differentiable: Modern implementations, like MuJoCo's, provide deterministic outputs (critical for reproducible research) and are differentiable, enabling gradient-based optimization for control and system identification.
- Native Joint Modeling: Robot joints (revolute, prismatic) are naturally modeled as equality constraints, providing a unified framework for both dynamics and kinematics.
Frequently Asked Questions
A constraint-based solver is a core algorithmic component of physics engines for robotic simulation. It calculates the forces necessary to satisfy kinematic and dynamic constraints, such as joint limits and contact non-penetration, enabling physically accurate virtual interactions.
A constraint-based solver is an algorithm within a physics engine that calculates forces to satisfy kinematic and dynamic constraints, such as preventing interpenetration at contact points or enforcing joint limits. It works by formulating the physical interactions as a numerical optimization problem, often a Linear Complementarity Problem (LCP) or a system of equations derived from Lagrange multipliers. At each simulation time step, the solver processes all active constraints, computes the necessary impulses or forces to resolve them (e.g., a normal force to push two colliding objects apart), and updates the system's velocities and positions to produce physically plausible motion.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
A constraint-based solver is a core component of a physics engine. To understand its role and function, it's essential to grasp the related computational concepts and simulation frameworks it interacts with.
Physics Engine
A physics engine is the overarching software library that simulates Newtonian mechanics. It integrates several subsystems:
- Rigid-Body Dynamics: Calculates motion from forces.
- Collision Detection: Identifies object intersections.
- Constraint-Based Solver: The component that resolves contacts and joints by calculating constraint forces. Engines like MuJoCo and Bullet are built around this architecture, where the solver is the computational core for handling interactions.
Contact Dynamics
Contact dynamics is the specific physical phenomenon a constraint-based solver must model. It involves calculating the forces that prevent interpenetration and account for friction when objects touch.
- Non-penetration Constraint: The solver ensures objects do not pass through each other.
- Friction Cone: A constraint modeling the allowable tangential forces based on a friction coefficient.
- Restitution: Models bounciness upon collision. The solver's job is to find a set of forces that satisfy all these contact constraints simultaneously, often formulated as a Linear Complementarity Problem (LCP).
Forward & Inverse Dynamics
These are the two fundamental modes of dynamic calculation that frame the solver's role.
- Forward Dynamics: Calculates a robot's acceleration given applied forces/torques. A constraint-based solver is invoked during this calculation to incorporate contact forces.
- Inverse Dynamics: Calculates the forces/torques needed to achieve a desired acceleration. While often constraint-free, it can be extended to include contact forces, again relying on a solver. The Featherstone Algorithm is a famous O(n) method for computing these dynamics for serial chains, which may integrate with a constraint solver for closed-loop systems or contacts.
Linear Complementarity Problem (LCP)
The Linear Complementarity Problem (LCP) is a canonical mathematical formulation for many constraint-based solvers. It finds vectors w and z such that:
w = Mz + q, w ≥ 0, z ≥ 0, and wᵀz = 0.
In physics simulation:
- z represents unknown constraint impulses or forces.
- w represents relative velocities at contacts.
- The complementarity condition (
wᵀz = 0) enforces that a force can only be positive when the bodies are in contact (w=0), and if bodies are separating (w>0), the force must be zero. Solvers like the Projected Gauss-Seidel method are common iterative solutions to this problem.
Simulation Fidelity & the Reality Gap
The accuracy of a constraint-based solver directly impacts simulation fidelity—how well virtual dynamics match reality. Inaccuracies in contact resolution (e.g., poor friction modeling) are a primary source of the reality gap. Techniques to bridge this gap include:
- Domain Randomization: Varying solver parameters (like friction coefficients) during training to create robust policies.
- System Identification: Tuning solver parameters to match real-world robot data. High-fidelity solvers are critical for valid Sim2Real transfer, as contact interactions are often the hardest to model correctly.
Time Stepping & Numerical Integration
A constraint-based solver operates within a time-stepping scheme. The simulation advances in discrete Δt steps:
- Detect collisions.
- Formulate constraints for contacts and joints.
- Solve the constraint problem to compute impulses/forces.
- Integrate accelerations to update velocities and positions. The solver must be fast and stable within this loop. Fixed-step solvers are preferred for deterministic simulation, crucial for reproducible robotics research. The choice of integrator (e.g., semi-implicit Euler) interacts closely with the constraint resolution method.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us