Program: 75209
Project: 75209
Buggy source:
/** 
 * Predict the next step size. This method should be called if the current integration step is accurate to estimate the step size for the next step. The predicted step size is the minimum of all predictions from step size control actors, and it never exceeds 10 times this step size. If there are no step-size control actors at all, then return the current step size.  This results in leaving the step size at its initial value.
 * @return the prediced next step size.
 * @exception IllegalActionException If the scheduler throws it.
 */
protected double _predictNextStepSize() throws IllegalActionException {
  if (!isDiscretePhase()) {
    double predictedStep=10.0 * getCurrentStepSize();
    boolean foundOne=false;
    CTSchedule schedule=(CTSchedule)getScheduler().getSchedule();
    Iterator actors=schedule.get(CTSchedule.STATE_STEP_SIZE_CONTROL_ACTORS).actorIterator();
    while (actors.hasNext()) {
      CTStepSizeControlActor actor=(CTStepSizeControlActor)actors.next();
      predictedStep=Math.min(predictedStep,actor.predictedStepSize());
      foundOne=true;
    }
    actors=schedule.get(CTSchedule.OUTPUT_STEP_SIZE_CONTROL_ACTORS).actorIterator();
    while (actors.hasNext()) {
      CTStepSizeControlActor actor=(CTStepSizeControlActor)actors.next();
      predictedStep=Math.min(predictedStep,actor.predictedStepSize());
      foundOne=true;
    }
    if (foundOne) {
      return predictedStep;
    }
 else {
      return getCurrentStepSize();
    }
  }
 else {
    return getInitialStepSize();
  }
}

Fixed version (ground truth):
/** 
 * Predict the next step size. This method should be called if the current integration step is accurate to estimate the step size for the next step. The predicted step size is the minimum of all predictions from step size control actors, and it never exceeds 10 times this step size. If there are no step-size control actors at all, then return the current step size.  This results in leaving the step size at its initial value.
 * @return the prediced next step size.
 * @exception IllegalActionException If the scheduler throws it.
 */
protected double _predictNextStepSize() throws IllegalActionException {
  if (!isDiscretePhase()) {
    double predictedStep=10.0 * getCurrentStepSize();
    boolean foundOne=false;
    CTSchedule schedule=(CTSchedule)getScheduler().getSchedule();
    Iterator actors=schedule.get(CTSchedule.STATE_STEP_SIZE_CONTROL_ACTORS).actorIterator();
    while (actors.hasNext()) {
      CTStepSizeControlActor actor=(CTStepSizeControlActor)actors.next();
      predictedStep=Math.min(predictedStep,actor.predictedStepSize());
      foundOne=true;
    }
    actors=schedule.get(CTSchedule.OUTPUT_STEP_SIZE_CONTROL_ACTORS).actorIterator();
    while (actors.hasNext()) {
      CTStepSizeControlActor actor=(CTStepSizeControlActor)actors.next();
      predictedStep=Math.min(predictedStep,actor.predictedStepSize());
      foundOne=true;
    }
    if (foundOne) {
      return predictedStep;
    }
 else {
      predictedStep=getCurrentStepSize() * 1.5;
      if (predictedStep <= getMaxStepSize()) {
        return predictedStep;
      }
      return getCurrentStepSize();
    }
  }
 else {
    return getInitialStepSize();
  }
}