ai4energy / OptControl.jl

A tool to solve optimal control problem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OptControl

Stable Dev Build Status

OptControl.jl is a interface that use symbols to build optimal control problem based on ModelingToolkit.jl, and then transforms optimal control problem to:

  • Differential Equations Problems(DEP)
  • Optimzation Problems(OP)

DEP can be solved by DifferentialEquations.jl and OP can be solved by JuMP.jl

An example of optimal control problem:

$$ \begin{matrix} min \int_{0}^{2} u^2dt \newline s.t. ~~~~~ \dot{\boldsymbol{x}} =\begin{bmatrix}0&1 \newline 0&0\end{bmatrix}\boldsymbol{x}+ \begin{bmatrix}0 \newline 1 \end{bmatrix}u \newline \boldsymbol{x}(0) = \begin{bmatrix} 1 \newline 1 \end{bmatrix}, \boldsymbol{x}(2)=\begin{bmatrix} 0 \newline 0 \end{bmatrix} \end{matrix} $$

And use OptControl.jl to transform it to JuMP code to solve it.

using ModelingToolkit,OptControl
@variables t u x[1:2]
f = [0 1; 0 0] * x + [0, 1] * u
L = 0.5 * u^2
t0 = [1.0, 1.0]
tf = [0.0, 0.0]
tspan = (0.0, 2.0)
N = 100
sol = generateJuMPcodes(L, f, x, u, tspan, t0, tf; N=N)

See document for more information.

About

A tool to solve optimal control problem

License:MIT License


Languages

Language:Julia 100.0%