Efficient Optimization of a Permanent Magnet Array for a Stable 2D Trap