Program: 73393
Project: 73393
Buggy source:
/** 
 * Consume at most one token from the <i>input</i> port and output the PID control. If there has been no previous iteration, only proportional output is generated. If there is no input, then produce no output.
 * @exception IllegalActionException If addition, multiplication,subtraction, or division is not supported by the supplied tokens.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (input.hasToken(0)) {
    Time currentTime=getDirector().getModelTime();
    DoubleToken currentToken=(DoubleToken)input.get(0);
    _currentInput=new TimedEvent(currentTime,currentToken);
    DoubleToken currentOutput=(DoubleToken)currentToken.multiply(Kp.getToken());
    if (_lastInput != null) {
      DoubleToken lastToken=(DoubleToken)_lastInput.contents;
      Time lastTime=_lastInput.timeStamp;
      DoubleToken timeGap=new DoubleToken(currentTime.subtract(lastTime).getDoubleValue());
      if (timeGap.isCloseTo(DoubleToken.ZERO,Complex.EPSILON).booleanValue()) {
        if (!((DoubleToken)Kd.getToken()).isCloseTo(DoubleToken.ZERO,Complex.EPSILON).booleanValue() && !currentToken.equals(lastToken)) {
          throw new IllegalActionException("String_Node_Str");
        }
      }
 else {
        if (!((DoubleToken)Ki.getToken()).isCloseTo(DoubleToken.ZERO,Complex.EPSILON).booleanValue()) {
          _accumulated=(DoubleToken)_accumulated.add(currentToken.add(lastToken).multiply(timeGap).multiply(new DoubleToken(0.5)));
          currentOutput=(DoubleToken)currentOutput.add(_accumulated.multiply(Ki.getToken()));
        }
        if (!Kd.equals(0)) {
          currentOutput=(DoubleToken)currentOutput.add(currentToken.subtract(lastToken).divide(timeGap).multiply(Kd.getToken()));
        }
      }
    }
    output.broadcast(currentOutput);
  }
}

Fixed version (ground truth):
/** 
 * Consume at most one token from the <i>input</i> port and output the PID control. If there has been no previous iteration, only proportional output is generated. If there is no input, then produce no output.
 * @exception IllegalActionException If addition, multiplication,subtraction, or division is not supported by the supplied tokens.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (input.hasToken(0)) {
    Time currentTime=getDirector().getModelTime();
    DoubleToken currentToken=(DoubleToken)input.get(0);
    _currentInput=new TimedEvent(currentTime,currentToken);
    DoubleToken currentOutput=(DoubleToken)currentToken.multiply(Kp.getToken());
    if (_lastInput != null) {
      DoubleToken lastToken=(DoubleToken)_lastInput.contents;
      Time lastTime=_lastInput.timeStamp;
      DoubleToken timeGap=new DoubleToken(currentTime.subtract(lastTime).getDoubleValue());
      if (timeGap.isCloseTo(DoubleToken.ZERO,Complex.EPSILON).booleanValue()) {
        if (!((DoubleToken)Kd.getToken()).isCloseTo(DoubleToken.ZERO,Complex.EPSILON).booleanValue() && !currentToken.equals(lastToken)) {
          throw new IllegalActionException("String_Node_Str");
        }
      }
 else {
        if (!((DoubleToken)Ki.getToken()).isCloseTo(DoubleToken.ZERO,Complex.EPSILON).booleanValue()) {
          _accumulated=(DoubleToken)_accumulated.add(currentToken.add(lastToken).multiply(timeGap).multiply(new DoubleToken(0.5)));
          currentOutput=(DoubleToken)currentOutput.add(_accumulated.multiply(Ki.getToken()));
        }
        if (!((DoubleToken)Kd.getToken()).isCloseTo(DoubleToken.ZERO,Complex.EPSILON).booleanValue()) {
          currentOutput=(DoubleToken)currentOutput.add(currentToken.subtract(lastToken).divide(timeGap).multiply(Kd.getToken()));
        }
      }
    }
    output.broadcast(currentOutput);
  }
}