# 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
The overall change in the East direction is large, and the trajectory distribution band presents a 'fann-shaped' diffusion, indicating that the model has a more relaxed space selection freedom in the middle section. The vertical change is longer, and the trajectory near the obstacle area does not undergo drastic adjustment in the vertical depth direction, indicating that the model mainly relies on lateral adjustment to avoid, rather than secondary deflection or uplift. Colored lines: Different colors represent well trajectories of multiple wells or different sections of the same well, distinguishing trajectories by well, construction stage, or design scheme. Red shaded area: Marks key intervals of engineering/geological interest. Figure 7: Optimal trajectories for trajectory avoidance in an obstacle environment at the beginning of a borehole. Figure 9 Trajectory planning in terminal obstacle environment. Visual indication of obstacles: gray spheres (radius = 80 m) located at coordinates (1200, 950, 800) [North, East, Depth]. A scale bar (0-500 m) is added at the bottom left, with all axes labeled in meters (m). As shown in Figure 9, when the obstacle is set at the end of the borehole, the trajectory undergoes a small but precise spatial offset before approaching the end to avoid the safety buffer zone of the obstacle body, the avoidance amplitude is small but the action is effective and does not affect the overall trajectory continuity. The reinforcement learning strategy still has the ability of fine-tuning in the later stage in the case of terminal obstacles, showing the ability of stable control and precise position correction in the convergence period. The reinforcement learning strategy has stabilized at the end stage, and obstacle avoidance is achieved through fine space adjustment rather than changing the deviation angle, which maximizes the continuity of trajectory curvature. The obstacle avoidance strategy is more conservative, avoiding drastic adjustment at the end of the wellbore, and ensuring the accuracy of the target point and the constructability of the path. Colored lines: Different colors represent well trajectories of multiple wells or different sections of the same well (vertical depth profiles along the east coordinate), distinguishing by well, construction stage, or scheme. Red area: Marks key layers of engineering/geological interest (e.g., reservoirs, fault/fracture zones). Figure 8: Trajectory avoidance training process in a mid-borehole obstacle environment. Figure 10 shows the optimal trajectory in a mid-borehole obstacle environment, and Figure 11 shows the optimal trajectory in a terminal obstacle environment. Optimal trajectories are distinguished by red bold lines (other training trajectories are shown in light blue). A scale bar (0-800 m) is added to the bottom right of each figure, with all axes labeled in meters (m). It can be seen from the figures that both optimal trajectories successfully avoid the obstacle safety buffer zone, showing good path planning ability and construction feasibility. In the case of the middle obstacle, the trajectory achieves a smooth bypass transition through the flexible linkage of azimuth angle and deviation angle before approaching the obstacle, and the path shows moderate deflection rather than sudden change in the horizontal projection, reflecting that the model has excellent local path reconstruction ability. In the end obstacle situation, the trajectory tends to converge as a whole, and the obstacle avoidance behavior is mainly based on slight adjustment, accurately and stably avoiding the obstacle body, which fully reflects the stable control ability and high-precision convergence characteristics of the reinforcement learning strategy near the target point. The trajectories of the two cases remain continuous and smooth in the vertical direction without dramatic curvature changes, which verifies the robustness and intelligent adaptability of the proposed path strategy under different stages of obstacle interference.