TaskAssignment[] sandboxPillar = basePillar.toArray(new TaskAssignment[basePillar.size()]); // Clone to avoid changing basePillar
List<TaskAssignment> subPillar = new ArrayList<TaskAssignment>(subPillarSize);
int minimumAbsDiff = Integer.MAX_VALUE;
for (int i = 0; i < subPillarSize; i++) {
int index = i + workingRandom.nextInt(basePillarSize - i);
TaskAssignment taskAssignment = sandboxPillar[index];
Task task = taskAssignment.getTask();
int absDiff = positive ? task.getStartPeriodRangeTo() - 1 - taskAssignment.getStartPeriod()
: taskAssignment.getStartPeriod() - task.getStartPeriodRangeFrom();
if (absDiff < minimumAbsDiff) {
minimumAbsDiff = absDiff;
}
subPillar.add(taskAssignment);
sandboxPillar[index] = sandboxPillar[i];