# Quadratic Model-Based Dynamically Updated PID Control of CSTR System with Varying Parameters +
## 2 Methods
### The DUPID Control Scheme
#### 2.2.2 The 2D DUPID Controller  
The process of selection of regression data in 2D DUPID is given in Figure 5. The 2D DUPID uses two coordinates, \(\Delta u\) and \(e_{s}\), in the process of points selection. This is carried out by calculating the Euclidian distances of each of the \(N_{pp}-1\) points with respect to the center point \(\Big{(}\Delta u^{(k)},e_{s}^{(k)}\Big{)}\). As a result, a local coordinate system around the last point is placed (see Figure 5a):  
\[D_{m}=\sqrt{\big{(}\Delta u^{(m)}-\Delta u^{(k)}\big{)}^{2}\ +\Big{(}e_{s}^{(m)}-e_{s}^{(k)} \Big{)}^{2}};m=1,\ldots,N_{pp}-1. \tag{9}\]At first, the vicinity set \(U_{v}\) consists of all the points encompassed by the circle centered at \(\left(\Delta u^{(k)},e_{s}^{(k)}\right)\) with radius \(\sigma_{tol}\) (red points):  
\[\left(\Delta u^{(m)}-\Delta u^{(k)}\right)^{2}+\left(e_{s}^{(m)}-e_{s}^{(k)} \right)^{2}\leq(\sigma_{tol})^{2}. \tag{10}\]  
The outer set \(U_{o}\) includes the points with distance greater than \(\sigma_{tol}\). (green and yellow points). Those points are additionally sorted based on the angles they form with the center point. If the number of points present in the outer set is larger than four, then the algorithm proceeds with the segmentation of the outer set until a point is found in each local quadrant with the smallest distance \(D_{m}\) (green points). If the number of points is less than four, then all points are considered for regression. Finally, if the number of points found is exactly four, then two outer subsets are formed, each comprised of two points. The first outer subset \(U_{o}^{1}\) contains the points found in the local quadrants 1 and 2, and the second outer subset \(U_{o}^{2}\) contains the points found in the local quadrants 3 and 4. The major downside of this approach is that it may suffer in terms of time and computer resources needed for those four points to be found. The underlying idea of splitting the outer set into two subsets is to ensure that the data are fitted by two quadratic models (red and blue dashed lines), where at least one of them intersects with the zero error axis (black dashed line). The subsets constructed from the outer set are defined as: \(U_{o}^{1}=\left\{\Delta u_{o}^{(1)},\Delta u_{o}^{(2)}\right\}\) and \(U_{o}^{2}=\left\{\Delta u_{o}^{(3)},\Delta u_{o}^{(4)}\right\}\). The values contained in both regression sets \(U_{r}^{1}=\left\{U_{v},U_{o}^{1}\right\}\) and \(U_{r}^{2}=\left\{U_{v},U_{o}^{2}\right\}\) are related to the entries found in the error sets, \(e_{s}^{(1)(r)}\) and \(e_{s}^{(2)(r)}\), respectively. The model parameters, \(p^{(1)}=\left\{A_{1},B_{1},C_{1}\right\}\) and \(p^{(2)}=\left\{A_{2},B_{2},C_{2}\right\}\) for both models are calculated from two optimizations problems, each defined as:  
\[\min_{p^{(i)}}\sum_{r=1}^{n_{r}}\left(e_{s}^{(i)(r)}-E_{M}^{(i)}\Big{(}\Delta u ^{(i)(r)},p^{(i)}\Big{)}\right)^{2},\;i=1,2; \tag{11}\]  
where \(n_{r}\) is the number of points in the regression set, \(\Delta u^{(i)(r)}\) are the points found in \(U_{r}^{(i)}\), \(E_{M}^{1}\Big{(}\Delta u^{(1)(r)},p^{(1)}\Big{)}\) is the quadratic model constructed from the \(\left(U_{r}^{1},e_{s}^{(1)(r)}\right)\) set, and \(E_{M}^{2}\Big{(}\Delta u^{(2)(r)},p^{(2)}\Big{)}\) is the model constructed based on the \(\left(U_{r}^{2},e_{s}^{(2)(r)}\right)\) set. Next, \(\Delta u^{(j+1)}\) is calculated in a similar fashion as given with Equation (6), but the number of roots can vary  
Figure 5: The effects of using of 2D 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 and red 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 \(e_{s}\). The data are normalized before it is fed to the algorithm.