# State and Parameter Estimation of a Mathematical Carcinoma Model under Chemotherapeutic Treatment
## 2 Materials and Methods
### Moving Horizon Estimation  
The MHE is an optimization-based method, where the minimization of a developed cost function is done on a moving window. A moving window of one step can coincide with the widely applied EKF. However, using a longer window and introducing some application-specific terms or constraints can be beneficial in several cases. Taking into account more measurements can result in an estimator more robust to external disturbances or delays. The cost function can be formulated in several ways, depending on the application. General arguments and terms are summarized in Table 2, where the notations are given according to (4) and (5). The \(\mathbf{W}_{i}\) matrices provide weighting between the terms of the cost function, their subscripts indicates the analogy between the EKF and MHE. The weighting matrices are analogous to the inverses of the covariance matrices (8), (10). The \(\mathbf{x}_{ol}\) vector function is the open-loop trajectory from the initial state of the current window, the arrival cost is calculated in the \(k-M\)-th step, where \(M\) is the length of the horizon. The difference between the current parameters and the previous window is denoted by \(\Delta\mathbf{p}\). Following the assumption that the mismatch between the model and measurements are caused by parameter uncertainty, intrapatient variability and measurement noise, the parameters \(\mathbf{p}=[a,b,n,w]\) are optimized, similarly to the EKF design. Given the arguments, the MHE problem can be generally formulated as follows:  
\[\min_{\mathbf{x}[k-m],\mathbf{p}}||\hat{\mathbf{x}}[k-m]-\mathbf{x}[k-m]||_{ \mathbf{W}_{p}}^{2}+\sum_{i=k-M}^{k}||\mathbf{z}-h(\mathbf{x}(\mathbf{p}))|| _{\mathbf{W}_{R}}^{2}+||\Delta\mathbf{p}||_{\mathbf{W}_{Q}}^{2}. \tag{19}\]  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & & **Arguments** & \\
**Penalization** & **State** & **Disturbance** & **Parameter** \\ \hline Measurement difference & \(||\mathbf{z}-h(\mathbf{x})||_{\mathbf{W}_{R}}^{2}\) & \(||\mathbf{z}-h(\mathbf{x}(\mathbf{w}))||_{\mathbf{W}_{R}}^{2}\) & \(||\mathbf{z}-h(\mathbf{x}(\mathbf{p}))||_{\mathbf{W}_{R}}^{2}\) \\ Modification & \(||\mathbf{x}-\mathbf{x}_{ol}||_{\mathbf{W}_{Q}}^{2}\) & \(||\mathbf{w}||_{\mathbf{W}_{Q}}^{2}\) &Compared to the general formulation, three modifications are implemented. First, as a worst case scenario the initial state of the horizon is set to the last estimated state. Secondly, the differences are normalized in order to make the weighting between the measurements and modifications easier, scaling the errors to the same order of magnitude. Division with zero is avoided: when the tumor volumes could not be exactly measured due to their small volumes, 1 [mm\({}^{3}\)] is assigned to their measured value. Unit volume ensures numerical stability and is physiologically more relevant as the tumors are not completely eliminated. The characteristics of the model is in agreement with this, as in ideal condition the volume converges to zero, but it is bound to be positive. Thirdly, a rational function (23) was introduced, which penalizes the difference less, when the measured tumor volumes are small. Justification for the second and third point is more detailed in Section 2.3.1. Considering these modifications the cost function in the \(k\)-th step is defined as  
\[\min_{\mathbf{p}} \ J[k]=\sum_{i=k-M}^{k}\Big{|}\Big{|}\frac{z[i]-y[i]}{z[i]}\Big{|} \Big{|}^{2}_{\mathbf{W}_{k}[i]}+\Big{|}\Big{|}\frac{\Delta\mathbf{p}}{\mathbf{ p}[k-1]}\Big{|}\Big{|}^{2}_{\mathbf{W}_{0}[k]},\] (20) subject to \[\mathbf{W}_{R}[i]=\frac{1}{M}\omega(i), \tag{21}\] \[\mathbf{W}_{Q}[k]=\frac{1}{3T_{s}[k]}diag(0,1,1,1),\] (22) \[\omega(i)=\Big{(}\frac{z[i]}{50+z[i]}\Big{)}^{2},\] (23) \[\mathbf{p}\in[\mathbf{lb},\mathbf{ub}], \tag{24}\]  
where \(T_{s}\) is the sampling time of the measurements which is irregular; it varies between 1 and 5 days.