Reinforcement Learning-Based Optimal Formation Tracking for UAVs With Safety Constraints