Description
With ControlSystem
we were attempting to build the stack towards doing nonlinear optimal control, but we found that having a separate ControlSystem
type is the wrong way to go about doing it because it would need to just recreate everything of ODESystem
. So the question instead is, how do we do optimal control using the ODESystem
of #1059 where it has potential control variables in there?
The idea is to have transformation functions. The first one would be something like direct_optimal_control(loss,sys,u0,tspan,p,ctrl;fit_parameters = false)
which would transform an ODESystem
into an OptimizationProblem
. It would do so by using the direct method, a la https://diffeqflux.sciml.ai/dev/examples/optimal_control/, basically generating the ODEProblem with fittable parameters #1088 and writing a loss function on the solution. It would be nice for the loss to be written symbolically and generate the full loss, and that might need some improvements to OptimizationProblem
. fit_parameters
would then flip yes/no on whether the p.p
would be simultaneously fit to the control values, and the way the control is represented (neural network, piecewise constant, etc.) would just be from how the user passes a parameterized control function.
Then we can have discretized_optimal_control
which would be like the current runge_kutta_discretize
which takes the problem and fully discretizes it to build a huge constrained nonlinear optimization problem, where u
and ctrl
are then indexable from the solution due to being symbolic arrays.
This then opens up indirect methods, which take ODESystem
and a symbolic loss and generates a BVP for Pontryagin's maximum principle, etc.
#1059 then makes the forward simulation and playing with the learned controllers trivial.