Program: 74958
Project: 74958
Buggy source:
/** 
 * Return the CTSchedule. Caching of the schedule is done in the super class, so this method does not test for the validation of the schedule.
 */
protected Schedule _getSchedule() throws NotSchedulableException, IllegalActionException {
  CTSchedule ctSchedule=new CTSchedule();
  _signalTypeMap=new SignalTypeMap();
  LinkedList continuousActors=new LinkedList();
  LinkedList discreteActors=new LinkedList();
  LinkedList dynamicActors=new LinkedList();
  LinkedList stateTransitionActors=new LinkedList();
  LinkedList arithmeticActors=new LinkedList();
  LinkedList sinkActors=new LinkedList();
  LinkedList eventGenerators=new LinkedList();
  LinkedList waveformGenerators=new LinkedList();
  LinkedList ctSubsystems=new LinkedList();
  LinkedList nonCTSubsystems=new LinkedList();
  Schedule continuousActorSchedule=new Schedule();
  Schedule discreteActorSchedule=new Schedule();
  Schedule dynamicActorSchedule=new Schedule();
  Schedule eventGeneratorSchedule=new Schedule();
  Schedule outputSchedule=new Schedule();
  Schedule outputSSCActorSchedule=new Schedule();
  Schedule statefulActorSchedule=new Schedule();
  Schedule stateSSCActorSchedule=new Schedule();
  Schedule stateTransitionSchedule=new Schedule();
  Schedule waveformGeneratorSchedule=new Schedule();
  CompositeActor container=(CompositeActor)getContainer().getContainer();
  boolean isCTCompositeActor=container instanceof CTCompositeActor;
  Iterator containerInPorts=container.inputPortList().iterator();
  while (containerInPorts.hasNext()) {
    IOPort inPort=(IOPort)containerInPorts.next();
    if (!isCTCompositeActor) {
      Receiver[][] localReceivers=inPort.getReceivers();
      Receiver localReceiver=localReceivers[0][0];
      if (localReceiver instanceof StateReceiver) {
        _signalTypeMap.setType(inPort,CONTINUOUS);
      }
 else {
        _signalTypeMap.setType(inPort,DISCRETE);
      }
    }
 else {
      Parameter signalType=(Parameter)inPort.getAttribute("String_Node_Str");
      if (signalType != null) {
        String type=((StringToken)signalType.getToken()).stringValue();
        type=type.trim().toUpperCase();
        if (type.equals("String_Node_Str")) {
          _signalTypeMap.setType(inPort,CONTINUOUS);
        }
 else         if (type.equals("String_Node_Str")) {
          _signalTypeMap.setType(inPort,DISCRETE);
        }
 else {
          throw new IllegalActionException(inPort,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
        }
      }
 else {
        _signalTypeMap.setType(inPort,CONTINUOUS);
      }
    }
    _signalTypeMap.propagateTypeInside(inPort);
  }
  Iterator allActors=container.deepEntityList().iterator();
  while (allActors.hasNext()) {
    Actor a=(Actor)allActors.next();
    if (_debugging & _verbose) {
      _debug("String_Node_Str" + ((Nameable)a).getFullName() + "String_Node_Str");
    }
    if (a instanceof CompositeActor) {
      if (a instanceof CTCompositeActor) {
        dynamicActors.add(a);
        arithmeticActors.add(a);
        ctSubsystems.add(a);
        statefulActorSchedule.add(new Firing(a));
        waveformGenerators.add(a);
        eventGenerators.add(a);
      }
 else {
        nonCTSubsystems.add(a);
      }
    }
 else {
      if (a instanceof CTStatefulActor) {
        statefulActorSchedule.add(new Firing(a));
      }
      if (a instanceof CTWaveformGenerator) {
        waveformGenerators.add(a);
      }
 else       if (a instanceof CTEventGenerator) {
        eventGenerators.add(a);
      }
 else       if (a instanceof CTDynamicActor) {
        dynamicActors.add(a);
      }
 else {
        arithmeticActors.add(a);
      }
    }
    if (a instanceof SequenceActor) {
      if (predecessorList(a).isEmpty()) {
        throw new NotSchedulableException(((Nameable)a).getName() + "String_Node_Str" + "String_Node_Str");
      }
      Iterator ports=((Entity)a).portList().iterator();
      while (ports.hasNext()) {
        IOPort port=(IOPort)ports.next();
        _signalTypeMap.setType(port,DISCRETE);
        if (port.isOutput()) {
          _signalTypeMap.propagateType(port);
        }
      }
    }
 else     if ((a instanceof CompositeActor) && !(a instanceof CTCompositeActor)) {
      Iterator ports=((Entity)a).portList().iterator();
      while (ports.hasNext()) {
        IOPort port=(IOPort)ports.next();
        if (port.isOutput()) {
          Receiver[][] insideReceivers=port.getInsideReceivers();
          Receiver insideReceiver=insideReceivers[0][0];
          if (insideReceiver instanceof StateReceiver) {
            _signalTypeMap.setType(port,CONTINUOUS);
          }
 else {
            _signalTypeMap.setType(port,DISCRETE);
          }
          _signalTypeMap.propagateType(port);
        }
      }
    }
 else {
      Iterator ports=((Entity)a).portList().iterator();
      while (ports.hasNext()) {
        IOPort port=(IOPort)ports.next();
        Parameter signalType=(Parameter)port.getAttribute("String_Node_Str");
        if (signalType != null) {
          String type=((StringToken)signalType.getToken()).stringValue();
          type=type.trim().toUpperCase();
          if (type.equals("String_Node_Str")) {
            _signalTypeMap.setType(port,CONTINUOUS);
            if (port.isOutput()) {
              _signalTypeMap.propagateType(port);
            }
          }
 else           if (type.equals("String_Node_Str")) {
            _signalTypeMap.setType(port,DISCRETE);
            if (port.isOutput()) {
              _signalTypeMap.propagateType(port);
            }
          }
 else {
            throw new InvalidStateException(port,"String_Node_Str");
          }
        }
 else         if (a instanceof CTCompositeActor) {
          if (_signalTypeMap.getType(port) == UNKNOWN) {
            _signalTypeMap.setType(port,CONTINUOUS);
          }
          if (port.isOutput()) {
            _signalTypeMap.propagateType(port);
          }
        }
      }
      if (predecessorList(a).isEmpty()) {
        ports=((Entity)a).portList().iterator();
        while (ports.hasNext()) {
          IOPort port=(IOPort)ports.next();
          if (_signalTypeMap.getType(port) == UNKNOWN) {
            _signalTypeMap.setType(port,CONTINUOUS);
            if (port.isOutput()) {
              _signalTypeMap.propagateType(port);
            }
          }
        }
      }
    }
  }
  DirectedAcyclicGraph arithmeticGraph=_toGraph(arithmeticActors);
  if (!arithmeticGraph.isAcyclic()) {
    throw new NotSchedulableException("String_Node_Str");
  }
  DirectedAcyclicGraph dynamicGraph=_toGraph(dynamicActors);
  if (!dynamicGraph.isAcyclic()) {
    throw new NotSchedulableException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  Object[] sortedArithmeticActors=arithmeticGraph.topologicalSort();
  for (int i=0; i < sortedArithmeticActors.length; i++) {
    Actor actor=(Actor)sortedArithmeticActors[i];
    Iterator inputPorts=actor.inputPortList().iterator();
    CTReceiver.SignalType knownInputType=UNKNOWN;
    boolean needManuallySetType=true;
    while (inputPorts.hasNext()) {
      IOPort inputPort=(IOPort)inputPorts.next();
      if (inputPort.getWidth() != 0) {
        CTReceiver.SignalType inputType=_signalTypeMap.getType(inputPort);
        if (inputType == UNKNOWN) {
          throw new NotSchedulableException("String_Node_Str" + "String_Node_Str" + inputPort.getFullName() + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
        }
 else         if (knownInputType == UNKNOWN) {
          knownInputType=inputType;
          needManuallySetType=false;
        }
 else         if (knownInputType != inputType) {
          needManuallySetType=true;
          break;
        }
      }
    }
    Iterator outputPorts=actor.outputPortList().iterator();
    while (outputPorts.hasNext()) {
      IOPort outputPort=(IOPort)outputPorts.next();
      if (outputPort.getWidth() != 0) {
        CTReceiver.SignalType outputType=_signalTypeMap.getType(outputPort);
        if (outputType == UNKNOWN) {
          if (needManuallySetType) {
            throw new NotSchedulableException("String_Node_Str" + "String_Node_Str" + outputPort.getFullName() + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
          }
 else {
            _signalTypeMap.setType(outputPort,knownInputType);
          }
        }
        _signalTypeMap.propagateType(outputPort);
      }
    }
  }
  _setPortSignalTypes(_signalTypeMap);
  if (_debugging) {
    _debug("String_Node_Str" + _signalTypeMap.toString() + "String_Node_Str");
  }
  discreteActors=_signalTypeMap.getDiscreteActors();
  continuousActors=_signalTypeMap.getContinuousActors();
  continuousActors.removeAll(ctSubsystems);
  continuousActors.addAll(ctSubsystems);
  discreteActors.removeAll(ctSubsystems);
  discreteActors.addAll(ctSubsystems);
  Iterator subsystems=nonCTSubsystems.iterator();
  while (subsystems.hasNext()) {
    CompositeActor subsystem=(CompositeActor)subsystems.next();
    if (discreteActors.contains(subsystem) && continuousActors.contains(subsystem)) {
      waveformGenerators.add(subsystem);
      discreteActors.remove(subsystem);
      continuousActors.remove(subsystem);
    }
  }
  DirectedAcyclicGraph discreteGraph=_toGraph(discreteActors);
  Object[] discreteSorted=discreteGraph.topologicalSort();
  for (int i=0; i < discreteSorted.length; i++) {
    Actor actor=(Actor)discreteSorted[i];
    if (continuousActors.contains(actor)) {
      if (actor instanceof CTCompositeActor) {
        discreteActorSchedule.add(new Firing(actor));
      }
 else {
        if ((actor instanceof CTEventGenerator) || (actor instanceof CTWaveformGenerator)) {
          continuousActors.remove(actor);
        }
      }
      continue;
    }
    discreteActorSchedule.add(new Firing(actor));
  }
  Iterator generators=waveformGenerators.iterator();
  while (generators.hasNext()) {
    Actor generator=(Actor)generators.next();
    waveformGeneratorSchedule.add(new Firing(generator));
  }
  if (!eventGenerators.isEmpty()) {
    DirectedAcyclicGraph eventGraph=_toGraph(eventGenerators);
    Object[] eventSorted=eventGraph.topologicalSort();
    for (int i=0; i < eventSorted.length; i++) {
      Actor actor=(Actor)eventSorted[i];
      eventGeneratorSchedule.add(new Firing(actor));
      if (actor instanceof CTStepSizeControlActor) {
        outputSSCActorSchedule.add(new Firing(actor));
      }
    }
  }
  Iterator continuousIterator=continuousActors.iterator();
  while (continuousIterator.hasNext()) {
    Actor actor=(Actor)continuousIterator.next();
    continuousActorSchedule.add(new Firing(actor));
  }
  LinkedList stateRelatedActors=new LinkedList();
  arithmeticGraph=_toArithmeticGraph(continuousActors);
  if (!dynamicActors.isEmpty()) {
    Object[] dynamicArray=dynamicActors.toArray();
    Object[] xSorted=dynamicGraph.topologicalSort(dynamicArray);
    for (int i=0; i < xSorted.length; i++) {
      Actor dynamicActor=(Actor)xSorted[i];
      dynamicActorSchedule.add(0,new Firing(dynamicActor));
      stateRelatedActors.add(dynamicActor);
      if (dynamicActor instanceof CTStepSizeControlActor) {
        stateSSCActorSchedule.add(new Firing(dynamicActor));
      }
      Object[] fx;
      fx=arithmeticGraph.backwardReachableNodes(dynamicActor);
      Object[] fxSorted=arithmeticGraph.topologicalSort(fx);
      for (int fxi=0; fxi < fxSorted.length; fxi++) {
        Actor actor=(Actor)fxSorted[fxi];
        if (stateTransitionActors.contains(actor)) {
          continue;
        }
        stateTransitionActors.add(actor);
        stateRelatedActors.add(actor);
        if (actor instanceof CTStepSizeControlActor) {
          stateSSCActorSchedule.add(new Firing(actor));
        }
      }
      if ((dynamicActor instanceof CTCompositeActor) && !stateTransitionActors.contains(dynamicActor)) {
        stateTransitionActors.add(dynamicActor);
      }
    }
  }
  Iterator stActors=stateTransitionActors.iterator();
  while (stActors.hasNext()) {
    Actor stActor=(Actor)stActors.next();
    stateTransitionSchedule.add(new Firing(stActor));
  }
  sinkActors=(LinkedList)continuousActors.clone();
  sinkActors.removeAll(stateRelatedActors);
  sinkActors.addAll(ctSubsystems);
  if (!sinkActors.isEmpty()) {
    arithmeticGraph=_toArithmeticGraph(sinkActors);
    Object[] sinkArray=sinkActors.toArray();
    Object[] gxSorted=arithmeticGraph.topologicalSort(sinkArray);
    for (int i=0; i < gxSorted.length; i++) {
      Actor a=(Actor)gxSorted[i];
      outputSchedule.add(new Firing(a));
      if (!eventGenerators.contains(a) && a instanceof CTStepSizeControlActor) {
        outputSSCActorSchedule.add(new Firing(a));
      }
    }
  }
  ctSchedule.add(continuousActorSchedule);
  ctSchedule.add(discreteActorSchedule);
  ctSchedule.add(dynamicActorSchedule);
  ctSchedule.add(eventGeneratorSchedule);
  ctSchedule.add(outputSchedule);
  ctSchedule.add(outputSSCActorSchedule);
  ctSchedule.add(stateTransitionSchedule);
  ctSchedule.add(statefulActorSchedule);
  ctSchedule.add(stateSSCActorSchedule);
  ctSchedule.add(waveformGeneratorSchedule);
  setValid(true);
  return ctSchedule;
}

Fixed version (ground truth):
/** 
 * Return the CTSchedule. Caching of the schedule is done in the super class, so this method does not test for the validation of the schedule.
 */
protected Schedule _getSchedule() throws NotSchedulableException, IllegalActionException {
  CTSchedule ctSchedule=new CTSchedule();
  _signalTypeMap=new SignalTypeMap();
  LinkedList continuousActors=new LinkedList();
  LinkedList discreteActors=new LinkedList();
  LinkedList dynamicActors=new LinkedList();
  LinkedList stateTransitionActors=new LinkedList();
  LinkedList arithmeticActors=new LinkedList();
  LinkedList sinkActors=new LinkedList();
  LinkedList eventGenerators=new LinkedList();
  LinkedList waveformGenerators=new LinkedList();
  LinkedList ctSubsystems=new LinkedList();
  LinkedList nonCTSubsystems=new LinkedList();
  Schedule continuousActorSchedule=new Schedule();
  Schedule discreteActorSchedule=new Schedule();
  Schedule dynamicActorSchedule=new Schedule();
  Schedule eventGeneratorSchedule=new Schedule();
  Schedule outputSchedule=new Schedule();
  Schedule outputSSCActorSchedule=new Schedule();
  Schedule statefulActorSchedule=new Schedule();
  Schedule stateSSCActorSchedule=new Schedule();
  Schedule stateTransitionSchedule=new Schedule();
  Schedule waveformGeneratorSchedule=new Schedule();
  CompositeActor container=(CompositeActor)getContainer().getContainer();
  boolean isCTCompositeActor=container instanceof CTCompositeActor;
  Iterator containerInPorts=container.inputPortList().iterator();
  while (containerInPorts.hasNext()) {
    IOPort inPort=(IOPort)containerInPorts.next();
    if (!isCTCompositeActor) {
      Receiver[][] localReceivers=inPort.getReceivers();
      Receiver localReceiver=localReceivers[0][0];
      if (localReceiver instanceof StateReceiver) {
        _signalTypeMap.setType(inPort,CONTINUOUS);
      }
 else {
        _signalTypeMap.setType(inPort,DISCRETE);
      }
    }
 else {
      Parameter signalType=(Parameter)inPort.getAttribute("String_Node_Str");
      if (signalType != null) {
        String type=((StringToken)signalType.getToken()).stringValue();
        type=type.trim().toUpperCase();
        if (type.equals("String_Node_Str")) {
          _signalTypeMap.setType(inPort,CONTINUOUS);
        }
 else         if (type.equals("String_Node_Str")) {
          _signalTypeMap.setType(inPort,DISCRETE);
        }
 else {
          throw new IllegalActionException(inPort,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
        }
      }
 else {
        _signalTypeMap.setType(inPort,CONTINUOUS);
      }
    }
    _signalTypeMap.propagateTypeInside(inPort);
  }
  Iterator allActors=container.deepEntityList().iterator();
  while (allActors.hasNext()) {
    Actor a=(Actor)allActors.next();
    if (_debugging & _verbose) {
      _debug("String_Node_Str" + ((Nameable)a).getFullName() + "String_Node_Str");
    }
    if (a instanceof CompositeActor) {
      if (a instanceof CTCompositeActor) {
        dynamicActors.add(a);
        arithmeticActors.add(a);
        ctSubsystems.add(a);
        statefulActorSchedule.add(new Firing(a));
        waveformGenerators.add(a);
        eventGenerators.add(a);
      }
 else {
        nonCTSubsystems.add(a);
      }
    }
 else {
      if (a instanceof CTStatefulActor) {
        statefulActorSchedule.add(new Firing(a));
      }
      if (a instanceof CTWaveformGenerator) {
        waveformGenerators.add(a);
      }
 else       if (a instanceof CTEventGenerator) {
        eventGenerators.add(a);
      }
 else       if (a instanceof CTDynamicActor) {
        dynamicActors.add(a);
      }
 else {
        arithmeticActors.add(a);
      }
    }
    if (a instanceof SequenceActor) {
      if (predecessorList(a).isEmpty()) {
        throw new NotSchedulableException(((Nameable)a).getName() + "String_Node_Str" + "String_Node_Str");
      }
      Iterator ports=((Entity)a).portList().iterator();
      while (ports.hasNext()) {
        IOPort port=(IOPort)ports.next();
        _signalTypeMap.setType(port,DISCRETE);
        if (port.isOutput()) {
          _signalTypeMap.propagateType(port);
        }
      }
    }
 else     if ((a instanceof CompositeActor) && !(a instanceof CTCompositeActor)) {
      Iterator ports=((Entity)a).portList().iterator();
      while (ports.hasNext()) {
        IOPort port=(IOPort)ports.next();
        if (port.isOutput()) {
          Receiver[][] insideReceivers=port.getInsideReceivers();
          if (insideReceivers.length > 0 && insideReceivers[0] != null && insideReceivers[0].length > 0) {
            Receiver insideReceiver=insideReceivers[0][0];
            if (insideReceiver instanceof StateReceiver) {
              _signalTypeMap.setType(port,CONTINUOUS);
            }
 else {
              _signalTypeMap.setType(port,DISCRETE);
            }
          }
 else {
            _signalTypeMap.setType(port,CONTINUOUS);
          }
          _signalTypeMap.propagateType(port);
        }
      }
    }
 else {
      Iterator ports=((Entity)a).portList().iterator();
      while (ports.hasNext()) {
        IOPort port=(IOPort)ports.next();
        Parameter signalType=(Parameter)port.getAttribute("String_Node_Str");
        if (signalType != null) {
          String type=((StringToken)signalType.getToken()).stringValue();
          type=type.trim().toUpperCase();
          if (type.equals("String_Node_Str")) {
            _signalTypeMap.setType(port,CONTINUOUS);
            if (port.isOutput()) {
              _signalTypeMap.propagateType(port);
            }
          }
 else           if (type.equals("String_Node_Str")) {
            _signalTypeMap.setType(port,DISCRETE);
            if (port.isOutput()) {
              _signalTypeMap.propagateType(port);
            }
          }
 else {
            throw new InvalidStateException(port,"String_Node_Str");
          }
        }
 else         if (a instanceof CTCompositeActor) {
          if (_signalTypeMap.getType(port) == UNKNOWN) {
            _signalTypeMap.setType(port,CONTINUOUS);
          }
          if (port.isOutput()) {
            _signalTypeMap.propagateType(port);
          }
        }
      }
      if (predecessorList(a).isEmpty()) {
        ports=((Entity)a).portList().iterator();
        while (ports.hasNext()) {
          IOPort port=(IOPort)ports.next();
          if (_signalTypeMap.getType(port) == UNKNOWN) {
            _signalTypeMap.setType(port,CONTINUOUS);
            if (port.isOutput()) {
              _signalTypeMap.propagateType(port);
            }
          }
        }
      }
    }
  }
  DirectedAcyclicGraph arithmeticGraph=_toGraph(arithmeticActors);
  if (!arithmeticGraph.isAcyclic()) {
    throw new NotSchedulableException("String_Node_Str");
  }
  DirectedAcyclicGraph dynamicGraph=_toGraph(dynamicActors);
  if (!dynamicGraph.isAcyclic()) {
    throw new NotSchedulableException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  Object[] sortedArithmeticActors=arithmeticGraph.topologicalSort();
  for (int i=0; i < sortedArithmeticActors.length; i++) {
    Actor actor=(Actor)sortedArithmeticActors[i];
    Iterator inputPorts=actor.inputPortList().iterator();
    CTReceiver.SignalType knownInputType=UNKNOWN;
    boolean needManuallySetType=true;
    while (inputPorts.hasNext()) {
      IOPort inputPort=(IOPort)inputPorts.next();
      if (inputPort.getWidth() != 0) {
        CTReceiver.SignalType inputType=_signalTypeMap.getType(inputPort);
        if (inputType == UNKNOWN) {
          throw new NotSchedulableException("String_Node_Str" + "String_Node_Str" + inputPort.getFullName() + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
        }
 else         if (knownInputType == UNKNOWN) {
          knownInputType=inputType;
          needManuallySetType=false;
        }
 else         if (knownInputType != inputType) {
          needManuallySetType=true;
          break;
        }
      }
    }
    Iterator outputPorts=actor.outputPortList().iterator();
    while (outputPorts.hasNext()) {
      IOPort outputPort=(IOPort)outputPorts.next();
      if (outputPort.getWidth() != 0) {
        CTReceiver.SignalType outputType=_signalTypeMap.getType(outputPort);
        if (outputType == UNKNOWN) {
          if (needManuallySetType) {
            throw new NotSchedulableException("String_Node_Str" + "String_Node_Str" + outputPort.getFullName() + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
          }
 else {
            _signalTypeMap.setType(outputPort,knownInputType);
          }
        }
        _signalTypeMap.propagateType(outputPort);
      }
    }
  }
  _setPortSignalTypes(_signalTypeMap);
  if (_debugging) {
    _debug("String_Node_Str" + _signalTypeMap.toString() + "String_Node_Str");
  }
  discreteActors=_signalTypeMap.getDiscreteActors();
  continuousActors=_signalTypeMap.getContinuousActors();
  continuousActors.removeAll(ctSubsystems);
  continuousActors.addAll(ctSubsystems);
  discreteActors.removeAll(ctSubsystems);
  discreteActors.addAll(ctSubsystems);
  Iterator subsystems=nonCTSubsystems.iterator();
  while (subsystems.hasNext()) {
    CompositeActor subsystem=(CompositeActor)subsystems.next();
    if (discreteActors.contains(subsystem) && continuousActors.contains(subsystem)) {
      waveformGenerators.add(subsystem);
      discreteActors.remove(subsystem);
      continuousActors.remove(subsystem);
    }
  }
  DirectedAcyclicGraph discreteGraph=_toGraph(discreteActors);
  Object[] discreteSorted=discreteGraph.topologicalSort();
  for (int i=0; i < discreteSorted.length; i++) {
    Actor actor=(Actor)discreteSorted[i];
    if (continuousActors.contains(actor)) {
      if (actor instanceof CTCompositeActor) {
        discreteActorSchedule.add(new Firing(actor));
      }
 else {
        if ((actor instanceof CTEventGenerator) || (actor instanceof CTWaveformGenerator)) {
          continuousActors.remove(actor);
        }
      }
      continue;
    }
    discreteActorSchedule.add(new Firing(actor));
  }
  Iterator generators=waveformGenerators.iterator();
  while (generators.hasNext()) {
    Actor generator=(Actor)generators.next();
    waveformGeneratorSchedule.add(new Firing(generator));
  }
  if (!eventGenerators.isEmpty()) {
    DirectedAcyclicGraph eventGraph=_toGraph(eventGenerators);
    Object[] eventSorted=eventGraph.topologicalSort();
    for (int i=0; i < eventSorted.length; i++) {
      Actor actor=(Actor)eventSorted[i];
      eventGeneratorSchedule.add(new Firing(actor));
      if (actor instanceof CTStepSizeControlActor) {
        outputSSCActorSchedule.add(new Firing(actor));
      }
    }
  }
  Iterator continuousIterator=continuousActors.iterator();
  while (continuousIterator.hasNext()) {
    Actor actor=(Actor)continuousIterator.next();
    continuousActorSchedule.add(new Firing(actor));
  }
  LinkedList stateRelatedActors=new LinkedList();
  arithmeticGraph=_toArithmeticGraph(continuousActors);
  if (!dynamicActors.isEmpty()) {
    Object[] dynamicArray=dynamicActors.toArray();
    Object[] xSorted=dynamicGraph.topologicalSort(dynamicArray);
    for (int i=0; i < xSorted.length; i++) {
      Actor dynamicActor=(Actor)xSorted[i];
      dynamicActorSchedule.add(0,new Firing(dynamicActor));
      stateRelatedActors.add(dynamicActor);
      if (dynamicActor instanceof CTStepSizeControlActor) {
        stateSSCActorSchedule.add(new Firing(dynamicActor));
      }
      Object[] fx;
      fx=arithmeticGraph.backwardReachableNodes(dynamicActor);
      Object[] fxSorted=arithmeticGraph.topologicalSort(fx);
      for (int fxi=0; fxi < fxSorted.length; fxi++) {
        Actor actor=(Actor)fxSorted[fxi];
        if (stateTransitionActors.contains(actor)) {
          continue;
        }
        stateTransitionActors.add(actor);
        stateRelatedActors.add(actor);
        if (actor instanceof CTStepSizeControlActor) {
          stateSSCActorSchedule.add(new Firing(actor));
        }
      }
      if ((dynamicActor instanceof CTCompositeActor) && !stateTransitionActors.contains(dynamicActor)) {
        stateTransitionActors.add(dynamicActor);
      }
    }
  }
  Iterator stActors=stateTransitionActors.iterator();
  while (stActors.hasNext()) {
    Actor stActor=(Actor)stActors.next();
    stateTransitionSchedule.add(new Firing(stActor));
  }
  sinkActors=(LinkedList)continuousActors.clone();
  sinkActors.removeAll(stateRelatedActors);
  sinkActors.addAll(ctSubsystems);
  if (!sinkActors.isEmpty()) {
    arithmeticGraph=_toArithmeticGraph(sinkActors);
    Object[] sinkArray=sinkActors.toArray();
    Object[] gxSorted=arithmeticGraph.topologicalSort(sinkArray);
    for (int i=0; i < gxSorted.length; i++) {
      Actor a=(Actor)gxSorted[i];
      outputSchedule.add(new Firing(a));
      if (!eventGenerators.contains(a) && a instanceof CTStepSizeControlActor) {
        outputSSCActorSchedule.add(new Firing(a));
      }
    }
  }
  ctSchedule.add(continuousActorSchedule);
  ctSchedule.add(discreteActorSchedule);
  ctSchedule.add(dynamicActorSchedule);
  ctSchedule.add(eventGeneratorSchedule);
  ctSchedule.add(outputSchedule);
  ctSchedule.add(outputSSCActorSchedule);
  ctSchedule.add(stateTransitionSchedule);
  ctSchedule.add(statefulActorSchedule);
  ctSchedule.add(stateSSCActorSchedule);
  ctSchedule.add(waveformGeneratorSchedule);
  setValid(true);
  return ctSchedule;
}