Assure randomIndices is empty in each initialization step.

This helps to reuse the current optimizer because the generateIndices
method can always create the appropriate values.