Program: 73176
Project: 73176
Buggy source:
/** 
 * Create a schedule for a set of actors.  Given a valid firing vector, simulate the scheduling of the actors until the end of one synchronous dataflow iteration. Each actor will appear in the schedule exactly the number of times that minimally solves the balance equations and in an order where each actor has sufficient tokens on its inputs to fire.   Note that no claim is made that this is an optimal solution in any other sense.
 * @param externalRates Map from external port to an Integerrepresenting the number of tokens produced or consumed from that port during the course of an iteration.
 * @param actorList The actors that need to be scheduled.
 * @param container The container.
 * @return An instance of the Schedule class, indicating the orderin which actors should fire.
 * @exception NotSchedulableException If the algorithm encounters an SDFgraph that is not consistent with the firing vector, or detects an inconsistent internal state, or detects a graph that cannot be scheduled.
 */
@SuppressWarnings("String_Node_Str") private Schedule _scheduleConnectedActors(Map externalRates,List actorList,CompositeActor container) throws NotSchedulableException {
  LinkedList readyToScheduleActorList=new LinkedList();
  Schedule newSchedule=new Schedule();
  Map firingsRemainingVector=new HashMap();
  firingsRemainingVector.putAll(_firingVector);
  LinkedList unscheduledActorList=new LinkedList();
  unscheduledActorList.addAll(actorList);
  try {
    Iterator actorsIterator=actorList.iterator();
    while (actorsIterator.hasNext()) {
      Actor actor=(Actor)actorsIterator.next();
      Iterator inputPorts=actor.inputPortList().iterator();
      while (inputPorts.hasNext()) {
        IOPort inputPort=(IOPort)inputPorts.next();
        Receiver[][] receivers=inputPort.getReceivers();
        if (receivers != null) {
          for (int m=0; m < receivers.length; m++) {
            for (int n=0; n < receivers[m].length; n++) {
              ((SDFReceiver)receivers[m][n])._waitingTokens=0;
            }
          }
        }
      }
    }
    Iterator externalOutputPorts=container.outputPortList().iterator();
    while (externalOutputPorts.hasNext()) {
      IOPort outputPort=(IOPort)externalOutputPorts.next();
      Receiver[][] receivers=outputPort.getInsideReceivers();
      if (receivers != null) {
        for (int m=0; m < receivers.length; m++) {
          for (int n=0; n < receivers[m].length; n++) {
            ((SDFReceiver)receivers[m][n])._waitingTokens=0;
          }
        }
      }
    }
    Iterator actors=actorList.iterator();
    while (actors.hasNext()) {
      Actor actor=(Actor)actors.next();
      int firingsRemaining=((Integer)firingsRemainingVector.get(actor)).intValue();
      if (firingsRemaining == 0) {
        unscheduledActorList.remove(actor);
        continue;
      }
      int inputCount=_countUnfulfilledInputs(actor,actorList,true);
      if (inputCount == 0) {
        readyToScheduleActorList.addFirst(actor);
      }
      if (_debugging && VERBOSE) {
        _debug("String_Node_Str" + ((ComponentEntity)actor).getName() + "String_Node_Str"+ inputCount+ "String_Node_Str");
      }
    }
    actors=actorList.iterator();
    while (actors.hasNext()) {
      Actor actor=(Actor)actors.next();
      Iterator outputPorts=actor.outputPortList().iterator();
      while (outputPorts.hasNext()) {
        IOPort outputPort=(IOPort)outputPorts.next();
        int count=DFUtilities.getTokenInitProduction(outputPort);
        if (_debugging && VERBOSE) {
          _debug("String_Node_Str" + count + "String_Node_Str"+ outputPort);
        }
        if (count > 0) {
          _simulateTokensCreated(outputPort,count,actorList,readyToScheduleActorList);
        }
      }
    }
    for (Iterator inputPorts=container.inputPortList().iterator(); inputPorts.hasNext(); ) {
      IOPort port=(IOPort)inputPorts.next();
      int count=((Integer)externalRates.get(port)).intValue();
      if (count > 0) {
        _simulateExternalInputs(port,count,actorList,readyToScheduleActorList);
      }
    }
    while (readyToScheduleActorList.size() > 0) {
      if (_debugging && VERBOSE) {
        _debug("String_Node_Str");
        for (Iterator readyActors=readyToScheduleActorList.iterator(); readyActors.hasNext(); ) {
          Entity readyActor=(Entity)readyActors.next();
          _debug(readyActor.getFullName());
        }
        _debug("String_Node_Str");
        for (Iterator remainingActors=unscheduledActorList.iterator(); remainingActors.hasNext(); ) {
          Entity remainingActor=(Entity)remainingActors.next();
          _debug(remainingActor.getFullName());
        }
      }
      Actor currentActor=(Actor)readyToScheduleActorList.getFirst();
      while (readyToScheduleActorList.remove(currentActor)) {
      }
      int numberOfFirings=_computeMaximumFirings(currentActor);
      int firingsRemaining=((Integer)firingsRemainingVector.get(currentActor)).intValue();
      if (numberOfFirings > firingsRemaining) {
        numberOfFirings=firingsRemaining;
      }
      if (_debugging && VERBOSE) {
        _debug("String_Node_Str" + currentActor.getName() + "String_Node_Str"+ numberOfFirings+ "String_Node_Str");
      }
      firingsRemaining-=numberOfFirings;
      firingsRemainingVector.put(currentActor,Integer.valueOf(firingsRemaining));
      if (_debugging && VERBOSE) {
        _debug(currentActor.getName() + "String_Node_Str" + firingsRemaining+ "String_Node_Str");
      }
      _simulateInputConsumption(currentActor,numberOfFirings);
      Firing firing=new Firing();
      firing.setActor(currentActor);
      firing.setIterationCount(numberOfFirings);
      newSchedule.add(firing);
      for (Iterator outputPorts=(currentActor).outputPortList().iterator(); outputPorts.hasNext(); ) {
        IOPort outputPort=(IOPort)outputPorts.next();
        int count=DFUtilities.getTokenProductionRate(outputPort);
        _simulateTokensCreated(outputPort,count * numberOfFirings,unscheduledActorList,readyToScheduleActorList);
      }
      if (firingsRemaining < 0) {
        throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      }
      if (firingsRemaining == 0) {
        if (_debugging && VERBOSE) {
          _debug("String_Node_Str" + currentActor + "String_Node_Str");
        }
        while (unscheduledActorList.remove(currentActor)) {
          ;
        }
        if (_debugging && VERBOSE) {
          _debug("String_Node_Str");
          for (Iterator readyActors=readyToScheduleActorList.iterator(); readyActors.hasNext(); ) {
            Entity entity=(Entity)readyActors.next();
            _debug(entity.getFullName());
          }
        }
      }
 else {
        int inputCount=_countUnfulfilledInputs(currentActor,unscheduledActorList,false);
        if ((inputCount <= 0) && unscheduledActorList.contains(currentActor)) {
          readyToScheduleActorList.addFirst(currentActor);
        }
      }
    }
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException(this,ex,"String_Node_Str");
  }
  if (unscheduledActorList.size() > 0) {
    StringBuffer message=new StringBuffer("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    int count=0;
    for (Iterator actors=unscheduledActorList.iterator(); actors.hasNext() && count < 100; count++) {
      Entity entity=(Entity)actors.next();
      message.append(entity.getFullName() + "String_Node_Str");
    }
    if (count >= 99) {
      message.append("String_Node_Str");
    }
    message.append("String_Node_Str");
    List scheduledActorList=new LinkedList();
    scheduledActorList.addAll(actorList);
    scheduledActorList.removeAll(unscheduledActorList);
    count=0;
    for (Iterator actors=scheduledActorList.iterator(); actors.hasNext() && count < 100; count++) {
      Entity entity=(Entity)actors.next();
      message.append(entity.getFullName() + "String_Node_Str");
    }
    if (count >= 99) {
      message.append("String_Node_Str");
    }
    throw new NotSchedulableException(this,message.toString());
  }
  if (_debugging) {
    _debug("String_Node_Str");
    _debug(newSchedule.toString());
  }
  return newSchedule;
}

Fixed version (ground truth):
/** 
 * Create a schedule for a set of actors.  Given a valid firing vector, simulate the scheduling of the actors until the end of one synchronous dataflow iteration. Each actor will appear in the schedule exactly the number of times that minimally solves the balance equations and in an order where each actor has sufficient tokens on its inputs to fire.   Note that no claim is made that this is an optimal solution in any other sense.
 * @param externalRates Map from external port to an Integerrepresenting the number of tokens produced or consumed from that port during the course of an iteration.
 * @param actorList The actors that need to be scheduled.
 * @param container The container.
 * @return An instance of the Schedule class, indicating the orderin which actors should fire.
 * @exception NotSchedulableException If the algorithm encounters an SDFgraph that is not consistent with the firing vector, or detects an inconsistent internal state, or detects a graph that cannot be scheduled.
 */
@SuppressWarnings("String_Node_Str") private Schedule _scheduleConnectedActors(Map externalRates,List actorList,CompositeActor container) throws NotSchedulableException {
  LinkedList readyToScheduleActorList=new LinkedList();
  Schedule newSchedule=new Schedule();
  Map firingsRemainingVector=new HashMap();
  firingsRemainingVector.putAll(_firingVector);
  LinkedList unscheduledActorList=new LinkedList();
  unscheduledActorList.addAll(actorList);
  try {
    Iterator actorsIterator=actorList.iterator();
    while (actorsIterator.hasNext()) {
      Actor actor=(Actor)actorsIterator.next();
      Iterator inputPorts=actor.inputPortList().iterator();
      while (inputPorts.hasNext()) {
        IOPort inputPort=(IOPort)inputPorts.next();
        Receiver[][] receivers=inputPort.getReceivers();
        if (receivers != null) {
          for (int m=0; m < receivers.length; m++) {
            for (int n=0; n < receivers[m].length; n++) {
              ((SDFReceiver)receivers[m][n])._waitingTokens=0;
            }
          }
        }
      }
    }
    Iterator externalOutputPorts=container.outputPortList().iterator();
    while (externalOutputPorts.hasNext()) {
      IOPort outputPort=(IOPort)externalOutputPorts.next();
      Receiver[][] receivers=outputPort.getInsideReceivers();
      if (receivers != null) {
        for (int m=0; m < receivers.length; m++) {
          for (int n=0; n < receivers[m].length; n++) {
            ((SDFReceiver)receivers[m][n])._waitingTokens=0;
          }
        }
      }
    }
    Iterator actors=actorList.iterator();
    while (actors.hasNext()) {
      Actor actor=(Actor)actors.next();
      int firingsRemaining=((Integer)firingsRemainingVector.get(actor)).intValue();
      if (firingsRemaining == 0) {
        unscheduledActorList.remove(actor);
        continue;
      }
      int inputCount=_countUnfulfilledInputs(actor,actorList,true);
      if (inputCount == 0) {
        readyToScheduleActorList.addFirst(actor);
      }
      if (_debugging && VERBOSE) {
        _debug("String_Node_Str" + ((ComponentEntity)actor).getName() + "String_Node_Str"+ inputCount+ "String_Node_Str");
      }
    }
    actors=actorList.iterator();
    while (actors.hasNext()) {
      Actor actor=(Actor)actors.next();
      Iterator outputPorts=actor.outputPortList().iterator();
      while (outputPorts.hasNext()) {
        IOPort outputPort=(IOPort)outputPorts.next();
        int count=DFUtilities.getTokenInitProduction(outputPort);
        if (_debugging && VERBOSE) {
          _debug("String_Node_Str" + count + "String_Node_Str"+ outputPort);
        }
        if (count > 0) {
          _simulateTokensCreated(outputPort,count,actorList,readyToScheduleActorList);
        }
      }
    }
    for (Iterator inputPorts=container.inputPortList().iterator(); inputPorts.hasNext(); ) {
      IOPort port=(IOPort)inputPorts.next();
      int count=((Integer)externalRates.get(port)).intValue();
      if (count > 0) {
        _simulateExternalInputs(port,count,actorList,readyToScheduleActorList);
      }
    }
    while (readyToScheduleActorList.size() > 0) {
      if (_debugging && VERBOSE) {
        _debug("String_Node_Str");
        for (Iterator readyActors=readyToScheduleActorList.iterator(); readyActors.hasNext(); ) {
          Entity readyActor=(Entity)readyActors.next();
          _debug(readyActor.getFullName());
        }
        _debug("String_Node_Str");
        for (Iterator remainingActors=unscheduledActorList.iterator(); remainingActors.hasNext(); ) {
          Entity remainingActor=(Entity)remainingActors.next();
          _debug(remainingActor.getFullName());
        }
      }
      Actor currentActor=(Actor)readyToScheduleActorList.getFirst();
      while (readyToScheduleActorList.remove(currentActor)) {
      }
      int numberOfFirings=_computeMaximumFirings(currentActor);
      int firingsRemaining=((Integer)firingsRemainingVector.get(currentActor)).intValue();
      if (numberOfFirings > firingsRemaining) {
        numberOfFirings=firingsRemaining;
      }
      if (_debugging && VERBOSE) {
        _debug("String_Node_Str" + currentActor.getName() + "String_Node_Str"+ numberOfFirings+ "String_Node_Str");
      }
      firingsRemaining-=numberOfFirings;
      firingsRemainingVector.put(currentActor,Integer.valueOf(firingsRemaining));
      if (_debugging && VERBOSE) {
        _debug(currentActor.getName() + "String_Node_Str" + firingsRemaining+ "String_Node_Str");
      }
      _simulateInputConsumption(currentActor,numberOfFirings);
      Firing firing=new Firing();
      firing.setActor(currentActor);
      firing.setIterationCount(numberOfFirings);
      newSchedule.add(firing);
      for (Iterator outputPorts=(currentActor).outputPortList().iterator(); outputPorts.hasNext(); ) {
        IOPort outputPort=(IOPort)outputPorts.next();
        int count=DFUtilities.getTokenProductionRate(outputPort);
        _simulateTokensCreated(outputPort,count * numberOfFirings,unscheduledActorList,readyToScheduleActorList);
      }
      if (firingsRemaining < 0) {
        throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      }
      if (firingsRemaining == 0) {
        if (_debugging && VERBOSE) {
          _debug("String_Node_Str" + currentActor + "String_Node_Str");
        }
        while (unscheduledActorList.remove(currentActor)) {
          ;
        }
        if (_debugging && VERBOSE) {
          _debug("String_Node_Str");
          for (Iterator readyActors=readyToScheduleActorList.iterator(); readyActors.hasNext(); ) {
            Entity entity=(Entity)readyActors.next();
            _debug(entity.getFullName());
          }
        }
      }
 else {
        int inputCount=_countUnfulfilledInputs(currentActor,unscheduledActorList,false);
        if ((inputCount <= 0) && unscheduledActorList.contains(currentActor)) {
          readyToScheduleActorList.addFirst(currentActor);
        }
      }
    }
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException(this,ex,"String_Node_Str");
  }
  if (unscheduledActorList.size() > 0) {
    StringBuffer message=new StringBuffer("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
    int count=0;
    for (Iterator actors=unscheduledActorList.iterator(); actors.hasNext() && count < 100; count++) {
      Entity entity=(Entity)actors.next();
      message.append(entity.getFullName() + "String_Node_Str");
    }
    if (count >= 99) {
      message.append("String_Node_Str");
    }
    message.append("String_Node_Str");
    List scheduledActorList=new LinkedList();
    scheduledActorList.addAll(actorList);
    scheduledActorList.removeAll(unscheduledActorList);
    count=0;
    for (Iterator actors=scheduledActorList.iterator(); actors.hasNext() && count < 100; count++) {
      Entity entity=(Entity)actors.next();
      message.append(entity.getFullName() + "String_Node_Str");
    }
    if (count >= 99) {
      message.append("String_Node_Str");
    }
    throw new NotSchedulableException(this,message.toString());
  }
  if (_debugging) {
    _debug("String_Node_Str");
    _debug(newSchedule.toString());
  }
  return newSchedule;
}