# Metabolic Reaction Network-Based Model Predictive Control of Bioprocesses
## 2 Methods
### Moving Horizon Estimation (MHE)  
Moving horizon estimation (MHE) estimates states and parameters at a point in time \(t_{i+H_{e}}\) from the measurements at this time point and the measurements at the previous \(H_{e}\) time points. Hence, an estimation horizon of \(H_{e}+1\) measurements is used for the state and parameter estimation. Once a new sample is taken at \(t_{H_{e}}+1\), the estimation horizon moves one time step, meaning that the measurements at \(t_{H_{e}}+1\) are used for the state and parameter estimation while the measurements related to the first point of the previous horizon (i.e., \(t_{i}\)) is discarded [12; 13; 14]. This is also illustrated in Figure 1.  
Concretely, a dynamic combined state and parameter estimation problem (in essence, a dynamic optimization problem) is solved over a time interval \([t_{i},t_{i+H_{\mathrm{c}}}]\). In this article, the MHE formulation of [7] is used. This formulation is presented below for completeness. For more details on this formulation, the interested reader is referred to [7].  
\[\min_{\mathbf{x}_{i_{\mathrm{c}},\mathbf{w}_{i},\ldots,\mathbf{w}_{i+H_{\mathrm{ c}}-1}}}\;\sum_{j=i}^{i+H_{\mathrm{c}}}\left\|\mathbf{m}_{j}-\mathbf{y}(t_{j}) \right\|_{\mathbf{V}}^{2}+\sum_{j=i}^{i+H_{\mathrm{c}}-1}\left\|\mathbf{w}_{j }\right\|_{\mathbf{W}}^{2}+\left\|\mathbf{x}_{i}^{\mathrm{c}}-\mathbf{\bar{x} }_{i}^{\mathrm{c}}\right\|_{\mathbf{\bar{p}}_{1}} \tag{4}\]  
subject to:  
\[\dot{\mathbf{x}}(t) =\mathbf{S}_{\mathrm{e}}\cdot\mathbf{K}\cdot\mathbf{\hat{u}}( \mathbf{x},\mathbf{p})\cdot\mathbf{q}_{\mathrm{bio}}^{\top}\cdot\mathbf{x}(t) +(\mathbf{X}_{\mathrm{in}}\cdot\mathbf{r}-\mathbf{x}(t))\cdot D+\boldsymbol{ \omega}_{\mathrm{x}}(t) \tag{5}\] \[\dot{\mathbf{p}}(t) =\boldsymbol{\omega}_{\mathrm{p}}(t)\] (6) \[\mathbf{x}(t_{i}) =\mathbf{x}_{i}\] (7) \[\mathbf{p}(t_{i}) =\mathbf{p}_{i}\] (8) \[\mathbf{0} =\mathbf{z}(t)-\mathbf{I}_{\mathrm{irr}}\cdot\mathbf{K}\cdot \mathbf{\hat{u}}(\mathbf{x},\mathbf{p})\] (9) \[\mathbf{y}(t) =\mathbf{x}(t)\] (10) \[\mathbf{x}(t) \geq\mathbf{0},\;\mathbf{z}(t)\geq\mathbf{0} \tag{11}\]  
with \(\mathbf{x}(t)=\left[\mathbf{c}_{\mathrm{ext}}^{\top}(t)\;\mathrm{c}_{\mathrm{ bio}}\right]^{\top}(t)\) being the state vector comprising both extracellular metabolites and biomass at \(t\), \(\mathbf{\hat{u}}\) the estimated free fluxes, \(\mathbf{p}\) the flux parameters, \(\mathbf{q}_{\mathrm{bio}}^{\top}=[0\;\ldots\;0\;1]\) a row vector selecting the partition of the extracellular stoichiometric \(\mathbf{S}_{\mathrm{e}}=\left[\mathbf{S}_{\mathrm{ext}}^{\top}\,\mathbf{s}_{ \mathrm{bio}}\right]\) corresponding with biomass, \(\mathbf{X}_{\mathrm{in}}\in\mathbb{R}4\times 2\) the matrix of concentrations at the bioreactor inlet for the different metabolites, and \(\mathbf{r}\in\mathbb{R}^{2\times 1}\) the vector of control variables manipulating the feed composition sent to the reactor and \(D\) the dilution rate. In addition, the process noise on the states and parameters is denoted by \(\boldsymbol{\omega}_{\mathrm{x}}(t)\) and \(\boldsymbol{\omega}_{\mathrm{p}}(t)\), respectively. Algebraic states \(\mathbf{z}(t)\) have been added for the description of the irreversible fluxes as denoted in Equation (9).  
Note that \(\mathbf{x}_{H_{\mathrm{c}}}^{c}\), i.e., the combined state and parameter vector at \(t_{i+H_{\mathrm{c}}}\) and the process noise estimates \(\mathbf{w}_{i},\ldots,\mathbf{w}_{i+H_{\mathrm{c}}-1}\) are the optimization variables for the MHE problem described in Equations (4)-(11). Note that the arrival cost parameters \(\mathbf{\bar{x}}_{i}^{\mathrm{c}}\) and \(\mathbf{\bar{P}}_{1}\) are updated via an unscented Kalman filter [16].