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

Implement a Velocity-Implicit Euler Integrator to speed up Jacobian construction and factorization #12528

Closed
antequ opened this issue Jan 3, 2020 · 2 comments

Comments

@antequ
Copy link
Contributor

antequ commented Jan 3, 2020

For second-order dynamical systems, we can implement implicit euler using Newton's method on the velocity and miscellaneous states and fixed-point iteration on the position states. This will speed up Jacobian computation and factorization. Details of this method are here: https://docs.google.com/document/d/118J6rkR9ghh2_3WY0O5EDXhfkgMOXXqTQ2usrhICv30/edit . All of this document will be transferred into doxygen or comments in the code.

This issue tracks the progress of a proposed four-PR train to merge my implementation of this integrator.

  • The first PR refactors common tests for implicit integrators.
  • The second PR implements the fixed-step version with forward differencing for Jacobian computation.
  • The third PR implements error control.
  • The fourth PR adds autodiff and central differencing.

Tagging +@sherm1 , +@edrumwri , +@amcastro-tri for visibility

@antequ antequ self-assigned this Jan 3, 2020
@antequ
Copy link
Contributor Author

antequ commented Jan 3, 2020

PR #12202 contains the initial WIP. Do NOT review that PR.

antequ added a commit to antequ/drake-1 that referenced this issue Jan 18, 2020
Change the tests in systems/analysis in the following ways in preparation for the new velocity-implicit Euler integrator (RobotLocomotion#12528):

1. Fix the incorrect velocity in the true solution in StiffDoubleMassSpring, as well as the incorrect damping force calculation in f2 in StiffDoubleMassSpring.
2. Add a velocity solution check to DoubleSpringMassDamperTest.
3. Move common tests from implicit_euler_integrator_test.cc and radau_integrator_test.cc into implicit_integrator_test.h
4. Add two flags into implicit_integrator_test.h to modify or skip tests based on whether an implicit integrator supports Error Control, Autodiff, and Central differencing. By default for existing integrators, all these flags are turned on and the tests are ran in full capability.

The purpose of the fourth change is so that I can separate the new integrator into three different PRs: When the fixed-step integrator is merged, it will run the tests without error control or auto/center diff. When the Error control is merged, it will run the tests with error control. When the full integrator is merged, it'll run the tests with all flags turned on.
By default for other integrators the tests run with full capability. I've tested locally to make sure that my fixed-step version, with error control removed, passes the tests with the flags turned off.
antequ added a commit that referenced this issue Jan 18, 2020
* Refactor implicit integration tests

Change the tests in systems/analysis in the following ways in preparation for the new velocity-implicit Euler integrator (#12528):

1. Fix the incorrect velocity in the true solution in StiffDoubleMassSpring, as well as the incorrect damping force calculation in f2 in StiffDoubleMassSpring.
2. Add a velocity solution check to DoubleSpringMassDamperTest.
3. Move common tests from implicit_euler_integrator_test.cc and radau_integrator_test.cc into implicit_integrator_test.h
4. Add two flags into implicit_integrator_test.h to modify or skip tests based on whether an implicit integrator supports Error Control, Autodiff, and Central differencing. By default for existing integrators, all these flags are turned on and the tests are ran in full capability.

The purpose of the fourth change is so that I can separate the new integrator into three different PRs: When the fixed-step integrator is merged, it will run the tests without error control or auto/center diff. When the Error control is merged, it will run the tests with error control. When the full integrator is merged, it'll run the tests with all flags turned on.
By default for other integrators the tests run with full capability. I've tested locally to make sure that my fixed-step version, with error control removed, passes the tests with the flags turned off.
antequ added a commit to antequ/drake-1 that referenced this issue Jan 24, 2020
With the new Velocity-Implicit Integrator Euler integrator RobotLocomotion#12528, we will have at least four implementations of Newton-Raphson iterations in our implicit integrators. This PR:

    Moves the convergence check in each iteration, which was written based on Hairer 1996, from each implicit integrator into the parent class ImplicitIntegrator.

In other words, it refactors the easiest component, the convergence check, and makes the convergence behavior consistent between the integrators. It will also simplify PR RobotLocomotion#12543 by moving the logic for this convergence check to a common location.
antequ added a commit to antequ/drake-1 that referenced this issue Jan 24, 2020
With the new Velocity-Implicit Integrator Euler integrator RobotLocomotion#12528, we will have at least four implementations of Newton-Raphson iterations in our implicit integrators. This PR:

    Moves the convergence check in each iteration, which was written based on Hairer 1996, from each implicit integrator into the parent class ImplicitIntegrator.

In other words, it refactors the easiest component, the convergence check, and makes the convergence behavior consistent between the integrators. It will also simplify PR RobotLocomotion#12543 by moving the logic for this convergence check to a common location.
antequ added a commit to antequ/drake-1 that referenced this issue Jan 24, 2020
With the new Velocity-Implicit Integrator Euler integrator RobotLocomotion#12528, we will have at least four implementations of Newton-Raphson iterations in our implicit integrators. This PR:

    Moves the convergence check in each iteration, which was written based on Hairer 1996, from each implicit integrator into the parent class ImplicitIntegrator.

In other words, it refactors the easiest component, the convergence check, and makes the convergence behavior consistent between the integrators. It will also simplify PR RobotLocomotion#12543 by moving the logic for this convergence check to a common location.
amcastro-tri pushed a commit that referenced this issue Jan 25, 2020
With the new Velocity-Implicit Integrator Euler integrator #12528, we will have at least four implementations of Newton-Raphson iterations in our implicit integrators. This PR:

    Moves the convergence check in each iteration, which was written based on Hairer 1996, from each implicit integrator into the parent class ImplicitIntegrator.

In other words, it refactors the easiest component, the convergence check, and makes the convergence behavior consistent between the integrators. It will also simplify PR #12543 by moving the logic for this convergence check to a common location.
antequ added a commit to antequ/drake-1 that referenced this issue Feb 7, 2020
…ptions.

This PR adds a fixed-step implementation of the new first-order Velocity-Implicit Euler Integrator (Issue RobotLocomotion#12528). This is the second PR out of four.

The documentation is based on the equations listed here: https://docs.google.com/document/d/118J6rkR9ghh2_3WY0O5EDXhfkgMOXXqTQ2usrhICv30/edit
antequ added a commit to antequ/drake-1 that referenced this issue Feb 15, 2020
…ptions.

This PR adds a fixed-step implementation of the new first-order Velocity-Implicit Euler Integrator (Issue RobotLocomotion#12528). This is the second PR out of four.

The documentation is based on the equations listed here: https://docs.google.com/document/d/118J6rkR9ghh2_3WY0O5EDXhfkgMOXXqTQ2usrhICv30/edit
antequ added a commit that referenced this issue Feb 15, 2020
* Velocity-Implicit Euler Fixed Steps. Simplified code and added descriptions.

This PR adds a fixed-step implementation of the new first-order Velocity-Implicit Euler Integrator (Issue #12528). This is the second PR out of four.

The documentation is based on the equations listed here: https://docs.google.com/document/d/118J6rkR9ghh2_3WY0O5EDXhfkgMOXXqTQ2usrhICv30/edit
antequ added a commit to antequ/drake-1 that referenced this issue Feb 21, 2020
…obotLocomotion#12528

This commit:
  1. Implements error control by taking two half-sized steps and estimating the error as the difference between the solution from the large step and the solution from two half-sized steps.
  2. Changes IntegratorBase to report statistics on the small steps for any steps "taken", while the error control and step-size limit logic still operates on the large step size.
  3. Updates documentation to explain the statistics and derive the error estimation order.
  4. (Passive) Enables the error-control tests for VelocityImplicitEulerTest, by turning on the supports_error_estimation() flag.
antequ added a commit to antequ/drake-1 that referenced this issue Mar 6, 2020
…obotLocomotion#12528

This commit:
  1. Implements error control by taking two half-sized steps and estimating the error as the difference between the solution from the large step and the solution from two half-sized steps.
  2. Changes IntegratorBase to report statistics on the small steps for any steps "taken", while the error control and step-size limit logic still operates on the large step size.
  3. Updates documentation to explain the statistics and derive the error estimation order.
  4. (Passive) Enables the error-control tests for VelocityImplicitEulerTest, by turning on the supports_error_estimation() flag.
antequ added a commit to antequ/drake-1 that referenced this issue Mar 20, 2020
…obotLocomotion#12528

This commit:
  1. Implements error control by taking two half-sized steps and estimating the error as the difference between the solution from the large step and the solution from two half-sized steps.
  2. Changes IntegratorBase to report statistics on the small steps for any steps "taken", while the error control and step-size limit logic still operates on the large step size.
  3. Updates documentation to explain the statistics and derive the error estimation order.
  4. (Passive) Enables the error-control tests for VelocityImplicitEulerTest, by turning on the supports_error_estimation() flag.
antequ added a commit to antequ/drake-1 that referenced this issue Mar 20, 2020
…obotLocomotion#12528

This commit:
  1. Implements error control by taking two half-sized steps and estimating the error as the difference between the solution from the large step and the solution from two half-sized steps.
  2. Changes IntegratorBase to report statistics on the small steps for any steps "taken", while the error control and step-size limit logic still operates on the large step size.
  3. Updates documentation to explain the statistics and derive the error estimation order.
  4. (Passive) Enables the error-control tests for VelocityImplicitEulerTest, by turning on the supports_error_estimation() flag.
antequ added a commit to antequ/drake-1 that referenced this issue Mar 27, 2020
…obotLocomotion#12528

This commit:
  1. Implements error control by taking two half-sized steps and estimating the error as the difference between the solution from the large step and the solution from two half-sized steps.
  2. Changes IntegratorBase to report statistics on the small steps for any steps "taken", while the error control and step-size limit logic still operates on the large step size.
  3. Updates documentation to explain the statistics and derive the error estimation order.
  4. (Passive) Enables the error-control tests for VelocityImplicitEulerTest, by turning on the supports_error_estimation() flag.
antequ added a commit to antequ/drake-1 that referenced this issue Mar 27, 2020
…obotLocomotion#12528

This commit:
  1. Implements error control by taking two half-sized steps and estimating the error as the difference between the solution from the large step and the solution from two half-sized steps.
  2. Changes IntegratorBase to report statistics on the small steps for any steps "taken", while the error control and step-size limit logic still operates on the large step size.
  3. Updates documentation to explain the statistics and derive the error estimation order.
  4. (Passive) Enables the error-control tests for VelocityImplicitEulerTest, by turning on the supports_error_estimation() flag.

checkpoint documentation editing

addressed review comments and fixed derivations

spacing

fixed more minor mistakes

minor comment fix for supports_error_estimation

touched up a few equations

fixed documentation by adding summary

added comments
antequ added a commit to antequ/drake-1 that referenced this issue Mar 27, 2020
…obotLocomotion#12528

This commit:
  1. Implements error control by taking two half-sized steps and estimating the error as the difference between the solution from the large step and the solution from two half-sized steps.
  2. Changes IntegratorBase to report statistics on the small steps for any steps "taken", while the error control and step-size limit logic still operates on the large step size.
  3. Updates documentation to explain the statistics and derive the error estimation order.
  4. (Passive) Enables the error-control tests for VelocityImplicitEulerTest, by turning on the supports_error_estimation() flag.
antequ added a commit to antequ/drake-1 that referenced this issue Mar 27, 2020
…obotLocomotion#12528

This commit:
  1. Implements error control by taking two half-sized steps and estimating the error as the difference between the solution from the large step and the solution from two half-sized steps.
  2. Changes IntegratorBase to report statistics on the small steps for any steps "taken", while the error control and step-size limit logic still operates on the large step size.
  3. Updates documentation to explain the statistics and derive the error estimation order.
  4. (Passive) Enables the error-control tests for VelocityImplicitEulerTest, by turning on the supports_error_estimation() flag.
  5. Removes TODO(antequ)s asking to remove non-error-controlled test parameters in the implicit_integrator_test.h file, because we decided to keep these tests in case we implement non-error-controlled integrators in the future.
antequ added a commit that referenced this issue Mar 28, 2020
…12528 (#12760)

Add Error Control to Velocity-Implicit Euler Integrator - third PR of #12528

This commit:
  1. Implements error control by taking two half-sized steps and estimating the error as the difference between the solution from the large step and the solution from two half-sized steps.
  2. Changes IntegratorBase to report statistics on the small steps for any steps "taken", while the error control and step-size limit logic still operates on the large step size.
  3. Updates documentation to explain the statistics and derive the error estimation order.
  4. (Passive) Enables the error-control tests for VelocityImplicitEulerTest, by turning on the supports_error_estimation() flag.
  5. Removes TODO(antequ)s asking to remove non-error-controlled test parameters in the implicit_integrator_test.h file, because we decided to keep these tests in case we implement non-error-controlled integrators in the future.
antequ added a commit to antequ/drake-1 that referenced this issue Mar 30, 2020
…egrator, fourth PR of RobotLocomotion#12528

This commit:
1. Adds automatic differentiation as a velocity-Jacobian computation scheme for the velocity-implicit Euler integrator, by following the model of ImplicitIntegrator<T>::ComputeAutoDiffJacobian().
2. Refactors ComputeLOfY() based on the templated <U> IntegratorBase<T>::EvalTimeDerivatives() to enable this computation.
3. Fixes the tests so that they reset integrators between testing the different Jacobian computation schemes, to force Jacobian recomputations.
4. Removes the boolean flags that skip tests that require AutoDiff'd Jacobians.
antequ added a commit to antequ/drake-1 that referenced this issue Apr 10, 2020
…egrator, fourth PR of RobotLocomotion#12528

This commit:
1. Adds automatic differentiation as a velocity-Jacobian computation scheme for the velocity-implicit Euler integrator, by following the model of ImplicitIntegrator<T>::ComputeAutoDiffJacobian().
2. Refactors ComputeLOfY() based on the templated <U> IntegratorBase<T>::EvalTimeDerivatives() to enable this computation.
3. Fixes the tests so that they reset integrators between testing the different Jacobian computation schemes, to force Jacobian recomputations.
4. Removes the boolean flags that skip tests that require AutoDiff'd Jacobians.
antequ added a commit to antequ/drake-1 that referenced this issue Apr 17, 2020
…egrator, fourth PR of RobotLocomotion#12528

This commit:
1. Adds automatic differentiation as a velocity-Jacobian computation scheme for the velocity-implicit Euler integrator, by following the model of ImplicitIntegrator<T>::ComputeAutoDiffJacobian().
2. Refactors ComputeLOfY() based on the templated <U> IntegratorBase<T>::EvalTimeDerivatives() to enable this computation.
3. Fixes the tests so that they reset integrators between testing the different Jacobian computation schemes, to force Jacobian recomputations.
4. Removes the boolean flags that skip tests that require AutoDiff'd Jacobians.
antequ added a commit to antequ/drake-1 that referenced this issue Apr 17, 2020
…egrator, fourth PR of RobotLocomotion#12528

This commit:
1. Adds automatic differentiation as a velocity-Jacobian computation scheme for the velocity-implicit Euler integrator, by following the model of ImplicitIntegrator<T>::ComputeAutoDiffJacobian().
2. Refactors ComputeLOfY() based on the templated <U> IntegratorBase<T>::EvalTimeDerivatives() to enable this computation.
3. Fixes the tests so that they reset integrators between testing the different Jacobian computation schemes, to force Jacobian recomputations. Filed RobotLocomotion#13069 so that this will not be needed in the future.
4. Removes the boolean flags that skip tests that require AutoDiff'd Jacobians.
antequ added a commit that referenced this issue Apr 17, 2020
…egrator, fourth PR of #12528 (#12967)

Add Automatic Differentiated Jacobians to Velocity-Implicit Euler Integrator, fourth PR of #12528

This commit:
1. Adds automatic differentiation as a velocity-Jacobian computation scheme for the velocity-implicit Euler integrator, by following the model of ImplicitIntegrator<T>::ComputeAutoDiffJacobian().
2. Refactors ComputeLOfY() based on the templated <U> IntegratorBase<T>::EvalTimeDerivatives() to enable this computation.
3. Fixes the tests so that they reset integrators between testing the different Jacobian computation schemes, to force Jacobian recomputations. Filed #13069 so that this will not be needed in the future.
4. Removes the boolean flags that skip tests that require AutoDiff'd Jacobians.
@sherm1 sherm1 added the component: simulator Simulator, integrators, and supporting code label May 11, 2020
@jwnimmer-tri jwnimmer-tri assigned sherm1 and unassigned antequ Nov 11, 2021
@sherm1
Copy link
Member

sherm1 commented Nov 11, 2021

We do have this integrator in Drake now.

@sherm1 sherm1 closed this as completed Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants