# Real-Time Tension Distribution Design for Cable-Driven Parallel Robot
## 4 Optimization of Cable Distribution  
### Optimization Algorithm  
Although the previous section included a useful method for computing the tension distribution of the control wrench, it remains essential to select the proper tension distribution in an optimal and effective manner, and a method that provides a minimum norm for energy reservation is needed. Notably, after utilizing the proposed tension function, we can easily achieve an optimal tension distribution by selecting or minimizing the cost function as \(\mathtt{min}\ C(f)\) without tension constraints. For instance, when choosing a tension with the lowest norm value in a tension space, we can choose \(f\) as follows:  
\[f_{o}=A^{+T}\tau_{d} \tag{27}\]  
Nevertheless, \(A^{+T}\tau_{d}\) is sometimes not a viable alternative, as it is possible that the tension requirement may not be satisfied. Consequently, a feasible \(f\) that can track \(A^{+T}\tau_{d}\) as closely as possible, meet the tension condition, and realize the desired control wrench is required. In order to achieve this goal, we can augment the tension function as follows:  
\[f=f_{\mathtt{min}}1+\lambda[1+\mathtt{Tanh}(\bar{S}L_{a})] \tag{28}\]  
with the use of \(L\) in Equation (12):  
\[L=\bar{S}L_{a} \tag{29}\]where \(\bar{S}\) represent a diagonal matrix, \(\bar{S}:= \begin{bmatrix}S_{1}&\cdots&0\\ \vdots&\ddots&\vdots\\ 0&\cdots&S_{n}\end{bmatrix} \). Notably, \(\bar{S}L_{a}\) can be computed as follows:  
\[\bar{S}L_{a}=\bar{L}_{a}S \tag{30}\]  
where \(\bar{L}_{a}\) denotes the matrix \(\bar{L}_{a}:= \begin{bmatrix}L_{a_{1}}&\cdots&0\\ \vdots&\ddots&\vdots\\ 0&\cdots&L_{a_{n}}\end{bmatrix} \) and the vector \(S\) can be represented as \(S=[S_{1},\ldots,S_{n}]^{T}\). Then, Equation (28) can be shown as \(f=f_{\mathtt{min}}1+\lambda[1+\mathtt{Tanh}(\bar{L}_{a}S)]\). The error between the tension function and desired tension distribution with a minimum norm can be represented as follows:  
\[e_{2}=\hat{f}-f_{o} \tag{31}\]  
and the desired control wrench tracking error becomes  
\[e_{1}=A^{T}\mathtt{Tanh}(\hat{S}\hat{L}_{a})-\bar{\tau} \tag{32}\]  
where \(\hat{L}_{a}\) represents the estimation of \(L_{a}\). Here, the objective is to simultaneously minimize \(e_{1}\) and \(e_{2}\) in order to achieve the desired wrench and optimal tension distribution solution. We define an error function as \(E_{2}=e_{2}^{T}e_{2}\) and \(E_{1}=e_{1}^{T}e_{1}\) to represent the error of tracking the desired wrench and tracking the optimal tension distribution, respectively. In order to simultaneously minimize \(E_{1}\) and \(E_{2}\), based on the gradient descent method, the updated law of the estimation of \(\hat{L}_{a}\) and \(\hat{S}\) can be formulated as follows:  
\[\hat{L}_{a}=-\alpha_{1}\frac{\partial E_{1}}{\partial\bar{L}_{a}}=-\alpha_{1} \hat{S}^{T}(\mathbf{U}_{m\times m}-\mathtt{Tanh}2(\hat{S}\hat{L}_{a}))^{T}Ae_{1} \tag{33}\]  
and  
\[\hat{S}=-\alpha_{2}\frac{\partial E_{2}}{\partial\hat{S}}=-\alpha_{2}\lambda \hat{L}_{a}^{T}(\mathbf{U}_{m\times m}-\mathtt{Tanh}2(\hat{L}_{a}\hat{S}))^{T}e_{2} \tag{34}\]  
where \(\hat{L}_{a}\), \(\hat{L}_{a}\), \(\hat{S}\), \(\hat{S}\) represent the estimation of \(\bar{L}_{a}\), \(L_{a}\), \(\bar{S}\), \(S\). Notably, although the updating law chosen in Equations (33) and (34) minimizes \(E_{1}\) and \(E_{2}\), variations in either of these processes have repercussions on the other. When the ideal tension \(f_{0}\) satisfies all tension constraints, this tension becomes one of the tension solutions that minimize \(E_{1}\) to zero. In this case, a decrease in \(E_{2}\) facilitates decreases in \(E_{1}\). However, when the ideal tension \(f_{0}\) is located outside of the tension constraints, reductions in \(E_{1}\) and \(E_{2}\) can actually lead to conflict, especially considering that updating \(\hat{S}\) may cause a divergence in tension from the desired wrench. In detail, as seen in Figure 2, \(f_{0}\) denotes the optimal tension selection out of the feasible tension space.