Program: 72337
Project: 72337
Buggy source:
/** 
 * Change a parameter in the .xml, making it vary within an interval defined by the parameters start and end. Run a ptolemy simulation for each step between the interval.
 * @param waitingTime The time the system will wait to close all the windows of a federation, after its execution has finished.This parameter is intended to give the user the ability to choose how long he will have to look at the simulation's results. If the variable is given a negative value, the user will be asked repetedly if he had time to look at the models and they will only close when he answers "yes".
 * @param vergil An instance of vergil.
 * @param modelPath The path to the model you want to run.
 * @param propertyLine The xml line of the parameter that we want to change.
 * @param start The value of the parameter.
 * @param end The end value of the parameter.
 * @param step The increment of the parameter value.
 * @param solver Which RKSolver to use
 * @exception IllegalActionException If there is a problem reading a file.
 */
public static void changeParameter(int waitingTime,AutomaticSimulation vergil,String[] modelPath,String propertyLine,float start,float end,float step,int solver) throws IllegalActionException {
  int numberOfFederates=modelPath.length;
  File[] file=new File[numberOfFederates];
  String[][] data=new String[numberOfFederates][3];
  String s="String_Node_Str" + step;
  s=s.substring(s.indexOf("String_Node_Str"));
  int numberOfDecimalDigits=s.length();
  for (int i=0; i < numberOfFederates; i++) {
    file[i]=new File(modelPath[i]);
    ArrayList<String> content;
    try {
      content=convertFileToString(file[i]);
    }
 catch (    IOException ex) {
      throw new IllegalActionException(null,ex,"String_Node_Str" + file[i]);
    }
    String[] info=_findPropertyLine(content,propertyLine);
    data[i][0]=info[0];
    data[i][1]=info[1];
    data[i][2]=info[2];
  }
  int numberOfInteractions=Math.round(((end - start) / step) + 1);
  for (int i=0; i < numberOfInteractions; i++) {
    float x=start + i * step;
    x=(float)(Math.round(x * Math.pow(10,numberOfDecimalDigits)) / Math.pow(10,numberOfDecimalDigits));
    final CompositeEntity[] model=new CompositeEntity[numberOfFederates];
    for (int j=0; j < numberOfFederates; j++) {
      System.out.println("String_Node_Str" + j + "String_Node_Str");
      String line=data[j][1] + x + "String_Node_Str";
      _writeInFile(file[j],data[j][0] + "String_Node_Str" + line+ "String_Node_Str"+ data[j][2]);
      model[j]=_openModel(modelPath[j]);
    }
    runAllModels(vergil);
    if (waitingTime < 0) {
      Scanner input=new Scanner(System.in,"String_Node_Str");
      while (true) {
        System.out.println("String_Node_Str");
        String answer=input.next();
        if (answer.equalsIgnoreCase("String_Node_Str"))         input.close();
        break;
      }
      _sleep(2000);
    }
 else     if (waitingTime > 0) {
      _sleep(waitingTime);
    }
    for (int j=0; j < numberOfFederates; j++) {
      _closeModel(model[j]);
    }
    _killRTIG();
  }
  try {
    Configuration.closeAllTableaux();
  }
 catch (  IllegalActionException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Change a parameter in the .xml, making it vary within an interval defined by the parameters start and end. Run a ptolemy simulation for each step between the interval.
 * @param waitingTime The time the system will wait to close all the windows of a federation, after its execution has finished.This parameter is intended to give the user the ability to choose how long he will have to look at the simulation's results. If the variable is given a negative value, the user will be asked repetedly if he had time to look at the models and they will only close when he answers "yes".
 * @param vergil An instance of vergil.
 * @param modelPath The path to the model you want to run.
 * @param propertyLine The xml line of the parameter that we want to change.
 * @param start The value of the parameter.
 * @param end The end value of the parameter.
 * @param step The increment of the parameter value.
 * @param solver Which RKSolver to use
 * @exception IllegalActionException If there is a problem reading a file.
 */
public static void changeParameter(int waitingTime,AutomaticSimulation vergil,String[] modelPath,String propertyLine,float start,float end,float step,int solver) throws IllegalActionException {
  int numberOfFederates=modelPath.length;
  File[] file=new File[numberOfFederates];
  String[][] data=new String[numberOfFederates][3];
  String s="String_Node_Str" + step;
  s=s.substring(s.indexOf("String_Node_Str"));
  int numberOfDecimalDigits=s.length();
  for (int i=0; i < numberOfFederates; i++) {
    file[i]=new File(modelPath[i]);
    ArrayList<String> content;
    try {
      content=convertFileToString(file[i]);
    }
 catch (    IOException ex) {
      throw new IllegalActionException(null,ex,"String_Node_Str" + file[i]);
    }
    String[] info=_findPropertyLine(content,propertyLine);
    data[i][0]=info[0];
    data[i][1]=info[1];
    data[i][2]=info[2];
  }
  int numberOfInteractions=Math.round(((end - start) / step) + 1);
  for (int i=0; i < numberOfInteractions; i++) {
    float x=start + i * step;
    x=(float)(Math.round(x * Math.pow(10,numberOfDecimalDigits)) / Math.pow(10,numberOfDecimalDigits));
    final CompositeEntity[] model=new CompositeEntity[numberOfFederates];
    for (int j=0; j < numberOfFederates; j++) {
      System.out.println("String_Node_Str" + j + "String_Node_Str");
      String line=data[j][1] + x + "String_Node_Str";
      _writeInFile(file[j],data[j][0] + "String_Node_Str" + line+ "String_Node_Str"+ data[j][2]);
      model[j]=_openModel(modelPath[j]);
    }
    runAllModels(vergil);
    if (waitingTime < 0) {
      Scanner input=new Scanner(System.in,"String_Node_Str");
      while (true) {
        System.out.println("String_Node_Str");
        String answer=input.next();
        if (answer.equalsIgnoreCase("String_Node_Str")) {
          input.close();
          break;
        }
      }
      _sleep(2000);
    }
 else     if (waitingTime > 0) {
      _sleep(waitingTime);
    }
    for (int j=0; j < numberOfFederates; j++) {
      _closeModel(model[j]);
    }
    _killRTIG();
  }
  try {
    Configuration.closeAllTableaux();
  }
 catch (  IllegalActionException e) {
    e.printStackTrace();
  }
}