# Quadratic Model-Based Dynamically Updated PID Control of CSTR System with Varying Parameters +
## 2 Methods
### The DUPID Control Scheme
#### 2.2.1 The 1D DUPID Controller  
To ensure the quality of the regression data, this approach partitions the set \(\mathbb{U}\) composed of \(N_{pp}\) points pairs \((\Delta u^{(i)},e_{s}^{(j)})\) into two subsets with respect to the last gathered point \((\Delta u^{(k)},e_{s}^{(k)})\) (red point fitted within triangle). The effect of data segmentation carried out by the 1D DUPID is shown in Figure 4.  
Figure 4: The effects of using of 1D DUPID algorithm to select adequate data for model construction for different values of \(\sigma_{tol}\): (**a**) \(\sigma_{tol}=0.1\) and (**b**) \(\sigma_{tol}=0.2\). The blue dashed lines in (**a,b**) are the obtained quadratic fits. The last point fed to the algorithm is marked with a triangle. The collected data used for testing consist of 20 random integer points drawn on the interval \([0,50]\) for \(\Delta u\) and \([-70,70]\) for \(\varepsilon_{5}\). The data are normalized before it is fed to the algorithm. The black dashed line is zero error axis mapped in the normalized search space.  
Figure 3: The flow chart diagram of the DUPID controller.  
The last point obtained in the regression set will be addressed as the center point. The first subset, i.e., the vicinity set \(U_{v}\), is comprised of all the points encompassed in \(\pm\sigma_{tol}\) distance of the center point, measured on the \(\Delta u\) axis (red points). The point selection in this version of the algorithm is carried out solely with respect to the coordinate \(\Delta u\) (hence its \"one-dimensional\" nature). The second subset, the outer set \(U_{o}\), contains the remaining points that are further from the center point \(\Delta u^{(k)}\pm\sigma_{tol}\) (yellow and green points). The approach of segmenting the regression data is carried out to ensure the constructed model compromises between local precision on one hand and robustness on the other hand. The local precision of the model is guaranteed by the points found in the vicinity set \(U_{v}\) whereas the robustness is established by the points found in the outer set \(U_{o}\). In this paper, the robustness of the fit is guaranteed by considering two anchor points (the green points) from the outer set. The anchor points are regarded as points whose distance with respect to \(\Delta u^{(k)}\) is greatest. After the regression set \(U_{r}=\{U_{v},U_{o}\}\) is constructed, the model parameters \(p=\{A,B,C\}\) are calculated from the optimization problem defined as:  
\[\min_{p}\sum_{r=1}^{n_{r}}\Big{(}e_{s}^{(r)}-E_{M}\Big{(}\Delta u^{(r)},p\Big{)} \Big{)}^{2}, \tag{5}\]  
where, \(n_{r}\) is the number of points in the regression set, \(\Delta u^{(r)}\) are the points found in \(U_{r}\), the set of the past control error values is defined as \(e_{s}=\left\{e_{s}^{(1)},\ \ldots,\ e_{s}^{(n_{r})}\right\}\), and \(E_{M}\Big{(}\Delta u^{(r)},p\Big{)}\) describes the quadratic model given with Equation (3). Next, \(\Delta u^{(j+1)}\) is calculated as:  
\[\Delta u^{(j+1)}=\underset{\Delta u_{i}}{\text{argmin}}\Big{|}\Delta u_{i}- \Delta u^{(k)}\Big{|}, \tag{6}\]  
where \(\Delta u_{i}\) represent, the roots of Equation (3):  
\[\Delta u_{i}=\{\Delta u_{i}|\ E_{M}=0\}. \tag{7}\]  
However, there might be a situation where the constructed fit does not intersect with the zero error axis. In such occasions \(\Delta u^{(j+1)}\) is calculated by differentiation of the constructed model:  
\[\Delta u^{(j+1)}=-\frac{B}{2A}. \tag{8}\]  
Afterwards, \(\Delta u^{(j+1)}\) is applied to the plant, and as a new error point \(e_{s}^{(j+1)}\) is obtained, the array of past \(N_{pp}\) points is moved with center at \((\Delta u^{(j+1)},e_{s}^{(j+1)})\) and the procedure for calculation of the next incremental value is repeated.