The problems of optimization of the planar resonant or leaky-wave antennas with waveguide excitation are considered. The directivity factor in some frequency range or deviation of the amplitude pattern from the desired one is optimized. The optimization algorithm consists of transformation of the outer problem to inner one, and of using the following combined methods: local variations, cross-sections, opposite directions, and basic problems of excitations. Numerical results for the resonant antenna and the detailed algorithm description for the leaky-wave antenna are presented.