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 307 forks source link

Update to latest CasADi interface for specifying Jacobian sparsity #3807

Closed nickbianco closed 2 weeks ago

nickbianco commented 3 weeks ago

Fixes issue #3801

Brief summary of changes

Updates Moco's CasADi-based optimal control library to use the most recent interface for specifying Jacobian sparsity. Previously, CasADi functions expected get_jacobian_sparsity() to return the full sparsity pattern for the function. Now, the interface requires implementing get_jac_sparsity(casadi_int oind, casadi_int iind, bool symmetric) which should return the sparsity for a given output index (oind) and input index (iind); we ignore the symmetric flag.

This PR also updates the CasADi version to 3.6.5, now that we use the latest Jacobian sparsity interface.

Testing I've completed

Checked that exampleMocoInverse produced the same number of non-zero elements in the Jacobian as in CasADi 3.5.5.

Looking for feedback on...

CHANGELOG.md (choose one)

[perf-win]


This change is Reviewable

aymanhab commented 2 weeks ago

@nickbianco Thanks, if there's nothing more that can be done to document this logic then let me know and I'll approve the PR.

nickbianco commented 2 weeks ago

@aymanhab I added some comments to document the sparsity changes. I think this is sufficient since this changes are pretty low-level.

nickbianco commented 2 weeks ago

Thanks @aymanhab! I'm cleaning up the experimenting that I was doing with the CI here. I'll merge after verifying that the Mac and Ubuntu's are passing and that the Windows failures are unrelated to the present changes.

nickbianco commented 2 weeks ago

CI cleaned up and test failures unrelated. Merging.

aymanhab commented 2 weeks ago

🥇