Algorithmic differentiation improves the computational efficiency of OpenSim-based trajectory optimization of human movement

Autoři: Antoine Falisse aff001;  Gil Serrancolí aff002;  Christopher L. Dembia aff003;  Joris Gillis aff004;  Friedl De Groote aff001
Působiště autorů: Department of Movement Sciences, KU Leuven, Leuven, Belgium aff001;  Department of Mechanical Engineering, Universitat Politècnica de Catalunya, Barcelona, Catalunya, Spain aff002;  Department of Mechanical Engineering, Stanford University, Stanford, California, United States of America aff003;  Department of Mechanical Engineering, KU Leuven, Leuven, Belgium aff004;  DMMS Lab, Flanders Make, Leuven, Belgium aff005
Vyšlo v časopise: PLoS ONE 14(10)
Kategorie: Research Article
doi: 10.1371/journal.pone.0217730


Algorithmic differentiation (AD) is an alternative to finite differences (FD) for evaluating function derivatives. The primary aim of this study was to demonstrate the computational benefits of using AD instead of FD in OpenSim-based trajectory optimization of human movement. The secondary aim was to evaluate computational choices including different AD tools, different linear solvers, and the use of first- or second-order derivatives. First, we enabled the use of AD in OpenSim through a custom source code transformation tool and through the operator overloading tool ADOL-C. Second, we developed an interface between OpenSim and CasADi to solve trajectory optimization problems. Third, we evaluated computational choices through simulations of perturbed balance, two-dimensional predictive simulations of walking, and three-dimensional tracking simulations of walking. We performed all simulations using direct collocation and implicit differential equations. Using AD through our custom tool was between 1.8 ± 0.1 and 17.8 ± 4.9 times faster than using FD, and between 3.6 ± 0.3 and 12.3 ± 1.3 times faster than using AD through ADOL-C. The linear solver efficiency was problem-dependent and no solver was consistently more efficient. Using second-order derivatives was more efficient for balance simulations but less efficient for walking simulations. The walking simulations were physiologically realistic. These results highlight how the use of AD drastically decreases computational time of trajectory optimization problems as compared to more common FD. Overall, combining AD with direct collocation and implicit differential equations decreases the computational burden of trajectory optimization of human movement, which will facilitate their use for biomechanical applications requiring the use of detailed models of the musculoskeletal system.

Klíčová slova:

Algorithms – Musculoskeletal system – Optimization – Skeletal joints – Source code – Walking – Pendulums – Mumps


1. Kelly M. An introduction to trajectory optimization: how to do your own direct collocation. SIAM Rev. 2017;59(4):849–904.

2. van den Bogert AJ, Hupperets M, Schlarb H, Krabbe B. Predictive musculoskeletal simulation using optimal control: Effects of added limb mass on energy cost and kinematics of walking and running. P I Mech Eng P-J Spo. 2012;226(2):123–33.

3. Meyer AJ, Eskinazi I, Jackson JN, Rao A V., Patten C, Fregly BJ. Muscle synergies facilitate computational prediction of subject-specific walking motions. Front Bioeng Biotechnol. 2016;4:77. doi: 10.3389/fbioe.2016.00077 27790612

4. Lin Y-C, Pandy MG. Three-dimensional data-tracking dynamic optimization simulations of human locomotion generated by direct collocation. J Biomech. 2017;59:1–8. doi: 10.1016/j.jbiomech.2017.04.038 28583674

5. Anderson FC, Pandy MG. Dynamic optimization of human walking. J Biomech Eng. 2001;123(5):381–90. doi: 10.1115/1.1392310 11601721

6. Ackermann M, van den Bogert AJ. Optimality principles for model-based prediction of human gait. J Biomech. 2010;43(6):1055–60. doi: 10.1016/j.jbiomech.2009.12.012 20074736

7. Song S, Geyer H. A neural circuitry that emphasizes spinal feedback generates diverse behaviours of human locomotion. J Physiol. 2015;593(16):3493–511. doi: 10.1113/JP270228 25920414

8. Lin Y-C, Walter JP, Pandy MG. Predictive simulations of neuromuscular coordination and joint-contact loading in human gait. Ann Biomed Eng. 2018;46(8):1216–27. doi: 10.1007/s10439-018-2026-6 29671152

9. De Groote F, Pipeleers G, Jonkers I, Demeulenaere B, Patten C, Swevers J, et al. A physiology based inverse dynamic analysis of human gait: potential and perspectives. Comput Methods Biomech Biomed Engin. 2009;12(5):563–74. doi: 10.1080/10255840902788587 19319704

