opensim-org / opensim-core

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

Performance improvements for `MultivariatePolynomialFunction` and `PolynomialPathFitter` #3767

Closed nickbianco closed 2 months ago

nickbianco commented 2 months ago

Fixes issue #3759, #3762. Partially addresses #3761.

Brief summary of changes

This PR implements several performance improvements related to FunctionBasedPath by speeding up function evaluations in MultivariatePolynomialFunction and adding a few new options to PolynomialPathFitter. A brief list of the main changes:

Testing I've completed

Added related tests to testFunctions.cpp and testWrapping.cpp. A summery of the performance benchmarking is below (seeing a ~20-25% speed up).

Looking for feedback on...

CHANGELOG.md (choose one)

[perf-win]

Performance analysis

Platform: Windows, self-hosted runner

Test Name lhs [secs] stderr [secs] rhs [secs] stderr [secs] Speedup
Arm26 0.36 0.00 0.36 0.00 1.00
Gait2354 0.44 0.00 0.42 0.00 1.03
MocoSlidingMass 1.51 0.00 1.52 0.00 1.00
passive_dynamic 5.63 0.00 5.79 0.00 0.97
passive_dynamic_noanalysis 3.49 0.00 3.48 0.00 1.00
RajagopalModel 9.06 0.00 9.10 0.01 0.99
ToyDropLanding_function_based_paths 15.92 1.35 12.63 0.00 1.26
ToyDropLanding 13.68 0.01 13.72 0.01 1.00
ToyDropLanding_nomuscles 0.57 0.00 0.57 0.00 1.01

This change is Reviewable

nickbianco commented 2 months ago

@pepbos would you be interested in reviewing this? It is related to muscle wrapping and performance.