Handle dummy derivatives in linearization_function
#2361
Merged
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.
The issue here is that the homogenous parameter PR that was merged broke
linearization_function
, which led to a further PR that broke the user interface tolinearization_function
such that the user now needs to provide an "example input" that encodes the types that the generated function would eventually be called with.I find this a very bad design and a quite unfortunate breaking change. The fundamental problem is that state and parameter types are important, but the modeling language does not allow the user to encode this information in the model, instead we now ask the users to provide the type information in the form of an example input.
This PR mitigates the effect of the breakage slightly be setting missing variables to
0.0
, a floating point type. This should be okay since dummy derivatives are always floats. The value is not important here, only the type.Several tests are added that tests a common workflow in control engineering, the use of an inverse-based
feedforward model. Such a model differentiates "inputs", exercising the dummy-derivative functionality of ModelingToolkit. I also test linearization and computation of sensitivity functions for such models (the thing this PR fixes)