10. De Groote F, Kinney AL, Rao AV, Fregly BJ. Evaluation of direct collocation optimal control problem formulations for solving the muscle redundancy problem. Ann Biomed Eng. 2016;44(10):2922–36. doi: 10.1007/s10439-016-1591-9 27001399

11. Lee L-F, Umberger BR. Generating optimal control simulations of musculoskeletal movement using OpenSim and MATLAB. PeerJ. 2016;4:e1638. doi: 10.7717/peerj.1638 26835184

12. van den Bogert AJ, Blana D, Heinrich D. Implicit methods for efficient musculoskeletal simulation and optimal control. Procedia IUTAM. 2011;2:297–316. doi: 10.1016/j.piutam.2011.04.027 22102983

13. Wächter A, Biegler LT. On the implementation of an interior-point filter line-search algorithm for large-scale nonlinear programming. Math Program. 2006;106(1):25–57.

14. Griewank A, Walther A. Evaluating derivatives: principles and techniques of algorithmic differentiation. 2nd ed. SIAM; 2008. 448 p.

15. Nocedal J, Wright SJ. Calculating Derivatives. In: Mikosch T V., Resnick S I, Robinson SM, editors. Numerical Optimization. 2nd ed. Springer-Verlag New York; 2006. p. 193–219.

16. Gebremedhin AH, Manne F, Pothen A. What color is your Jacobian? Graph coloring for computing derivatives. SIAM Rev. 2005;47(4):629–705.

17. Andersson JAE. A general-purpose software framework for dynamic optimization. KU Leuven; 2013.

18. Walther A, Griewank A. Getting started with ADOL-C. In: Naumann U, Schenk O, editors. Combinatorial Scientific Computing. Chapman & Hall/CRC Computational Science; 2012. p. 181–202.

19. CppAD: A package for differentiation of C++ algorithms.

20. Weinstein MJ, Rao A V. A source transformation via operator overloading method for the automatic differentiation of mathematical functions in MATLAB. ACM Trans Math Softw. 2016;42(2):11:1–11:44.

21. Andersson JAE, Gillis J, Horn G, Rawlings JB, Diehl M. CasADi: a software framework for nonlinear optimization and optimal control. Math Program Comput. 2019;11(1):1–36.

22. Falisse A, Van Rossom S, Jonkers I, De Groote F. EMG-driven optimal estimation of subject-specific Hill model muscle-tendon parameters of the knee joint actuators. IEEE Trans Biomed Eng. 2017;64(9):2253–62. doi: 10.1109/TBME.2016.2630009 27875132

23. Patterson MA, Rao A V. GPOPS-II: a MATLAB software for solving multiple-phase optimal control problems using hp-adaptive Gaussian quadrature collocation methods and sparse nonlinear programming. ACM Trans Math Softw. 2014;41(1):1:1–1:37.

24. Delp SL, Anderson FC, Arnold AS, Loan P, Habib A, John CT, et al. OpenSim: open-source software to create and analyze dynamic simulations of movement. IEEE Trans Biomed Eng. 2007;54(11):1940–50. doi: 10.1109/TBME.2007.901024 18018689

25. Seth A, Hicks JL, Uchida TK, Habib A, Dembia CL, Dunne JJ, et al. OpenSim: simulating musculoskeletal dynamics and neuromuscular control to study human and animal movement. PLOS Comput Biol. 2018;14(7):e1006223. doi: 10.1371/journal.pcbi.1006223 30048444

26. Sherman MA, Seth A, Delp SL. Simbody: multibody dynamics for biomedical research. Procedia IUTAM. 2011;2:241–61. 25866705

27. Giftthaler M, Neunert M, Stäuble M, Frigerio M, Semini C, Buchli J. Automatic differentiation of rigid body dynamics for optimal control and estimation. Adv Robot. 2017;31(22):1225–37.

28. Tedrake R. and the Drake Development Team. Drake: model-based design and verification for robotics. 2019.

29. Docquier N, Poncelet A, Fisette P. ROBOTRAN: A powerful symbolic gnerator of multibody models. Mech Sci. 2013;4(1):199–219.

30. Wojtusch J, Kunz J, Stryk O Von. MBSlib-An efficient multibody systems library for kinematics and dynamics simulation, optimization and sensitivity analysis. IEEE Robot Autom Lett. 2016;1(2):954–60.

