Program: 74868
Project: 74868
Buggy source:
/** 
 * Always returns true, indicating that the (sub)system is always ready for one iteration. <P> If this is not a top-level director, some additional work is done to synchronize time with the executive director. In particular, it will compare its local time, say t, with the current time of the executive director, say t0. If t == t0, do nothing. <BR> If t > t0, then rollback to the "known good" time (which should be less than the outside time) and catch up with the outside time. <BR> If t < t0, then throw an exception because the CT subsystem should always run ahead of the outside event-based system. <BR> <P> If this director is not a top-level director, the iteration end time is resolved from the current time of the outside system, say t1, the next iteration time of the outside system, say t2, and the runAheadLength parameter of this director, say t3. The iteration end time is set to be <code>t5 = t1 + min(t2, t3)</code>. The iteration end time may be further refined in the fire() method due to possible event generated during the iteration. In particular, when the first event is detected, say at t5 and t5 < t4, then the iteration ends at t5. <p>  This method updates the suggested step size.
 * @return true Always.
 * @exception IllegalActionException If the local time isless than the current time of the executive director, or thrown by a directed actor.
 */
public boolean prefire() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str",getName(),"String_Node_Str");
  }
  if (!_isTopLevel()) {
    CompositeActor container=(CompositeActor)getContainer();
    Director executiveDirector=container.getExecutiveDirector();
    _outsideTime=executiveDirector.getModelTime();
    Time localTime=getModelTime();
    Time outsideNextIterationTime=executiveDirector.getModelNextIterationTime();
    if (_debugging) {
      _debug("String_Node_Str" + _outsideTime,"String_Node_Str" + outsideNextIterationTime,"String_Node_Str" + localTime);
    }
    if (outsideNextIterationTime.compareTo(_outsideTime) < 0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str" + _outsideTime + "String_Node_Str"+ outsideNextIterationTime);
    }
    if (_outsideTime.compareTo(localTime) > 0) {
      throw new IllegalActionException(this,executiveDirector,"String_Node_Str" + "String_Node_Str");
    }
 else     if (_outsideTime.compareTo(localTime) < 0) {
      if (_debugging) {
        _debug(getName() + "String_Node_Str" + localTime+ "String_Node_Str"+ _knownGoodTime+ "String_Node_Str"+ _outsideTime);
      }
      _rollback();
      _propagateResolvedStates();
      _catchUp();
      if (_debugging) {
        _debug("String_Node_Str" + localTime);
      }
    }
    if (_debugging) {
      _debug("String_Node_Str" + "String_Node_Str");
    }
    _setIterationBeginTime(getModelTime());
    double aheadLength=outsideNextIterationTime.subtract(_outsideTime).getDoubleValue();
    if (_debugging) {
      _debug(getName(),"String_Node_Str" + localTime,"String_Node_Str" + _outsideTime,"String_Node_Str" + outsideNextIterationTime + "String_Node_Str"+ aheadLength);
    }
    if (aheadLength < getTimeResolution()) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      aheadLength=0;
    }
 else     if (aheadLength > _runAheadLength) {
      aheadLength=_runAheadLength;
    }
    double currentSuggestedNextStepSize=getSuggestedNextStepSize();
    if (aheadLength < currentSuggestedNextStepSize || currentSuggestedNextStepSize == 0) {
      setSuggestedNextStepSize(aheadLength);
    }
    if (_debugging) {
      _debug(getName(),"String_Node_Str" + getSuggestedNextStepSize());
    }
    return true;
  }
 else {
    return super.prefire();
  }
}

Fixed version (ground truth):
/** 
 * Always returns true, indicating that the (sub)system is always ready for one iteration. <P> If this is not a top-level director, some additional work is done to synchronize time with the executive director. In particular, it will compare its local time, say t, with the current time of the executive director, say t0. If t == t0, do nothing. <BR> If t > t0, then rollback to the "known good" time (which should be less than the outside time). <BR> If t < t0, then throw an exception because the CT subsystem should always run ahead of the outside event-based system. <BR> <P> If this director is not a top-level director, the iteration end time is resolved from the current time of the outside system, say t1, the next iteration time of the outside system, say t2, and the runAheadLength parameter of this director, say t3. The iteration end time is set to be <code>t5 = t1 + min(t2, t3)</code>. The iteration end time may be further refined in the fire() method due to possible event generated during the iteration. In particular, when the first event is detected, say at t5 and t5 < t4, then the iteration ends at t5. <p>  This method updates the suggested step size.
 * @return true Always.
 * @exception IllegalActionException If the local time isless than the current time of the executive director, or thrown by a directed actor.
 */
public boolean prefire() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str",getName(),"String_Node_Str");
  }
  if (!_isTopLevel()) {
    CompositeActor container=(CompositeActor)getContainer();
    Director executiveDirector=container.getExecutiveDirector();
    _outsideTime=executiveDirector.getModelTime();
    Time localTime=getModelTime();
    Time outsideNextIterationTime=executiveDirector.getModelNextIterationTime();
    if (_debugging) {
      _debug("String_Node_Str" + _outsideTime,"String_Node_Str" + outsideNextIterationTime,"String_Node_Str" + localTime);
    }
    if (outsideNextIterationTime.compareTo(_outsideTime) < 0) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str" + _outsideTime + "String_Node_Str"+ outsideNextIterationTime);
    }
    double aheadLength=_runAheadLength;
    if (_outsideTime.compareTo(localTime) > 0) {
      throw new IllegalActionException(this,executiveDirector,"String_Node_Str" + "String_Node_Str");
    }
 else     if (_outsideTime.compareTo(localTime) < 0) {
      if (_debugging) {
        _debug(getName() + "String_Node_Str" + localTime+ "String_Node_Str"+ _knownGoodTime+ "String_Node_Str"+ _outsideTime);
      }
      _rollback();
      aheadLength=_outsideTime.subtract(getModelTime()).getDoubleValue();
    }
 else {
      aheadLength=outsideNextIterationTime.subtract(_outsideTime).getDoubleValue();
    }
    if (_debugging) {
      _debug(getName(),"String_Node_Str" + localTime,"String_Node_Str" + _outsideTime,"String_Node_Str" + outsideNextIterationTime + "String_Node_Str"+ aheadLength);
    }
    if (aheadLength < getTimeResolution()) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      aheadLength=0;
    }
 else     if (aheadLength > _runAheadLength) {
      aheadLength=_runAheadLength;
    }
    double currentSuggestedNextStepSize=getSuggestedNextStepSize();
    if (aheadLength < currentSuggestedNextStepSize || currentSuggestedNextStepSize == 0) {
      setSuggestedNextStepSize(aheadLength);
    }
    if (_debugging) {
      _debug(getName(),"String_Node_Str" + getSuggestedNextStepSize());
    }
    _setIterationBeginTime(getModelTime());
    return true;
  }
 else {
    return super.prefire();
  }
}