Acoustic metamaterials based on local resonances: Homogenization, optimization and applications