At present, if the optimization proceeds beyond the optimum, it may cause an increase in the batch index. The next round will then start from the higher batch instead of the batch index of the optimum. This code changes it to take the batch index of the optimum, at the cost of potentially getting the batch library twice if these are the same. (But the time impact of this is negligible and the benefits can be significant.)
At present, if the optimization proceeds beyond the optimum, it may cause an increase in the batch index. The next round will then start from the higher batch instead of the batch index of the optimum. This code changes it to take the batch index of the optimum, at the cost of potentially getting the batch library twice if these are the same. (But the time impact of this is negligible and the benefits can be significant.)