31. Carpentier J, Saurel G, Buondonno G, Mirabel J, Lamiraux F, Stasse O, et al. The Pinocchio C ++ library: A fast and flexible implementation of rigid body dynamics algorithms and their analytical derivatives. 2019 IEEE/SICE Int Symp Syst Integr. 2019;614–9.

32. Guennebaud G, Jacob B, Others. Eigen v3. 2010.

33. Abadi M, Agarwal A, Barham P, Brevdo E, Chen Z, Citro C, et al. TensorFlow: Large-Scale Machine Learning on Heterogeneous Distributed Systems. arXiv [Preprint] arXiv:160304467 Available online at: 2016;

34. The Theano Development Team, Al-Rfou R, Alain G, Almahairi A, Angermueller C, Bahdanau D, et al. Theano: A Python framework for fast computation of mathematical expressions. arXiv [Preprint] arXiv:160502688 Available online at: 2016;1–19.

35. Degrave J, Hermans M, Dambre J, Wyffels F. A differentiable physics engine for deep learning in robotics. Front Neurorobot. 2019;13(March):1–9.

36. Nocedal J, Wright SJ. Interior-point methods for nonlinear programming. In: Mikosch T V., Resnick S I, Robinson SM, editors. Numerical Optimization. 2nd ed. Springer-Verlag New York; 2006. p. 563–97.

37. Betts JT. The optimal control problem. In: Practical Methods for Optimal Control and Estimation Using Nonlinear Programming. 2nd ed. Philadelphia: SIAM; 2010. p. 123–218.

38. Hamner SR, Seth A, Delp SL. Muscle contributions to propulsion and support during running. J Biomech. 2010;43(14):2709–16. doi: 10.1016/j.jbiomech.2010.06.025 20691972

39. Koelewijn AD, Dorschky E, van den Bogert AJ. A metabolic energy expenditure model with a continuous first derivative and its application to predictive simulations of gait. Comput Methods Biomech Biomed Engin. 2018;21(8):521–31. doi: 10.1080/10255842.2018.1490954 30027769

40. Raasch CC, Zajac FE, Ma B, Levine WS. Muscle coordination of maximum-speed pedaling. J Biomech. 1997;30(96):595–602.

41. Zajac FE. Muscle and tendon: properties, models, scaling, and application to biomechanics and motor control. Crit Rev Biomed Eng. 1989;17(4):359–411. 2676342

42. van den Bogert AJ, Geijtenbeek T, Even-Zohar O, Steenbrink F, Hardin EC. A real-time system for biomechanical analysis of human movement and muscle function. Med Biol Eng Comput. 2013;51(10):1069–77. doi: 10.1007/s11517-013-1076-z 23884905

43. Amestoy PR, Duff IS, L’Excellent J-Y. Multifrontal parallel distributed symmetric and unsymmetric solvers. Comput Methods Appl Mech Eng. 2000;184(2–4):501–20.

44. HSL. A collection of Fortran codes for large scale scientific computation.

45. Bhargava LJ, Pandy MG, Anderson FC. A phenomenological model for estimating metabolic energy consumption in muscle contraction. J Biomech. 2004;37(1):81–8. doi: 10.1016/s0021-9290(03)00239-2 14672571

46. Nocedal J, Wright SJ. A regularization procedure. In: Mikosch T V., Resnick S I, Robinson SM, editors. Numerical Optimization. 2nd ed. Springer-Verlag New York; 2006. p. 635–6.

47. Gill PE, Murray W, Saunders MA. SNOPT: An SQP algorithm for large-scale constrained optimization. SIAM Rev. 2005;47(1):99–131.

48. Byrd RH, Nocedal J, Waltz RA. KNITRO: an integrated package for nonlinear optimization. In: Di Pillo G, Roma M, editors. Large Scale Nonlinear Optimization Nonconvex Optimization and Its Applications. Boston: Springer; 2006.

49. Limebeer DJN, Rao A V. Faster, higher, and greener: Vehicular optimal control. IEEE Control Syst Mag. 2015;35(2):36–56.

50. Hall C, Nester CJ. Sagittal plane compensations for artificially induced limitation of the first metatarsophalangeal joint: a preliminary study. J Am Podiatr Med Assoc. 2004;94(3):269–74. 15153589

51. Miller RH. A comparison of muscle energy models for simulating human walking in three dimensions. J Biomech. 2014;47(6):1373–81. doi: 10.1016/j.jbiomech.2014.01.049 24581797

Článek vyšel v časopise


2019 Číslo 10