Program: 72963
Project: 72963
Buggy source:
/** 
 * Get the next actor that can be fired from a specified event queue. Check whether the event is safe to process, the actors prefire returns true and the event can be scheduled. Because Ptides does not store tokens in receivers but keeps them in the event until the actor is really fired, we have to temporarily put tokens into receivers and then remove them in order for the prefire to give correct results.
 * @param queue The event queue.
 * @return The next actor to fire or null.
 * @exception IllegalActionException Thrown by safeToProcess, prefireor schedule.
 */
private Actor _getNextActorFrom(DEEventQueue queue) throws IllegalActionException {
  Object[] eventArray=queue.toArray();
  for (  Object event : eventArray) {
    System.out.println(event);
    if (_isSafeToProcess((PtidesEvent)event)) {
      PtidesEvent ptidesEvent=(PtidesEvent)event;
      Actor actor=ptidesEvent.actor();
      Time timestamp=ptidesEvent.timeStamp();
      if (queue == _pureEvents) {
        for (        Object triggeredEventObject : _eventQueue.toArray()) {
          PtidesEvent triggeredEvent=(PtidesEvent)triggeredEventObject;
          if (triggeredEvent.actor() == actor && triggeredEvent.timeStamp().compareTo(timestamp) < 0) {
            ptidesEvent=triggeredEvent;
          }
        }
      }
      actor=ptidesEvent.actor();
      timestamp=ptidesEvent.timeStamp();
      List<PtidesEvent> sameTagEvents=new ArrayList<PtidesEvent>();
      int i=0;
      while (i < queue.size()) {
        PtidesEvent eventInQueue=((PtidesListEventQueue)queue).get(i);
        if (eventInQueue.hasTheSameTagAs(ptidesEvent) && eventInQueue.actor().equals(actor)) {
          sameTagEvents.add(eventInQueue);
          if (eventInQueue.receiver() != null) {
            if (eventInQueue.receiver() instanceof PtidesReceiver) {
              ((PtidesReceiver)eventInQueue.receiver()).putToReceiver(eventInQueue.token());
            }
          }
        }
        i++;
      }
      _currentLogicalTime=timestamp;
      _currentLogicalIndex=ptidesEvent.microstep();
      _currentSourceTimestamp=ptidesEvent.sourceTimestamp();
      boolean prefire=actor.prefire();
      _currentLogicalTime=null;
      for (      PtidesEvent sameTagEvent : sameTagEvents) {
        if (sameTagEvent.receiver() != null) {
          if (sameTagEvent.receiver() instanceof PtidesReceiver) {
            ((PtidesReceiver)sameTagEvent.receiver()).remove(sameTagEvent.token());
          }
        }
      }
      if (prefire)       System.out.println(getModelTime() + "String_Node_Str" + actor+ "String_Node_Str"+ timestamp);
      if (prefire && (!_resourceScheduling || ((queue != _pureEvents && actor instanceof TimeDelay) || _actorsFinished.contains(actor) || _schedule(actor,timestamp)) && (!(actor instanceof CompositeActor) || ((CompositeActor)actor).getDirector().scheduleContainedActors()))) {
        System.out.println("String_Node_Str");
        _currentLogicalTime=timestamp;
        _currentLogicalIndex=ptidesEvent.microstep();
        _currentSourceTimestamp=ptidesEvent.sourceTimestamp();
        _removeEventsFromQueue(_eventQueue,ptidesEvent);
        _removeEventsFromQueue(_pureEvents,ptidesEvent);
        _actorsFinished.remove(actor);
        if (_debugging) {
          _debug("String_Node_Str" + actor + "String_Node_Str"+ timestamp);
        }
        return actor;
      }
    }
  }
  if (_debugging) {
    _debug("String_Node_Str");
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Get the next actor that can be fired from a specified event queue. Check whether the event is safe to process, the actors prefire returns true and the event can be scheduled. Because Ptides does not store tokens in receivers but keeps them in the event until the actor is really fired, we have to temporarily put tokens into receivers and then remove them in order for the prefire to give correct results.
 * @param queue The event queue.
 * @return The next actor to fire or null.
 * @exception IllegalActionException Thrown by safeToProcess, prefireor schedule.
 */
private Actor _getNextActorFrom(DEEventQueue queue) throws IllegalActionException {
  Object[] eventArray=queue.toArray();
  for (  Object event : eventArray) {
    if (_isSafeToProcess((PtidesEvent)event)) {
      PtidesEvent ptidesEvent=(PtidesEvent)event;
      Actor actor=ptidesEvent.actor();
      Time timestamp=ptidesEvent.timeStamp();
      if (queue == _pureEvents) {
        for (        Object triggeredEventObject : _eventQueue.toArray()) {
          PtidesEvent triggeredEvent=(PtidesEvent)triggeredEventObject;
          if (triggeredEvent.actor() == actor && triggeredEvent.timeStamp().compareTo(timestamp) < 0) {
            ptidesEvent=triggeredEvent;
          }
        }
      }
      actor=ptidesEvent.actor();
      timestamp=ptidesEvent.timeStamp();
      List<PtidesEvent> sameTagEvents=new ArrayList<PtidesEvent>();
      int i=0;
      while (i < queue.size()) {
        PtidesEvent eventInQueue=((PtidesListEventQueue)queue).get(i);
        if (eventInQueue.hasTheSameTagAs(ptidesEvent) && eventInQueue.actor().equals(actor)) {
          sameTagEvents.add(eventInQueue);
          if (eventInQueue.receiver() != null) {
            if (eventInQueue.receiver() instanceof PtidesReceiver) {
              ((PtidesReceiver)eventInQueue.receiver()).putToReceiver(eventInQueue.token());
            }
          }
        }
        i++;
      }
      _currentLogicalTime=timestamp;
      _currentLogicalIndex=ptidesEvent.microstep();
      _currentSourceTimestamp=ptidesEvent.sourceTimestamp();
      boolean prefire=actor.prefire();
      _currentLogicalTime=null;
      for (      PtidesEvent sameTagEvent : sameTagEvents) {
        if (sameTagEvent.receiver() != null) {
          if (sameTagEvent.receiver() instanceof PtidesReceiver) {
            ((PtidesReceiver)sameTagEvent.receiver()).remove(sameTagEvent.token());
          }
        }
      }
      if (prefire && (!_resourceScheduling || ((queue != _pureEvents && actor instanceof TimeDelay) || _actorsFinished.contains(actor) || _schedule(actor,timestamp)) && (!(actor instanceof CompositeActor) || ((CompositeActor)actor).getDirector().scheduleContainedActors()))) {
        _currentLogicalTime=timestamp;
        _currentLogicalIndex=ptidesEvent.microstep();
        _currentSourceTimestamp=ptidesEvent.sourceTimestamp();
        _removeEventsFromQueue(_eventQueue,ptidesEvent);
        _removeEventsFromQueue(_pureEvents,ptidesEvent);
        _actorsFinished.remove(actor);
        if (_debugging) {
          _debug("String_Node_Str" + actor + "String_Node_Str"+ timestamp);
        }
        return actor;
      }
    }
  }
  if (_debugging) {
    _debug("String_Node_Str");
  }
  return null;
}