Program: 73528
Project: 73528
Buggy source:
/** 
 * Instantiate new model structures to get ready for a simulation run. Check if the enclosing director is a DEDirector. If not, throw an exception. Call the preinitialize() method in the super class. The superclass instantiates an event queue structure, however, here a  PtidesListEventQueue structure is instantiated in its place.  We do this because a Ptides scheduler not only need to access the first event in the event queue, but all other events, in sorted order.  Also, the delayOffset used in the  safe-to-process analysis is calculated. This is followed by a check to see if sensors, actuators, and networks ports are annotated with the corresponding parameters, and whether they are connected to the  corresponding sensor/actuator/network actors. Finally, the parameter stopWhenQueueIsEmpty is set to false.  In general, Ptides models should never stop when the event queue is empty, because it can wait and react to future sensor input events.
 * @see #_calculateDelayOffsets
 * @exception IllegalActionException If the enclosing director doesnot exist or is not a DEDirector, delayOffset cannot be calculated,  sensor/actuator/network consistency cannot be checked, or if the  super class throws it.
 */
public void preinitialize() throws IllegalActionException {
  NamedObj container=getContainer();
  if (!(container instanceof Actor)) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  Director executiveDirector=((Actor)container).getExecutiveDirector();
  if (executiveDirector == null || !(executiveDirector instanceof DEDirector)) {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
  }
  super.preinitialize();
  _eventQueue=new PtidesListEventQueue();
  _checkSensorActuatorNetworkConsistency();
  _calculateDelayOffsets();
  stopWhenQueueIsEmpty.setExpression("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Instantiate new model structures to get ready for a simulation run. Check if the enclosing director is a DEDirector. If not, throw an exception. Call the preinitialize() method in the super class. The superclass instantiates an event queue structure, however, here a  PtidesListEventQueue structure is instantiated in its place.  We do this because a Ptides scheduler not only need to access the first event in the event queue, but all other events, in sorted order.  Also, the delayOffset used in the  safe-to-process analysis is calculated. This is followed by a check to see if sensors, actuators, and networks ports are annotated with the corresponding parameters, and whether they are connected to the  corresponding sensor/actuator/network actors. Finally, the parameter stopWhenQueueIsEmpty is set to false.  In general, Ptides models should never stop when the event queue is empty, because it can wait and react to future sensor input events.
 * @see #_calculateDelayOffsets
 * @exception IllegalActionException If the enclosing director doesnot exist or is not a DEDirector, delayOffset cannot be calculated,  sensor/actuator/network consistency cannot be checked, or if the  super class throws it.
 */
public void preinitialize() throws IllegalActionException {
  NamedObj container=getContainer();
  if (!(container instanceof Actor)) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  Director executiveDirector=((Actor)container).getExecutiveDirector();
  if (executiveDirector == null || !(executiveDirector instanceof DEDirector)) {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
  }
  if (((BooleanToken)animateExecution.getToken()).booleanValue()) {
    Parameter parameter=(Parameter)((NamedObj)executiveDirector).getAttribute("String_Node_Str");
    if (parameter == null) {
      throw new IllegalActionException(executiveDirector,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
    }
    if (!((BooleanToken)parameter.getToken()).booleanValue()) {
      throw new IllegalActionException(executiveDirector,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    }
  }
  super.preinitialize();
  _eventQueue=new PtidesListEventQueue();
  _checkSensorActuatorNetworkConsistency();
  _calculateDelayOffsets();
  stopWhenQueueIsEmpty.setExpression("String_Node_Str");
}