public static void logPerformances(Policy policy, boolean logBadTrajectories) {
    float[] performance = performance(policy, logBadTrajectories);

    PrintWriter performanceLog = null;
    try {
      performanceLog = new PrintWriter(new FileWriter("performance.log", true));
    } catch (IOException e) {
      e.printStackTrace();
    }

    String line;
    if (policy.getClass() == DirectPolicySearch.class) {
      DirectPolicySearch dps = (DirectPolicySearch) policy;
      float totalComputationTime = (float) dps.getTotalComputationTime() / 1000f / 60f;

      line =
          dps.getName()
              + ";"
              + dps.getTotalNbOfIterations()
              + ";"
              + totalComputationTime
              + ";"
              + performance[0]
              + ";"
              + performance[1];
    } else if (policy.getClass() == Qiteration.class) {
      Qiteration qit = (Qiteration) policy;
      float totalComputationTime = (float) qit.getTotalComputationTime() / 1000f / 60f;

      line =
          qit.getName()
              + ";"
              + qit.getDiscountFactor()
              + ";"
              + qit.getTotalNbOfIterations()
              + ";"
              + totalComputationTime
              + ";"
              + performance[0]
              + ";"
              + performance[1];
    } else {
      line = policy.getName() + ";" + performance[0] + ";" + performance[1];
    }
    performanceLog.println(line);

    performanceLog.close();
  }
  public static void testAllDps() {

    PrintWriter performanceLog = null;
    try {
      performanceLog = new PrintWriter(new FileWriter("performance.log", true));
    } catch (IOException e) {
      e.printStackTrace();
    }

    DirectPolicySearch dps = null;
    String path =
        File.separator
            + "home"
            + File.separator
            + "s051607"
            + File.separator
            + "tfe"
            + File.separator
            + "sebbot"
            + File.separator;

    float[] performance = new float[2];
    float[] scores = new float[10];
    float[] badTrajectories = new float[10];
    float[] max = new float[2];
    float[] min = new float[2];
    float[] mean = new float[2];
    float[] stdDev = new float[2];

    String line = "";

    for (int nbOfBFs = 12; nbOfBFs <= 12 + 9 * 2; nbOfBFs = nbOfBFs + 2) {
      for (int cce = 1; cce <= 3; cce++) {
        for (int nbOfIterations = 1; nbOfIterations <= 50; nbOfIterations++) {
          max[0] = 0f;
          max[1] = 0f;
          min[0] = 99999999f;
          min[1] = 99999999f;
          mean[0] = 0f;
          mean[1] = 0f;
          stdDev[0] = 0f;
          stdDev[1] = 0f;

          for (int i = 1; i <= 10; i++) {
            String suffix =
                i
                    + File.separator
                    + "DPS_"
                    + nbOfBFs
                    + "_"
                    + (cce * nbOfBFs * (4 * 7 + 4))
                    + "_"
                    + "100"
                    + "_"
                    + nbOfIterations
                    + ".zip";

            try {
              dps = DirectPolicySearch.load(path + suffix);
            } catch (Exception e) {
              continue;
            }

            performance = performance(dps, false);

            scores[i - 1] = performance[0];
            badTrajectories[i - 1] = performance[1];
          }

          min[0] = MathTools.min(scores);
          min[1] = MathTools.min(badTrajectories);

          max[0] = MathTools.max(scores);
          max[1] = MathTools.max(badTrajectories);

          mean[0] = MathTools.mean(scores);
          mean[1] = MathTools.mean(badTrajectories);

          stdDev[0] = MathTools.stdDev(scores, mean[0]);
          stdDev[1] = MathTools.stdDev(badTrajectories, mean[1]);

          float computationTime = (float) dps.getTotalComputationTime() / 1000 / 60;

          line =
              dps.getInitialStates().size()
                  + ";"
                  + nbOfBFs
                  + ";"
                  + cce
                  + ";"
                  + nbOfIterations
                  + ";"
                  + computationTime
                  + ";"
                  + min[1]
                  + ";"
                  + max[1]
                  + ";"
                  + stdDev[1]
                  + ";"
                  + mean[1]
                  + ";"
                  + min[0]
                  + ";"
                  + max[0]
                  + ";"
                  + stdDev[0]
                  + ";"
                  + mean[0];

          performanceLog.println(line);
          performanceLog.flush();
        }
      }
    }

    performanceLog.close();
  }