# Commuted PD Controller for Nonlinear Systems: Glucose-Insulin Regulatory Case
## 2 Materials and Methods
### Robustness and Stability  
Our control objective consists of stabilizing the glucose level around the basal value in finite time. To study the stability, we consider two switching surfaces: \(s_{1}=\{x_{1}=x_{1_{h}}\}\) and \(s_{2}=\{x_{1}=x_{1_{H}}\}\). So, the glucose level can be divided into three possible regions:  
\[S_{1}=(0,x_{1_{h}})\,\ S_{0}=(x_{1_{h}},x_{1_{H}})\,\ S_{2}=(x_{1_{H}},+ \infty), \tag{11}\]  
verifying that \(x_{1}(t)\in\mathbb{R}=\mathbb{S}_{1}\cup\mathbb{S}_{0}\cup\mathbb{S}_{2}\). Considering \(x(t)=(x_{1}(t),x_{2}(t),x_{3}(t))^{T}\), the closed-loop system has the following general representation:  
\[\dot{x}(t)=f(t,x(t)),\]  
To simplify the presentation, we omit the dependence on \(t\) of \(x(t)\). Function \(f(t,x)\) is then defined as a piecewise continuous function:  
\[f(t,x)=\left\{\begin{array}{ll}f_{1}(t,x),&x_{1}\in S_{1}\\ f_{0}(t,x),&x_{1}\in S_{0}\\ f_{2}(t,x),&x_{1}\in S_{2}\,\end{array}\right. \tag{12}\]  
where  
\[f_{1}(t,x)=\left(\begin{array}{c}\frac{1}{1-k_{2}}(-(p_{1}+k_{1})(x_{1}-G_ {b})-x_{1}x_{2}+D(t))\\ -p_{2}x_{2}+p_{3}(x_{3}-I_{b})\\ -n(x_{3}-I_{b})\end{array}\right), \tag{13}\]  
\[f_{0}(t,x)=\left(\begin{array}{c}-p_{1}(x_{1}-G_{b})-x_{1}x_{2}+D(t)\\ -p_{2}x_{2}+p_{3}(x_{3}-I_{b})\\ -n(x_{3}-I_{b})+\gamma(x_{1}-\sigma)^{+}t\end{array}\right), \tag{14}\]  
\[f_{2}(t,x)=\left(\begin{array}{c}-p_{1}(x_{1}-G_{b})-x_{1}x_{2}+D(t)\\ -p_{2}x_{2}+p_{3}(x_{3}-I_{b})\\ -n(x_{3}-I_{b})+\gamma(x_{1}-\sigma)^{+}t+(k_{1}-p_{1}k_{2})(x_{1}-G_{b})-k_{2 }x_{1}x_{2}+k_{2}D(t)\end{array}\right). \tag{15}\]According to [PERSON]'s theory (see [31; 32; 33] for an overview on this subject), a vector solution \(x(t)\) of (12) is said to exist if it is absolutely continuous on \([0,\infty)\), and for almost all \(t\in[0,\infty)\), \(\dot{x}\) belongs to \(C[f_{j},f_{0}]\) with \(j=1,2\), the convex closure over all sets of measure zero. Moreover, system (12) is quadratically stable if there exist Lyapunov functions \(V_{j}=V_{j}(t,x)\), \(j=1,2\), verifying two conditions [32]:  
1. \(x\in\mathbf{R}^{3}-\{s_{j}\}\): \(\dot{V}_{j}<0\),
2. \(x\in\{s_{j}\}\): \(\sup\limits_{\alpha\in[0,1]}\left(\frac{\partial V_{j}}{\partial x}\big{(} \alpha f_{0}(t,x)+(1-\alpha)f_{j}(t,x)\big{)}\right)<0\).  
To ensure stability, the control design parameters \(k_{1}\) and \(k_{2}\) have to verify (i) and (ii), obtaining a rule on how to choose these values. Appendix A presents stability's proof details. So, the stability of the closed-loop system is ensured and the commuted PD controller (8)-(10) verifies the control objective.  
The control algorithm to establish healthy behavior in our pancreatic system can be summarized as follows:  
Step 1: Determine parameters \(x_{1_{H}}>0\) and \(x_{1_{h}}>0\), necessary to active controllers \(u_{g}(t)\) or \(u(t)\).  
Step 2: Set the control parameters \(k_{1}>0\) and \(k_{2}>0\) of control \(u_{PD}(t)\) (8), satisfying the stability conditions.  
Step 3: Measure \(x_{1}(t)\) every sample time, and define \(u(t)\) in (7) and \(u_{g}(t)\) in (5) as:  
\[x_{1}(t)\in[x_{1_{H}},x_{1_{H}}] \Rightarrow \left\{\begin{array}{l}u(t)=0\\ u_{g}(t)=0\end{array}\right.\] \[x_{1}(t)<x_{1_{h}} \Rightarrow \left\{\begin{array}{l}u(t)=0\\ u_{g}(t)=-u_{PD}(t)\end{array}\right.\] \[x_{1}(t)>x_{1_{H}} \Rightarrow \left\{\begin{array}{l}u(t)=u_{PD}(t)\\ u_{g}(t)=0\end{array}\right.\]