mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
add files for examples
This commit is contained in:
parent
0a2a0a64ff
commit
8195ef0618
9 changed files with 6565 additions and 0 deletions
110
jsprit-examples/input/R101.txt
Normal file
110
jsprit-examples/input/R101.txt
Normal file
|
|
@ -0,0 +1,110 @@
|
||||||
|
R101
|
||||||
|
|
||||||
|
VEHICLE
|
||||||
|
NUMBER CAPACITY
|
||||||
|
25 200
|
||||||
|
|
||||||
|
CUSTOMER
|
||||||
|
CUST NO. XCOORD. YCOORD. DEMAND READY TIME DUE DATE SERVICE TIME
|
||||||
|
|
||||||
|
0 35 35 0 0 230 0
|
||||||
|
1 41 49 10 161 171 10
|
||||||
|
2 35 17 7 50 60 10
|
||||||
|
3 55 45 13 116 126 10
|
||||||
|
4 55 20 19 149 159 10
|
||||||
|
5 15 30 26 34 44 10
|
||||||
|
6 25 30 3 99 109 10
|
||||||
|
7 20 50 5 81 91 10
|
||||||
|
8 10 43 9 95 105 10
|
||||||
|
9 55 60 16 97 107 10
|
||||||
|
10 30 60 16 124 134 10
|
||||||
|
11 20 65 12 67 77 10
|
||||||
|
12 50 35 19 63 73 10
|
||||||
|
13 30 25 23 159 169 10
|
||||||
|
14 15 10 20 32 42 10
|
||||||
|
15 30 5 8 61 71 10
|
||||||
|
16 10 20 19 75 85 10
|
||||||
|
17 5 30 2 157 167 10
|
||||||
|
18 20 40 12 87 97 10
|
||||||
|
19 15 60 17 76 86 10
|
||||||
|
20 45 65 9 126 136 10
|
||||||
|
21 45 20 11 62 72 10
|
||||||
|
22 45 10 18 97 107 10
|
||||||
|
23 55 5 29 68 78 10
|
||||||
|
24 65 35 3 153 163 10
|
||||||
|
25 65 20 6 172 182 10
|
||||||
|
26 45 30 17 132 142 10
|
||||||
|
27 35 40 16 37 47 10
|
||||||
|
28 41 37 16 39 49 10
|
||||||
|
29 64 42 9 63 73 10
|
||||||
|
30 40 60 21 71 81 10
|
||||||
|
31 31 52 27 50 60 10
|
||||||
|
32 35 69 23 141 151 10
|
||||||
|
33 53 52 11 37 47 10
|
||||||
|
34 65 55 14 117 127 10
|
||||||
|
35 63 65 8 143 153 10
|
||||||
|
36 2 60 5 41 51 10
|
||||||
|
37 20 20 8 134 144 10
|
||||||
|
38 5 5 16 83 93 10
|
||||||
|
39 60 12 31 44 54 10
|
||||||
|
40 40 25 9 85 95 10
|
||||||
|
41 42 7 5 97 107 10
|
||||||
|
42 24 12 5 31 41 10
|
||||||
|
43 23 3 7 132 142 10
|
||||||
|
44 11 14 18 69 79 10
|
||||||
|
45 6 38 16 32 42 10
|
||||||
|
46 2 48 1 117 127 10
|
||||||
|
47 8 56 27 51 61 10
|
||||||
|
48 13 52 36 165 175 10
|
||||||
|
49 6 68 30 108 118 10
|
||||||
|
50 47 47 13 124 134 10
|
||||||
|
51 49 58 10 88 98 10
|
||||||
|
52 27 43 9 52 62 10
|
||||||
|
53 37 31 14 95 105 10
|
||||||
|
54 57 29 18 140 150 10
|
||||||
|
55 63 23 2 136 146 10
|
||||||
|
56 53 12 6 130 140 10
|
||||||
|
57 32 12 7 101 111 10
|
||||||
|
58 36 26 18 200 210 10
|
||||||
|
59 21 24 28 18 28 10
|
||||||
|
60 17 34 3 162 172 10
|
||||||
|
61 12 24 13 76 86 10
|
||||||
|
62 24 58 19 58 68 10
|
||||||
|
63 27 69 10 34 44 10
|
||||||
|
64 15 77 9 73 83 10
|
||||||
|
65 62 77 20 51 61 10
|
||||||
|
66 49 73 25 127 137 10
|
||||||
|
67 67 5 25 83 93 10
|
||||||
|
68 56 39 36 142 152 10
|
||||||
|
69 37 47 6 50 60 10
|
||||||
|
70 37 56 5 182 192 10
|
||||||
|
71 57 68 15 77 87 10
|
||||||
|
72 47 16 25 35 45 10
|
||||||
|
73 44 17 9 78 88 10
|
||||||
|
74 46 13 8 149 159 10
|
||||||
|
75 49 11 18 69 79 10
|
||||||
|
76 49 42 13 73 83 10
|
||||||
|
77 53 43 14 179 189 10
|
||||||
|
78 61 52 3 96 106 10
|
||||||
|
79 57 48 23 92 102 10
|
||||||
|
80 56 37 6 182 192 10
|
||||||
|
81 55 54 26 94 104 10
|
||||||
|
82 15 47 16 55 65 10
|
||||||
|
83 14 37 11 44 54 10
|
||||||
|
84 11 31 7 101 111 10
|
||||||
|
85 16 22 41 91 101 10
|
||||||
|
86 4 18 35 94 104 10
|
||||||
|
87 28 18 26 93 103 10
|
||||||
|
88 26 52 9 74 84 10
|
||||||
|
89 26 35 15 176 186 10
|
||||||
|
90 31 67 3 95 105 10
|
||||||
|
91 15 19 1 160 170 10
|
||||||
|
92 22 22 2 18 28 10
|
||||||
|
93 18 24 22 188 198 10
|
||||||
|
94 26 27 27 100 110 10
|
||||||
|
95 25 24 20 39 49 10
|
||||||
|
96 22 27 11 135 145 10
|
||||||
|
97 25 21 12 133 143 10
|
||||||
|
98 19 21 10 58 68 10
|
||||||
|
99 20 26 9 83 93 10
|
||||||
|
100 18 18 17 185 195 10
|
||||||
1235
jsprit-examples/input/deliveries_solomon_c101.xml
Normal file
1235
jsprit-examples/input/deliveries_solomon_c101.xml
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
1235
jsprit-examples/input/pickups_and_deliveries_tw_solomon_c101.xml
Normal file
1235
jsprit-examples/input/pickups_and_deliveries_tw_solomon_c101.xml
Normal file
File diff suppressed because it is too large
Load diff
1235
jsprit-examples/input/pickups_and_deliveries_tw_solomon_r101.xml
Normal file
1235
jsprit-examples/input/pickups_and_deliveries_tw_solomon_r101.xml
Normal file
File diff suppressed because it is too large
Load diff
1235
jsprit-examples/input/pickups_solomon_c101.xml
Normal file
1235
jsprit-examples/input/pickups_solomon_c101.xml
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,88 @@
|
||||||
|
package examples;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import algorithms.VehicleRoutingAlgorithms;
|
||||||
|
import algorithms.selectors.SelectBest;
|
||||||
|
import analysis.AlgorithmSearchProgressChartListener;
|
||||||
|
import analysis.SolutionPlotter;
|
||||||
|
import analysis.SolutionPrinter;
|
||||||
|
import analysis.SolutionPrinter.Print;
|
||||||
|
import basics.VehicleRoutingAlgorithm;
|
||||||
|
import basics.VehicleRoutingProblem;
|
||||||
|
import basics.VehicleRoutingProblemSolution;
|
||||||
|
import basics.VehicleRoutingProblem.Constraint;
|
||||||
|
import basics.io.VrpXMLReader;
|
||||||
|
|
||||||
|
public class PickupAndDeliveryExample {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* some preparation - create output folder
|
||||||
|
*/
|
||||||
|
File dir = new File("output");
|
||||||
|
// if the directory does not exist, create it
|
||||||
|
if (!dir.exists()){
|
||||||
|
System.out.println("creating directory ./output");
|
||||||
|
boolean result = dir.mkdir();
|
||||||
|
if(result) System.out.println("./output created");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Build the problem.
|
||||||
|
*
|
||||||
|
* But define a problem-builder first.
|
||||||
|
*/
|
||||||
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A solomonReader reads solomon-instance files, and stores the required information in the builder.
|
||||||
|
*/
|
||||||
|
new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_tw_solomon_r101.xml");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
|
||||||
|
*/
|
||||||
|
|
||||||
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
|
|
||||||
|
SolutionPlotter.plotVrpAsPNG(vrp, "output/pd_solomon_r101.png", "pd_r101");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define the required vehicle-routing algorithms to solve the above problem.
|
||||||
|
*
|
||||||
|
* The algorithm can be defined and configured in an xml-file.
|
||||||
|
*/
|
||||||
|
// VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||||
|
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig_solomon.xml");
|
||||||
|
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png"));
|
||||||
|
/*
|
||||||
|
* Solve the problem.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve best solution.
|
||||||
|
*/
|
||||||
|
VehicleRoutingProblemSolution solution = new SelectBest().selectSolution(solutions);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* print solution
|
||||||
|
*/
|
||||||
|
SolutionPrinter.print(solution, Print.VERBOSE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Plot solution.
|
||||||
|
*/
|
||||||
|
SolutionPlotter.plotSolutionAsPNG(vrp, solution, "output/pd_solomon_r101_solution.png","pd_r101");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
104
jsprit-examples/src/main/java/examples/SolomonR101Example.java
Normal file
104
jsprit-examples/src/main/java/examples/SolomonR101Example.java
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (C) 2013 Stefan Schroeder
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Stefan Schroeder - initial API and implementation
|
||||||
|
******************************************************************************/
|
||||||
|
package examples;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import readers.SolomonReader;
|
||||||
|
import algorithms.VehicleRoutingAlgorithms;
|
||||||
|
import algorithms.selectors.SelectBest;
|
||||||
|
import analysis.SolutionPlotter;
|
||||||
|
import analysis.SolutionPrinter;
|
||||||
|
import analysis.SolutionPrinter.Print;
|
||||||
|
import basics.VehicleRoutingAlgorithm;
|
||||||
|
import basics.VehicleRoutingProblem;
|
||||||
|
import basics.VehicleRoutingProblemSolution;
|
||||||
|
|
||||||
|
public class SolomonR101Example {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
/*
|
||||||
|
* some preparation - create output folder
|
||||||
|
*/
|
||||||
|
File dir = new File("output");
|
||||||
|
// if the directory does not exist, create it
|
||||||
|
if (!dir.exists()){
|
||||||
|
System.out.println("creating directory ./output");
|
||||||
|
boolean result = dir.mkdir();
|
||||||
|
if(result) System.out.println("./output created");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Build the problem.
|
||||||
|
*
|
||||||
|
* But define a problem-builder first.
|
||||||
|
*/
|
||||||
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A solomonReader reads solomon-instance files, and stores the required information in the builder.
|
||||||
|
*/
|
||||||
|
new SolomonReader(vrpBuilder).read("input/R101.txt");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
|
||||||
|
*/
|
||||||
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
|
|
||||||
|
SolutionPlotter.plotVrpAsPNG(vrp, "output/solomon_R101.png", "R101");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define the required vehicle-routing algorithms to solve the above problem.
|
||||||
|
*
|
||||||
|
* The algorithm can be defined and configured in an xml-file.
|
||||||
|
*/
|
||||||
|
// VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||||
|
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig_solomon.xml");
|
||||||
|
// vra.setPrematureBreak(100);
|
||||||
|
// vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png"));
|
||||||
|
/*
|
||||||
|
* Solve the problem.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve best solution.
|
||||||
|
*/
|
||||||
|
VehicleRoutingProblemSolution solution = new SelectBest().selectSolution(solutions);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* print solution
|
||||||
|
*/
|
||||||
|
SolutionPrinter.print(solution, Print.VERBOSE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Plot solution.
|
||||||
|
*/
|
||||||
|
SolutionPlotter.plotSolutionAsPNG(vrp, solution, "output/solomon_R101_solution.png","R101");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
package examples;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import algorithms.VehicleRoutingAlgorithms;
|
||||||
|
import algorithms.selectors.SelectBest;
|
||||||
|
import analysis.AlgorithmSearchProgressChartListener;
|
||||||
|
import analysis.SolutionPlotter;
|
||||||
|
import analysis.SolutionPrinter;
|
||||||
|
import analysis.SolutionPrinter.Print;
|
||||||
|
import basics.VehicleRoutingAlgorithm;
|
||||||
|
import basics.VehicleRoutingProblem;
|
||||||
|
import basics.VehicleRoutingProblemSolution;
|
||||||
|
import basics.VehicleRoutingProblem.Constraint;
|
||||||
|
import basics.io.VrpXMLReader;
|
||||||
|
|
||||||
|
public class VRPWithBackhaulsExample {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* some preparation - create output folder
|
||||||
|
*/
|
||||||
|
File dir = new File("output");
|
||||||
|
// if the directory does not exist, create it
|
||||||
|
if (!dir.exists()){
|
||||||
|
System.out.println("creating directory ./output");
|
||||||
|
boolean result = dir.mkdir();
|
||||||
|
if(result) System.out.println("./output created");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Build the problem.
|
||||||
|
*
|
||||||
|
* But define a problem-builder first.
|
||||||
|
*/
|
||||||
|
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A solomonReader reads solomon-instance files, and stores the required information in the builder.
|
||||||
|
*/
|
||||||
|
new VrpXMLReader(vrpBuilder).read("input/pickups_and_deliveries_tw_solomon_r101.xml");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finally, the problem can be built. By default, transportCosts are crowFlyDistances (as usually used for vrp-instances).
|
||||||
|
*/
|
||||||
|
vrpBuilder.addProblemConstraint(Constraint.DELIVERIES_FIRST);
|
||||||
|
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||||
|
|
||||||
|
SolutionPlotter.plotVrpAsPNG(vrp, "output/pd_solomon_r101.png", "pd_r101");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define the required vehicle-routing algorithms to solve the above problem.
|
||||||
|
*
|
||||||
|
* The algorithm can be defined and configured in an xml-file.
|
||||||
|
*/
|
||||||
|
// VehicleRoutingAlgorithm vra = new SchrimpfFactory().createAlgorithm(vrp);
|
||||||
|
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig_solomon.xml");
|
||||||
|
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/sol_progress.png"));
|
||||||
|
/*
|
||||||
|
* Solve the problem.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve best solution.
|
||||||
|
*/
|
||||||
|
VehicleRoutingProblemSolution solution = new SelectBest().selectSolution(solutions);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* print solution
|
||||||
|
*/
|
||||||
|
SolutionPrinter.print(solution, Print.VERBOSE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Plot solution.
|
||||||
|
*/
|
||||||
|
SolutionPlotter.plotSolutionAsPNG(vrp, solution, "output/pd_withBackhauls_solomon_r101_solution.png","pd_withBackhauls_r101");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue