# Parallel Hybrid Electric Vehicle Modelling and Model Predictive Control
## 4 The MPC with Softened Constraints for the HEV  
The conventional MPC objective function in Equation (31) subject to the constraints in Equation (30) regarding states, outputs, inputs, and input increase may deal with so many hard constraints. The MPC optimizer may not find out a solution that satisfies all constraints. Thus, we considered to widen the MPC feasibility by converting some possible hard constraints from Equation (30) into softened constraints to increase the possibility of finding a solution. The new MPC scheme subject to the softened constraints has the following form:  
\[ \begin{array}{c}\underset{U\triangleq\{\Delta u_{k},\ldots\Delta u_{k+N_{u }-1}\}}{min}\\ \\ \Bigg{\{}J(U,x(k)=\sum\limits_{i=0}^{N_{u}-1}\Big{[}(y_{k+i|k}-r_{k+i|k})^{ \prime}Q\Big{(}y_{k+i|k}-r_{k+i|k}\Big{)}+\Delta u^{\prime}_{k+i|k}R\Delta u_{k+ i|k}+\varepsilon^{\prime}_{i}(k)\Lambda\varepsilon_{i}(k)+2\mu^{\prime} \varepsilon_{k+i|k}\Big{]}\Bigg{\}}\\ \\ \text{subject to}\\ \left[\begin{array}{cc}1&z^{\prime}_{i}\\ z_{i}&X+\mu\varepsilon_{i}I\end{array}\right]\geq 0\\ \\ \left\{\begin{array}{c}minX_{jj}<x_{max}^{2}\\ \\ \forall z_{i}\in\text{\emph{vert}}\Big{\{}\chi^{k+i|k}_{u^{\prime}(\cdot|k)}(x (k))\Big{\}},\ \forall i\in\{1,\ldots,N\}\\ \end{array}\right.\end{array}  \tag{37}\]  
where \(\mu\) is assigned as big values as a weighting factor (\(\mu>0\)), and \(\varepsilon_{i}\) is the constraints penalty terms (\(\varepsilon_{i}\geq 0\)) added into the MPC objective function. \(X\) and \(z_{i}\) are the corresponding matrix of the hard constraints. The new items in Equation (37) are softened constraints selected from hard constraints in \(u_{k}\in\mathcal{U}\), and \(u_{k}\in\mathcal{U}\), \(\Delta u_{k+i}\in[\Delta umax_{min}]\), for \(i=0,1,\ldots,N_{u}-1\),  
\(y_{k}\in\mathcal{Y}\), and \(y_{k+i|k}\in[\text{\emph{ymax}}_{min}]\), for \(i=0,1,\ldots,N_{y}-1\), \(\Delta u_{k}=u_{k}-u_{k-1}\in\Delta U\), and \(\Delta u_{k+i}=0\), for \(i\geq N_{u}\), \(x_{k|k}=x(k)\), \(x_{k+i+1|k}=A(k)x_{k+i|k}+B(k)u_{k+i|k}=u_{k+i-1|k}+\Delta u_{k+i|k}\), \(y_{k+i|k}=C(k)x_{k+i|k}\), where, \(\varepsilon_{i}(k)=\left[\varepsilon_{y};\varepsilon_{u}\right]\), \(y_{k+i|k}y_{maxmin}\), and \(u_{k+i|k}u_{maxmin}\); and \(\Lambda=\Lambda^{\prime}\geq 0\) is the additional penalty matrix (generally \(\Lambda>0\) and assign to small values). In this new MPC scheme, the penalty term of the softened constraints \(\sum\limits_{i=0}^{N_{p}}\left[\varepsilon^{\prime}_{k+i|k}\Lambda\varepsilon_ {k+i|k}+2\mu^{\prime}\varepsilon_{k+i|k}\right]\) is added into the objective function with the positive definite and symmetric matrix \(\Lambda\). This term penalizes the violations of constraints and, where possible, the free constrained solution is returned. This MPC calculates the new optimization vector \(U_{S}=\left[ \begin{array}{c}U\\ \varepsilon\end{array} \right]\) and the new MPC computational algorithms are:  
\[\Psi_{S}(x(t))=\underset{U_{S}}{min}\bigg{\{}\frac{1}{2}U_{S}^{\prime}H_{S} U_{S}+x^{\prime}(t)F_{S}U_{S}\bigg{\}}, \tag{38}\]  
subject to \(G_{S}U_{S}\leq W_{S}+E_{S}x(k)\), where \(U_{S}\triangleq\left[  
\[G_{S}=\left[ \begin{array}{cc}G&0\\ g_{S}&-I\\ 0&-I\end{array} \right]\text{with}\;g_{S}=\left[ \begin{array}{ccccc}0&0&0&\ldots &0\\ ZB&0&0&\ldots&0\\ ZAB&ZB&0&\ldots&0\\ \ldots&\ddots&\ddots&\ddots&\vdots\\ ZA^{N_{p}-1}B&ZA^{N_{p}-2}B&\ldots&\ldots&ZB\end{array} \right],\]  
\[W_{S}=\left[ \begin{array}{c}W\\ w_{S}\\ 0\end{array} \right]\text{with}\;w_{S}=\left[ \begin{array}{c}z\\ \vdots\\ z\end{array} \right]\text{,and}\;E_{S}=\left[ \begin{array}{c}E\\ e_{S}\\ 0\end{array} \right]\text{with}\;e_{S}=\left[ \begin{array}{c}-ZA\\ -ZA^{2}\\ \ldots\\ -ZA^{N_{p}}\end{array} \right].\]  
To illustrate the ability of this controller, we test the two MPC schemes in Equations (31) and (36) by the following simple example as considering the non-linear system shown below:  
\[ \begin{array}{c}\dot{x}_{1}=2x_{2}+u(1+x_{1})\\ \dot{x}_{2}=2x_{1}+u(1-3x_{2})\end{array}