Example #1
0
  /**
   * Prints costs and #vehicles to the given writer
   *
   * @param out the destination writer
   * @param solution the solution to be printed
   */
  public static void print(
      PrintWriter out,
      VehicleRoutingProblem problem,
      VehicleRoutingProblemSolution solution,
      Print print) {
    String leftAlign = "| %-13s | %-8s | %n";

    out.format("+--------------------------+%n");
    out.printf("| problem                  |%n");
    out.format("+---------------+----------+%n");
    out.printf("| indicator     | value    |%n");
    out.format("+---------------+----------+%n");

    out.format(leftAlign, "noJobs", problem.getJobs().values().size());
    Jobs jobs = getNuOfJobs(problem);
    out.format(leftAlign, "noServices", jobs.nServices);
    out.format(leftAlign, "noShipments", jobs.nShipments);
    out.format(leftAlign, "fleetsize", problem.getFleetSize().toString());
    out.format("+--------------------------+%n");

    String leftAlignSolution = "| %-13s | %-40s | %n";
    out.format("+----------------------------------------------------------+%n");
    out.printf("| solution                                                 |%n");
    out.format("+---------------+------------------------------------------+%n");
    out.printf("| indicator     | value                                    |%n");
    out.format("+---------------+------------------------------------------+%n");
    out.format(leftAlignSolution, "costs", solution.getCost());
    out.format(leftAlignSolution, "noVehicles", solution.getRoutes().size());
    out.format(leftAlignSolution, "unassgndJobs", solution.getUnassignedJobs().size());
    out.format("+----------------------------------------------------------+%n");

    if (print.equals(Print.VERBOSE)) {
      printVerbose(out, problem, solution);
    }
  }
Example #2
0
 private static void printVerbose(
     VehicleRoutingProblem problem, VehicleRoutingProblemSolution solution) {
   printVerbose(SYSTEM_OUT_AS_PRINT_WRITER, problem, solution);
   SYSTEM_OUT_AS_PRINT_WRITER.flush();
 }