1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

modify core.reporting.SolutionPrinter to print unassignedJobs

This commit is contained in:
oblonski 2014-08-11 23:21:30 +02:00
parent e0a764c113
commit c832364557
3 changed files with 23 additions and 10 deletions

View file

@ -30,8 +30,10 @@ import jsprit.core.problem.vehicle.PenaltyVehicleType;
* Printer to print the details of a vehicle-routing-problem solution.
*
* @author stefan schroeder
* @deprecated use jsprit.core.reporting.SolutionPrinter instead
*
*/
@Deprecated
public class SolutionPrinter {
/**
@ -93,7 +95,7 @@ public class SolutionPrinter {
System.out.format("+---------------+------------------------------------------+%n");
System.out.format(leftAlignSolution, "costs",solution.getCost());
System.out.format(leftAlignSolution, "nVehicles",solution.getRoutes().size());
System.out.format(leftAlignSolution, "badJobs", solution.getUnassignedJobs().size());
System.out.format(leftAlignSolution, "unassignedJobs", solution.getUnassignedJobs().size());
System.out.format("+----------------------------------------------------------+%n");
if(print.equals(Print.VERBOSE)){

View file

@ -77,10 +77,10 @@ public class SolutionPrinter {
System.out.printf("| indicator | value |%n");
System.out.format("+---------------+----------+%n");
System.out.format(leftAlign, "nJobs", problem.getJobs().values().size());
System.out.format(leftAlign, "noJobs", problem.getJobs().values().size());
Jobs jobs = getNuOfJobs(problem);
System.out.format(leftAlign, "nServices",jobs.nServices);
System.out.format(leftAlign, "nShipments",jobs.nShipments);
System.out.format(leftAlign, "noServices",jobs.nServices);
System.out.format(leftAlign, "noShipments",jobs.nShipments);
System.out.format(leftAlign, "fleetsize",problem.getFleetSize().toString());
System.out.format("+--------------------------+%n");
@ -92,7 +92,8 @@ public class SolutionPrinter {
System.out.printf("| indicator | value |%n");
System.out.format("+---------------+------------------------------------------+%n");
System.out.format(leftAlignSolution, "costs",solution.getCost());
System.out.format(leftAlignSolution, "nVehicles",solution.getRoutes().size());
System.out.format(leftAlignSolution, "noVehicles",solution.getRoutes().size());
System.out.format(leftAlignSolution, "unassgndJobs", solution.getUnassignedJobs().size());
System.out.format("+----------------------------------------------------------+%n");
if(print.equals(Print.VERBOSE)){
@ -130,6 +131,14 @@ public class SolutionPrinter {
}
System.out.format("+*:=PenaltyVehicle+%n");
System.out.format("+--------------------------------------------------------------------------------------------------------------------------------+%n");
System.out.format("+----------------+%n");
System.out.format("| unassignedJobs |%n");
System.out.format("+----------------+%n");
String unassignedJobAlgin = "| %-14s |%n";
for(Job j : solution.getUnassignedJobs()){
System.out.format(unassignedJobAlgin,j.getId());
}
System.out.format("+----------------+%n");
}
private static String getVehicleString(VehicleRoute route) {

View file

@ -16,8 +16,9 @@
******************************************************************************/
package jsprit.examples;
import jsprit.analysis.toolbox.*;
import jsprit.analysis.toolbox.SolutionPrinter.Print;
import jsprit.analysis.toolbox.GraphStreamViewer;
import jsprit.analysis.toolbox.Plotter;
import jsprit.analysis.toolbox.StopWatch;
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
@ -28,6 +29,7 @@ import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import jsprit.core.problem.vehicle.VehicleImpl;
import jsprit.core.problem.vehicle.VehicleType;
import jsprit.core.problem.vehicle.VehicleTypeImpl;
import jsprit.core.reporting.SolutionPrinter;
import jsprit.core.util.Coordinate;
import jsprit.core.util.Solutions;
import jsprit.util.Examples;
@ -105,12 +107,12 @@ public class MultipleDepotExampleWithPenaltyVehicles {
* solve the problem
*/
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml");
vra.setMaxIterations(5000);
vra.setMaxIterations(1);
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
// vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
SolutionPrinter.print(vrp,Solutions.bestOf(solutions),Print.VERBOSE);
SolutionPrinter.print(vrp, Solutions.bestOf(solutions), jsprit.core.reporting.SolutionPrinter.Print.VERBOSE);
new Plotter(vrp, Solutions.bestOf(solutions)).plot("output/p08_solution.png", "p08");