An adaptive optimization method for estimating the number of components in a Gaussian mixture model