in principle superior, because Wannier functions may be constructed as being localized in space and are still an exact representation of the point symmetry group of the host PhC. Effective solutions developed for the electronic case, namely, maximally localized generalized Wannier functions [@marzari1; @marzari2], have been applied only recently to the electromagnetic case [@whittaker; @busch2]. Since then, the theory of photonic Wannier functions has been applied to the analysis of 2D PhC cavities, waveguides [@busch2; @Busch2003], waveguide crossings [@Jiao2005] and PhC heterostructures [@Istrate2006]. The generalization of the approach to the case of 2D slab PhCs and 3D PhCs has been also reported in [@McGurn2005; @Takeda2006]. However, the construction of well-localized Wannier functions involves a multidimensional optimization problem [@WanProb2], with the arbitrary phase of each Bloch mode (defined below) as optimizations parameters. Therefore, the practical importance of this approach has been fairly limited up to now. In the present work we systematically analyze this optimization problem employing local as well as global optimization procedures. We propose a novel locality measure for the Wannier functions which allows for a highly efficient optimization of the locality of the Wannier function.

Wannier functions are defined as the Fourier transform of the Bloch modes $${{\mathbf{B}}_{n 