private static void batch_sls(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);

    String name =
        INIT_MODES[initMode]
            + NEIGHBOURHOOD_MODES[neighbourhoodMode]
            + PIVOTING_MODES[pivotingMode]
            + ILS_MODES[ILS_OFF];
    String nameAvRelPerDev =
        "R-avRelPer"
            + INIT_MODES[initMode]
            + NEIGHBOURHOOD_MODES[neighbourhoodMode]
            + PIVOTING_MODES[pivotingMode]
            + ILS_MODES[ILS_OFF]
            + ".dat";

    try {

      BufferedWriter writer = new BufferedWriter(new FileWriter(name));
      BufferedWriter writer2 = new BufferedWriter(new FileWriter(nameAvRelPerDev));

      int averageRelativePercentageDeviation = 0;
      long sumOfComputationTime = 0;

      for (File instanceFile : files) {
        // Run each algorithm 5 times on each instance:
        int relPerDev = 0;
        int cost = 0;
        long runTime = 0;

        Map<String, Object> results = null;
        for (int i = 0; i < 5; ++i) {
          results = itImp.findSolution(instanceFile);
          relPerDev += (Integer) results.get(RELATIVE_PERCENTAGE_DEVIATION);
          cost += (Integer) results.get(COST);
          runTime += (Long) results.get(COMPUTATION_TIME);
        }

        relPerDev /= 5;
        cost /= 5;
        runTime /= 5;

        // Change these 2 lines to change the content of the results files for each algorithm:
        writer.write(
            instanceFile.getName()
                + "\t"
                + relPerDev
                + "\t"
                + runTime
                + "\t"
                + cost
                + "\t"
                + (Integer) results.get(BEST_KNOWN)
                + "\n");
        writer.flush();
        writer2.write(
            relPerDev
                + "\n"); // Files used mainly to compute the p-values, contain only the relative
        // percentage deviations.
        writer2.flush();

        averageRelativePercentageDeviation += relPerDev;
        sumOfComputationTime += (Long) results.get(COMPUTATION_TIME);
      }

      // At the end of each file:
      averageRelativePercentageDeviation /= files.length;
      writer.write(
          averageRelativePercentageDeviation
              + "\n"); // The average relative percentage deviation for the algorithm.
      writer.write(
          Long.toString(sumOfComputationTime)
              + "\n"); // The sum of the computation times for the algorithm.
      sumOfComputationTime /= files.length;
      writer.write(
          Long.toString(sumOfComputationTime)
              + "\n"); // The average of the computation times for the algorithm.
      writer.flush();
      writer2.flush();

      writer.close();
      writer2.close();

    } 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);

    name =
        INIT_MODES[initMode]
            + NEIGHBOURHOOD_MODES[neighbourhoodMode]
            + PIVOTING_MODES[pivotingMode]
            + ILS_MODES[ILS_ON];
    nameAvRelPerDev =
        "R-avRelPer"
            + INIT_MODES[initMode]
            + NEIGHBOURHOOD_MODES[neighbourhoodMode]
            + PIVOTING_MODES[pivotingMode]
            + ILS_MODES[ILS_ON]
            + ".dat";

    try {

      BufferedWriter writer = new BufferedWriter(new FileWriter(name));
      BufferedWriter writer2 = new BufferedWriter(new FileWriter(nameAvRelPerDev));

      int averageRelativePercentageDeviation = 0;
      long sumOfComputationTime = 0;

      for (File instanceFile : files) {
        // Run each algorithm 5 times on each instance:
        int relPerDev = 0;
        int cost = 0;
        long runTime = 0;

        Map<String, Object> results = null;
        for (int i = 0; i < 5; ++i) {
          results = itImp.findSolution(instanceFile);
          relPerDev += (Integer) results.get(RELATIVE_PERCENTAGE_DEVIATION);
          cost += (Integer) results.get(COST);
          runTime += (Long) results.get(COMPUTATION_TIME);
        }

        relPerDev /= 5;
        cost /= 5;
        runTime /= 5;

        // Change these 2 lines to change the content of the results files for each algorithm:
        writer.write(
            instanceFile.getName()
                + "\t"
                + relPerDev
                + "\t"
                + runTime
                + "\t"
                + cost
                + "\t"
                + (Integer) results.get(BEST_KNOWN)
                + "\n");
        writer.flush();
        writer2.write(
            relPerDev
                + "\n"); // Files used mainly to compute the p-values, contain only the relative
        // percentage deviations.
        writer2.flush();

        averageRelativePercentageDeviation += relPerDev;
        sumOfComputationTime += (Long) results.get(COMPUTATION_TIME);
      }

      // At the end of each file:
      averageRelativePercentageDeviation /= files.length;
      writer.write(
          averageRelativePercentageDeviation
              + "\n"); // The average relative percentage deviation for the algorithm.
      writer.write(
          Long.toString(sumOfComputationTime)
              + "\n"); // The sum of the computation times for the algorithm.
      sumOfComputationTime /= files.length;
      writer.write(
          Long.toString(sumOfComputationTime)
              + "\n"); // The average of the computation times for the algorithm.
      writer.flush();
      writer2.flush();

      writer.close();
      writer2.close();

    } catch (IOException e) {
      e.printStackTrace();
      System.out.println(e.getMessage());
    }
  }
  /**
   * This method is used in case the batch string is used with a directory name. It calls each type
   * of algorithm on each instance in the specified folder. The results are written in files with
   * the algorithms modes as names. These files contain thus a line per instance.
   *
   * @param file The {@link File} object representing the folder containing all the instances.
   */
  private static void batch(File file) {
    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);

    // We look at all the possible algorithms (not vnd).
    for (int initMode = 0; initMode <= 1; ++initMode) {
      for (int neighbourhoodMode = 0; neighbourhoodMode <= 2; ++neighbourhoodMode) {
        for (int pivotingMode = 0; pivotingMode <= 1; ++pivotingMode) {

          Algorithm itImp = new Algorithm(pivotingMode, neighbourhoodMode, initMode, ILS_OFF);

          String name =
              INIT_MODES[initMode]
                  + NEIGHBOURHOOD_MODES[neighbourhoodMode]
                  + PIVOTING_MODES[pivotingMode];
          String nameAvRelPerDev =
              "R-avRelPer"
                  + INIT_MODES[initMode]
                  + NEIGHBOURHOOD_MODES[neighbourhoodMode]
                  + PIVOTING_MODES[pivotingMode]
                  + ".dat";

          try {

            BufferedWriter writer = new BufferedWriter(new FileWriter(name));
            BufferedWriter writer2 = new BufferedWriter(new FileWriter(nameAvRelPerDev));

            int averageRelativePercentageDeviation = 0;
            long sumOfComputationTime = 0;

            for (File instanceFile : files) {
              Map<String, Object> results = itImp.findSolution(instanceFile);

              // Change these 2 lines to change the content of the results files for each algorithm:
              writer.write(
                  instanceFile.getName()
                      + "\t"
                      + results.get(RELATIVE_PERCENTAGE_DEVIATION)
                      + "\t"
                      + results.get(COMPUTATION_TIME)
                      + "\t"
                      + results.get(COST)
                      + "\t"
                      + results.get(BEST_KNOWN)
                      + "\n");
              writer2.write(
                  results.get(RELATIVE_PERCENTAGE_DEVIATION)
                      + "\n"); // Files used mainly to compute the p-values, contain only the
              // relative percentage deviations.

              averageRelativePercentageDeviation +=
                  (Integer) results.get(RELATIVE_PERCENTAGE_DEVIATION);
              sumOfComputationTime += (Long) results.get(COMPUTATION_TIME);
            }

            // At the end of each file:
            averageRelativePercentageDeviation /= files.length;
            writer.write(
                averageRelativePercentageDeviation
                    + "\n"); // The average relative percentage deviation for the algorithm.
            writer.write(
                Long.toString(sumOfComputationTime)
                    + "\n"); // The sum of the computation times for the algorithm.
            sumOfComputationTime /= files.length;
            writer.write(
                Long.toString(sumOfComputationTime)
                    + "\n"); // The average of the computation times for the algorithm.
            writer.flush();
            writer2.flush();

            writer.close();
            writer2.close();

          } catch (IOException e) {
            e.printStackTrace();
            System.out.println(e.getMessage());
          }
        }
      }
    }
  }
  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());
      }
    }
  }