Skip to content
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 ControlSystem for Nonlinear Optimal Control #562

Merged
merged 3 commits into from
Aug 26, 2020

Conversation

ChrisRackauckas
Copy link
Member

This pull request adds a ControlSystem construct for specifying nonlinear optimal control problems. The format is as follows:

using ModelingToolkit

@variables t x(t) v(t) u(t)
@derivatives D'~t

loss = (4-x)^2 + 2v^2 + u^2
eqs = [
    D(x) ~ v
    D(v) ~ u^3
]

sys = ControlSystem(loss,eqs,t,[x,v],[u],[])

Over time it will get full standardization with the rest of ModelingToolkit's abstract system interface, which means that things like pins and observables should get supported. Through component-based modeling should already work.

This is an abstract specification, so it is symbolic in nature and does not do the computation itself. Instead, all computation on a ControlSystem occurs through the transformation into another system type. In order to demonstrate this, I created the first transformation function, runge_kutta_discretize, which takes in a ControlSystem and outputs an OptimizationSystem that is defined by the collocation of some Runge-Kutta method (defaulting to a 5th order RadauIIA). That means that all of the machinery for OptimizationSystem can then be used to transform this into a OptimizationProblem to be numerically handled, and sparse symbolic Hessians should already work, etc.

As a demonstration of this:

dt = 0.1
tspan = (0.0,1.0)
runge_kutta_discretize(sys,dt,tspan)

creates an OptimizationSystem, which one can then transform to a numerical problem to solve. Note that for this transformation to work, I did the long-overdue thing of expanding OptimizationSystem to have constraints. We will need to update OptimizationProblem to have an interface for this, and then setup GalacticOptim to appropriately handle constraints, and then this will be a "direct to numerics" thing, but for now it's purely symbolic.

@freemin7
Copy link

What other approaches will there be to work on except runge_kutta_discretize?

@ChrisRackauckas
Copy link
Member Author

universal_diffeq_control which would setup a DiffEqFlux training problem, variational_solve which transforms to a variational PDE, etc.

@freemin7
Copy link

Are pseudo spectral approaches considered or do they need much MTK work?
How about collocation techniques based on other classes of ODE solvers?

@ChrisRackauckas
Copy link
Member Author

Other collocations can be done as well, yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants