Task scheduling and voltage selection for energy minimization