-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
add an example to IO docs #2926
Conversation
Thank you for the example! I'll confess that I'm still confused. I came here looking for solutions to #2905 (i.e. general black box I think I'm confused about the |
It sounds to me like your
What exactly is it that you want? |
My background is reinforcement learning, I struggle to read through the documentation on control topics. I think I'm just out of my depth here, so I'll refrain from further comments. Thank you for the link.
In plain Julia, it'd be something like: control_setpoint(x) = maximum(u->Q_value(x, u), [10,15,20,25]) # choose the setpoint which has highest Q value
integral = x = 0.0
for t in 0:10
u = control_setpoint(x) # assumed to be constant for that timestep
x = g(x, u, t) # arbitrary non-linear state dynamic
integral += some_f(x) # Riemann sum
end
# learn a Q_value function to maximize `integral` I've been looking for how to express the I don't want to derail this further, thank you again for providing an example in this PR. |
Your example is completely in discrete time, including the dynamics, while Hybrid continuous-discrete systems are not yet fully supported in MTK (as described here), so you cannot implement a discrete-time controller in any convenient way yet. Furthermore, MTK will not give any guarantees of what |
In my real example, the state is continuous and changes quickly (minutes), while my setpoints (my control signal |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@thazhemadam how could the formatter fail after taking its suggestions? Different versions? 😅 |
|
||
!!! note "Un-simplified system" | ||
|
||
This function expects `sys` to be un-simplified, i.e., `structural_simplify` or `@mtkbuild` should not be called on the system before passing it into this function. `generate_control_function` calls a special version of `structural_simplify` internally. | ||
|
||
### Example: | ||
|
||
|
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 🐶
|
||
The following example implements a simple first-order system with an input `u` and state `x`. The function `f` is generated using `generate_control_function`, and the function `f` is then tested with random input and state values. | ||
|
||
|
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 🐶
nothing # hide | ||
``` | ||
|
||
|
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 🐶
|
||
We can inspect the state realization chosen by MTK | ||
|
||
|
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 🐶
|
||
Now we can test the generated function `f` with random input and state values | ||
|
||
|
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 🐶
😅 review dog, woof. |
No description provided.