|
22 | 22 | import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
23 | 23 | import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
24 | 24 | import jsprit.core.algorithm.selector.SelectBest;
|
| 25 | +import jsprit.core.analysis.SolutionAnalyser; |
25 | 26 | import jsprit.core.problem.VehicleRoutingProblem;
|
26 | 27 | import jsprit.core.problem.io.VrpXMLReader;
|
27 | 28 | import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
@@ -56,7 +57,7 @@ public static void main(String[] args) {
|
56 | 57 | * Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
|
57 | 58 | */
|
58 | 59 |
|
59 |
| - VehicleRoutingProblem vrp = vrpBuilder.build(); |
| 60 | + final VehicleRoutingProblem vrp = vrpBuilder.build(); |
60 | 61 |
|
61 | 62 | new Plotter(vrp).plot("output/pd_solomon_r101.png", "pd_r101");
|
62 | 63 |
|
@@ -93,9 +94,25 @@ public static void main(String[] args) {
|
93 | 94 | Plotter plotter = new Plotter(vrp, solution);
|
94 | 95 | plotter.setLabel(Label.SIZE);
|
95 | 96 | plotter.plot("output/pd_solomon_r101_solution.png","pd_r101");
|
96 |
| - |
97 |
| - |
98 |
| - |
99 |
| - } |
| 97 | + |
| 98 | + //some stats |
| 99 | + SolutionAnalyser analyser = new SolutionAnalyser(vrp,solution,new SolutionAnalyser.DistanceCalculator() { |
| 100 | + |
| 101 | + @Override |
| 102 | + public double getDistance(String fromLocationId, String toLocationId) { |
| 103 | + return vrp.getTransportCosts().getTransportCost(fromLocationId,toLocationId,0.,null,null); |
| 104 | + } |
| 105 | + |
| 106 | + }); |
| 107 | + |
| 108 | + System.out.println("tp_distance: " + analyser.getDistance()); |
| 109 | + System.out.println("tp_time: " + analyser.getTransportTime()); |
| 110 | + System.out.println("waiting: " + analyser.getWaitingTime()); |
| 111 | + System.out.println("service: " + analyser.getServiceTime()); |
| 112 | + System.out.println("#picks: " + analyser.getNumberOfPickups()); |
| 113 | + System.out.println("#deliveries: " + analyser.getNumberOfDeliveries()); |
| 114 | + |
| 115 | + |
| 116 | + } |
100 | 117 |
|
101 | 118 | }
|
0 commit comments