# Borehole Trajectory Optimization Design Based on the SAC Algorithm with a Self-Attention Mechanism
## 4 Experimental Design and Result Analysis
### Wellbore Trajectory Design Under Vertical Obstacle Interference Scenarios
Figure 12 shows the trajectory training process in a double-obstacle environment. The dark blue lines represent the proposed SAC + self-attention trajectories, light blue lines represent baseline SAC trajectories, red cubes denote the first obstacle, and blue cylinders denote the second obstacle. All axes are labeled with \"North (m)\", \"East (m)\", and \"Height (m)\" to indicate coordinates and units (meters). Colored lines: Different colors represent well trajectories of multiple wells or different sections of the same well, distinguishing by well, construction stage, or scheme. Red area: Marks key layers of engineering/geological interest. Figure 9: Trajectory avoidance training process in an obstacle environment at the end of a borehole. Figure 11: Optimal trajectories for trajectory avoidance in an obstacle environment at the end of a borehole. Figure 10: Optimal trajectories for trajectory avoidance in a mid-borehole obstacle environment. In order to further verify the obstacle avoidance performance and design ability of SAC algorithm, double obstacles are set up. Figure 12 shows all the training trajectories. The figure shows two vertical obstacle wells (red and blue cylinders), which are located in the early, middle, and rear sections of the path, respectively. All trajectories show good continuity and spatial coordination during the avoidance process. Smooth offset is achieved before and after the two obstacle bodies, and no collision or sharp turning occurs. The overall curvature of the trajectory is well controlled, especially in the smooth transition between the two obstacles, which fully verifies the path reconstruction ability and continuity maintenance ability of the SAC strategy. From the horizontal projection, it can be seen that most of the trajectories move eastward near the first obstacle body (North \(\approx 400\) m), and quickly adjust the direction towards the second obstacle body after crossing the obstacle area. When approaching the second obstacle body (North \(\approx 800\) m), the path makes reasonable avoidance again, and finally converges again in the target area, where the obstacle avoidance action is clear and effective. The overall path still maintains a high uniformity between the two obstacles, and there is no path aggregation or excessive offset, indicating that the strategy has multi-stage obstacle avoidance ability and overall trajectory optimization ability. From the vertical projection, it can be seen that all the trajectories change little in the vertical direction, mainly focusing on the initial deflection process (from vertical to horizontal), and then remain highly stable in the 600-800 m interval. It shows that the two obstacle avoidances are mainly realized by spatial reconstruction in the horizontal direction without obvious vertical disturbance, which meets the requirements of curvature control and well deviation stability in engineering. The red and blue obstacle  
Figure 12: Trajectory avoidance training process in a double-obstacle environment. areas are not crossed in both vertical projections, and the trajectory avoidance strategy is reasonable and effective. Figure 13 shows the optimal trajectory in a double-obstacle environment. All axes are labeled with \"North (m)\", \"East (m)\", and \"Height (m)\" to indicate spatial coordinates and units (meters). The optimal trajectory is identified by a bold green line. This ensures clear visualization of the trajectory's spatial distribution and its relationship with obstacles. Figure 13 shows the path distribution of the obtained optimal wellbore trajectory in the three-dimensional perspective and different projection planes. In the three-dimensional view, the trajectory is smooth and continuous, and there is no sharp curvature fluctuation, indicating that the SAC strategy successfully incorporates the two obstacle avoidance behaviors into the overall planning system to realize the natural transition of the path.