-
-
Notifications
You must be signed in to change notification settings - Fork 235
increase flexibility in disturbance-argument codegen #4033
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
Conversation
|
|
||
| These functions support two types of disturbance inputs: | ||
|
|
||
| - **Unknown disturbances** (`disturbance_inputs`): Variables that are part of ``w`` but NOT added as function arguments to ``f``. MTK assumes these variables are zero, but any dynamics associated with them (such as disturbance models) are included in the generated function. This allows a state estimator to estimate the state of the disturbance model, provided that this state is [observable](https://en.wikipedia.org/wiki/Observability) from measured outputs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| - **Unknown disturbances** (`disturbance_inputs`): Variables that are part of ``w`` but NOT added as function arguments to ``f``. MTK assumes these variables are zero, but any dynamics associated with them (such as disturbance models) are included in the generated function. This allows a state estimator to estimate the state of the disturbance model, provided that this state is [observable](https://en.wikipedia.org/wiki/Observability) from measured outputs. | |
| - **Unknown disturbances** (`disturbance_inputs`): Variables that are part of ``w`` but NOT added as function arguments to ``f``. MTK assumes these variables are zero, but any dynamics associated with them (such as disturbance models) are included in the generated function. This allows a state estimator to estimate the state of the disturbance model, provided that this state is [observable](https://en.wikipedia.org/wiki/Observability) from measured outputs. |
|
|
||
| - **Unknown disturbances** (`disturbance_inputs`): Variables that are part of ``w`` but NOT added as function arguments to ``f``. MTK assumes these variables are zero, but any dynamics associated with them (such as disturbance models) are included in the generated function. This allows a state estimator to estimate the state of the disturbance model, provided that this state is [observable](https://en.wikipedia.org/wiki/Observability) from measured outputs. | ||
|
|
||
| - **Known disturbances** (`known_disturbance_inputs`): Variables that are part of ``w`` AND added as function arguments to ``f``, resulting in ``f(x, u, p, t, w)``. Use this when disturbances can be measured or are otherwise known. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| - **Known disturbances** (`known_disturbance_inputs`): Variables that are part of ``w`` AND added as function arguments to ``f``, resulting in ``f(x, u, p, t, w)``. Use this when disturbances can be measured or are otherwise known. | |
| - **Known disturbances** (`known_disturbance_inputs`): Variables that are part of ``w`` AND added as function arguments to ``f``, resulting in ``f(x, u, p, t, w)``. Use this when disturbances can be measured or are otherwise known. |
| Base.depwarn("The `disturbance_argument` keyword argument is deprecated. Use `known_disturbance_inputs` instead. " * | ||
| "For `disturbance_argument=true`, pass `known_disturbance_inputs=disturbance_inputs, disturbance_inputs=nothing`. " * | ||
| "For `disturbance_argument=false`, use `disturbance_inputs` as before.", | ||
| :generate_control_function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| Base.depwarn("The `disturbance_argument` keyword argument is deprecated. Use `known_disturbance_inputs` instead. " * | |
| "For `disturbance_argument=true`, pass `known_disturbance_inputs=disturbance_inputs, disturbance_inputs=nothing`. " * | |
| "For `disturbance_argument=false`, use `disturbance_inputs` as before.", | |
| :generate_control_function) | |
| Base.depwarn( | |
| "The `disturbance_argument` keyword argument is deprecated. Use `known_disturbance_inputs` instead. " * | |
| "For `disturbance_argument=true`, pass `known_disturbance_inputs=disturbance_inputs, disturbance_inputs=nothing`. " * | |
| "For `disturbance_argument=false`, use `disturbance_inputs` as before.", | |
| :generate_control_function) |
|
|
||
| if !isscheduled(sys) | ||
| sys = mtkcompile(sys; inputs, disturbance_inputs, split) | ||
| sys = mtkcompile(sys; inputs, disturbance_inputs=all_disturbances, split) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| sys = mtkcompile(sys; inputs, disturbance_inputs=all_disturbances, split) | |
| sys = mtkcompile(sys; inputs, disturbance_inputs = all_disturbances, split) |
|
|
||
| # Prepare disturbance arrays for substitution and function arguments | ||
| unknown_disturbances = disturbance_inputs === nothing ? [] : unwrap.(disturbance_inputs) | ||
| known_disturbances = known_disturbance_inputs === nothing ? [] : unwrap.(known_disturbance_inputs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| known_disturbances = known_disturbance_inputs === nothing ? [] : unwrap.(known_disturbance_inputs) | |
| known_disturbances = known_disturbance_inputs === nothing ? [] : | |
| unwrap.(known_disturbance_inputs) |
| Base.depwarn("The `disturbance_argument` keyword argument is deprecated. Use `known_disturbance_inputs` instead. " * | ||
| "For `disturbance_argument=true`, pass `known_disturbance_inputs=disturbance_inputs, disturbance_inputs=nothing`. " * | ||
| "For `disturbance_argument=false`, use `disturbance_inputs` as before.", | ||
| :build_explicit_observed_function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| Base.depwarn("The `disturbance_argument` keyword argument is deprecated. Use `known_disturbance_inputs` instead. " * | |
| "For `disturbance_argument=true`, pass `known_disturbance_inputs=disturbance_inputs, disturbance_inputs=nothing`. " * | |
| "For `disturbance_argument=false`, use `disturbance_inputs` as before.", | |
| :build_explicit_observed_function) | |
| Base.depwarn( | |
| "The `disturbance_argument` keyword argument is deprecated. Use `known_disturbance_inputs` instead. " * | |
| "For `disturbance_argument=true`, pass `known_disturbance_inputs=disturbance_inputs, disturbance_inputs=nothing`. " * | |
| "For `disturbance_argument=false`, use `disturbance_inputs` as before.", | |
| :build_explicit_observed_function) |
Benchmark Results (Julia vlts)Time benchmarks
Memory benchmarks
|
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
Allows to use both known and unknown disturbance inputs at the same time. Should be backwards compatible