Program: 75934
Project: 75934
Buggy source:
/** 
 * Sanity check the parameters; if the parameters are legal create a continuous-time subsystem that implement the transfer function, preinitialize all the actors in the subsystem,  and set the opaqueness of this actor to true. This method need the write access on the workspace.
 * @throws IllegalActionException If there is no CTDirector,or any contained actors throw it in its preinitialize() method .
 */
public void preinitialize() throws IllegalActionException {
  double[] bRow=((DoubleMatrixToken)numerator.getToken()).doubleMatrix()[0];
  double[] a=((DoubleMatrixToken)denominator.getToken()).doubleMatrix()[0];
  int m=bRow.length;
  int n=a.length;
  if (m > n) {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
  }
  double[] b=new double[n];
  for (int i=1; i <= m; i++) {
    b[n - i]=bRow[m - i];
  }
  for (int i=0; i < n; i++) {
    System.out.println("String_Node_Str" + i + "String_Node_Str"+ a[i]+ "String_Node_Str"+ i+ "String_Node_Str"+ b[i]);
  }
  try {
    _workspace.getWriteAccess();
    removeAllEntities();
    removeAllRelations();
    if (n == 1) {
      if (a[0] == b[0]) {
        connect(input,output);
      }
 else {
        Scale scaleD=new Scale(this,"String_Node_Str");
        scaleD.factor.setToken(new DoubleToken(b[0] / a[0]));
        connect(input,scaleD.input);
        connect(output,scaleD.output);
      }
    }
 else {
      double d=b[0] / a[0];
      int order=n - 1;
      AddSubtract inputAdder=new AddSubtract(this,"String_Node_Str");
      AddSubtract outputAdder=new AddSubtract(this,"String_Node_Str");
      Integrator[] integrators=new Integrator[order];
      IORelation[] nodes=new IORelation[order];
      Scale[] feedback=new Scale[order];
      Scale[] feedforward=new Scale[order];
      for (int i=0; i < order; i++) {
        integrators[i]=new Integrator(this,"String_Node_Str" + i);
        feedback[i]=new Scale(this,"String_Node_Str" + i);
        feedback[i].factor.setToken(new DoubleToken(-a[i + 1] / a[0]));
        feedforward[i]=new Scale(this,"String_Node_Str" + i);
        feedforward[i].factor.setToken(new DoubleToken((b[order - i] - d * a[order - i]) / a[0]));
        nodes[i]=(IORelation)connect(integrators[i].output,feedforward[i].input,"String_Node_Str" + i);
        feedback[i].input.link(nodes[i]);
        connect(feedback[i].output,inputAdder.plus);
        connect(feedforward[i].output,outputAdder.plus);
        if (i >= 1) {
          integrators[i].input.link(nodes[i - 1]);
        }
      }
      connect(inputAdder.output,integrators[0].input);
      IORelation inputRelation=(IORelation)connect(input,inputAdder.plus,"String_Node_Str");
      IORelation outputRelation=(IORelation)connect(output,outputAdder.output,"String_Node_Str");
      if (d != 0) {
        Scale scaleD=new Scale(this,"String_Node_Str");
        scaleD.factor.setToken(new DoubleToken(d));
        scaleD.input.link(inputRelation);
        connect(scaleD.output,outputAdder.plus);
      }
    }
    _opaque=false;
    _workspace.incrVersion();
    System.out.println("String_Node_Str");
  }
 catch (  NameDuplicationException ex) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + ex.getMessage());
  }
 finally {
    _workspace.doneWriting();
  }
  for (Iterator i=deepEntityList().iterator(); i.hasNext(); ) {
    Actor actor=(Actor)i.next();
    actor.preinitialize();
  }
}

Fixed version (ground truth):
/** 
 * Sanity check the parameters; if the parameters are legal create a continuous-time subsystem that implement the transfer function, preinitialize all the actors in the subsystem,  and set the opaqueness of this actor to true. This method need the write access on the workspace.
 * @throws IllegalActionException If there is no CTDirector,or any contained actors throw it in its preinitialize() method .
 */
public void preinitialize() throws IllegalActionException {
  double[] bRow=((DoubleMatrixToken)numerator.getToken()).doubleMatrix()[0];
  double[] a=((DoubleMatrixToken)denominator.getToken()).doubleMatrix()[0];
  int m=bRow.length;
  int n=a.length;
  if (m > n) {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
  }
  double[] b=new double[n];
  for (int i=1; i <= m; i++) {
    b[n - i]=bRow[m - i];
  }
  for (int i=0; i < n; i++) {
    System.out.println("String_Node_Str" + i + "String_Node_Str"+ a[i]+ "String_Node_Str"+ i+ "String_Node_Str"+ b[i]);
  }
  try {
    _workspace.getWriteAccess();
    removeAllEntities();
    removeAllRelations();
    if (n == 1) {
      if (a[0] == b[0]) {
        connect(input,output);
      }
 else {
        Scale scaleD=new Scale(this,"String_Node_Str");
        scaleD.factor.setToken(new DoubleToken(b[0] / a[0]));
        connect(input,scaleD.input);
        connect(output,scaleD.output);
      }
    }
 else {
      double d=b[0] / a[0];
      int order=n - 1;
      AddSubtract inputAdder=new AddSubtract(this,"String_Node_Str");
      AddSubtract outputAdder=new AddSubtract(this,"String_Node_Str");
      Integrator[] integrators=new Integrator[order];
      IORelation[] nodes=new IORelation[order];
      Scale[] feedback=new Scale[order];
      Scale[] feedforward=new Scale[order];
      for (int i=0; i < order; i++) {
        integrators[i]=new Integrator(this,"String_Node_Str" + i);
        feedback[i]=new Scale(this,"String_Node_Str" + i);
        feedback[i].factor.setToken(new DoubleToken(-a[i + 1] / a[0]));
        feedforward[i]=new Scale(this,"String_Node_Str" + i);
        feedforward[i].factor.setToken(new DoubleToken((b[i + 1] - d * a[i + 1]) / a[0]));
        nodes[i]=(IORelation)connect(integrators[i].output,feedforward[i].input,"String_Node_Str" + i);
        feedback[i].input.link(nodes[i]);
        connect(feedback[i].output,inputAdder.plus);
        connect(feedforward[i].output,outputAdder.plus);
        if (i >= 1) {
          integrators[i].input.link(nodes[i - 1]);
        }
      }
      connect(inputAdder.output,integrators[0].input);
      IORelation inputRelation=(IORelation)connect(input,inputAdder.plus,"String_Node_Str");
      IORelation outputRelation=(IORelation)connect(output,outputAdder.output,"String_Node_Str");
      if (d != 0) {
        Scale scaleD=new Scale(this,"String_Node_Str");
        scaleD.factor.setToken(new DoubleToken(d));
        scaleD.input.link(inputRelation);
        connect(scaleD.output,outputAdder.plus);
      }
    }
    _opaque=false;
    _workspace.incrVersion();
    System.out.println("String_Node_Str");
  }
 catch (  NameDuplicationException ex) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + ex.getMessage());
  }
 finally {
    _workspace.doneWriting();
  }
  for (Iterator i=deepEntityList().iterator(); i.hasNext(); ) {
    Actor actor=(Actor)i.next();
    actor.preinitialize();
  }
}