-
Notifications
You must be signed in to change notification settings - Fork 12
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
New API to allow In-place and Static Return functions #13
Merged
Conversation
This file contains 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.
Complete overhaul of existing code. Now provides an abstract
FunctionBase
that provides basic functionality for defining custom functions and their derivatives.New Function Base
Example of the new API:
Function signatures are either
StaticReturn
orInplace
, and diff methods are eitherForwardAD
orFiniteDifference
orUserDefined
.By default, these Jacobian methods must be defined by the user, but this PR does provide a macro to define them automatically for both auto and finite differencing:
which defines these methods and modifies the struct (adding caches) to provide allocation-free differentiation methods.
New API for Discrete Models
Instead of defining both continuous and discrete methods for the same model, all models are either continuous or discrete. A continuous model can be converted to a discrete one using
DiscretizedModel
and providing an integrator, such asEuler
orRK4
. Rather than being abstract or singleton types as they were before, these types now allocate storage needed to evaluate these methods and their Jacobians allocation-free.The continuous dynamics API now looks like
The discrete dynamics API:
All discrete models also provide the follow methods to evaluate the dynamics error:
which is
f(x,u) - xn
for explicit integrators (defined automatically) orf(xn,un,x,u) - xn
for implicit integrators.Other Changes
state_diff_size
has been replaced byerrstate_size
state_diff_jacobian
and∇²differential!
have swapped the order of the first 2 arguments