Coder Social home page Coder Social logo

ilyaorson / control_neuralode Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 1.0 925 KB

Neural ODEs as Feedback Policies for Nonlinear Optimal Control (IFAC 2023) https://doi.org/10.1016/j.ifacol.2023.10.1248

Home Page: https://arxiv.org/abs/2210.11245

License: MIT License

Julia 100.00%
neuralode adjoint-sensitivities optimal-control automatic-differentiation ordinary-differential-equations neural-networks julia optimization

control_neuralode's Introduction

Feedback Control Policies with Neural ODEs

This code showcases how a state-feedback neural policy, as commonly used in reinforcement learning, may be used similarly in an optimal control problem while enforcing state and control constraints.

Constrained Van der Pol problem

$$\begin{equation} \begin{aligned} \min_{\theta} \quad & J = \int_0^5 x_1^2 + x_2^2 + u^2 ,dt, \\ & \\ \textrm{s.t.} \quad & \dot x_1(t) = x_1(1-x_2^2) - x_2 + u, \\ & \dot x_2(t) = x_1, \\ & u(t) = \pi_\theta^2(x_1, x_2) \\ & \\ & x(t_0) = (0, 1), \\ & \\ & x_1(t) + 0.4 \geq 0, \\ & -0.3 \leq u(t) \leq 1, \\ \end{aligned} \end{equation}$$

Phase Space with embedded policy (before and after optimization)

vdp_initial vdp_constrained

JuliaCon 2021

The main ideas where presented in this talk of JuliaCon2021.

Watch the video

Running the study cases

This code requires Julia 1.7.

Reproduce the environment with the required dependencies:

julia> using Pkg; Pkg.activate(;temp=true)
julia> Pkg.add(url="https://github.com/IlyaOrson/ControlNeuralODE.jl")

Run the test cases:

julia> using ControlNeuralODE: van_der_pol, bioreactor, batch_reactor, semibatch_reactor
julia> van_der_pol(store_results=true)

This will generate plots while the optimization runs and store result data in data/.

Methodology (Control Vector Iteration for the Neural Policy parameters)

By substituting the control function of the problem by the output of the policy, the weights of the controller become the new unconstrained controls of the system. The problem becomes a parameter estimation problem where the Neural ODE adjoint method may be used to backpropagate sensitivities with respect to functional cost.

This method was originally called the Kelley-Bryson gradient procedure (developed in the 60s); which is historically interesting due to being one of the earliest uses of backpropagation. Its continuous time extension is known as Control Vector Iteration (CVI) in the optimal control literature, where it shares the not so great reputation of indirect methods.

Its modern implementation depends crucially on automatic differentiation to avoid the manual derivations; one of the features that made the original versions unattractive. This is where DiffEqFlux.jl and similar software shine. See the publication for a clear explanation of the technical details.

Acknowledgements

The idea was inspired heavily by the trebuchet demo of Flux and the differentiable control example of DiffEqFlux. A similar idea was contrasted with reinforcement learning in this work. Chris Rackauckas advise was very useful.

Citation

If you find this work helpful please consider citing the following paper:

@misc{https://doi.org/10.48550/arxiv.2210.11245,
  doi = {10.48550/ARXIV.2210.11245},
  url = {https://arxiv.org/abs/2210.11245},
  author = {Sandoval, Ilya Orson and Petsagkourakis, Panagiotis and del Rio-Chanona, Ehecatl Antonio},
  keywords = {Optimization and Control (math.OC), Artificial Intelligence (cs.AI), Systems and Control (eess.SY), FOS: Mathematics, FOS: Mathematics, FOS: Computer and information sciences, FOS: Computer and information sciences, FOS: Electrical engineering, electronic engineering, information engineering, FOS: Electrical engineering, electronic engineering, information engineering},
  title = {Neural ODEs as Feedback Policies for Nonlinear Optimal Control},
  publisher = {arXiv},
  year = {2022},
  copyright = {arXiv.org perpetual, non-exclusive license}
}

control_neuralode's People

Contributors

ilyaorson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

optimal-pse-lab

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.