A sparse MPC solver for walking motion generation (old version).
Notes on implementation

Representation of matrices

Note, that parts of state and control matrices (Model of the system) corresponding to x and y coordinates are identical. This property is preserved in all subsequent transformations, hence there is no need to compute and store all elements of static matrices (Cholesky factor for example). Consequently, we mainly operate on 3x3 matrices, which are stored in the following way:

  0   3   6
  1   4   7
  2   5   8

Cholesky factor

The Cholesky factor consists of two parts:

Implementing bounds

Consider the variable

$ \mbm{x} = \left[\begin{array}{c} x_1 \\ x_2 \\ x_3 \\ x_4 \\ x_5 \\ x_6 \end{array}\right]. $

Suppose that variables $x_1$ and $x_4$ have simple bounds (and the rest of the variables are are not subject to inequality constraints), i.e.,

$\\ lb_1 \leq x_1 \leq ub_1 \\ lb_2 \leq x_2 \leq ub_2 $

The above four inequality constraints can be written as

$\\ \mbm{a}_1^T\mbm{x} \leq ub_1 \\ \mbm{a}_1^T\mbm{x} \geq lb_1 \\ \mbm{a}_2^T\mbm{x} \leq ub_2 \\ \mbm{a}_2^T\mbm{x} \geq lb_1, $

where

$\\ \mbm{a}_1^T = \left[\begin{array}{cccccc} 1 & 0 & 0 & 0 & 0 & 0 \end{array}\right] \\ \mbm{a}_2^T = \left[\begin{array}{cccccc} 0 & 0 & 0 & 1 & 0 & 0 \end{array}\right]. $

Note that both $\mbm{a}_1^T\mbm{x} \leq ub_1$ and $\mbm{a}_1^T\mbm{x} \geq lb_1$ can not be in the working set at the same time (because if we are on one of the bounds we can not be on the other one).

Attention:
Note, that if we do not distinguish lower and upper bounds, Lagrange multipliers can be negative.