The essence of my question is the following: I have a system of two ODEs. One has an initial-value constraint and the other has a final-value constraint. This can be thought of as a single system with an initial-value constraint on some variables and a final-value constraint on the others.
Here are the details:
I am trying to use a continuous-time finite-horizon LQR controller to drive a linear dynamical system. I'd like to continue using the Python ecosystem.
The system is in the form $\dot{x}(t) = Ax(t) + Bu(t)$, subject to $x(0)=x_0$
The LQR solution generates a matrix $K(t)$ such that the optimal control input u(t), linear in $x(t)$, is $u(t) = K(t)x(t)$.
where $K(t) = R^{-1} B^T P(t)$
and $P(t)$ is the solution to a continuous time Riccati differential equation (note that this $P(t)$ is a matrix)
$\dot{P}(t) = -A^T P(t) - P(t) A + P(t) B R^{-1} B^T P(t) + Q$ subject to $P(t_f) = Q$
$A$, $B$, $x_0$, $Q$, $Qf$, $R$, $t_f$ are all given.
In English: you have some dynamical system that starts in state $x_0$. The LQR controller generates a feedback matrix to use between time $0$ and $t_f$ ($t_f$ is commonly called the time-horizon of the problem)
Note that the two ODEs are coupled only in one direction -- the solution to $P(t)$ does not depend on $x(t)$. Therefore one way to solve the problem is to reverse the Riccati equation in order to turn the final-value problem into an initial-value problem and find a numerical solution between time $0$ and $t_f$ using a standard ODE integrator. I can then use this numerical solution to find $x(t)$. This concerns me because the numerical ODE solver for x(t) will not necessarily sample the ODE at the same times as the times in the numerical solution to $P(t). Maybe there is some clever way to enforce this.
The other way I foresee of solving the problem is to solve the sytem together, but I don't know how to deal with the mix of initial-value and final-value constraints. Are these problems computationally heavy to solve? Can I do it in SciPy / Python?