Add zero-iteration early exit to the primal solvers, certified by the duality gap.
The primal cost has curvature of at least M in every zone, making it strongly convex in the M-norm and bounding the suboptimality of any point by the Fenchel duality gap at its constraint forces: cost(qacc) - cost* <= 0.5*grad'*M^-1*grad Since M's factorization always exists, this certificate is evaluable before the solver does any work: one triangular solve and one dot product. When the warmstarted solution is already certified to satisfy the tolerance, CG and Newton now return with zero iterations; for Newton this skips building and factorizing the Hessian. If the certificate declines, Newton gets a second exit after factorization: the Newton decrement, checked before the first line search. Because the gap bounds cost suboptimality, stiff constraints can convert it into force errors of order sqrt(2*gap*stiffness). Newton solutions are characteristically force-accurate, so Newton zero-iteration exits also require the gradient criterion, preserving constraint-force accuracy at rest; CG solutions are characteristically cost-accurate and exit on the gap alone. On a settling pile of 50 boxes (300 dofs, ~200 contacts), end-to-end time per step drops 13% over a settle-then-rest run and 27% in the quiescent limit, with Newton iterations falling from 0.98 to 0.40 per step. Tests: WarmstartZeroIterations sweeps solver/cone/jacobian on a settled box, asserting zero iterations, forward/inverse consistency, and agreement with a tolerance=0 control solve from the same state. WarmstartZeroIterationsIslands checks per-island exits with a kicked box next to a settled one. RefsiteConservesMomentum now requests an exact solve (tolerance=0), since it asserts momentum conservation tighter than the solver tolerance contract. PiperOrigin-RevId: 947993735 Change-Id: I2fd855774bff619709b2c386f1ba2714286e0821
This commit is contained in:
committed by
Copybara-Service
parent
1e66efd114
commit
c69ef03083
@@ -418,9 +418,10 @@ adjust it properly through the XML.
|
||||
|
||||
:at:`iterations`: :at-val:`int, "100"`
|
||||
Maximum number of iterations of the constraint solver. When the warmstart attribute of :ref:`flag <option-flag>` is
|
||||
enabled (which is the default), accurate results are obtained with fewer iterations. Larger and more complex systems
|
||||
with many interacting constraints require more iterations. Note that mjData.solver contains statistics about solver
|
||||
convergence, also shown in the profiler.
|
||||
enabled (which is the default), accurate results are obtained with fewer iterations; if the warmstarted solution
|
||||
already satisfies the tolerance, the CG and Newton solvers terminate with zero iterations. Larger and more complex
|
||||
systems with many interacting constraints require more iterations. Note that mjData.solver contains statistics about
|
||||
solver convergence, also shown in the profiler.
|
||||
|
||||
.. _option-tolerance:
|
||||
|
||||
@@ -428,7 +429,9 @@ adjust it properly through the XML.
|
||||
Tolerance threshold used for early termination of the iterative solver. For PGS, the threshold is applied to the cost
|
||||
improvement between two iterations. For CG and Newton, it is applied to the smaller of the cost improvement and the
|
||||
gradient norm. For Newton, it is additionally applied to the Newton decrement :math:`\tfrac{1}{2} g^T H^{-1} g`, the
|
||||
predicted cost improvement of the next iteration. Set the tolerance to 0 to disable early termination.
|
||||
predicted cost improvement of the next iteration. Before the first iteration, CG and Newton also apply it to a
|
||||
:ref:`convergence certificate<soAlgorithms>` of the warmstarted solution, possibly terminating with zero iterations.
|
||||
Set the tolerance to 0 to disable early termination.
|
||||
|
||||
.. _option-ls_iterations:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user