private static void batch_sls_qualitfied_runTime_distributions(File file) { System.out.println("BATCH BEGINS"); if (!file.isDirectory()) { System.out.println("The file '" + file.getName() + "' is not a directory."); return; } // A filter to avoid the system hidden files, like '.DS_Store' on MAC OS. FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return !name.equals(".DS_Store"); } }; File[] files = file.listFiles(filter); System.out.println("On files:"); for (File f : files) { System.out.println(f.getName()); } System.out.println("Computations:"); // ------------------------------------------------------- // We look at the 2 SLS algorithms (only slack init mode). // First the SA: // ------------------------------------------------------- int pivotingMode = SA_MODE; int neighbourhoodMode = INSERT_MODE; int initMode = SLACK_INIT; Algorithm itImp = new Algorithm(pivotingMode, neighbourhoodMode, initMode, ILS_OFF); for (File instanceFile : files) { try (BufferedWriter writer = new BufferedWriter( new FileWriter( Algorithm.MAX_RELATIVE_PERCENTAGE_DEVIATION + " " + Algorithm.ILS_MODES[Algorithm.ILS_OFF] + " " + instanceFile.getName())); ) { // Run each algorithm 5 times on each instance: long runTime = 0; Map<String, Object> results = null; for (int i = 0; i < 25; ++i) { results = itImp.findSolutionWithMinimalQuality(instanceFile); runTime = (Long) results.get(COMPUTATION_TIME); // Change these 2 lines to change the content of the results files for each algorithm: writer.write(runTime + "\n"); writer.flush(); } } catch (IOException e) { e.printStackTrace(); System.out.println(e.getMessage()); } } // ------------------------------------------------------- // Then the ILS: // ------------------------------------------------------- pivotingMode = FIRST_MODE; neighbourhoodMode = INSERT_MODE; initMode = SLACK_INIT; itImp = new Algorithm(pivotingMode, neighbourhoodMode, initMode, ILS_ON); for (File instanceFile : files) { try (BufferedWriter writer = new BufferedWriter( new FileWriter( Algorithm.MAX_RELATIVE_PERCENTAGE_DEVIATION + " " + Algorithm.ILS_MODES[Algorithm.ILS_ON] + " " + instanceFile.getName())); ) { // Run each algorithm 5 times on each instance: long runTime = 0; Map<String, Object> results = null; for (int i = 0; i < 25; ++i) { results = itImp.findSolutionWithMinimalQuality(instanceFile); runTime = (Long) results.get(COMPUTATION_TIME); // Change these 2 lines to change the content of the results files for each algorithm: writer.write(runTime + "\n"); writer.flush(); } } catch (IOException e) { e.printStackTrace(); System.out.println(e.getMessage()); } } }