-
-
Notifications
You must be signed in to change notification settings - Fork 217
feat: create JuMPControlProblem for optimal control #3549
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
base: master
Are you sure you want to change the base?
Conversation
@ChrisRackauckas assuming this passes stuff I think it's ready. |
Requires SciML/SciMLBase.jl#996 |
@testset "ODE Solution, no cost" begin | ||
# Test solving without anything attached. | ||
@parameters α=1.5 β=1.0 γ=3.0 δ=1.0 | ||
@variables x(..) y(..) |
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.
Do I have to define the variables to optimize over using x(..)
? What if I want to solve an OC problem with components defined in MTKstdlib? Those components have x(t)
variables. It would be nice to have a test for that use case as well since component-based modeling would be the fundamental reason to use MTK over any other tool
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.
No, that's just if you also want to evaluate them at a point, since this just late binds t
. We could also make an evaluate
operator or something that is the same as evaluate(x(t), 0.2) == x(0.2)
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.
there appears to be no tests that the dynamics are satisfied, testing the transcription. This could be tested by simulating the system using the found optimal control included with an interpolation
function is_bangbang(input_sol, lbounds, ubounds, rtol = 1e-4) | ||
bangbang = true | ||
for v in 1:(length(input_sol.u[1]) - 1) | ||
all(i -> ≈(i[v], bounds[v]; rtol) || ≈(i[v], bounds[u]; rtol), input_sol.u) || | ||
(bangbang = false) | ||
end | ||
bangbang | ||
end |
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.
function is_bangbang(input_sol, lbounds, ubounds, rtol = 1e-4) | |
bangbang = true | |
for v in 1:(length(input_sol.u[1]) - 1) | |
all(i -> ≈(i[v], bounds[v]; rtol) || ≈(i[v], bounds[u]; rtol), input_sol.u) || | |
(bangbang = false) | |
end | |
bangbang | |
end | |
function is_bangbang(input_sol, lbounds, ubounds, rtol = 1e-4) | |
for v in 1:(length(input_sol.u[1]) - 1) | |
all(i -> ≈(i[v], bounds[v]; rtol) || ≈(i[v], bounds[u]; rtol), input_sol.u) || | |
return false | |
end | |
true | |
end |
JuMPControlProblem(sys::ODESystem, u0, tspan, p; dt) | ||
Convert an ODESystem representing an optimal control system into a JuMP model | ||
for solving using optimization. Must provide `dt` for determining the length |
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.
dt
is presumably not defined as "determining the length of the interpolation arrays". Instead of mentioning why a variable is required, maybe mention what the variable represents?
will add optimal control tests here when the interface for inputs and stuff is settled.