Locally resonant metamaterials can exhibit bandgaps at low frequencies with the wavelengths much longer than their lattice size. In this study, a rainbow metamaterial is proposed for the pur-pose of vibration suppression within broad frequency ranges. A Π-shaped beam is partitioned into subspace by parallel plate insertions. Cantilever-mass microstructures are later attached to each subspace of the composite beam as local resonators. For the purpose of enlarging the bandgaps of the metamaterials, the mass of resonators are varied along the axial direction of the beam, namely 'rainbow-shaped'. The frequency response functions of the metamaterial are calculated by a novel analytical model that built on the basis of the displacement transfer matrix method. With the pro-posed analytical model, the receptance functions of the rainbow metamaterial is optimized by vir-tue of the Genetic Algorithm method, with the mass of each resonators as design variables. The optimized rainbow metamaterials show good vibration attenuation in the prescribed optimization frequency range.