Program: 75273
Project: 75273
Buggy source:
/** 
 * Check each remote receiver to see if the number of tokens in the receiver is greater than or equal to the tokenConsumptionRate of the containing port. The actor is deferrable if the above test is true for any receiver. At the same time, find the maximum number of tokens in all receivers, which is used to find minimax actor later on.
 * @param actor The actor to be checked.
 * @return true if the actor is deferrable, false if not.
 * @throws IllegalActionException If any called method throwsIllegalActionException.
 */
protected boolean _isDeferrable(Actor actor) throws IllegalActionException {
  boolean deferrable=false;
  int maxSize=0;
  Iterator outputPorts=actor.outputPortList().iterator();
  while (outputPorts.hasNext()) {
    IOPort outputPort=(IOPort)outputPorts.next();
    Receiver[][] farReceivers=outputPort.getRemoteReceivers();
    for (int i=0; i < farReceivers.length; i++)     for (int j=0; j < farReceivers[i].length; j++) {
      SDFReceiver farReceiver=(SDFReceiver)farReceivers[i][j];
      IOPort port=farReceiver.getContainer();
      if (port == outputPort)       continue;
      int tokenConsumptionRate=1;
      Parameter rate=null;
      if (port.isInput()) {
        rate=(Parameter)port.getAttribute("String_Node_Str");
        if (rate == null) {
          rate=(Parameter)port.getAttribute("String_Node_Str");
        }
      }
      if (port.isOutput()) {
        rate=(Parameter)port.getAttribute("String_Node_Str");
        if (rate == null) {
          rate=(Parameter)port.getAttribute("String_Node_Str");
        }
      }
      if (rate != null) {
        Token token=rate.getToken();
        if (token instanceof ArrayToken) {
          Token[] tokens=((ArrayToken)token).arrayValue();
          Receiver[][] portReceivers=port.getReceivers();
          int channelIndex=0;
          foundChannelIndex:           for (int m=0; m < portReceivers.length; m++)           for (int n=0; n < portReceivers[m].length; n++)           if (farReceiver == portReceivers[m][n]) {
            channelIndex=m;
            break foundChannelIndex;
          }
          tokenConsumptionRate=((IntToken)tokens[channelIndex]).intValue();
        }
 else {
          tokenConsumptionRate=((IntToken)token).intValue();
        }
      }
      if (farReceiver.size() >= tokenConsumptionRate) {
        deferrable=true;
      }
      if (farReceiver.size() > maxSize) {
        maxSize=farReceiver.size();
      }
    }
  }
  if (deferrable) {
    int[] flags=(int[])_actorsFlags.get(actor);
    flags[_maxNumberOfTokens]=maxSize;
  }
  return deferrable;
}

Fixed version (ground truth):
/** 
 * Check each remote receiver to see if the number of tokens in the receiver is greater than or equal to the tokenConsumptionRate of the containing port. The actor is deferrable if the above test is true for any receiver. At the same time, find the maximum number of tokens in all receivers, which is used to find minimax actor later on.
 * @param actor The actor to be checked.
 * @return true if the actor is deferrable, false if not.
 * @throws IllegalActionException If any called method throwsIllegalActionException.
 */
protected boolean _isDeferrable(Actor actor) throws IllegalActionException {
  boolean deferrable=false;
  int maxSize=0;
  Iterator outputPorts=actor.outputPortList().iterator();
  while (outputPorts.hasNext()) {
    IOPort outputPort=(IOPort)outputPorts.next();
    Receiver[][] farReceivers=outputPort.getRemoteReceivers();
    for (int i=0; i < farReceivers.length; i++)     for (int j=0; j < farReceivers[i].length; j++) {
      SDFReceiver farReceiver=(SDFReceiver)farReceivers[i][j];
      IOPort port=farReceiver.getContainer();
      if (port == outputPort)       continue;
      int tokenConsumptionRate=1;
      Variable rate=null;
      if (port.isInput()) {
        rate=SDFUtilities.getRateVariable(port,"String_Node_Str");
      }
      if (port.isOutput()) {
        rate=SDFUtilities.getRateVariable(port,"String_Node_Str");
      }
      if (rate != null) {
        Token token=rate.getToken();
        if (token instanceof ArrayToken) {
          Token[] tokens=((ArrayToken)token).arrayValue();
          Receiver[][] portReceivers=port.getReceivers();
          int channelIndex=0;
          foundChannelIndex:           for (int m=0; m < portReceivers.length; m++)           for (int n=0; n < portReceivers[m].length; n++)           if (farReceiver == portReceivers[m][n]) {
            channelIndex=m;
            break foundChannelIndex;
          }
          tokenConsumptionRate=((IntToken)tokens[channelIndex]).intValue();
        }
 else {
          tokenConsumptionRate=((IntToken)token).intValue();
        }
      }
      if (farReceiver.size() >= tokenConsumptionRate) {
        deferrable=true;
      }
      if (farReceiver.size() > maxSize) {
        maxSize=farReceiver.size();
      }
    }
  }
  if (deferrable) {
    int[] flags=(int[])_actorsFlags.get(actor);
    flags[_maxNumberOfTokens]=maxSize;
  }
  return deferrable;
}