The paper discusses the optimization of the array factor pattern in a 49-element active planar phased array using particle swarm optimization (PSO) in response to antenna element failures, which can lead to degraded performance. Multiple recovery cases are evaluated, demonstrating that PSO effectively recovers patterns with up to 20% element failure, while also developing a software tool to facilitate this optimization process. The study highlights the advantages of PSO in minimizing computational effort while achieving optimal solutions in real-time scenarios.