I am running a simulation where I need to repeatedly solve a set of LPs or QPs with slightly different input parameters for a Model Predictive Control application. The problem is I need it to be fast, so exploiting some parallelization is probably required? Ideally in Python.
Here is the problem:
$$ \underset{u_{i,j,k}}{\text{min}} \quad J_{i,j} = \sum_{k=0}^{N=30} \Bigg( R_{i,j,k} u_{i,j,k} + x_{i,j,k}^\top Q_{i,j,k} x_{i,j,k} \Bigg) $$
subject to:
$$ x_{i,j,k+1} = A_{i,k} x_{i,j,k} + B_{i,k} u_{i,j,k} $$
$$ \underline{u}_{i,j,k} \leq u_{i,j,k} \leq \overline{u}_{i,j,k} $$ $$ \underline{x}_{i,j,k} \leq x_{i,j,k} \leq \overline{x}_{i,j,k} $$ $$ x_{i,j,0} = x_i^{(0)} $$ $$ i \in \{1, ..., 30\} $$ $$ j \in \{1, ..., 30\} $$
Note that $x^\top Q x$ could also be modeled as $Qx$ to keep the problem linear.
Some ideas I've had so far:
Treating the set as one big optimization problem: This works but is incredibly slow (using Pyomo and CPLEX and CVXPy). Maybe there is another library designed for fast repeated solving like this.
Using a GPU computing library like Pytorch and running gradient descent in parallel: We would convert the constrained LP/QP into a unconstrained NLP with logarithmic barrier functions. Essentially interior point method on the GPU. Could potentially be faster but could become a pretty complex implementation.
Multi-parametric programming/Explicit MPC: Probably the most optimal solution but I cannot find a method to solve for the explicit solution. The difficulty is that $R$ is a linear cost and can be negative. UPDATE: This is infeasible due to the problem size and time-varying state space matrices.
Any other ideas?
Pytorch
are for separable and unconstrained optimization problems. SGD is not appropriate for this problem. $\endgroup$xQx
wasQx
instead. It is updated now. $\endgroup$