mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
change algorithmReader to allow concurrency
This commit is contained in:
parent
cdf4878bf9
commit
277ffdb51a
9 changed files with 317 additions and 208 deletions
|
|
@ -9,10 +9,12 @@ import algorithms.VehicleRoutingAlgorithms;
|
|||
import analysis.AlgorithmSearchProgressChartListener;
|
||||
import analysis.SolutionPlotter;
|
||||
import analysis.SolutionPrinter;
|
||||
import analysis.StopWatch;
|
||||
import basics.VehicleRoutingAlgorithm;
|
||||
import basics.VehicleRoutingProblem;
|
||||
import basics.VehicleRoutingProblem.FleetSize;
|
||||
import basics.VehicleRoutingProblemSolution;
|
||||
import basics.algo.VehicleRoutingAlgorithmListeners.Priority;
|
||||
import basics.io.VrpXMLReader;
|
||||
import basics.route.Vehicle;
|
||||
import basics.route.VehicleImpl;
|
||||
|
|
@ -62,8 +64,8 @@ public class MultipleDepotExampleWithPenaltyVehicles {
|
|||
vrpBuilder.addVehicle(vehicle);
|
||||
}
|
||||
for(int i=0;i<nuOfPenaltyVehicles;i++){
|
||||
VehicleType penaltyType = VehicleType.Builder.newInstance(depotCounter + "_" + (i+1) + "_penaltyType", capacity).setFixedCost(50).setCostPerDistance(3.0).build();
|
||||
String vehicleId = depotCounter + "_" + (i+1) + "_penaltyVehicle";
|
||||
VehicleType penaltyType = VehicleType.Builder.newInstance(depotCounter + "_" + (i+1) + "_type#penalty", capacity).setFixedCost(50).setCostPerDistance(3.0).build();
|
||||
String vehicleId = depotCounter + "_" + (i+1) + "_vehicle#penalty";
|
||||
VehicleImpl.VehicleBuilder vehicleBuilder = VehicleImpl.VehicleBuilder.newInstance(vehicleId);
|
||||
vehicleBuilder.setLocationCoord(depotCoord);
|
||||
vehicleBuilder.setType(penaltyType);
|
||||
|
|
@ -95,6 +97,9 @@ public class MultipleDepotExampleWithPenaltyVehicles {
|
|||
* solve the problem
|
||||
*/
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml");
|
||||
vra.setNuOfIterations(5000);
|
||||
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
||||
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
SolutionPrinter.print(Solutions.getBest(solutions));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue