added: xs_0 and as_0 args in NonLinModelDAE constructor for initial guesses - #445
Merged
Merged
Conversation
It allows providing an initial guess (or warm-start) for the algebraic variable when simulating in open-loop. I will use the value of this argument for the upcoming closed-loop functionalities. This is particularly important for DAEs, I experienced it myself by playing with some famous DAE models.
as_0 argument in NonLinModelDAE constructor as_0 argument in NonLinModelDAE constructor for initial guess
as_0 argument in NonLinModelDAE constructor for initial guessxs_0 and as_0 argument in NonLinModelDAE constructor for initial guesses
xs_0 and as_0 argument in NonLinModelDAE constructor for initial guessesxs_0 and as_0 args in NonLinModelDAE constructor for initial guesses
This is needed to reset the warm-starting strategy for `NonLinModelDAE` simulations. It's also now possible to send `x_0=nothing` to `sim!`. It will automatically compute the steady-state for the `LinModel` case.
It will reset the warm-start strategy before starting the loop for simulations of `NonLinModelDAE` plant models. Note that it also compute the steady-state for the `LinModel` case, but the results is overwritten by the next `setstate!(plant, x_0)` line.
It allows call like `setstate!(model, 0)`, or `sim!` with arguments `x_0=0` or `x̂_0=0`.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #445 +/- ##
==========================================
+ Coverage 96.87% 96.92% +0.04%
==========================================
Files 28 28
Lines 6628 6656 +28
==========================================
+ Hits 6421 6451 +30
+ Misses 207 205 -2
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:
|
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.
Warm-starting states and algebraic variable for DAEs
This PR introduces two new keyword arguments in
NonLinModelDAEconstructor:xs_0=zeros(nx): initial guess (optimization warm-start) for the states.as_0=zeros(na): initial guess (optimization warm-start) for the algebraic variables.It currently allows providing an initial guess for the the state and the algebraic variable when simulating in open-loop. These guesses are only used at the discrete time$k=0$ , that is, just after construction of $k=0$ , the values computed at the previous time steps are used since it is assumed that they represent better guesses. I will use the value of these two arguments for the upcoming closed-loop functionalities.
NonLinModelDAEor afterinitstate!(model::NonLinModelDAE, u, d)is called. AfterThis is particularly important for the algebraic variables of DAEs. I experienced it myself by playing with some famous DAE models. This PR covers the suggestion of @baggepinnen here.
The function
setstate!(obj, x)now supports scalarxIt allows call like
setstate!(model, 0), and alsosim!with arguments likex_0=0orx̂_0=0.