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

comply with .editorconfig

This commit is contained in:
oblonski 2015-08-29 12:46:52 +02:00
parent 58afc3590d
commit 33075b479f
416 changed files with 29653 additions and 29979 deletions

View file

@ -11,7 +11,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package jsprit.examples;
@ -41,18 +41,18 @@ import java.util.Collection;
public class MultipleDepotExample {
public static void main(String[] args) {
/*
public static void main(String[] args) {
/*
* some preparation - create output folder
*/
Examples.createOutputFolder();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
Examples.createOutputFolder();
VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance();
/*
* Read cordeau-instance p01, BUT only its services without any vehicles
* Read cordeau-instance p01, BUT only its services without any vehicles
*/
new VrpXMLReader(vrpBuilder).read("input/vrp_cordeau_01.xml");
new VrpXMLReader(vrpBuilder).read("input/vrp_cordeau_01.xml");
/*
* add vehicles with its depots
* 4 depots:
@ -60,36 +60,36 @@ public class MultipleDepotExample {
* (30,40)
* (50,30)
* (60,50)
*
*
* each with 4 vehicles each with a capacity of 80
*/
int nuOfVehicles = 4;
int capacity = 80;
Coordinate firstDepotCoord = Coordinate.newInstance(20, 20);
Coordinate second = Coordinate.newInstance(30, 40);
Coordinate third = Coordinate.newInstance(50, 30);
Coordinate fourth = Coordinate.newInstance(60, 50);
int depotCounter = 1;
for(Coordinate depotCoord : Arrays.asList(firstDepotCoord,second,third,fourth)){
for(int i=0;i<nuOfVehicles;i++){
VehicleTypeImpl vehicleType = VehicleTypeImpl.Builder.newInstance(depotCounter + "_type").addCapacityDimension(0, capacity).setCostPerDistance(1.0).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance(depotCounter + "_" + (i + 1) + "_vehicle").setStartLocation(Location.newInstance(depotCoord.getX(), depotCoord.getY())).setType(vehicleType).build();
vrpBuilder.addVehicle(vehicle);
}
depotCounter++;
}
int nuOfVehicles = 4;
int capacity = 80;
Coordinate firstDepotCoord = Coordinate.newInstance(20, 20);
Coordinate second = Coordinate.newInstance(30, 40);
Coordinate third = Coordinate.newInstance(50, 30);
Coordinate fourth = Coordinate.newInstance(60, 50);
int depotCounter = 1;
for (Coordinate depotCoord : Arrays.asList(firstDepotCoord, second, third, fourth)) {
for (int i = 0; i < nuOfVehicles; i++) {
VehicleTypeImpl vehicleType = VehicleTypeImpl.Builder.newInstance(depotCounter + "_type").addCapacityDimension(0, capacity).setCostPerDistance(1.0).build();
VehicleImpl vehicle = VehicleImpl.Builder.newInstance(depotCounter + "_" + (i + 1) + "_vehicle").setStartLocation(Location.newInstance(depotCoord.getX(), depotCoord.getY())).setType(vehicleType).build();
vrpBuilder.addVehicle(vehicle);
}
depotCounter++;
}
/*
* define problem with finite fleet
*/
vrpBuilder.setFleetSize(FleetSize.FINITE);
vrpBuilder.setFleetSize(FleetSize.FINITE);
/*
* build the problem
*/
VehicleRoutingProblem vrp = vrpBuilder.build();
VehicleRoutingProblem vrp = vrpBuilder.build();
/*
* plot to see how the problem looks like
*/
@ -98,17 +98,17 @@ public class MultipleDepotExample {
/*
* solve the problem
*/
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.THREADS,"5").buildAlgorithm();
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
SolutionPrinter.print(Solutions.bestOf(solutions));
new Plotter(vrp, Solutions.bestOf(solutions)).plot("output/p01_solution.png", "p01");
new GraphStreamViewer(vrp, Solutions.bestOf(solutions)).setRenderDelay(100).display();
}
VehicleRoutingAlgorithm vra = Jsprit.Builder.newInstance(vrp).setProperty(Jsprit.Parameter.THREADS, "5").buildAlgorithm();
vra.getAlgorithmListeners().addListener(new StopWatch(), Priority.HIGH);
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
SolutionPrinter.print(Solutions.bestOf(solutions));
new Plotter(vrp, Solutions.bestOf(solutions)).plot("output/p01_solution.png", "p01");
new GraphStreamViewer(vrp, Solutions.bestOf(solutions)).setRenderDelay(100).display();
}
}