mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
Merge branch 'bad-job-list'
This commit is contained in:
commit
264dafd06a
31 changed files with 528 additions and 460 deletions
|
|
@ -245,7 +245,7 @@ public class BicycleMessenger {
|
|||
VehicleRoutingTransportCosts routingCosts = new CrowFlyCosts(problemBuilder.getLocations()); //which is the default VehicleRoutingTransportCosts in builder above
|
||||
problemBuilder.setRoutingCost(routingCosts);
|
||||
//finally build the problem
|
||||
problemBuilder.addPenaltyVehicles(20.0,50000);
|
||||
// problemBuilder.addPenaltyVehicles(20.0,50000);
|
||||
VehicleRoutingProblem bicycleMessengerProblem = problemBuilder.build();
|
||||
|
||||
/*
|
||||
|
|
@ -269,13 +269,14 @@ public class BicycleMessenger {
|
|||
|
||||
//create your algorithm
|
||||
VehicleRoutingAlgorithmBuilder vraBuilder = new VehicleRoutingAlgorithmBuilder(bicycleMessengerProblem,"input/algorithmConfig_open.xml");
|
||||
// vraBuilder.setNuOfThreads(2);
|
||||
vraBuilder.addDefaultCostCalculators();
|
||||
vraBuilder.setStateAndConstraintManager(stateManager, constraintManager);
|
||||
VehicleRoutingAlgorithm algorithm = vraBuilder.build();
|
||||
algorithm.setNuOfIterations(2000);
|
||||
algorithm.setMaxIterations(5000);
|
||||
VariationCoefficientTermination prematureAlgorithmTermination = new VariationCoefficientTermination(200, 0.001);
|
||||
algorithm.setPrematureAlgorithmTermination(prematureAlgorithmTermination);
|
||||
algorithm.addListener(prematureAlgorithmTermination);
|
||||
// algorithm.setPrematureAlgorithmTermination(prematureAlgorithmTermination);
|
||||
// algorithm.addListener(prematureAlgorithmTermination);
|
||||
// algorithm.addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||
|
||||
//search
|
||||
|
|
@ -294,7 +295,8 @@ public class BicycleMessenger {
|
|||
|
||||
//and the problem as well as the solution
|
||||
Plotter plotter1 = new Plotter(bicycleMessengerProblem, Solutions.bestOf(solutions));
|
||||
plotter1.plotShipments(false);
|
||||
plotter1.setLabel(Plotter.Label.ID);
|
||||
plotter1.plotShipments(false);
|
||||
// plotter1.setBoundingBox(5000, 45500, 25000, 66500);
|
||||
plotter1.plot("output/bicycleMessengerSolution.png", "bicycleMessenger");
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
******************************************************************************/
|
||||
package jsprit.examples;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import jsprit.analysis.toolbox.AlgorithmSearchProgressChartListener;
|
||||
import jsprit.analysis.toolbox.GraphStreamViewer;
|
||||
import jsprit.analysis.toolbox.Plotter;
|
||||
|
|
@ -34,6 +32,8 @@ import jsprit.instance.reader.VrphGoldenReader;
|
|||
import jsprit.instance.reader.VrphGoldenReader.VrphType;
|
||||
import jsprit.util.Examples;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Shows how to benchmark the algorithm on different classical HVRP and FSM instances.
|
||||
*
|
||||
|
|
@ -57,7 +57,7 @@ public class HVRPBenchmarkExample {
|
|||
//read modified Golden-instance, you can find all relevant instances in jsprit-instances/instances/vrph
|
||||
//you can build various problems, see VrphType doc for more details
|
||||
new VrphGoldenReader(vrpBuilder, VrphType.HVRPFD).read("input/cn_14mix.txt");
|
||||
vrpBuilder.addPenaltyVehicles(10.0);
|
||||
// vrpBuilder.addPenaltyVehicles(10.0);
|
||||
VehicleRoutingProblem vrp = vrpBuilder.build();
|
||||
|
||||
//try also input//jsprit-examples/input/algorithmConfig_considerFixedCosts_routeLevel.xml
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
******************************************************************************/
|
||||
package jsprit.examples;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import jsprit.analysis.toolbox.GraphStreamViewer;
|
||||
import jsprit.analysis.toolbox.SolutionPrinter;
|
||||
import jsprit.analysis.toolbox.SolutionPrinter.Print;
|
||||
|
|
@ -35,6 +33,8 @@ import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
|||
import jsprit.core.util.Coordinate;
|
||||
import jsprit.core.util.Solutions;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* customers (id,x,y,demand)
|
||||
* 1 22 22 18
|
||||
|
|
@ -113,7 +113,7 @@ public class HVRPExample {
|
|||
vrpBuilder.addVehicle(vehicle3_1);
|
||||
|
||||
//add penaltyVehicles to allow invalid solutions temporarily
|
||||
vrpBuilder.addPenaltyVehicles(5, 1000);
|
||||
// vrpBuilder.addPenaltyVehicles(5, 1000);
|
||||
|
||||
//set fleetsize finite
|
||||
vrpBuilder.setFleetSize(FleetSize.FINITE);
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@
|
|||
******************************************************************************/
|
||||
package jsprit.examples;
|
||||
|
||||
import jsprit.analysis.toolbox.*;
|
||||
import jsprit.analysis.toolbox.SolutionPrinter.Print;
|
||||
import jsprit.analysis.toolbox.GraphStreamViewer;
|
||||
import jsprit.analysis.toolbox.Plotter;
|
||||
import jsprit.analysis.toolbox.StopWatch;
|
||||
import jsprit.core.algorithm.VehicleRoutingAlgorithm;
|
||||
import jsprit.core.algorithm.io.VehicleRoutingAlgorithms;
|
||||
import jsprit.core.algorithm.listener.VehicleRoutingAlgorithmListeners.Priority;
|
||||
|
|
@ -28,6 +29,7 @@ import jsprit.core.problem.solution.VehicleRoutingProblemSolution;
|
|||
import jsprit.core.problem.vehicle.VehicleImpl;
|
||||
import jsprit.core.problem.vehicle.VehicleType;
|
||||
import jsprit.core.problem.vehicle.VehicleTypeImpl;
|
||||
import jsprit.core.reporting.SolutionPrinter;
|
||||
import jsprit.core.util.Coordinate;
|
||||
import jsprit.core.util.Solutions;
|
||||
import jsprit.util.Examples;
|
||||
|
|
@ -59,7 +61,7 @@ public class MultipleDepotExampleWithPenaltyVehicles {
|
|||
*
|
||||
* each with 14 vehicles each with a capacity of 500 and a maximum duration of 310
|
||||
*/
|
||||
int nuOfVehicles = 14;
|
||||
int nuOfVehicles = 13;
|
||||
int capacity = 500;
|
||||
double maxDuration = 310;
|
||||
Coordinate firstDepotCoord = Coordinate.newInstance(-33, 33);
|
||||
|
|
@ -68,7 +70,8 @@ public class MultipleDepotExampleWithPenaltyVehicles {
|
|||
int depotCounter = 1;
|
||||
for(Coordinate depotCoord : Arrays.asList(firstDepotCoord,second)){
|
||||
for(int i=0;i<nuOfVehicles;i++){
|
||||
VehicleType vehicleType = VehicleTypeImpl.Builder.newInstance(depotCounter + "_type").addCapacityDimension(0, capacity).setCostPerDistance(1.0).build();
|
||||
VehicleType vehicleType = VehicleTypeImpl.Builder.newInstance(depotCounter + "_type")
|
||||
.addCapacityDimension(0, capacity).setFixedCost(100.).setCostPerDistance(1.0).build();
|
||||
String vehicleId = depotCounter + "_" + (i+1) + "_vehicle";
|
||||
VehicleImpl.Builder vehicleBuilder = VehicleImpl.Builder.newInstance(vehicleId);
|
||||
vehicleBuilder.setStartLocationCoordinate(depotCoord);
|
||||
|
|
@ -83,7 +86,7 @@ public class MultipleDepotExampleWithPenaltyVehicles {
|
|||
/*
|
||||
* define penalty-type with the same id, but other higher fixed and variable costs
|
||||
*/
|
||||
vrpBuilder.addPenaltyVehicles(3, 50);
|
||||
// vrpBuilder.addPenaltyVehicles(3, 50);
|
||||
|
||||
/*
|
||||
* define problem with finite fleet
|
||||
|
|
@ -104,12 +107,12 @@ public class MultipleDepotExampleWithPenaltyVehicles {
|
|||
* solve the problem
|
||||
*/
|
||||
VehicleRoutingAlgorithm vra = VehicleRoutingAlgorithms.readAndCreateAlgorithm(vrp, "input/algorithmConfig.xml");
|
||||
vra.setNuOfIterations(5000);
|
||||
vra.setMaxIterations(1);
|
||||
vra.getAlgorithmListeners().addListener(new StopWatch(),Priority.HIGH);
|
||||
vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||
// vra.getAlgorithmListeners().addListener(new AlgorithmSearchProgressChartListener("output/progress.png"));
|
||||
Collection<VehicleRoutingProblemSolution> solutions = vra.searchSolutions();
|
||||
|
||||
SolutionPrinter.print(vrp,Solutions.bestOf(solutions),Print.VERBOSE);
|
||||
SolutionPrinter.print(vrp, Solutions.bestOf(solutions), jsprit.core.reporting.SolutionPrinter.Print.VERBOSE);
|
||||
|
||||
new Plotter(vrp, Solutions.bestOf(solutions)).plot("output/p08_solution.png", "p08");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue