Program: 74314
Project: 74314
Buggy source:
/** 
 * Recursively compute the minimum delay. To avoid loops, remember visited ports.
 * @param port Port to compute minimum delay for.
 * @param visitedPorts Ports that have already been considered in the recursive computation.
 * @return Dependency describing the minimum Delay.
 * @exception IllegalActionException Thrown if minimum delay cannot be computed.
 */
private Dependency _getMinimumDelay(IOPort port,Collection<IOPort> visitedPorts) throws IllegalActionException {
  if (visitedPorts.contains(port)) {
    return getDefaultDependency();
  }
 else {
    visitedPorts.add(port);
  }
  if (_minimumDelays.get(port) != null) {
    return _minimumDelays.get(port);
  }
  Dependency minimumDelay=getDefaultDependency();
  if (port.isInput()) {
    if (this._actor.inputPortList().contains(port)) {
      if (this._actor.getContainer() != null && this._actor.getExecutiveDirector().defaultDependency().equals(this._actor.getDirector().defaultDependency())) {
        minimumDelay=((CausalityInterfaceForComposites)((CompositeActor)this._actor.getContainer()).getCausalityInterface())._getMinimumDelay(port,visitedPorts);
      }
 else {
        minimumDelay=getDefaultDependency();
      }
    }
 else {
      if (port.getContainer() instanceof CompositeActor) {
        Collection<IOPort> equivalentPorts=(((CompositeActor)port.getContainer()).getCausalityInterface()).equivalentPorts(port);
        for (        IOPort equivalentPort : equivalentPorts) {
          Collection<IOPort> sourcePorts=equivalentPort.sourcePortList();
          for (          IOPort sourcePort : sourcePorts) {
            Dependency dependency=_getMinimumDelay(sourcePort,visitedPorts);
            if (dependency.compareTo(minimumDelay) == Dependency.LESS_THAN) {
              minimumDelay=dependency;
            }
          }
        }
        for (        IOPort equivalentPort : equivalentPorts) {
          _minimumDelays.put(equivalentPort,minimumDelay);
          Collection<IOPort> sourcePorts=equivalentPort.sourcePortList();
          for (          IOPort sourcePort : sourcePorts) {
            _minimumDelays.put(sourcePort,minimumDelay);
          }
        }
      }
 else {
        Collection<IOPort> sourcePorts=port.sourcePortList();
        for (        IOPort actorOutputPort : sourcePorts) {
          Dependency dependency=_getMinimumDelay(actorOutputPort,visitedPorts);
          if (dependency.compareTo(minimumDelay) == Dependency.LESS_THAN) {
            minimumDelay=dependency;
          }
        }
        if (sourcePorts.size() == 0) {
          minimumDelay=getDefaultDependency();
        }
      }
    }
  }
 else   if (port.isOutput()) {
    if (this._actor.outputPortList().contains(port)) {
      Collection<IOPort> sourcePorts=port.sourcePortList();
      for (      IOPort actorOutputPort : sourcePorts) {
        Dependency dependency=_getMinimumDelay(actorOutputPort,visitedPorts);
        if (dependency.compareTo(minimumDelay) == Dependency.LESS_THAN) {
          minimumDelay=dependency;
        }
      }
      if (sourcePorts.size() == 0) {
        minimumDelay=getDefaultDependency();
      }
    }
 else {
      if (port.getContainer() instanceof CompositeActor) {
        if (((CompositeActor)port.getContainer()).getDirector() != this._actor.getDirector() && ((CompositeActor)port.getContainer()).getDirector().defaultDependency().equals(this._actor.getDirector().defaultDependency())) {
          Collection<IOPort> deepInputPorts=port.deepInsidePortList();
          for (          IOPort inputPort : deepInputPorts) {
            Dependency delay=_getMinimumDelay(inputPort,visitedPorts);
            if (delay.compareTo(minimumDelay) == Dependency.LESS_THAN) {
              minimumDelay=delay;
            }
          }
        }
 else {
          this._actor.getDirector().defaultDependency();
        }
      }
 else {
        CausalityInterface causalityInterface=((Actor)port.getContainer()).getCausalityInterface();
        Collection<IOPort> inputPorts=causalityInterface.dependentPorts(port);
        for (        IOPort inputPort : inputPorts) {
          Dependency delay=_getMinimumDelay(inputPort,visitedPorts);
          delay=delay.oTimes(causalityInterface.getDependency(inputPort,port));
          if (delay.compareTo(minimumDelay) == Dependency.LESS_THAN) {
            minimumDelay=delay;
          }
        }
        if (inputPorts.size() == 0) {
          minimumDelay=getDefaultDependency();
        }
      }
    }
  }
  _minimumDelays.put(port,minimumDelay);
  return minimumDelay;
}

Fixed version (ground truth):
/** 
 * Recursively compute the minimum delay. To avoid loops, remember visited ports.
 * @param port Port to compute minimum delay for.
 * @param visitedPorts Ports that have already been considered in the recursive computation.
 * @return Dependency describing the minimum Delay.
 * @exception IllegalActionException Thrown if minimum delay cannot be computed.
 */
private Dependency _getMinimumDelay(IOPort port,Collection<IOPort> visitedPorts) throws IllegalActionException {
  if (visitedPorts.contains(port)) {
    return getDefaultDependency();
  }
 else {
    visitedPorts.add(port);
  }
  if (_minimumDelays.get(port) != null) {
    return _minimumDelays.get(port);
  }
  Dependency minimumDelay=getDefaultDependency().oPlusIdentity();
  if (port.isInput()) {
    if (this._actor.inputPortList().contains(port)) {
      if (this._actor.getContainer() != null && this._actor.getExecutiveDirector().defaultDependency().equals(this._actor.getDirector().defaultDependency())) {
        minimumDelay=((CausalityInterfaceForComposites)((CompositeActor)this._actor.getContainer()).getCausalityInterface())._getMinimumDelay(port,visitedPorts);
      }
 else {
        minimumDelay=getDefaultDependency();
      }
    }
 else {
      if (port.getContainer() instanceof CompositeActor) {
        Collection<IOPort> equivalentPorts=(((CompositeActor)port.getContainer()).getCausalityInterface()).equivalentPorts(port);
        for (        IOPort equivalentPort : equivalentPorts) {
          if (equivalentPort.isInput()) {
            Collection<IOPort> sourcePorts=equivalentPort.sourcePortList();
            for (            IOPort sourcePort : sourcePorts) {
              Dependency dependency=_getMinimumDelay(sourcePort,visitedPorts);
              if (dependency.compareTo(minimumDelay) == Dependency.LESS_THAN) {
                minimumDelay=dependency;
              }
            }
          }
        }
        for (        IOPort equivalentPort : equivalentPorts) {
          _minimumDelays.put(equivalentPort,minimumDelay);
          Collection<IOPort> sourcePorts=equivalentPort.sourcePortList();
          for (          IOPort sourcePort : sourcePorts) {
            _minimumDelays.put(sourcePort,minimumDelay);
          }
        }
      }
 else {
        Collection<IOPort> sourcePorts=port.sourcePortList();
        for (        IOPort actorOutputPort : sourcePorts) {
          Dependency dependency=_getMinimumDelay(actorOutputPort,visitedPorts);
          if (dependency.compareTo(minimumDelay) == Dependency.LESS_THAN) {
            minimumDelay=dependency;
          }
        }
        if (sourcePorts.size() == 0) {
          minimumDelay=getDefaultDependency();
        }
      }
    }
  }
 else   if (port.isOutput()) {
    if (this._actor.outputPortList().contains(port)) {
      Collection<IOPort> sourcePorts=port.sourcePortList();
      for (      IOPort actorOutputPort : sourcePorts) {
        Dependency dependency=_getMinimumDelay(actorOutputPort,visitedPorts);
        if (dependency.compareTo(minimumDelay) == Dependency.LESS_THAN) {
          minimumDelay=dependency;
        }
      }
      if (sourcePorts.size() == 0) {
        minimumDelay=getDefaultDependency();
      }
    }
 else {
      if (port.getContainer() instanceof CompositeActor) {
        if (((CompositeActor)port.getContainer()).getDirector() != this._actor.getDirector() && ((CompositeActor)port.getContainer()).getDirector().defaultDependency().equals(this._actor.getDirector().defaultDependency())) {
          Collection<IOPort> deepInputPorts=port.deepInsidePortList();
          for (          IOPort inputPort : deepInputPorts) {
            Dependency delay=_getMinimumDelay(inputPort,visitedPorts);
            if (delay.compareTo(minimumDelay) == Dependency.LESS_THAN) {
              minimumDelay=delay;
            }
          }
        }
 else {
          this._actor.getDirector().defaultDependency();
        }
      }
 else {
        CausalityInterface causalityInterface=((Actor)port.getContainer()).getCausalityInterface();
        Collection<IOPort> inputPorts=causalityInterface.dependentPorts(port);
        for (        IOPort inputPort : inputPorts) {
          Dependency delay=_getMinimumDelay(inputPort,visitedPorts);
          delay=delay.oTimes(causalityInterface.getDependency(inputPort,port));
          if (delay.compareTo(minimumDelay) == Dependency.LESS_THAN) {
            minimumDelay=delay;
          }
        }
        if (inputPorts.size() == 0) {
          minimumDelay=getDefaultDependency();
        }
      }
    }
  }
  _minimumDelays.put(port,minimumDelay);
  return minimumDelay;
}