Skip to content

Commit 9aafc84

Browse files
committed
modify example
1 parent 83cc5ef commit 9aafc84

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

jsprit-examples/src/main/java/jsprit/examples/PickupAndDeliveryExample.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
2323
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
2424
import jsprit.core.algorithm.selector.SelectBest;
25+
import jsprit.core.analysis.SolutionAnalyser;
2526
import jsprit.core.problem.VehicleRoutingProblem;
2627
import jsprit.core.problem.io.VrpXMLReader;
2728
import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
@@ -56,7 +57,7 @@ public static void main(String[] args) {
5657
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
5758
*/
5859

59-
VehicleRoutingProblem vrp = vrpBuilder.build();
60+
final VehicleRoutingProblem vrp = vrpBuilder.build();
6061

6162
new Plotter(vrp).plot("output/pd_solomon_r101.png", "pd_r101");
6263

@@ -93,9 +94,25 @@ public static void main(String[] args) {
9394
Plotter plotter = new Plotter(vrp, solution);
9495
plotter.setLabel(Label.SIZE);
9596
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+
}
100117

101118
}

0 commit comments

Comments
 (0)