Skip to content

Added: NonLinMPC and MovingHorizonEstimator now use value_and_gradient!/jacobian! of DI.jl #197

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

Merged
merged 7 commits into from
Apr 28, 2025

Conversation

franckgaga
Copy link
Member

@franckgaga franckgaga commented Apr 28, 2025

This theoretically more efficient than calling the objective/constraint functions and DI.jacobian!/DI.gradient! separately. For AutoForwardDiff backend, this feature is similar to DiffResult.jl.

@franckgaga franckgaga changed the title Added: NonLinMPC and MovingHorizonEstimator now use value_and_jacobian! of DI.jl Added: NonLinMPC and MovingHorizonEstimator now use value_and_gradient!/jacobian! of DI.jl Apr 28, 2025
@codecov-commenter
Copy link

codecov-commenter commented Apr 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.81%. Comparing base (b6341bc) to head (282010a).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #197      +/-   ##
==========================================
- Coverage   98.90%   98.81%   -0.10%     
==========================================
  Files          25       25              
  Lines        4220     4223       +3     
==========================================
- Hits         4174     4173       -1     
- Misses         46       50       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@franckgaga
Copy link
Member Author

franckgaga commented Apr 28, 2025

This is also more efficient in practice. With the benchmark of the inverted pendulum with SingleShooting and Ipopt, I get on Julia v1.11.5 before this improvement:

btime_NMPC_track_solver_IP = median(bm) = TrialEstimate(432.509 ms)

and after this improvement:

btime_NMPC_track_solver_IP = median(bm) = TrialEstimate(395.618 ms)

@franckgaga franckgaga merged commit 9e80002 into main Apr 28, 2025
4 checks passed
@franckgaga franckgaga deleted the DI_val_and_deriv branch April 28, 2025 19:28
@franckgaga
Copy link
Member Author

franckgaga commented Apr 28, 2025

BTW thanks once more @gdalle for DI.jl !

I wanted to use DiffResults.jl in the past to improve the efficiency of ForwardDiff calls, but I completely forgot about this. Reading through your doc and noticing value_and_jacobian! reminded me to implement it, and it was very easy with DI.jl API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants