Package org.ar.tools

Examples of org.ar.tools.CSVFileWriter


   
    //open a reader to get the Sudokus
    BufferedReader in = new BufferedReader(new FileReader(inSudokuFile));
    String strLine;
    //write the results in a CSV file
    CSVFileWriter out = new CSVFileWriter(outCSVResults, ',');
    FileOutputStream fout = new FileOutputStream(output);
    PrintStream printStream = new PrintStream(fout);
    Vector<String> fields;
    long startTime, endTime;
    int k = 0;
   
    double sum = 0;
    double bck = 0;
    String solution = "";
    double avg_time;
    double avg_bck;
   
    while ((strLine = in.readLine()) != null)  
    {  
      k++;
      fields = new Vector<String>();
      fields.add(""+k);
     
      for(int i=0; i < searchers.size(); i++)
      {
        avg_time = 0;
        avg_bck = 0;
        for(int j = 0; j < NO_RUNS; j++)
        {
          startTime   = System.currentTimeMillis();
          solution = searchers.get(i).run(strLine);
          endTime   = System.currentTimeMillis();
          avg_time += endTime - startTime;
          avg_bck  += searchers.get(i).noBactracks;       

        }
        avg_bck /= (double)NO_RUNS;
        avg_time /= (double)NO_RUNS;
        fields.add(solution);
       
        fields.add(""+ (avg_time));
        fields.add("" + avg_bck);
        fields.add("" + (avg_bck + searchers.get(i).noGivens - 81));
        sum += avg_time;
        bck += avg_bck;
      }
      //print the solution in the file
      printStream.println(solution);
      out.writeFields(fields);
    }
    in.close();
    out.close();
    fout.close()
  }
View Full Code Here

TOP

Related Classes of org.ar.tools.CSVFileWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.