## 3 Offline Optimization and Adaptation Under Nonlinear Task Constraints
### Optimization and Adaptation Procedure
#### 3.3.2 Adaptation Procedure
For 30 timesteps, each timestep involves 7 joint range constraints, 4 hyperplane constraints, 6 repellers constraints (from robot links 1 to 6), and waypoints constraints for the start and end points, resulting in a total of \((7+4+6)\times 30+2=512\) constraints. In EKMPs [23], the optimization targets the Lagrange multipliers that define the task constraints, with a quadratic programming (QP) approach employed. As a result, the number of optimization variables is equal to the number of task constraints, which is 512. Using the optimal multipliers, a kernel matrix is constructed to derive the mean and covariance for each timestep. In our method, before optimization, the overall ProMP distributions are decoupled into the mean and standard deviation for each timestep. We then identify timesteps that may violate the task constraints based on the mean and standard deviation at each timestep. We find that there are 8 timesteps violating the task constraints, and the waypoint constraints at the start and end points are already satisfied, resulting in \((7+4+6)\times 8=136\) constraints. In addition to optimizing the mean and covariance of ProMPs, we also optimize the mean and standard deviation of the joint positions for the 8 timesteps with \(665+14\times 8=777\) parameters in total. During optimization, we discover that the algorithm in [21] integrates all nonlinear task constraints with \((\boldsymbol{\mu}_{\boldsymbol{w}},\boldsymbol{\Sigma}_{\boldsymbol{w}})\) for each timestep. This integration necessitates the evaluation of symmetric positive definiteness for the covariance matrix \(\boldsymbol{\Sigma}_{\boldsymbol{w}}\) during optimization, resulting in the most iterations and the longest optimization time. EKMPs [23], which involve large matrix computations, also encounter numerical instability. Specifically, as the number of timesteps and task constraints increases, the matrix size grows, and many matrix parameters become unstable during inversion. Some elements may also become redundant, which is a characteristic of the KMP formulation. Although QP optimization reduces the number of iterations, the extensive matrix computations required to calculate the mean and covariance at each timestep still lead to longer optimization times. In contrast, our method essentially decouples the ProMP parameters to each timestep and identifies the feature timesteps that violate task constraints, optimizing the distribution for those specific timesteps separately. Notably, after optimizing the mean and standard deviation, the optimization of the mean and covariance of ProMPs becomes linear in terms of \(\boldsymbol{\mu}_{\boldsymbol{w}}\) and \(\boldsymbol{\Sigma}_{\boldsymbol{w}}\), which avoids introducing numerical instability. Here, we do not rely on ProMPs' inherent ability to generate new parameters. Instead, we address the issue of ProMPs' limited extrapolation ability through optimization. However, since our method utilizes TensorFlow's automatic differentiation rather than a QP formulation, the total \begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Algorithm in [21]** & **EKMPs in [23]** & **Our Method** \\ \hline Parameters for Optimization & 665 & 512 & 777 \\ Constraints Formulas \(F_{\mathrm{c}_{kj}}\), Numbers & 512 & 512 & 136 \\ Total Iteration Numbers & 265 & 36 & 64 \\ Optimization Time (s) & 853.36 & 728.58 & 126.45 \\ Distribution Loss & 76.48\% & 70.32\% & 84.36\% \\ Task Success Rate & 92\% & 91\% & 99\% \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Robot offline movement adaptation comparison. We set the same task constraints in the danger scene (Figure 6(a)). Given the initial collision-free end-effector trajectory sets, we obtain the corresponding Joint space distributions using Jacobian IK. Some Joint distributions may lead to collisions for robot links 1 to 6, and the goal is to optimize the distributions for task execution, which is then performed 100 times. number of iterations is slightly higher than that of EKMP.