Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lagrangian] Add regularization term in lagrangian constraints #5299

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

bakpaul
Copy link
Contributor

@bakpaul bakpaul commented Feb 28, 2025

This PR adds a way to add a regularization term (defined by a scalar $$r$$) during the "inversion" of $$\mathbf{W}$$ by the Gauss-Seidel by computing $$\mathbf{W}_{r} = \mathbf{W}+r\mathbf{I}$$.

This helps in configuration where the constraint set in unsolvable. It might also help for the convergence of the GS. The only thing to keep in mind is that it relaxes the equality meaning that now the constraints are not necessary solved entirely. This will cause issues when using generic collision detection because 0 interpenetration is not guaranteed (requires more skinning). It is better to use volume-based collision definition such as LDI for instance.

This PR adds a data named regularizationTerm to two types of objects :

  1. ConstraintSolvers:
    • GenericConstraintSolver
    • LCPConstraintSolver
  2. ConstraintCorrection:
    • GenericConstraintCorrection
    • LinearSolverConstraintCorrection
    • PrecomputedConstraintCorrection

I made sure that it also works for unbuilt version of both solvers.
It would have been sufficient to add it only for either the constraint solvers or the corrections. But this way we have the possibility to define a global regularization or a local one (see examples)

We could potentially also want to add this parameter to the component BilateralLagrangianConstraint and even to the CollisionModels because we might want to treat differently constraints applied on the same object. This is not a good idea, it comes from the current API that enables multiples ways of defining constraints, if all of the constraints where defined by only one unified pipeline we could do this by only having one version of the data in one level of the API.

An example of unsolvable constraint set is given in BilateralLagrangianConstraint_with_regularization_unsolvable.scn. The points of one face of a cube are attached to two different set of points:

regul

We can see that with the regularization, the solver finds the best compromise (in the middle), without it it never converges and you get the last configuration. When run apart, the regularized version runs at 689.44 FPS whereas the unregularized one runs at 94 FPS.


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@bakpaul bakpaul added pr: status to review To notify reviewers to review this pull-request pr: new feature Implement a new feature labels Feb 28, 2025
@hugtalbot
Copy link
Contributor

Wow wow wow, nice @bakpaul
[ci-build][with-all-tests]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: new feature Implement a new feature pr: status to review To notify reviewers to review this pull-request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants