Repository navigation
added: ExplicitMPC now supports automatic differentiation - #524
Open
franckgaga wants to merge 10 commits into
Open
franckgaga wants to merge 10 commits into
franckgaga wants to merge 10 commits into
Conversation
verif_obsv=true keyword argument to all LinModel state observersExplicitMPC now support automatic differentiation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #524 +/- ##
==========================================
- Coverage 97.32% 97.27% -0.06%
==========================================
Files 28 28
Lines 7077 7087 +10
==========================================
+ Hits 6888 6894 +6
- Misses 189 193 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
It seems to crash on `ControlSystems.jl` side, but it's clean in this repo.
Member
Author
|
Now it's possible to autodiff this MRE with using ModelPredictiveControl, ForwardDiff
using Logging # new line
const ERROR_ONLY = ConsoleLogger(stderr, Logging.Error) # new line
A = [0.9 0.08; -0.15 0.75]
Bu = reshape([0.005, 0.09], 2, 1)
C = [1.0 0.0]
# The first move of an ExplicitMPC as a function of its input weight
function first_move(Nwt)
T = typeof(Nwt)
model = LinModel{T}(A, Bu, C, 0, 0, 0.1)
estim = KalmanFilter(model; nint_ym=0, verify_obsv=false) # added: verify_obsv=false
mpc = ExplicitMPC(estim; Hp=20, Hc=2)
preparestate!(mpc, [0.0])
return moveinput!(mpc, [1.0])[1]
end
@show first_move(0.5)
@show ForwardDiff.derivative(first_move, 0.5)
with_logger(ERROR_ONLY) do
@time ForwardDiff.derivative(first_move, 0.5)
endDoes it seems to fit your needs? |
ExplicitMPC now support automatic differentiationExplicitMPC now supports automatic differentiation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bugfix for #523. I only tested it with
ForwardDiff.jl, for now.I added a
verify_obsv=truekeyword argument to allLinModelstate observers, that is:SteadyKalmanFilterKalmanFilterLuenbergerThe failed checkups for the Hessian condition number$\mathrm{cond}(\mathbf{\tilde{H}})$ and the prediction horizon $H_p$ will still emit a
@warn, but it can be silenced locally with: