AI Algorithm for Predicting and Optimizing Trajectory of UAV Swarm