How to programatically solve the optimal control problem?

262 Views Asked by At

I have to programatically (write a program) find a control function $u(\cdot)$ to minimize the following functional:

$$ J(u,x) = \int_0^T { f_0(x(t), u(t), t)}dt + \Phi(x(0)) \rightarrow \min$$

Where $x$ and $u$ should satisfy this Cauchy problem: $$\begin{cases} {dx \over dt} = A(t)x(t) + B(t)u(t) \\ x(T) = x_T = const \end{cases}$$ In which: $$ A(t) = \left(\begin{matrix} a_{11}(t) & a_{12}(t) \\ a_{21}(t) & a_{22}(t) \end{matrix}\right), \quad B(t) = \left(\begin{matrix} b_{11}(t) & b_{12}(t) \\ b_{21}(t) & a_{22}(t) \end{matrix}\right),\quad x = \left(\begin{matrix} x_1(t) \\ x_2(t)\end{matrix}\right)$$

I thought about using Pontryagin's Maximum Principle, but it's too hard to implement with c++ or python and not nessesary in my task.

Can someone please suggest me a nice and easy to implement method (or algorithm) to solve this?