opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
801 stars 324 forks source link

Adding stepwise regression feature to `PolynomialPathFitter` #3779

Closed nickbianco closed 6 months ago

nickbianco commented 6 months ago

Fixes issue #3761

[perf-win]

Brief summary of changes

Adds the option to use stepwise regression when fitting polynomial coefficients in PolynomialPathFitter. This approach fits polynomials using individual terms one at a time and keeps the terms that result in the lowest fitting error. Terms (and coefficients) are added until the path length and moment arm tolerances are achieved.

One key change was made to MultivariatePolynomialFunction: coefficients equal to zero are now ignored when evaluating polynomial functions to maximize speed.

Testing I've completed

Looking for feedback on...

CHANGELOG.md (choose one)

Performance analysis

Platform: Windows, self-hosted runner

Test Name lhs [secs] stderr [secs] rhs [secs] stderr [secs] Speedup
Arm26 0.35 0.00 0.36 0.00 0.97
ellipsoid_wrap 4.12 0.00 4.15 0.01 0.99
ellipsoid_wrap_function_based_paths 3.41 0.00 3.42 0.00 1.00
Gait2354 0.42 0.00 0.42 0.00 1.01
MocoSlidingMass 1.48 0.00 1.48 0.00 1.00
passive_dynamic 5.61 0.00 5.59 0.00 1.00
passive_dynamic_noanalysis 3.45 0.01 3.41 0.00 1.01
RajagopalModel 8.89 0.01 8.88 0.01 1.00
ToyDropLanding 13.38 0.01 13.41 0.00 1.00
ToyDropLanding_fbp_stepwisereg 13.91 0.07 12.31 0.01 1.13
ToyDropLanding_function_based_paths 12.43 0.01 12.51 0.03 0.99
ToyDropLanding_nomuscles 0.57 0.00 0.56 0.00 1.01

This change is Reviewable

nickbianco commented 6 months ago

Thanks @pepbos! I made some updates based on your comments. Unless you have any other comments, I'll merge after the tests pass.