Efficient Analysis and Optimization of Planar Periodic Structures