Optimal selection of statistical units: an approach via simulated annealing